test2 / app.py
Bush233's picture
Create app.py
ed6b9f3 verified
raw
history blame contribute delete
526 Bytes
import gradio as gr
# pipeline函数用来加载模型并且推理
from transformers import pipeline
# 创建文本生成管道
pipe = pipeline("text-generation", model="Bush233/olmo3-190m-zh-full-continue")
# 定义预测(predict)函数
def predict(message):
# 调用pipe管道实现文本生成
# message:输入的提示词
# max_new_tokens:输出token的最大值
output = pipe(message, max_new_tokens=256)
return output[0]["generated_text"]
gr.Interface(fn=predict, inputs="text", outputs="text").launch()