Gradio 是一个用于构建交互式界面的 Python 库,可以轻松创建和共享机器学习模型的 Web 应用程序。下面是一个简单的 Gradio 使用示例:
import gradio as gr | |
def evaluate(*args): | |
args_str = ' '.join(str(arg) for arg in args) | |
return args_str | |
gr.Interface( | |
fn=evaluate, | |
inputs=[ | |
gr.components.Textbox( | |
lines=2, | |
label="Instruction", | |
placeholder="Tell me about alpacas.", | |
), | |
gr.components.Textbox(lines=2, label="Input", placeholder="none"), | |
gr.components.Slider(minimum=0, maximum=1, value=0.1, label="Temperature"), | |
gr.components.Slider(minimum=0, maximum=1, value=0.75, label="Top p"), | |
gr.components.Slider(minimum=0, maximum=100, step=1, value=40, label="Top k"), | |
gr.components.Slider(minimum=1, maximum=4, step=1, value=4, label="Beams"), | |
gr.components.Slider(minimum=1, maximum=2000, step=1, value=128, label="Max tokens"), | |
gr.components.Checkbox(label="Stream output"), | |
], | |
outputs=[ | |
gr.inputs.Textbox( | |
lines=5, | |
label="Output", | |
) | |
], | |
title="🦙🌲 Alpaca-LoRA", | |
description="Alpaca-LoRA is a 7B-parameter LLaMA model finetuned to follow instructions. It is trained on the [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) dataset and makes use of the Huggingface LLaMA implementation. For more information, please visit [the project's website](https://github.com/tloen/alpaca-lora).", # noqa: E501 | |
).queue().launch(server_name="0.0.0.0", share=False) |
正文完