text2vec-base-chinese

text2vec-base-chinese is a Chinese‑language sentence embedding model released by shibing624 . It belongs to the Sentence‑Transformers family and is trained with the

shibing624 348K downloads apache-2.0 Sentence Similarity
Frameworkssentence-transformerspytorchonnxsafetensorsopenvino
Languageszh
Datasetsshibing624/nli_zh
TagsbertSentence Transformerssentence-similarity
Downloads
348K
License
apache-2.0
Pipeline
Sentence Similarity
Author
shibing624

Run text2vec-base-chinese locally on a Q4KM hard drive

Get blazing‑fast Chinese semantic search out of the box with Q4KM hard drives pre‑loaded with text2vec-base-chinese . Ready for plug‑and‑play deployment on your on‑premise servers. Shop now and...

Shop Q4KM Drives

Technical Overview

text2vec-base-chinese is a Chinese‑language sentence embedding model released by shibing624. It belongs to the Sentence‑Transformers family and is trained with the CoSENT (Cosine‑based Sentence) loss. The model maps any Chinese sentence (or short paragraph) into a 768‑dimensional dense vector that captures its semantic meaning. These vectors can be compared with a simple cosine similarity, enabling fast, accurate text matching, semantic search, and clustering without the need for task‑specific fine‑tuning.

Key Features & Capabilities

  • 768‑dimensional embeddings generated in a single forward pass.
  • Optimized for Chinese semantic similarity (STS‑B) and NLI tasks.
  • Supports the standard sentence‑similarity pipeline tag, making it plug‑and‑play with the Sentence‑Transformers library.
  • Compatible with multiple deployment formats: PyTorch, ONNX, OpenVINO, Safetensors, and Azure‑ML endpoints.
  • Fast inference (≈3 k QPS on a single V100) while keeping memory footprint modest.

Architecture Highlights

  • Backbone: hfl/chinese-macbert-base, a 12‑layer, 768‑hidden‑size BERT‑style encoder pre‑trained on large Chinese corpora.
  • Training objective: CoSENT loss, which directly optimizes cosine similarity between positive sentence pairs and pushes negative pairs apart.
  • Fine‑tuned on the shibing624/nli_zh dataset, a collection of Chinese natural‑language‑inference (NLI) triples that provide high‑quality semantic supervision.
  • Output head: a mean‑pooling layer that aggregates token embeddings into a single 768‑dim vector.

Intended Use Cases

  • Semantic search over Chinese document collections.
  • Duplicate detection or plagiarism checking for Chinese text.
  • Sentence‑level clustering, topic modeling, or recommendation systems.
  • Pre‑processing for downstream Chinese NLP pipelines (e.g., intent classification, QA retrieval).

Benchmark Performance

The model’s primary evaluation metric is the Spearman correlation on Chinese semantic similarity benchmarks. In the published evaluation table, text2vec-base-chinese achieves an average Spearman score of 51.61 across seven Chinese text‑matching datasets (ATEC, BQ, LCQMC, PAWSX, STS‑B, SOHU‑dd, SOHU‑dc). This places it above classic Word2Vec baselines (35.03) and comparable to other CoSENT models based on larger backbones.

Why these benchmarks matter:

  • ATEC, BQ, LCQMC test short‑sentence paraphrase detection.
  • PAWSX focuses on word‑order and lexical variation.
  • STS‑B is the standard Chinese semantic textual similarity benchmark.
  • SOHU‑dd / SOHU‑dc evaluate domain‑specific matching.

Compared to multilingual SBERT models (e.g., paraphrase‑multilingual‑MiniLM‑L12‑v2) the Chinese‑specific CoSENT model delivers higher STS‑B performance (79.30 vs 78.90) while keeping inference speed competitive (≈3 k QPS). The larger “large‑Chinese” CoSENT variant (text2vec‑large‑chinese) pushes the average to 53.12 but requires more memory; for many production scenarios the base model offers the best trade‑off between accuracy and resource consumption.

