Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,10 @@ rm_tokenizer = AutoTokenizer.from_pretrained('OpenAssistant/reward-model-deberta
|
|
20 |
rm_model = AutoModelForSequenceClassification.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2', torch_dtype=torch.bfloat16)
|
21 |
|
22 |
@spaces.GPU
|
23 |
-
def generate_text(usertitle, content,
|
24 |
input_text = f"title: {usertitle}\ncontent: {content}"
|
25 |
inputs = tokenizer(input_text, return_tensors='pt').to('cuda')
|
26 |
-
generated_sequences = model.generate(inputs['input_ids'],
|
27 |
decoded_sequences = [tokenizer.decode(g, skip_special_tokens=True) for g in generated_sequences]
|
28 |
|
29 |
def score(sequence):
|
|
|
20 |
rm_model = AutoModelForSequenceClassification.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2', torch_dtype=torch.bfloat16)
|
21 |
|
22 |
@spaces.GPU
|
23 |
+
def generate_text(usertitle, content, temperature, max_length, N=3):
|
24 |
input_text = f"title: {usertitle}\ncontent: {content}"
|
25 |
inputs = tokenizer(input_text, return_tensors='pt').to('cuda')
|
26 |
+
generated_sequences = model.generate(inputs['input_ids'], attention_mask=attention_mask, temperature=temperature, max_length=max_length, pad_token_id=tokenizer.eos_token_id, num_return_sequences=N, do_sample=True)
|
27 |
decoded_sequences = [tokenizer.decode(g, skip_special_tokens=True) for g in generated_sequences]
|
28 |
|
29 |
def score(sequence):
|