Views
No views yet
nomic-embed-text-v1 is 8192 context length text encoder that surpasses OpenAI text-embedding-ada-002 and text-embedding-3-small performance on short and long context tasks.| Name | SeqLen | MTEB | LoCo | Jina Long Context | Open Weights | Open Training Code | Open Data |
|---|---|---|---|---|---|---|---|
| nomic-embed-text-v1 | 8192 | 62.39 | 85.53 | 54.16 | ✅ | ✅ | ✅ |
| jina-embeddings-v2-base-en | 8192 | 60.39 | 85.45 | 51.90 | ✅ | ❌ | ❌ |
| text-embedding-3-small | 8191 | 62.26 | 82.40 | 58.20 | ❌ | ❌ | ❌ |
| text-embedding-ada-002 | 8191 | 60.99 | 52.7 | 55.25 | ❌ | ❌ | ❌ |
nomic-embed-text-v1 is now multimodal! nomic-embed-vision-v1 is aligned to the embedding space of nomic-embed-text-v1, meaning any text embedding is multimodal!search_document: <text here> and embed your user queries as search_query: <text here>.search_document1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True)
4sentences = ['search_document: TSNE is a dimensionality reduction algorithm created by Laurens van Der Maaten']
5embeddings = model.encode(sentences)
6print(embeddings)search_query1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True)
4sentences = ['search_query: Who is Laurens van Der Maaten?']
5embeddings = model.encode(sentences)
6print(embeddings)clustering1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True)
4sentences = ['clustering: the quick brown fox']
5embeddings = model.encode(sentences)
6print(embeddings)classification1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True)
4sentences = ['classification: the quick brown fox']
5embeddings = model.encode(sentences)
6print(embeddings)1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True)
4sentences = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?']
5embeddings = model.encode(sentences)
6print(embeddings)1import torch
2import torch.nn.functional as F
3from transformers import AutoTokenizer, AutoModel
4
5def mean_pooling(model_output, attention_mask):
6 token_embeddings = model_output[0]
7 input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
8 return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
9
10sentences = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?']
11
12tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
13model = AutoModel.from_pretrained('nomic-ai/nomic-embed-text-v1', trust_remote_code=True)
14model.eval()
15
16encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
17
18with torch.no_grad():
19 model_output = model(**encoded_input)
20
21embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
22embeddings = F.normalize(embeddings, p=2, dim=1)
23print(embeddings)1- tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
2+ tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased', model_max_length=8192)
3
4
5- model = AutoModel.from_pretrained('nomic-ai/nomic-embed-text-v1', trust_remote_code=True)
6+ model = AutoModel.from_pretrained('nomic-ai/nomic-embed-text-v1', trust_remote_code=True, rotary_scaling_factor=2)1import { pipeline } from '@xenova/transformers';
2
3// Create a feature extraction pipeline
4const extractor = await pipeline('feature-extraction', 'nomic-ai/nomic-embed-text-v1', {
5 quantized: false, // Comment out this line to use the quantized version
6});
7
8// Compute sentence embeddings
9const texts = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?'];
10const embeddings = await extractor(texts, { pooling: 'mean', normalize: true });
11console.log(embeddings);nomic Python client is as easy as1from nomic import embed
2
3output = embed.text(
4 texts=['Nomic Embedding API', '#keepAIOpen'],
5 model='nomic-embed-text-v1',
6 task_type='search_document'
7)
8
9print(output)contrastors repository1@misc{nussbaum2024nomic,
2 title={Nomic Embed: Training a Reproducible Long Context Text Embedder},
3 author={Zach Nussbaum and John X. Morris and Brandon Duderstadt and Andriy Mulyar},
4 year={2024},
5 eprint={2402.01613},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}