kali commited on
Commit
4791c81
1 Parent(s): 0f170ce

mistral model in app file commit

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -1,7 +1,35 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # it is a 46.7B params llm model.
5
+
6
+ model_id = "mistralai/Mixtral-8x7B-v0.1"
7
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
8
+
9
+ model = AutoModelForCausalLM.from_pretrained(model_id)
10
+
11
+ text = "Hello my name is"
12
+ inputs = tokenizer(text, return_tensors="pt")
13
+
14
+ outputs = model.generate(**inputs, max_new_tokens=20)
15
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
16
+
17
 
18
  def greet(name):
19
+ # it is a 46.7B params llm model.
20
+
21
+ model_id = "mistralai/Mixtral-8x7B-v0.1"
22
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
23
+
24
+ model = AutoModelForCausalLM.from_pretrained(model_id)
25
+
26
+ text = name #"Hello my name is"
27
+ inputs = tokenizer(text, return_tensors="pt")
28
+
29
+ outputs = model.generate(**inputs, max_new_tokens=20)
30
+ #print(tokenizer.decode(outputs[0], skip_special_tokens=True))
31
+
32
+ return tokenizer.decode(outputs[0], skip_special_tokens) #="Hello " + name + "!!"
33
 
34
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
35
  iface.launch()