Set min length
Browse files
app.py
CHANGED
@@ -8,8 +8,8 @@ model = AutoModelForCausalLM.from_pretrained("rinna/japanese-gpt-1b")
|
|
8 |
|
9 |
generator = pipeline("text-generation", tokenizer=tokenizer, model=model)
|
10 |
|
11 |
-
def generate(text,
|
12 |
-
out = generator(text, do_sample=True, max_length=
|
13 |
text = out[0]['generated_text']
|
14 |
|
15 |
return text, translate_from_jp_to_en(text)
|
@@ -20,7 +20,7 @@ description = "Demo for generating text in Japanase using a GPT model"
|
|
20 |
article = "Built by Narrativa"
|
21 |
examples = [['日本のeスポーツ障害者がステレオタイプを撃ち落とす', 128]]
|
22 |
gr.Interface(fn=generate, inputs=[gr.inputs.Textbox(lines=4, label="Prompt"),
|
23 |
-
gr.inputs.Slider(minimum=8, maximum=1024, step=8, default=
|
24 |
outputs=["text", "text"],
|
25 |
title=title, description=description,
|
26 |
article= article,
|
|
|
8 |
|
9 |
generator = pipeline("text-generation", tokenizer=tokenizer, model=model)
|
10 |
|
11 |
+
def generate(text, min_length=512):
|
12 |
+
out = generator(text, do_sample=True, min_length=min_length, max_length=1024, num_return_sequences=1)
|
13 |
text = out[0]['generated_text']
|
14 |
|
15 |
return text, translate_from_jp_to_en(text)
|
|
|
20 |
article = "Built by Narrativa"
|
21 |
examples = [['日本のeスポーツ障害者がステレオタイプを撃ち落とす', 128]]
|
22 |
gr.Interface(fn=generate, inputs=[gr.inputs.Textbox(lines=4, label="Prompt"),
|
23 |
+
gr.inputs.Slider(minimum=8, maximum=1024, step=8, default=128, label="Number of tokens")],
|
24 |
outputs=["text", "text"],
|
25 |
title=title, description=description,
|
26 |
article= article,
|