Useph El commited on
Commit
2857f30
·
1 Parent(s): 57b56de

Update `app.py`

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,7 +1,24 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
  import gradio as gr
3
 
4
+ # Load the model and tokenizer
5
+ model_name = "silma-ai/SILMA-9B-Instruct-v1.0"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ def generate_response(prompt):
10
+ inputs = tokenizer(prompt, return_tensors="pt")
11
+ outputs = model.generate(**inputs, max_length=200, num_return_sequences=1)
12
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+
14
+ # Gradio Interface
15
+ interface = gr.Interface(
16
+ fn=generate_response,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="SILMA-9B Instruct",
20
+ description="Provide a prompt, and the model generates a response."
21
+ )
22
+
23
+ interface.launch()
24