Spaces:
Sleeping
Sleeping
hashhac
commited on
Commit
·
bd4a44f
1
Parent(s):
289ad8b
added mask
Browse files
app.py
CHANGED
@@ -129,11 +129,20 @@ def generate_response(prompt):
|
|
129 |
|
130 |
full_prompt += "Assistant: "
|
131 |
|
132 |
-
# Generate response
|
133 |
-
inputs = llm_tokenizer(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
with torch.no_grad():
|
135 |
output = llm_model.generate(
|
136 |
-
|
|
|
137 |
max_new_tokens=128,
|
138 |
do_sample=True,
|
139 |
temperature=0.7,
|
|
|
129 |
|
130 |
full_prompt += "Assistant: "
|
131 |
|
132 |
+
# Generate response with explicit attention mask
|
133 |
+
inputs = llm_tokenizer(
|
134 |
+
full_prompt,
|
135 |
+
return_tensors="pt",
|
136 |
+
padding=True,
|
137 |
+
truncation=True,
|
138 |
+
max_length=512,
|
139 |
+
return_attention_mask=True # Explicitly request attention mask
|
140 |
+
).to(device)
|
141 |
+
|
142 |
with torch.no_grad():
|
143 |
output = llm_model.generate(
|
144 |
+
input_ids=inputs["input_ids"],
|
145 |
+
attention_mask=inputs["attention_mask"], # Pass the attention mask
|
146 |
max_new_tokens=128,
|
147 |
do_sample=True,
|
148 |
temperature=0.7,
|