Spaces:
Runtime error
Runtime error
MohammedAlakhras
commited on
Commit
•
debfe31
1
Parent(s):
e6f5a57
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import torch
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
|
|
3 |
|
4 |
# Define the device
|
5 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -21,6 +22,17 @@ def answer_question(
|
|
21 |
num_beams=2,
|
22 |
**kwargs,
|
23 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
inputs = tokenizer(prompt, return_tensors="pt")
|
25 |
# Move the inputs to the device
|
26 |
inputs = {key: val.to(device) for key, val in inputs.items()}
|
@@ -60,4 +72,10 @@ Hi i have sore lumps under the skin on my legs. they started on my left ankle an
|
|
60 |
### Response:
|
61 |
"""
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
print(answer_question(example_prompt))
|
|
|
1 |
import torch
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
3 |
+
import gradio as gr
|
4 |
|
5 |
# Define the device
|
6 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
22 |
num_beams=2,
|
23 |
**kwargs,
|
24 |
):
|
25 |
+
prompt="""
|
26 |
+
Below is an instruction that describes a task, paired with an input that provides further context.Write a response that appropriately completes the request.
|
27 |
+
|
28 |
+
### Instruction:
|
29 |
+
If you are a doctor, please answer the medical questions based on the patient's description.
|
30 |
+
|
31 |
+
### Input:
|
32 |
+
"""+prompt+"""
|
33 |
+
|
34 |
+
### Response:
|
35 |
+
"""
|
36 |
inputs = tokenizer(prompt, return_tensors="pt")
|
37 |
# Move the inputs to the device
|
38 |
inputs = {key: val.to(device) for key, val in inputs.items()}
|
|
|
72 |
### Response:
|
73 |
"""
|
74 |
|
75 |
+
def gui_interface(prompt):
|
76 |
+
return answer_question(prompt)
|
77 |
+
|
78 |
+
iface = gr.Interface(fn=gui_interface, inputs="text", outputs="text")
|
79 |
+
iface.launch()
|
80 |
+
|
81 |
print(answer_question(example_prompt))
|