|
import gradio as gr |
|
from transformers import AutoTokenizer, GPTJForCausalLM |
|
|
|
|
|
model_name = "mrm8488/bertin-gpt-j-6B-ES-v1-8bit" |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = GPTJForCausalLM.from_pretrained(model_name) |
|
|
|
|
|
def chatbot(message): |
|
inputs = tokenizer(message, return_tensors="pt") |
|
outputs = model.generate(inputs.input_ids, max_length=150) |
|
response = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return response |
|
|
|
|
|
demo = gr.Interface( |
|
fn=chatbot, |
|
inputs="text", |
|
outputs="text", |
|
title="Chatbot en Espa帽ol" |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|