binxu.wang
commited on
Commit
•
4dc002b
1
Parent(s):
ef210ec
add
Browse files
app.py
CHANGED
@@ -20,9 +20,9 @@ from transformers import BertTokenizerFast, BertTokenizer
|
|
20 |
model = GPT2LMHeadModel.from_pretrained("binxu/Ziyue-GPT2")
|
21 |
generator = pipeline('text-generation', model=model, tokenizer='bert-base-chinese')
|
22 |
|
23 |
-
def generate(prompt, num_beams, max_length, repetition_penalty,
|
24 |
|
25 |
-
torch.manual_seed(
|
26 |
|
27 |
outputs = generator(prompt, max_length=max_length, num_return_sequences=5, num_beams=num_beams, repetition_penalty=repetition_penalty)
|
28 |
output_texts = [output['generated_text'] for output in outputs]
|
|
|
20 |
model = GPT2LMHeadModel.from_pretrained("binxu/Ziyue-GPT2")
|
21 |
generator = pipeline('text-generation', model=model, tokenizer='bert-base-chinese')
|
22 |
|
23 |
+
def generate(prompt, num_beams, max_length, repetition_penalty, ):
|
24 |
|
25 |
+
torch.manual_seed(42)
|
26 |
|
27 |
outputs = generator(prompt, max_length=max_length, num_return_sequences=5, num_beams=num_beams, repetition_penalty=repetition_penalty)
|
28 |
output_texts = [output['generated_text'] for output in outputs]
|