nein0six commited on
Commit
dbd54ee
·
verified ·
1 Parent(s): 1bc2e43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -1,23 +1,15 @@
1
  import gradio as gr
2
- from llama_cpp import Llama
3
 
4
- # Download het biomedische GGML-model (direct van Hugging Face)
5
- model_url = "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML"
 
6
 
7
- # Initialiseer het model (werkt op CPU)
8
- llm = Llama(
9
- model_path=model_url,
10
- n_ctx=2048,
11
- n_threads=4,
12
- )
13
 
14
- def chat_fn(message, history):
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()