Update app.py
Browse files
app.py
CHANGED
|
@@ -16,14 +16,8 @@ model = AutoModelForCausalLM.from_pretrained(model_name, token=api_token)
|
|
| 16 |
|
| 17 |
# Define the inference function
|
| 18 |
def generate_text(prompt, max_length, temperature):
|
| 19 |
-
inputs = tokenizer(prompt, return_tensors="pt"
|
| 20 |
-
output = model.generate(
|
| 21 |
-
inputs['input_ids'],
|
| 22 |
-
max_length=max_length,
|
| 23 |
-
temperature=temperature,
|
| 24 |
-
do_sample=True, # Enable sampling
|
| 25 |
-
attention_mask=inputs['attention_mask'] # Pass attention mask
|
| 26 |
-
)
|
| 27 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
| 28 |
|
| 29 |
|
|
|
|
| 16 |
|
| 17 |
# Define the inference function
|
| 18 |
def generate_text(prompt, max_length, temperature):
|
| 19 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 20 |
+
output = model.generate(inputs['input_ids'], max_length=max_length, temperature=temperature)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
| 22 |
|
| 23 |
|