Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
)
|
13 |
|
14 |
-
|
15 |
-
output = llm(
|
16 |
-
f"Je bent een biomedische chatbot. Beantwoord de vraag: {message}",
|
17 |
-
max_tokens=200,
|
18 |
-
temperature=0.7,
|
19 |
-
)
|
20 |
-
return output['choices'][0]['text']
|
21 |
-
|
22 |
-
iface = gr.ChatInterface(chat_fn, title="Biomedische Chatbot")
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
|
4 |
+
model_id = "raidium/MQG"
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
7 |
|
8 |
+
def answer(message, history=[]):
|
9 |
+
inputs = tokenizer.encode(message, return_tensors="pt")
|
10 |
+
outputs = model.generate(inputs, max_length=256)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
|
|
13 |
|
14 |
+
iface = gr.ChatInterface(answer, title="Medische Q&A (MQG)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
iface.launch()
|