|
|
|
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration |
|
|
|
|
|
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration |
|
|
|
|
|
model_name = 'facebook/blenderbot-400M-distill' |
|
tokenizer = BlenderbotTokenizer.from_pretrained(model_name) |
|
model = BlenderbotForConditionalGeneration.from_pretrained(model_name) |
|
|
|
def func (message): |
|
inputs = tokenizer(message, return_tensors="pt") |
|
result = model.generate(**inputs) |
|
return tokenizer.decode(result[0]) |
|
|
|
import gradio as gr |
|
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="Conversation Bot") |
|
app.launch() |