Feature Extraction
sentence-transformers
Safetensors
Transformers
multilingual
qwen3
text-generation
custom_code
text-embeddings-inference
Instructions to use MongoDB/voyage-4-nano with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use MongoDB/voyage-4-nano with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("MongoDB/voyage-4-nano", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use MongoDB/voyage-4-nano with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="MongoDB/voyage-4-nano", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MongoDB/voyage-4-nano", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("MongoDB/voyage-4-nano", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Prompt for doc?
#1
by ChanningDai - opened
Hi, thanks for the release!
I noticed that there is a special prompt for the query ("Represent the query for retrieving supporting documents: "). Does the doc also require one?
It's likely to be "Represent the document for retrieval: ". Got it from MangoDB API doc.
I would also be interested in this but maybe, you are right, I tried to reproduce some of the spreadsheet results and with this this document prompt I get comparable results on most tasks besides FinQARetrieval where the score is 2.5% slower. Where is the document page that you found?
| Query Prompt | Document Prompt | Average | AILACasedocs | AILAStatutes | ChatDoctorRetrieval | DS1000Retrieval | FinQARetrieval | FinanceBenchRetrieval | HC3FinanceRetrieval | LegalQuAD | LegalSummarization |
|---|---|---|---|---|---|---|---|---|---|---|---|
| "Represent the query for retrieving supporting documents: " | "" | 66.996 | 41.228 | 50.638 | 68.268 | 63.739 | 80.892 | 90.944 | 65.531 | 69.9 | 71.82 |
| "Represent the query for retrieving supporting documents: " | "Represent the document for retrieval: " | 66.67955556 | 41.444 | 48.585 | 67 | 63.937 | 82.485 | 90.882 | 63.089 | 70.411 | 72.283 |
| Results from Spreadsheet | 67.096 | 42.844 | 48.56 | 66.97 | 63.87 | 85.03 | 90.88 | 62.97 | 70.34 | 72.4 |
hongliu9903 changed discussion status to closed