text2vec converts words, sentences, and paragraphs into vector matrices in Python. It bundles Word2Vec, BM25, Sentence-BERT, CoSENT, and related similarity models with training and inference helpers.
Overview
text2vec focuses on representing text as dense vectors and computing semantic similarity. Implementations include classical Word2Vec and RankBM25, BERT-family matching models, Sentence-BERT-style encoders, and CoSENT with a ranking-oriented loss the authors compare against SBERT on Chinese and English STS benchmarks.
You can load pretrained models from Hugging Face hubs, compute embeddings in code, run batch vectorization through a CLI, and scale inference across multiple GPUs or CPUs via multiprocessing examples. Released checkpoints cover Chinese, multilingual, and BGE-tuned variants with documented evaluation tables on ATEC, BQ, LCQMC, PAWSX, STS-B, and additional corpora.
Training scripts support supervised and unsupervised text-matching setups, multi-GPU training, FlagEmbedding-style BGE fine-tuning with contrastive triples, and optional deployment examples using Jina gRPC or FastAPI HTTP services built around the models.
Downstream examples include cosine similarity between sentences, semantic search over a candidate list, and integration with the separate similarities library for larger-scale matching workflows.
Key features
- Sentence and word embeddings
- CoSENT and Sentence-BERT trainers
- Word2Vec and RankBM25 baselines
- Pretrained Chinese and multilingual models
- Multi-GPU inference and training
- CLI batch text vectorization
- Hugging Face and transformers usage
- Jina and FastAPI serve examples
Use cases
- Score semantic similarity between sentences
- Encode documents for search indexes
- Fine-tune Chinese STS matching models
- Batch-embed corpora from shell scripts
- Serve embedding APIs in private infra