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