Spaces:
Sleeping
Sleeping
Allen Park
commited on
Commit
·
090dd00
1
Parent(s):
0e15888
make PROMPT not hardcoded and take input values from gradio interface
Browse files
app.py
CHANGED
@@ -7,19 +7,15 @@ Given the following QUESTION, DOCUMENT and ANSWER you must analyze the provided
|
|
7 |
|
8 |
--
|
9 |
QUESTION (THIS DOES NOT COUNT AS BACKGROUND INFORMATION):
|
10 |
-
|
11 |
-
organisms; two examples being
|
12 |
-
Clytostoma from tropical America and
|
13 |
-
Syneilesis from East Asia?
|
14 |
|
15 |
--
|
16 |
DOCUMENT:
|
17 |
-
|
18 |
-
in the groundsel tribe within the Asteraceae.
|
19 |
|
20 |
--
|
21 |
ANSWER:
|
22 |
-
|
23 |
|
24 |
--
|
25 |
|
@@ -29,9 +25,10 @@ Your output should be in JSON FORMAT with the keys "REASONING" and "SCORE":
|
|
29 |
|
30 |
|
31 |
def greet(question, document, answer):
|
|
|
32 |
tokenizer = AutoTokenizer.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct")
|
33 |
model = AutoModelForCausalLM.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct", cache_dir='/tmp/cache', torch_dtype=torch.float16, low_cpu_mem_usage=True)
|
34 |
-
inputs = tokenizer(
|
35 |
model.generate(inputs)
|
36 |
generated_text = tokenizer.decode(inputs.input_ids[0])
|
37 |
print(generated_text)
|
|
|
7 |
|
8 |
--
|
9 |
QUESTION (THIS DOES NOT COUNT AS BACKGROUND INFORMATION):
|
10 |
+
{question}
|
|
|
|
|
|
|
11 |
|
12 |
--
|
13 |
DOCUMENT:
|
14 |
+
{document}
|
|
|
15 |
|
16 |
--
|
17 |
ANSWER:
|
18 |
+
{answer}
|
19 |
|
20 |
--
|
21 |
|
|
|
25 |
|
26 |
|
27 |
def greet(question, document, answer):
|
28 |
+
NEW_FORMAT = PROMPT.format(question=question, document=document, answer=answer)
|
29 |
tokenizer = AutoTokenizer.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct")
|
30 |
model = AutoModelForCausalLM.from_pretrained("PatronusAI/Llama-3-Patronus-Lynx-8B-Instruct", cache_dir='/tmp/cache', torch_dtype=torch.float16, low_cpu_mem_usage=True)
|
31 |
+
inputs = tokenizer(NEW_FORMAT, return_tensors="pt")
|
32 |
model.generate(inputs)
|
33 |
generated_text = tokenizer.decode(inputs.input_ids[0])
|
34 |
print(generated_text)
|