Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import torch
|
2 |
import gradio as gr
|
|
|
3 |
from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
|
4 |
|
5 |
tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
@@ -14,10 +15,10 @@ nlp = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
|
14 |
def generate(prompt):
|
15 |
# generate 10 samples using contrastive search
|
16 |
outs = nlp(prompt, max_length=76, num_return_sequences=3, do_sample=True, repetition_penalty=1.2, temperature=0.7, top_k=3, early_stopping=True)
|
17 |
-
|
18 |
print(prompt)
|
19 |
-
print(
|
20 |
-
return
|
21 |
|
22 |
|
23 |
# for i in range(len(outs)):
|
|
|
1 |
import torch
|
2 |
import gradio as gr
|
3 |
+
import json
|
4 |
from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
|
5 |
|
6 |
tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
|
|
15 |
def generate(prompt):
|
16 |
# generate 10 samples using contrastive search
|
17 |
outs = nlp(prompt, max_length=76, num_return_sequences=3, do_sample=True, repetition_penalty=1.2, temperature=0.7, top_k=3, early_stopping=True)
|
18 |
+
jsonStr = json.dumps(outs)
|
19 |
print(prompt)
|
20 |
+
print(jsonStr)
|
21 |
+
return jsonStr
|
22 |
|
23 |
|
24 |
# for i in range(len(outs)):
|