Spaces:
Runtime error
Runtime error
added app created with mistral to create mistral
Browse files
app.py
CHANGED
@@ -1,3 +1,16 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
|
4 |
+
def generate_response(input_text):
|
5 |
+
model_name = "cognitivecomputations/dolphin-2.1-mistral-7b"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_length=200, num_beams=5, early_stopping=True)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
return response
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
16 |
+
iface.launch()
|