feat: add Arctic Embed 2.0 (M and L) models - #656
Conversation
Add Snowflake/snowflake-arctic-embed-m-v2.0 (768 dims, GTE-based, multilingual, 8192 tokens) and Snowflake/snowflake-arctic-embed-l-v2.0 (1024 dims, XLM-RoBERTa-based, multilingual, 8192 tokens). Arctic Embed 2.0 adds multilingual support (100+ languages) without sacrificing English performance. Both models support 8192 token context (16x longer than Arctic Embed 1.0's 512 tokens). Canonical vectors generated via: - M: ONNX runtime inference (same execution path as fastembed) - L: sentence-transformers + PyTorch (reference implementation) Both models use Apache-2.0 license and are available on HuggingFace with pre-built ONNX exports.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds medium and large Snowflake Arctic Embed v2.0 multilingual ONNX models to the supported model registry. It defines their embedding dimensions, token limits, licenses, sizes, sources, and file paths. It also adds canonical test vectors for both models. Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@fastembed/text/onnx_embedding.py`:
- Line 175: Update the model descriptors for
Snowflake/snowflake-arctic-embed-m-v2.0 and
Snowflake/snowflake-arctic-embed-l-v2.0 to state “74 languages” instead of “100+
languages,” unless a revision-specific source in the descriptors substantiates
the broader claim.
- Line 177: Update the Snowflake Arctic-Embed v2.0 handling in OnnxTextModel so
query inputs receive the required “query: ” prefix before tokenization, or
revise both query/document prefix descriptions to clearly require callers to add
it. Ensure the documented contract matches the actual preprocessing behavior for
v2.0 models.
- Around line 194-195: Update the large model descriptor in the relevant model
configuration to include onnx/model.onnx_data alongside onnx/model.onnx in its
allowed/downloaded model files, ensuring the external ONNX data file is cached
with the model.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f2f124ae-7a9f-4327-9f08-cb0c33a1a8f5
📒 Files selected for processing (2)
fastembed/text/onnx_embedding.pytests/test_text_onnx_embeddings.py
| description=( | ||
| "Text embeddings, Unimodal (text), Multilingual (100+ languages), " | ||
| "8192 input tokens truncation, " | ||
| "Prefixes for queries/documents: not necessary, 2025 year." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate and inspect the referenced source, related model registrations, and base embedding behavior.
git ls-files | rg '(^|/)fastembed/(text/onnx_embedding.py|text/text_embedding_base.py|.*\.py)$' | head -200
echo '--- onnx_embedding references around Snowflake/arctic ---'
rg -n "snowflake|arctic|Prefixes for queries/documents|query:|document" fastembed/text/onnx_embedding.py fastembed/text -S || true
echo '--- snippets ---'
if [ -f fastembed/text/onnx_embedding.py ]; then
nl -ba fastembed/text/onnx_embedding.py | sed -n '140,210p'
fi
if [ -f fastembed/text/text_embedding_base.py ]; then
nl -ba fastembed/text/text_embedding_base.py | sed -n '1,260p'
fiRepository: qdrant/fastembed
Length of output: 14796
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import re, urllib.request
target='https://raw.githubusercontent.com/Snowflake-Labs/snowflake-arctic-embed-m-v2.0/main/model_card.md'
try:
text=urllib.request.urlopen(target, timeout=20).read().decode()
print('--- raw model card excerpt ---')
for i,line in enumerate(text.splitlines(),1):
if 'query' in line.lower() or 'document' in line.lower() or 'prefix' in line.lower():
print(f'{i}: {line}')
except Exception as exc:
print(f'FETCH_ERROR {exc}')
hug='https://huggingface.co/Snowflake/snowflake-arctic-embed-m-v2.0'
query='https://huggingface.co/api/models/Snowflake/snowflake-arctic-embed-m-v2.0'
try:
text=urllib.request.urlopen(query, timeout=20).read().decode()
import json
data=json.loads(text)
print('--- huggingface model tags ---', data.get('tags'))
except Exception as exc:
print(f'HF_API_ERROR {exc}')
PYRepository: qdrant/fastembed
Length of output: 449
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate model definitions and embedding entrypoints without external network calls.
printf '--- onnx_embedding.py model metadata and implementations ---\n'
awk 'NR>=90 && NR<=220 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_embedding.py
printf '\n--- base/embedding query/document flow ---\n'
awk 'NR>=20 && NR<=190 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_text_model.py
awk 'NR>=130 && NR<=190 {printf "%4d: %s\n", NR, $0}' fastembed/text/text_embedding.py
awk 'NR>=35 && NR<=55 {printf "%4d: %s\n", NR, $0}' fastembed/text/text_embedding_base.py
printf '\n--- OnnxTextModel constructor fields relevant to query document handling ---\n'
awk 'NR>=1 && NR<=90 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_text_model.pyRepository: qdrant/fastembed
Length of output: 245
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate model definitions and embedding entrypoints without external network calls.
printf '%s\n' '--- onnx_embedding.py model metadata and implementations ---'
awk 'NR>=90 && NR<=220 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_embedding.py
printf '%s\n' ''
printf '%s\n' '--- base/embedding query document flow ---'
awk 'NR>=20 && NR<=190 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_text_model.py
awk 'NR>=130 && NR<=190 {printf "%4d: %s\n", SR, $0}' fastembed/text/text_embedding.py
awk 'NR>=35 && NR<=55 {printf "%4d: %s\n", NR, $0}' fastembed/text/text_embedding_base.py
printf '%s\n' ''
printf '%s\n' '--- OnnxTextModel constructor fields relevant to query document handling ---'
awk 'NR>=1 && NR<=90 {printf "%4d: %s\n", NR, $0}' fastembed/text/onnx_text_model.pyRepository: qdrant/fastembed
Length of output: 20989
🌐 Web query:
Snowflake/snowflake-arctic-embed-m-v2.0 Snowflake/snowflake-arctic-embed-l-v2.0 query: prefix query embeddings
💡 Result:
For Snowflake's Arctic-Embed v2.0 series (including both the medium and large variants), it is recommended to use a query prefix for optimal retrieval quality [1][2]. The specific prefix to use for these v2.0 models is "query: " (note the space after the colon) [1][2][3]. This prefix should be applied only to the query text, not to the documents [1][2]. When using the Hugging Face transformers library, you prepend this string to your query before tokenization [1][2]. Alternatively, if you are using the sentence-transformers library, you can encode queries by specifying prompt_name="query" in the model.encode() method, which handles the prefix automatically [1][3]. It is important to note that this requirement is specific to the v2.0 models. While earlier versions (such as v1.5) also required a prefix for optimal performance, they used a different, longer instruction string ("Represent this sentence for searching relevant passages: ") [4][5][6]. Using the incorrect prefix or failing to use one can negatively impact retrieval performance [7].
Citations:
- 1: https://huggingface.co/Snowflake/snowflake-arctic-embed-m-v2.0
- 2: https://huggingface.co/Snowflake/snowflake-arctic-embed-l-v2.0
- 3: https://huggingface.co/Snowflake/snowflake-arctic-embed-l-v2.0/blob/9fd85e702ce5326f8b5340aabd05792e4e72af83/README.md
- 4: https://github.com/Snowflake-Labs/arctic-embed
- 5: https://huggingface.co/Snowflake/snowflake-arctic-embed-m
- 6: https://huggingface.co/Snowflake/snowflake-arctic-embed-l
- 7: query_prefix in examples Snowflake-Labs/arctic-embed#1
Update the v2.0 query-prefix contract.
The Snowflake Arctic-Embed v2.0 model cards recommend query: only for query text. The Prefixes for queries/documents: not necessary descriptions at lines 177 and 190 are misleading. If these models use the default OnnxTextModel path, raw query text is tokenized without that prefix, so add explicit query preprocessing or update both descriptions to document that callers must add query: .
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@fastembed/text/onnx_embedding.py` at line 177, Update the Snowflake
Arctic-Embed v2.0 handling in OnnxTextModel so query inputs receive the required
“query: ” prefix before tokenization, or revise both query/document prefix
descriptions to clearly require callers to add it. Ensure the documented
contract matches the actual preprocessing behavior for v2.0 models.
Source: MCP tools
…, and L model external data - Change '100+ languages' to '74 languages' (per HuggingFace model card metadata) - Update prefix description: Arctic Embed 2.0 recommends 'query: ' prefix for retrieval queries - Add additional_files=['onnx/model.onnx_data'] for L model (external ONNX data file required for loading)
Add Snowflake/snowflake-arctic-embed-m-v2.0 (768 dims, GTE-based, multilingual, 8192 tokens) and Snowflake/snowflake-arctic-embed-l-v2.0 (1024 dims, XLM-RoBERTa-based, multilingual, 8192 tokens).
Arctic Embed 2.0 adds multilingual support (100+ languages) without sacrificing English performance. Both models support 8192 token context (16x longer than Arctic Embed 1.0's 512 tokens).
Canonical vectors generated via:
Both models use Apache-2.0 license and are available on HuggingFace with pre-built ONNX exports.
All Submissions:
New Feature Submissions:
pre-commitwithpip3 install pre-commitand set up hooks withpre-commit install?New models submission: