Skip to content

Commit d0d7b26

Browse files
committed
refactor: normalize
1 parent 4a83cd9 commit d0d7b26

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vllm/model_executor/models/jina_embeddings_v4.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ def _apply_vision_pooling_optimized(
226226
output = seq_states.mean(dim=0)
227227

228228
# Normalize and handle potential NaNs by replacing with zeros
229-
output = F.normalize(output, p=2, dim=-1)
230-
output = torch.nan_to_num(output)
229+
output = F.normalize(output, p=2, dim=-1, eps=1e-12)
231230
pooled_outputs.append(output)
232231

233232
offset += prompt_len
@@ -274,7 +273,7 @@ def _apply_vision_pooling_pytorch(
274273
pooled = seq_states.mean(dim=0)
275274

276275
# Normalize embeddings
277-
pooled = F.normalize(pooled, p=2, dim=-1)
276+
pooled = F.normalize(pooled, p=2, dim=-1, eps=1e-12)
278277
pooled_outputs.append(pooled)
279278

280279
offset += prompt_len

0 commit comments

Comments
 (0)