Triying / app.py
Arxhxi's picture
Rename launch.py to app.py
38806e4
raw
history blame contribute delete
628 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
def generate_response(input_text):
model_name = "cognitivecomputations/dolphin-2.1-mistral-7b"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200, num_beams=5, early_stopping=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
iface.launch()