rishanthrajendhran commited on
Commit
a0c598a
·
verified ·
1 Parent(s): fd686a5

Updated example code in README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -4
README.md CHANGED
@@ -72,10 +72,51 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
72
  tokenizer = AutoTokenizer.from_pretrained("rishanthrajendhran/VeriFastScore")
73
  model = AutoModelForCausalLM.from_pretrained("rishanthrajendhran/VeriFastScore")
74
 
75
- prompt = "<your prompt with evidence and response>"
76
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
77
- outputs = model.generate(**inputs, max_new_tokens=512)
78
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  ```
80
 
81
  ## Training Details
 
72
  tokenizer = AutoTokenizer.from_pretrained("rishanthrajendhran/VeriFastScore")
73
  model = AutoModelForCausalLM.from_pretrained("rishanthrajendhran/VeriFastScore")
74
 
75
+ system_prompt = '''You are trying to verify how factual a response is by extracting fine-grained, verifiable claims. Each claim must describe one single event or one single state (for example, “Nvidia was founded in 1993 in Sunnyvale, California, U.S.”) in one sentence with at most one embedded clause. Each fact should be understandable on its own and require no additional context. This means that all entities must be referred to by name but not by pronoun. Use the name of entities rather than definite noun phrases (e.g., “the teacher”) whenever possible. If a definite noun phrase is used, be sure to add modifiers (e.g., an embedded clause or a prepositional phrase). Each fact must be situated within relevant temporal and location details whenever needed.
76
+
77
+ All necessary specific details—including entities, dates, and locations—must be explicitly named, and verify here means that every detail of a claim is directly confirmed by the provided evidence. The verification process involves cross-checking each detail against the evidence; a detail is considered verified if it is clearly confirmed by the evidence.
78
+
79
+ Avoid extracting stories, personal experiences, hypotheticals (e.g., those using “would be” or the subjunctive mood), subjective opinions, suggestions, advice, instructions, or similarly non-factual content; however, biographical, historical, scientific, and similar texts are acceptable. Also, ignore any listed references.
80
+
81
+ For each extracted claim, classify it as follows:
82
+
83
+ Supported: Every detail of the claim (including entities, dates, and locations) is directly confirmed by the provided evidence with no contradictions.
84
+ Unsupported: One or more details of the claim are either missing from or contradicted by the provided evidence, even though the claim remains verifiable using external sources.
85
+
86
+ You do not need to justify what you extract.
87
+
88
+ Output format:
89
+ <fact 1>: <your judgment of fact 1>
90
+ <fact 2>: <your judgment of fact 2>
91
+
92
+ <fact n>: <your judgment of fact n>
93
+
94
+ If no verifiable claim can be extracted, simply output "No verifiable claim."'''
95
+
96
+ prompt = "### Response\n{response}\n### Evidence\n{evidence}".format(
97
+ response=response,
98
+ evidence=evidence
99
+ )
100
+
101
+ conversation_history = [
102
+ {
103
+ "role": "system",
104
+ "content": system_prompt,
105
+ }, {
106
+ "role": "user",
107
+ "content": prompt
108
+ }
109
+ ]
110
+ inputs = self.tokenizer.apply_chat_template(
111
+ conversation=conversation_history,
112
+ add_generation_prompt=True,
113
+ tokenize=True,
114
+ truncation=False,
115
+ padding="do_not_pad"
116
+ ).to(model.device)
117
+
118
+ outputs = model.generate(**inputs, max_new_tokens=2048)
119
+ print(tokenizer.decode(outputs, skip_special_tokens=True))
120
  ```
121
 
122
  ## Training Details