sounar commited on
Commit
08422e4
1 Parent(s): 3247e99

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
+
5
+ # Load the model
6
+ model_name = "ruslanmv/Medical-Llama3-8B"
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)
9
+
10
+ def generate_response(question):
11
+ inputs = tokenizer(question, return_tensors="pt").input_ids.to(model.device)
12
+ outputs = model.generate(inputs, max_new_tokens=256)
13
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+
15
+ iface = gr.Interface(
16
+ fn=generate_response,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="Medical Query Assistant",
20
+ description="Ask medical questions and receive AI-powered answers.",
21
+ )
22
+
23
+ iface.launch(share=True)