Open 0110G opened 1 month ago
It may be because of the different normalization of all-MiniLM-L6-v2 . Can you try a different model? For exammple BGESmall and let me know.
My use case involves minilm only.
Okay. It is to pin-point the issue.
Mostly your implementation does not take care of mean_pooling
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
See: https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
This is something that I didnt face in qdrants python fast embed implementation
Yes. FastEmbed does this separately for this model. https://github.com/qdrant/fastembed/blob/9387ca320507737306ba6ec663398813158f8e29/fastembed/text/mini_lm_embedding.py#L50-L54
It's not updated here.
Would you be able to add this support. It will be really helpful. Noticed this issue in rust implementation as well
I work on these projects on the weekends. So then most probably.
The output this lib returns doesn't even match torch model output before mean pooling 😅
Now that's unexpected.
Will you be able to fix this?
I can take a look during the weekends.
Any updates
I was at work and couldn't get to this. If you're willing, I want you to know that contributions are welcome.
Hi. I am getting different embeddings when
Output:
[-3.44772786e-02 3.10232081e-02 6.73494861e-03 2.61090137e-02 -3.93620506e-02 -1.60302490e-01 6.69240057e-02 -6.44144369e-03...
import ( "github.com/anush008/fastembed-go" "fmt" )
func main() {
}