ThomasBlumet
commited on
Commit
·
4faf856
1
Parent(s):
a20783b
change model
Browse files
app.py
CHANGED
@@ -20,11 +20,14 @@ model = GPT2Model.from_pretrained('gpt2')
|
|
20 |
# Generate text using the model and tokenizer
|
21 |
#@spaces.GPU(duration=60)
|
22 |
def generate_text(input_text):
|
23 |
-
input_ids = tokenizer.encode(input_text, return_tensors="pt")#.to("cuda")
|
24 |
#attention_mask = input_ids.ne(tokenizer.pad_token_id).long()
|
25 |
#output = model.generate(input_ids, max_new_tokens=512, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)# attention_mask=attention_mask, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)
|
26 |
-
output = model.generate(input_ids) #, attention_mask=attention_mask, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)
|
27 |
-
return tokenizer.decode(output[0])
|
|
|
|
|
|
|
28 |
|
29 |
# Example of disabling Exllama backend (if applicable in your configuration)
|
30 |
#config = {"disable_exllama": True}
|
|
|
20 |
# Generate text using the model and tokenizer
|
21 |
#@spaces.GPU(duration=60)
|
22 |
def generate_text(input_text):
|
23 |
+
#input_ids = tokenizer.encode(input_text, return_tensors="pt")#.to("cuda")
|
24 |
#attention_mask = input_ids.ne(tokenizer.pad_token_id).long()
|
25 |
#output = model.generate(input_ids, max_new_tokens=512, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)# attention_mask=attention_mask, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)
|
26 |
+
#output = model.generate(input_ids) #, attention_mask=attention_mask, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2, top_k=50, top_p=0.95, temperature=0.7, do_sample=True)
|
27 |
+
#return tokenizer.decode(output[0])
|
28 |
+
encoded_input = tokenizer(input_text, return_tensors='pt')
|
29 |
+
output = model(**encoded_input)
|
30 |
+
return output
|
31 |
|
32 |
# Example of disabling Exllama backend (if applicable in your configuration)
|
33 |
#config = {"disable_exllama": True}
|