Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
9a9b4f9
1
Parent(s):
903c7ca
Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,11 @@ model = AutoModelForCausalLM.from_pretrained("NovelAI/genji-python-6B").half().e
|
|
11 |
|
12 |
import gradio as gr
|
13 |
|
14 |
-
maxLength=400
|
15 |
top_k = 50
|
16 |
repetition_penalty = 1.13
|
17 |
repetition_penalty_range = 512
|
18 |
repetition_penalty_slope = 3.33
|
19 |
-
def generator(text, temperature,top_p):
|
20 |
tokens = tokenizer(text, return_tensors="pt").input_ids.cuda()[:, -(2047-maxLength):]
|
21 |
out = model.generate(
|
22 |
tokens.long(),
|
@@ -44,11 +43,12 @@ gr.Interface(
|
|
44 |
[gr.inputs.Textbox(label="input text", lines=5),
|
45 |
gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0.2, label="Temperature"),
|
46 |
gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=1, label="Top P")
|
|
|
47 |
],
|
48 |
gr.outputs.Textbox(label="Output text"),
|
49 |
title=title,
|
50 |
description=description,
|
51 |
article=article,
|
52 |
examples=[
|
53 |
-
['def print_Hello_Huggingface():']
|
54 |
]).launch(debug=True)
|
|
|
11 |
|
12 |
import gradio as gr
|
13 |
|
|
|
14 |
top_k = 50
|
15 |
repetition_penalty = 1.13
|
16 |
repetition_penalty_range = 512
|
17 |
repetition_penalty_slope = 3.33
|
18 |
+
def generator(text, temperature ,top_p, maxLength):
|
19 |
tokens = tokenizer(text, return_tensors="pt").input_ids.cuda()[:, -(2047-maxLength):]
|
20 |
out = model.generate(
|
21 |
tokens.long(),
|
|
|
43 |
[gr.inputs.Textbox(label="input text", lines=5),
|
44 |
gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0.2, label="Temperature"),
|
45 |
gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=1, label="Top P")
|
46 |
+
gr.inputs.Slider(minimum=1, maximum=400, step=10, default=300, label="Max Length")
|
47 |
],
|
48 |
gr.outputs.Textbox(label="Output text"),
|
49 |
title=title,
|
50 |
description=description,
|
51 |
article=article,
|
52 |
examples=[
|
53 |
+
['def print_Hello_Huggingface():', 0.2, 1,300]
|
54 |
]).launch(debug=True)
|