A high-performance embedding model from the Orange organization, built by extending nomic-ai/nomic-embed-text-v1.5 to 1536 dimensions using a learnable linear projection.
This model is a modified version of
Nomic Embed v1.5, which itself is an improvement over the original Nomic Embed model. The key enhancement is that this model has been projected from the native 768-dimensional space to a
1536-dimensional space while preserving semantic similarity.
1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("Orange/orange-nomic-v1.5-1536", trust_remote_code=True)
4
5# Embed documents
6documents = ['search_document: The quick brown fox jumps over the lazy dog']
7doc_embeddings = model.encode(documents)
8
9# Embed queries
10queries = ['search_query: What animal is in the sentence?']
11query_embeddings = model.encode(queries)
1from sentence_transformers import SentenceTransformer
2import torch.nn.functional as F
3
4model = SentenceTransformer("Orange/orange-nomic-v1.5-1536", trust_remote_code=True)
5
6# Encode sentences
7sentences = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?']
8embeddings = model.encode(sentences, convert_to_tensor=True)
9
10# Optional: Apply layer normalization and truncate for Matryoshka
11matryoshka_dim = 768 # Can use any dimension <= 1536
12embeddings = F.layer_norm(embeddings, normalized_shape=(embeddings.shape[1],))
13embeddings = embeddings[:, :matryoshka_dim]
14embeddings = F.normalize(embeddings, p=2, dim=1)
15
16print(embeddings.shape) # torch.Size([2, 768])
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
10model_name = "Orange/orange-nomic-v1.5-1536"
11tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
12model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
13model.eval()
14
15sentences = ['search_query: What is TSNE?', 'search_query: Who is Laurens van der Maaten?']
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.layer_norm(embeddings, normalized_shape=(embeddings.shape[1],))
23embeddings = embeddings[:, :1536] # Use full 1536-dim
24embeddings = F.normalize(embeddings, p=2, dim=1)
25print(embeddings.shape) # torch.Size([2, 1536])
This model supports Matryoshka Representation Learning - you can use smaller embedding dimensions:
See the model card on HuggingFace for the complete MTEB leaderboard results.
If you use this model in your research, please cite the original Nomic Embed work:
1@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}
This model is licensed under Apache 2.0.