MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / _get_embedding

Method _get_embedding

methods/embedding_rag.py:69–74  ·  view source on GitHub ↗
(self, outputs, attention_mask)

Source from the content-addressed store, hash-verified

67 """Base class for models using mean pooling."""
68
69 def _get_embedding(self, outputs, attention_mask):
70 last_hidden = outputs.last_hidden_state if hasattr(outputs, 'last_hidden_state') else outputs[0]
71 mask_expanded = attention_mask.unsqueeze(-1).expand(last_hidden.size()).float()
72 sum_embeddings = (last_hidden * mask_expanded).sum(dim=1)
73 sum_mask = mask_expanded.sum(dim=1).clamp(min=1e-9)
74 return sum_embeddings / sum_mask
75
76
77class Qwen3EmbeddingEmbeddings(MeanPoolingEmbeddings):

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected