04/16/2024: Release the ** snowflake-arctic-embed ** family of text embedding models. The releases are state-of-the-art for Retrieval quality at each of their representative size profiles.
Technical Report
is coming shortly. For more details, please refer to our Github:
Arctic-Text-Embed
.
Models
snowflake-arctic-embed is a suite of text embedding models that focuses on creating high-quality retrieval models optimized for performance.
The
snowflake-arctic-embedding
models achieve
state-of-the-art performance on the MTEB/BEIR leaderboard
for each of their size variants. Evaluation is performed using these
scripts
. As shown below, each class of model size achieves SOTA retrieval accuracy compared to other top models.
The models are trained by leveraging existing open-source text representation models, such as bert-base-uncased, and are trained in a multi-stage pipeline to optimize their retrieval performance. First, the models are trained with large batches of query-document pairs where negatives are derived in-batch—pretraining leverages about 400m samples of a mix of public datasets and proprietary web search data. Following pretraining models are further optimized with long training on a smaller dataset (about 1m samples) of triplets of query, positive document, and negative document derived from hard harmful mining. Mining of the negatives and data curation is crucial to retrieval accuracy. A detailed technical report can be found
here
.
Aside from being great open-source models, the largest model,
snowflake-arctic-embed-l
, can serve as a natural replacement for closed-source embedding, as shown below.
This tiny model packs quite the punch. Based on the
all-MiniLM-L6-v2
model with only 22m parameters and 384 dimensions, this model should meet even the strictest latency/TCO budgets. Despite its size, its retrieval accuracy is closer to that of models with 100m paramers.
Based on the
intfloat/e5-small-unsupervised
model, this small model does not trade off retrieval accuracy for its small size. With only 33m parameters and 384 dimensions, this model should easily allow scaling to large datasets.
Based on the
intfloat/e5-base-unsupervised
model, this medium model is the workhorse that provides the best retrieval performance without slowing down inference.
Based on the
nomic-ai/nomic-embed-text-v1-unsupervised
model, this long-context variant of our medium-sized model is perfect for workloads that can be constrained by the regular 512 token context of our other models. Without the use of RPE, this model supports up to 2048 tokens. With RPE, it can scale to 8192!
Based on the
intfloat/e5-large-unsupervised
model, this large model is a direct drop-in for closed APIs and delivers the most accurate retrieval experience.
You can use the sentence-transformers package to use an snowflake-arctic-embed model, as shown below.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Snowflake/snowflake-arctic-embed-s")
queries = ['what is snowflake?', 'Where can I get the best tacos?']
documents = ['The Data Cloud!', 'Mexico City of Course!']
query_embeddings = model.encode(queries, prompt_name="query")
document_embeddings = model.encode(documents)
scores = query_embeddings @ document_embeddings.T
for query, query_scores inzip(queries, scores):
doc_score_pairs = list(zip(documents, query_scores))
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
# Output passages & scoresprint("Query:", query)
for document, score in doc_score_pairs:
print(score, document)
Query: what is snowflake?
0.533809 The Data Cloud!
0.49207097 Mexico City of Course!
Query: Where can I get the best tacos?
0.56592476 Mexico City of Course!
0.48255116 The Data Cloud!
Using Huggingface transformers
You can use the transformers package to use an snowflake-arctic-embed model, as shown below. For optimal retrieval quality, use the CLS token to embed each text portion and use the query prefix below (just on the query).
import torch
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('Snowflake/snowflake-arctic-embed-s')
model = AutoModel.from_pretrained('Snowflake/snowflake-arctic-embed-s', add_pooling_layer=False)
model.eval()
query_prefix = 'Represent this sentence for searching relevant passages: '
queries = ['what is snowflake?', 'Where can I get the best tacos?']
queries_with_prefix = ["{}{}".format(query_prefix, i) for i in queries]
query_tokens = tokenizer(queries_with_prefix, padding=True, truncation=True, return_tensors='pt', max_length=512)
documents = ['The Data Cloud!', 'Mexico City of Course!']
document_tokens = tokenizer(documents, padding=True, truncation=True, return_tensors='pt', max_length=512)
# Compute token embeddingswith torch.no_grad():
query_embeddings = model(**query_tokens)[0][:, 0]
doument_embeddings = model(**document_tokens)[0][:, 0]
# normalize embeddings
query_embeddings = torch.nn.functional.normalize(query_embeddings, p=2, dim=1)
doument_embeddings = torch.nn.functional.normalize(doument_embeddings, p=2, dim=1)
scores = torch.mm(query_embeddings, doument_embeddings.transpose(0, 1))
for query, query_scores inzip(queries, scores):
doc_score_pairs = list(zip(documents, query_scores))
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
#Output passages & scoresprint("Query:", query)
for document, score in doc_score_pairs:
print(score, document)
Using Transformers.js
If you haven't already, you can install the
Transformers.js
JavaScript library from
NPM
by running:
npm i @xenova/transformers
You can then use the model to compute embeddings as follows:
import { pipeline, dot } from'@xenova/transformers';
// Create feature extraction pipelineconst extractor = awaitpipeline('feature-extraction', 'Snowflake/snowflake-arctic-embed-s', {
quantized: false, // Comment out this line to use the quantized version
});
// Generate sentence embeddingsconst sentences = [
'Represent this sentence for searching relevant passages: Where can I get the best tacos?',
'The Data Cloud!',
'Mexico City of Course!',
]
const output = awaitextractor(sentences, { normalize: true, pooling: 'cls' });
// Compute similarity scoresconst [source_embeddings, ...document_embeddings ] = output.tolist();
const similarities = document_embeddings.map(x =>dot(source_embeddings, x));
console.log(similarities); // [0.48255123876493394, 0.5659250100112143]
FAQ
TBD
Contact
Feel free to open an issue or pull request if you have any questions or suggestions about this project.
You also can email Daniel Campos(
daniel.campos@snowflake.com
).
License
Arctic is licensed under the
Apache-2
. The released models can be used for commercial purposes free of charge.
Acknowledgement
We want to thank the open-source community, which has provided the great building blocks upon which we could make our models.
We thank our modeling engineers, Danmei Xu, Luke Merrick, Gaurav Nuti, and Daniel Campos, for making these great models possible.
We thank our leadership, Himabindu Pucha, Kelvin So, Vivek Raghunathan, and Sridhar Ramaswamy, for supporting this work.
We also thank the open-source community for producing the great models we could build on top of and making these releases possible.
Finally, we thank the researchers who created BEIR and MTEB benchmarks.
It is largely thanks to their tireless work to define what better looks like that we could improve model performance.
Runs of Snowflake snowflake-arctic-embed-s on huggingface.co
30.2K
Total runs
0
24-hour runs
436
3-day runs
290
7-day runs
153
30-day runs
More Information About snowflake-arctic-embed-s huggingface.co Model
snowflake-arctic-embed-s huggingface.co is an AI model on huggingface.co that provides snowflake-arctic-embed-s's model effect (), which can be used instantly with this Snowflake snowflake-arctic-embed-s model. huggingface.co supports a free trial of the snowflake-arctic-embed-s model, and also provides paid use of the snowflake-arctic-embed-s. Support call snowflake-arctic-embed-s model through api, including Node.js, Python, http.
snowflake-arctic-embed-s huggingface.co is an online trial and call api platform, which integrates snowflake-arctic-embed-s's modeling effects, including api services, and provides a free online trial of snowflake-arctic-embed-s, you can try snowflake-arctic-embed-s online for free by clicking the link below.
Snowflake snowflake-arctic-embed-s online free url in huggingface.co:
snowflake-arctic-embed-s is an open source model from GitHub that offers a free installation service, and any user can find snowflake-arctic-embed-s on GitHub to install. At the same time, huggingface.co provides the effect of snowflake-arctic-embed-s install, users can directly use snowflake-arctic-embed-s installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
snowflake-arctic-embed-s install url in huggingface.co: