Skip to content

Commit

Permalink
make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-chung committed Nov 9, 2024
1 parent da1a189 commit fcc76d4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mteb/models/vlm2vec_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,15 @@ def get_text_embeddings(self, texts: list[str], batch_size: int = 32):

all_text_embeddings = torch.cat(all_text_embeddings, dim=0)
return all_text_embeddings

def calculate_probs(self, text_embeddings, image_embeddings):
text_embeddings = text_embeddings / text_embeddings.norm(
dim=-1, keepdim=True
)
image_embeddings = image_embeddings / image_embeddings.norm(
dim=-1, keepdim=True
)
logits = torch.matmul(image_embeddings, text_embeddings.T)
probs = (logits * 100).softmax(dim=-1)
return probs
text_embeddings = text_embeddings / text_embeddings.norm(dim=-1, keepdim=True)
image_embeddings = image_embeddings / image_embeddings.norm(
dim=-1, keepdim=True
)
logits = torch.matmul(image_embeddings, text_embeddings.T)
probs = (logits * 100).softmax(dim=-1)
return probs

def get_fused_embeddings(
self,
Expand Down

0 comments on commit fcc76d4

Please sign in to comment.