Views
No views yet

pq256x4fs fast-scan FAISS index or using the example code published alongside our 1.5 model).| Model Name | # params | # non-emb params | # dimensions | BEIR (15) | MIRACL (4) | CLEF (Focused) | CLEF (Full) |
|---|---|---|---|---|---|---|---|
| snowflake-arctic-m-v2.0 | 305M | 113M | 768 | 55.4 | 55.2 | 51.7 | 53.9 |
| snowflake-arctic-m | 109M | 86M | 768 | 54.9 | 24.9 | 34.4 | 29.1 |
| me5 base | 560M | 303M | 1024 | 51.4 | 54.0 | 43.0 | 34.6 |
| bge-m3 (BAAI) | 568M | 303M | 1024 | 48.8 | 56.8 | 40.8 | 41.3 |
| gte (Alibaba) | 305M | 113M | 768 | 51.1 | 52.3 | 47.7 | 53.1 |
| Model | BEIR (15) | Relative Performance | MIRACL (4) | Relative Performance | CLEF (5) | Relative Performance | CLEF (Full) | Relative Performance | |
|---|---|---|---|---|---|---|---|---|---|
| snowflake-arctic-m-v2.0 | 768 | 55.4 | N/A | 55.2 | N/A | 51.7 | N/A | 53.9 | N/A |
| snowflake-arctic-m-v2.0 | 256 | 54.4 | -1.81% | 54.0 | -2.17% | 50.6 | -2.13% | 52.3 | -3.06% |
1from sentence_transformers import SentenceTransformer
2
3# Load the model
4model_name = 'Snowflake/snowflake-arctic-embed-m-v2.0'
5model = SentenceTransformer(model_name, trust_remote_code=True)
6
7# Define the queries and documents
8queries = ['what is snowflake?', 'Where can I get the best tacos?']
9documents = ['The Data Cloud!', 'Mexico City of Course!']
10
11# Compute embeddings: use `prompt_name="query"` to encode queries!
12query_embeddings = model.encode(queries, prompt_name="query")
13document_embeddings = model.encode(documents)
14
15# Compute cosine similarity scores
16scores = model.similarity(query_embeddings, document_embeddings)
17
18# Output the results
19for query, query_scores in zip(queries, scores):
20 doc_score_pairs = list(zip(documents, query_scores))
21 doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
22 print("Query:", query)
23 for document, score in doc_score_pairs:
24 print(score, document)
251import torch
2from transformers import AutoModel, AutoTokenizer
3
4model_name = 'Snowflake/snowflake-arctic-embed-m-v2.0'
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModel.from_pretrained(model_name, add_pooling_layer=False, trust_remote_code=True)
7model.eval()
8
9query_prefix = 'query: '
10queries = ['what is snowflake?', 'Where can I get the best tacos?']
11queries_with_prefix = ["{}{}".format(query_prefix, i) for i in queries]
12query_tokens = tokenizer(queries_with_prefix, padding=True, truncation=True, return_tensors='pt', max_length=8192)
13
14documents = ['The Data Cloud!', 'Mexico City of Course!']
15document_tokens = tokenizer(documents, padding=True, truncation=True, return_tensors='pt', max_length=8192)
16
17# Compute token embeddings
18with torch.no_grad():
19 query_embeddings = model(**query_tokens)[0][:, 0]
20 document_embeddings = model(**document_tokens)[0][:, 0]
21
22
23# normalize embeddings
24query_embeddings = torch.nn.functional.normalize(query_embeddings, p=2, dim=1)
25document_embeddings = torch.nn.functional.normalize(document_embeddings, p=2, dim=1)
26
27scores = torch.mm(query_embeddings, document_embeddings.transpose(0, 1))
28for query, query_scores in zip(queries, scores):
29 doc_score_pairs = list(zip(documents, query_scores))
30 doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
31 #Output passages & scores
32 print("Query:", query)
33 for document, score in doc_score_pairs:
34 print(score, document)npm i @huggingface/transformers1import { pipeline, dot } from '@huggingface/transformers';
2
3// Create feature extraction pipeline
4const extractor = await pipeline('feature-extraction', 'Snowflake/snowflake-arctic-embed-m-v2.0');
5
6// Generate sentence embeddings
7const sentences = [
8 'query: what is snowflake?',
9 'The Data Cloud!',
10 'Mexico City of Course!',
11]
12const output = await extractor(sentences, { normalize: true, pooling: 'cls' });
13
14// Compute similarity scores
15const [source_embeddings, ...document_embeddings ] = output.tolist();
16const similarities = document_embeddings.map(x => dot(source_embeddings, x));
17console.log(similarities); // [0.32719788157046004, 0.06960141111667434]