chatapi / app.py
siriusdemon
update
233f117
raw
history blame contribute delete
574 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_id = "llm-jp/llm-jp-3-1.8b-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(model_id)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def chat(message, history=[]):
prompt = message
result = pipe(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)[0]["generated_text"]
return result
gr.ChatInterface(fn=chat, title="🗣️ 日本語LLM Chatbot").launch()