Views
No views yet
nomic-ai/nomic-embed-text-v1-unsupervised for academic Computer Science text.| Base model | nomic-ai/nomic-embed-text-v1-unsupervised |
| Domain | Academic CS (arxiv cs.* + Qasper) |
| Tokens added | 500 (lowercase NL whole words) |
| New token ids | 30522 … 31021 |
| Embedding matrix | [31040, 768] (pad ×64; was [30528, 768]) |
config.vocab_size | 31040 |
| Init method | FVT — mean of former WordPiece piece embeddings |
| Transformer body | Unchanged |
| Training | None (surgery only); intended for ≤512-token training later |
cs.* categories (title + abstract) + Qasper full text.tokenizer.json → model.vocab (WordPiece). Sync vocab.txt as slow-path mirror only. Not HF add_tokens.W_new; copy rows 0..30521 unchanged; FVT-init new rows; set vocab_size=31040.tokenize(term) → one new id → that id indexes the initialized row; old rows untouched; general-text cosine ≈ 1 vs base.dataset, stochastic, datasets, gaussian, clustering, convolutional, embedding, probabilistic, decoding, dynamical, deterministic, bayesian, segmentation, embeddings, markov, achieves, polarization, asymptotic, mimo, experimentally, outperforms, queries, iterative, metrics, benchmark, photonic, throughput, generalization, relativistic, characterize, heterogeneous, robustness, dispersion, localization, excitation, planar, numerically, dipole, classifier, correlations, architectures, decoder, approximations, frac, automata, variational, dielectric, recurrent, latent, optimizedadded_domain_tokens.json| File | Description |
|---|---|
model.safetensors | Weights including expanded embedding matrix |
config.json | vocab_size=31040, NomicBert config |
tokenizer.json | Fast tokenizer with extended model.vocab |
tokenizer_config.json | Tokenizer settings (do_lower_case, specials, …) |
modeling_hf_nomic_bert.py | Nomic remote modeling code (required) |
configuration_hf_nomic_bert.py | Nomic config class |
added_domain_tokens.json | All 500 tokens + id map |
1from transformers import AutoTokenizer, AutoModel
2import torch
3import torch.nn.functional as F
4
5repo = "OmarH455/nomic-embed-text-v1-unsupervised-cs-surgery"
6tok = AutoTokenizer.from_pretrained(repo)
7model = AutoModel.from_pretrained(repo, trust_remote_code=True)
8model.eval()
9
10# Round-trip check: domain term is one token
11assert tok.tokenize("convolutional") == ["convolutional"]
12assert tok.encode("bayesian", add_special_tokens=False) == [tok.convert_tokens_to_ids("bayesian")]
13
14def mean_pool(out, mask):
15 e = out[0]
16 m = mask.unsqueeze(-1).expand(e.size()).float()
17 return (e * m).sum(1) / m.sum(1).clamp(min=1e-9)
18
19text = "search_document: Stochastic gradient methods for convolutional segmentation on large datasets."
20enc = tok(text, return_tensors="pt")
21with torch.no_grad():
22 emb = mean_pool(model(**enc), enc["attention_mask"])
23 emb = F.normalize(emb, p=2, dim=1)
24print(emb.shape) # [1, 768]python surgery/cs_phase4_verify.pytokenizer.json is the source of truth (not vocab.txt alone).30522 real vocab → 30528 matrix originally). New size 31040 follows the same rule.trust_remote_code=True (NomicBert custom code).