Spaces:
Runtime error
Runtime error
mdacampora
commited on
Commit
•
acb3080
1
Parent(s):
67a414c
Update app.py
Browse files
app.py
CHANGED
@@ -17,17 +17,22 @@ model = PeftModel.from_pretrained(model, peft_model_id)
|
|
17 |
|
18 |
|
19 |
|
20 |
-
def make_inference(
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
|
33 |
if __name__ == "__main__":
|
@@ -52,5 +57,5 @@ gr.Interface(
|
|
52 |
],
|
53 |
gr.outputs.Textbox(label="Updated Conversation"),
|
54 |
title="tax-convos-demo",
|
55 |
-
description="
|
56 |
).launch()
|
|
|
17 |
|
18 |
|
19 |
|
20 |
+
def make_inference(conversation):
|
21 |
+
conversation_history = conversation
|
22 |
+
response = ""
|
23 |
+
while True:
|
24 |
+
batch = tokenizer(
|
25 |
+
f"### Problem:\n{conversation_history}\n{response}",
|
26 |
+
return_tensors="pt",
|
27 |
+
)
|
28 |
+
with torch.cuda.amp.autocast():
|
29 |
+
output_tokens = model.generate(**batch, max_new_tokens=50)
|
30 |
+
new_response = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
31 |
+
if new_response.strip() == "":
|
32 |
+
break
|
33 |
+
response = f"\n{new_response}"
|
34 |
+
conversation_history += response
|
35 |
+
return conversation_history
|
36 |
|
37 |
|
38 |
if __name__ == "__main__":
|
|
|
57 |
],
|
58 |
gr.outputs.Textbox(label="Updated Conversation"),
|
59 |
title="tax-convos-demo",
|
60 |
+
description="Ask any tax-related questions you may have.",
|
61 |
).launch()
|