Spaces:
Sleeping
Sleeping
File size: 1,185 Bytes
e3a8627 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
model_name = "Azurro/APT3-1B-Instruct-v1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
pipeline = transformers.pipeline("text-generation", model=model, tokenizer=tokenizer)
def generate_text(input_text, max_tokens, temperature, top_p):
sequences = pipeline(max_new_tokens=max_tokens, temperature=temperature, top_p=top_p, eos_token_id=tokenizer.eos_token_id, text_inputs=input_text)
txt = ""
for seq in sequences:
txt += seq['generated_text']
return txt
models_list = ["Azurro/APT3-1B-Instruct-v1"]
iface = gr.Interface(
fn=generate_text,
inputs=[
gr.Textbox(lines=2, placeholder="Wpisz tekst tutaj...", label="Wpisz tekst"),
gr.Slider(value=500, label="Maksymalna długość", step=1, minimum=1, maximum=4000),
gr.Slider(label="Temperatura", minimum=0.0, maximum=2.0, step=0.01, value=1.0),
gr.Number(value=1.0, label="Top P", step=0.01, minimum=0.0, maximum=2.0)
],
outputs=gr.Textbox(label="Wygenerowany tekst")
)
iface.launch()
|