milvus-io / milvus-model

The embedding/reranking model zoo help user to convert their unstructured data into embeddings
Apache License 2.0
22 stars 17 forks source link

Fix: Correct parameter name in _encode method for BGEM3FlagModel #45

Closed thititj closed 1 week ago

thititj commented 3 weeks ago

Fix: BGEM3EmbeddingFunction encode() parameter mismatch

Issue

When using the BGEM3EmbeddingFunction class, users encounter the following error:

M3Embedder.encode() missing 1 required positional argument: 'queries'

This occurs because the _encode() method is using sentences as the parameter name when calling self.model.encode(), but the underlying BGEM3FlagModel expects the parameter to be named queries.

Solution

Changed the parameter name in the _encode() method from sentences to queries to match the expected parameter name of the underlying model:

# Before
output = self.model.encode(sentences=texts, **self._encode_config)

# After
output = self.model.encode(queries=texts, **self._encode_config)

Testing

Additional Context

This fix aligns with the FlagEmbedding implementation which uses queries as the parameter name in its encode method.

Related Issues

Resolves the error reported in various contexts where users attempt to use the BGE-M3 model with Milvus.