Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
# it is a 46.7B params llm model. | |
model_id = "mistralai/Mixtral-8x7B-v0.1" | |
tokenizer = AutoTokenizer.from_pretrained(model_id) | |
model = AutoModelForCausalLM.from_pretrained(model_id) | |
text = "Hello my name is" | |
inputs = tokenizer(text, return_tensors="pt") | |
outputs = model.generate(**inputs, max_new_tokens=20) | |
print(tokenizer.decode(outputs[0], skip_special_tokens=True)) | |
def greet(name): | |
# it is a 46.7B params llm model. | |
model_id = "mistralai/Mixtral-8x7B-v0.1" | |
tokenizer = AutoTokenizer.from_pretrained(model_id) | |
model = AutoModelForCausalLM.from_pretrained(model_id) | |
text = name #"Hello my name is" | |
inputs = tokenizer(text, return_tensors="pt") | |
outputs = model.generate(**inputs, max_new_tokens=20) | |
#print(tokenizer.decode(outputs[0], skip_special_tokens=True)) | |
return tokenizer.decode(outputs[0], skip_special_tokens) #="Hello " + name + "!!" | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() |