Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ tokenizer = AutoTokenizer.from_pretrained("akoksal/LongForm-OPT-2.7B")
|
|
8 |
generate = pipeline('text-generation', model='akoksal/LongForm-OPT-2.7B', tokenizer=tokenizer)
|
9 |
|
10 |
|
11 |
-
def predict(instruction, topp, temperature):
|
12 |
if "[EOI]" not in instruction:
|
13 |
instruction = instruction + " [EOI]"
|
14 |
x = generate(instruction,
|
@@ -16,14 +16,16 @@ def predict(instruction, topp, temperature):
|
|
16 |
max_length=64,
|
17 |
top_p=topp,
|
18 |
num_return_sequences=1,
|
|
|
19 |
temperature=temperature
|
20 |
)[0]["generated_text"]
|
21 |
|
22 |
return x
|
23 |
|
24 |
iface = gr.Interface(fn=predict, inputs=["text",
|
25 |
-
gr.inputs.Slider(0,
|
26 |
-
gr.inputs.Slider(0,
|
|
|
27 |
],
|
28 |
outputs="text")
|
29 |
iface.launch()
|
|
|
8 |
generate = pipeline('text-generation', model='akoksal/LongForm-OPT-2.7B', tokenizer=tokenizer)
|
9 |
|
10 |
|
11 |
+
def predict(instruction, topp, max_new_tokens, temperature):
|
12 |
if "[EOI]" not in instruction:
|
13 |
instruction = instruction + " [EOI]"
|
14 |
x = generate(instruction,
|
|
|
16 |
max_length=64,
|
17 |
top_p=topp,
|
18 |
num_return_sequences=1,
|
19 |
+
max_new_tokens=max_new_tokens,
|
20 |
temperature=temperature
|
21 |
)[0]["generated_text"]
|
22 |
|
23 |
return x
|
24 |
|
25 |
iface = gr.Interface(fn=predict, inputs=["text",
|
26 |
+
gr.inputs.Slider(0, 3, default=0.90, label="top_p"),
|
27 |
+
gr.inputs.Slider(0, 2, default=64, label="max_new_tokens"),
|
28 |
+
gr.inputs.Slider(0, 1, default=1, label="temperature")
|
29 |
],
|
30 |
outputs="text")
|
31 |
iface.launch()
|