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-l-v2.0 | 568M | 303M | 1024 | 55.6 | 55.8 | 52.9 | 54.3 |
| snowflake-arctic-m | 109M | 86M | 768 | 54.9 | 24.9 | 34.4 | 29.1 |
| snowflake-arctic-l | 335M | 303M | 1024 | 56.0 | 34.8 | 38.2 | 33.7 |
| 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-l-v2.0 | 1024 | 55.6 | N/A | 55.8 | N/A | 52.9 | N/A | 54.3 | N/A |
| snowflake-arctic-l-v2.0 | 256 | 54.3 | -0.18% | 54.3 | -2.70% | 51.9 | -1.81% | 53.4 | -1.53% |
1from sentence_transformers import SentenceTransformer
2
3# Load the model
4model_name = 'Snowflake/snowflake-arctic-embed-l-v2.0'
5model = SentenceTransformer(model_name)
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-l-v2.0'
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModel.from_pretrained(model_name, add_pooling_layer=False)
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)Query: what is snowflake?
tensor(0.2715) The Data Cloud!
tensor(0.0661) Mexico City of Course!
Query: Where can I get the best tacos?
tensor(0.2797) Mexico City of Course!
tensor(0.1250) The Data Cloud!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 dtype: 'q8',
6});
7
8// Generate sentence embeddings
9const sentences = [
10 'query: what is snowflake?',
11 'The Data Cloud!',
12 'Mexico City of Course!',
13]
14const output = await extractor(sentences, { normalize: true, pooling: 'cls' });
15
16// Compute similarity scores
17const [source_embeddings, ...document_embeddings ] = output.tolist();
18const similarities = document_embeddings.map(x => dot(source_embeddings, x));
19console.log(similarities); // [0.24783534471401417, 0.05313122704326892]