You can also use the model for retrieval. For example:
import { pipeline, cos_sim } from'@xenova/transformers';
// Create a feature-extraction pipelineconst extractor = awaitpipeline('feature-extraction', 'Xenova/bge-m3');
// Define query to use for retrievalconst query = 'What is BGE M3?';
// List of documents you want to embedconst texts = [
'BGE M3 is an embedding model supporting dense retrieval, lexical matching and multi-vector interaction.',
'BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document',
];
// Compute sentence embeddingsconst embeddings = awaitextractor(texts, { pooling: 'cls', normalize: true });
// Compute query embeddingsconst query_embeddings = awaitextractor(query, { pooling: 'cls', normalize: true });
// Sort by cosine similarity scoreconst scores = embeddings.tolist().map(
(embedding, i) => ({
id: i,
score: cos_sim(query_embeddings.data, embedding),
text: texts[i],
})
).sort((a, b) => b.score - a.score);
console.log(scores);
// [// { id: 0, score: 0.62532672968664, text: 'BGE M3 is an embedding model supporting dense retrieval, lexical matching and multi-vector interaction.' },// { id: 1, score: 0.33111060648806, text: 'BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document' },// ]
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using
🤗 Optimum
and structuring your repo like this one (with ONNX weights located in a subfolder named
onnx
).
Runs of Xenova bge-m3 on huggingface.co
86.3K
Total runs
-3.9K
24-hour runs
-11.4K
3-day runs
-21.3K
7-day runs
-34.6K
30-day runs
More Information About bge-m3 huggingface.co Model
bge-m3 huggingface.co is an AI model on huggingface.co that provides bge-m3's model effect (), which can be used instantly with this Xenova bge-m3 model. huggingface.co supports a free trial of the bge-m3 model, and also provides paid use of the bge-m3. Support call bge-m3 model through api, including Node.js, Python, http.
bge-m3 huggingface.co is an online trial and call api platform, which integrates bge-m3's modeling effects, including api services, and provides a free online trial of bge-m3, you can try bge-m3 online for free by clicking the link below.
bge-m3 is an open source model from GitHub that offers a free installation service, and any user can find bge-m3 on GitHub to install. At the same time, huggingface.co provides the effect of bge-m3 install, users can directly use bge-m3 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.