Spaces:
Running
Running
tanveeshsingh
commited on
Commit
·
56dc4f7
1
Parent(s):
60c488a
Changes in app.py
Browse files
app.py
CHANGED
@@ -21,9 +21,7 @@ async def lynx(input_style_dropdown,document_input,question_input,answer_input):
|
|
21 |
base_url="https://s6mipt5j797e6fql.us-east-1.aws.endpoints.huggingface.cloud/v1/",
|
22 |
api_key=os.getenv("HF_TOKEN")
|
23 |
)
|
24 |
-
|
25 |
-
Given the following QUESTION, DOCUMENT and ANSWER you must analyze the provided answer and determine whether it is faithful to the contents of the DOCUMENT. The ANSWER must not offer new information beyond the context provided in the DOCUMENT. The ANSWER also must not contradict information provided in the DOCUMENT. Output your final verdict by strictly following this format: "PASS" if the answer is faithful to the DOCUMENT and "FAIL" if the answer is not faithful to the DOCUMENT. Show your reasoning.
|
26 |
-
|
27 |
--
|
28 |
QUESTION (THIS DOES NOT COUNT AS BACKGROUND INFORMATION):
|
29 |
{question}
|
@@ -39,14 +37,13 @@ ANSWER:
|
|
39 |
--
|
40 |
|
41 |
Your output should be in JSON FORMAT with the keys "REASONING" and "SCORE":
|
42 |
-
{{"REASONING": <your reasoning as bullet points>, "SCORE": <your final score>}}
|
43 |
-
""")
|
44 |
chat_completion = await client.chat.completions.create(
|
45 |
model="tgi",
|
46 |
messages=[
|
47 |
{
|
48 |
"role": "user",
|
49 |
-
"content":
|
50 |
}
|
51 |
],
|
52 |
top_p=None,
|
|
|
21 |
base_url="https://s6mipt5j797e6fql.us-east-1.aws.endpoints.huggingface.cloud/v1/",
|
22 |
api_key=os.getenv("HF_TOKEN")
|
23 |
)
|
24 |
+
prompt = Template("""Given the following QUESTION, DOCUMENT and ANSWER you must analyze the provided answer and determine whether it is faithful to the contents of the DOCUMENT. The ANSWER must not offer new information beyond the context provided in the DOCUMENT. The ANSWER also must not contradict information provided in the DOCUMENT. Output your final verdict by strictly following this format: "PASS" if the answer is faithful to the DOCUMENT and "FAIL" if the answer is not faithful to the DOCUMENT. Show your reasoning.
|
|
|
|
|
25 |
--
|
26 |
QUESTION (THIS DOES NOT COUNT AS BACKGROUND INFORMATION):
|
27 |
{question}
|
|
|
37 |
--
|
38 |
|
39 |
Your output should be in JSON FORMAT with the keys "REASONING" and "SCORE":
|
40 |
+
{{"REASONING": <your reasoning as bullet points>, "SCORE": <your final score>}}""")
|
|
|
41 |
chat_completion = await client.chat.completions.create(
|
42 |
model="tgi",
|
43 |
messages=[
|
44 |
{
|
45 |
"role": "user",
|
46 |
+
"content": prompt.render(question=question_input,context=document_input,answer=answer_input)
|
47 |
}
|
48 |
],
|
49 |
top_p=None,
|