|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
import gradio as gr |
|
|
|
|
|
model_name = "EleutherAI/gpt-neo-1.3B" |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModelForCausalLM.from_pretrained(model_name) |
|
|
|
|
|
def chat_with_model(input_text): |
|
inputs = tokenizer(input_text, return_tensors="pt") |
|
outputs = model.generate(inputs["input_ids"], max_length=150, temperature=1.0) |
|
response = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return response |
|
|
|
|
|
iface = gr.Interface(fn=chat_with_model, inputs="text", outputs="text", title="AI Chatbot") |
|
|
|
|
|
iface.launch() |
|
|