Commit
·
c4395ff
1
Parent(s):
8fc3a64
upload last-token model
Browse files
modeling_jina_embeddings_c1.py
CHANGED
@@ -39,16 +39,6 @@ def batch(iterable, n=1):
|
|
39 |
yield iterable[ndx : min(ndx + n, items)]
|
40 |
|
41 |
|
42 |
-
def mean_pooling(model_output, attention_mask):
|
43 |
-
token_embeddings = model_output[0]
|
44 |
-
input_mask_expanded = (
|
45 |
-
attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
46 |
-
)
|
47 |
-
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(
|
48 |
-
input_mask_expanded.sum(1), min=1e-9
|
49 |
-
)
|
50 |
-
|
51 |
-
|
52 |
def last_token_pooling(model_output, attention_mask):
|
53 |
token_embeddings = model_output[0]
|
54 |
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
|
|
|
39 |
yield iterable[ndx : min(ndx + n, items)]
|
40 |
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
def last_token_pooling(model_output, attention_mask):
|
43 |
token_embeddings = model_output[0]
|
44 |
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
|