Hardware Requirements

VRAM for Inference – The model’s PyTorch checkpoint occupies roughly 300 MB. A single forward pass for a batch of 64 sentences needs about 2 GB of GPU memory; a batch of 256 sentences fits comfortably on a 4 GB GPU. For ONNX or OpenVINO deployments the memory footprint drops to ~1 GB.

Recommended GPU – Any modern NVIDIA GPU with ≥ 4 GB VRAM (e.g., RTX 2060, GTX 1660 Ti, or Tesla T4) can run the model at > 2 k QPS. For higher throughput (≥ 5 k QPS) a V100/A100 or RTX 3080 (10 GB+) is advisable.

CPU – On CPU‑only inference the model runs at ~ 150–200 QPS on an 8‑core Intel Xeon (2.6 GHz). Using ONNX Runtime with MKL‑DNN can improve CPU speed by ~30 %.

Storage – The model files (PyTorch, Safetensors, ONNX) total under 400 MB. Including the tokenizer and config files, a full installation requires ≈ 500 MB of disk space.

Use Cases

Primary Applications

  • Semantic Search: Index a Chinese knowledge base and retrieve relevant passages with a single cosine‑similarity lookup.
  • Duplicate Detection: Flag near‑duplicate user‑generated content (e.g., forum posts, news articles).
  • Paraphrase Mining: Build a paraphrase database for data augmentation in downstream Chinese NLP tasks.
  • Intent Matching: Match user queries to predefined intent sentences in chatbot or voice‑assistant pipelines.

Real‑World Examples

  • Customer‑support ticket routing – map incoming tickets to a set of predefined issue categories.
  • E‑commerce product recommendation – match product titles or descriptions to user search queries.
  • Legal document analysis – identify similar clauses across contracts written in Chinese.

Integration Possibilities – The model can be loaded via the sentence_transformers Python library, exported to ONNX for Java/Node.js services, or wrapped in an Azure ML endpoint (tag deploy:azure). Its sentence‑similarity pipeline tag ensures compatibility with Hugging Face transformers pipelines, making integration into existing ML stacks straightforward.

Training Details

Methodology – The model was fine‑tuned using the CoSENT loss on the shibing624/nli_zh dataset. Positive pairs consist of premise‑hypothesis sentences that share the same NLI label (entailment), while negative pairs are sampled from opposite labels. Mean‑pooling over the final hidden states yields the 768‑dim embedding.

Datasets

  • shibing624/nli_zh – a Chinese NLI corpus (≈ 200 k sentence pairs) providing high‑quality semantic supervision.
  • Additional internal validation sets derived from Chinese STS‑B and other matching benchmarks.

Compute Requirements – Training was performed on a single NVIDIA V100 (16 GB) for roughly 3 hours, using a batch size of 256 and the AdamW optimizer with a learning rate of 2e‑5. The total training FLOPs are estimated at ~ 0.5 TFLOP, which is modest for a BERT‑size model.

Fine‑Tuning Capabilities – Users can further fine‑tune the model on domain‑specific sentence pairs (e.g., medical Q&A) by re‑using the same CoSENT loss script (examples/training_sup_text_matching_model.py) and providing a custom .jsonl dataset. The model’s architecture remains unchanged, so downstream inference speed is preserved.

Licensing Information

The model card lists the license as Apache‑2.0 (the README explicitly states license: apache-2.0). Apache‑2.0 is a permissive open‑source license that allows:

  • Free commercial and non‑commercial use.
  • Modification, redistribution, and creation of derivative works.
  • Patents granted to the contributors.

Restrictions – The only obligations are:

  • Preserve the copyright notice and license text in any redistributed copies.
  • State any modifications you make to the original model.
There are no “unknown” restrictions; the Apache‑2.0 terms are clear and widely accepted in enterprise environments.

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives