Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import torch
|
|
| 9 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 10 |
|
| 11 |
# Hugging Face Hub repository containing the fine-tuned model
|
| 12 |
-
MODEL_REPO = "degide/tinyllama-medical-
|
| 13 |
|
| 14 |
print("Downloading and loading the fine-tuned medical chatbot...")
|
| 15 |
|
|
@@ -63,7 +63,7 @@ def generate_medical_response(message, history):
|
|
| 63 |
|
| 64 |
prompt = (
|
| 65 |
f"</s><|system|>You are a highly accurate and helpful medical assistant.</s>"
|
| 66 |
-
f"<
|
| 67 |
)
|
| 68 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 69 |
|
|
@@ -71,12 +71,10 @@ def generate_medical_response(message, history):
|
|
| 71 |
outputs = model.generate(
|
| 72 |
**inputs,
|
| 73 |
max_new_tokens=256,
|
| 74 |
-
temperature=0.3,
|
| 75 |
-
top_p=0.85,
|
| 76 |
repetition_penalty=1.0,
|
| 77 |
do_sample=True,
|
| 78 |
-
|
| 79 |
-
pad_token_id=tokenizer.eos_token_id
|
| 80 |
)
|
| 81 |
|
| 82 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
| 9 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 10 |
|
| 11 |
# Hugging Face Hub repository containing the fine-tuned model
|
| 12 |
+
MODEL_REPO = "degide/tinyllama-medical-assistant"
|
| 13 |
|
| 14 |
print("Downloading and loading the fine-tuned medical chatbot...")
|
| 15 |
|
|
|
|
| 63 |
|
| 64 |
prompt = (
|
| 65 |
f"</s><|system|>You are a highly accurate and helpful medical assistant.</s>"
|
| 66 |
+
f"<|user|>{message}</s>"
|
| 67 |
)
|
| 68 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 69 |
|
|
|
|
| 71 |
outputs = model.generate(
|
| 72 |
**inputs,
|
| 73 |
max_new_tokens=256,
|
| 74 |
+
temperature=0.3,
|
|
|
|
| 75 |
repetition_penalty=1.0,
|
| 76 |
do_sample=True,
|
| 77 |
+
pad_token_id=tokenizer.eos_token_id,
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|