frankrobotics commited on
Commit
fde5a4a
Β·
verified Β·
1 Parent(s): ee06da2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,7 +1,29 @@
1
  import gradio as gr
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  def model(params):
4
- return "hello world"
 
 
 
 
 
 
5
 
6
  app = gr.Interface(fn=model, inputs="textbox", outputs="textbox")
7
  app.launch()
 
1
  import gradio as gr
2
 
3
+ import torch
4
+ from transformers import pipeline
5
+
6
+ model_id = "meta-llama/Llama-3.2-3B-Instruct"
7
+ pipe = pipeline(
8
+ "text-generation",
9
+ model=model_id,
10
+ torch_dtype=torch.bfloat16,
11
+ device_map="auto",
12
+ )
13
+ messages = [
14
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
15
+ {"role": "user", "content": "Who are you?"},
16
+ ]
17
+
18
+
19
  def model(params):
20
+ outputs = pipe(
21
+ messages,
22
+ max_new_tokens=256,
23
+ )
24
+ output = outputs[0]["generated_text"][-1]
25
+ print(output)
26
+ return output
27
 
28
  app = gr.Interface(fn=model, inputs="textbox", outputs="textbox")
29
  app.launch()