hashhac commited on
Commit
bd4a44f
·
1 Parent(s): 289ad8b

added mask

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -129,11 +129,20 @@ def generate_response(prompt):
129
 
130
  full_prompt += "Assistant: "
131
 
132
- # Generate response
133
- inputs = llm_tokenizer(full_prompt, return_tensors="pt").to(device)
 
 
 
 
 
 
 
 
134
  with torch.no_grad():
135
  output = llm_model.generate(
136
- **inputs,
 
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,