Recommended Vector Embedding Models for the patent‑oa Sub‑Skill
The patent‑oa sub‑skill recommends Zhipu embedding‑3 as its default vector embedding model, with four alternative presets available including DashScope, OpenAI, MiniMax, and local BAAI models.
The patent‑oa sub‑skill in the handsomestWei/patent-disclosure-skill repository implements a flexible embedding layer that abstracts multiple providers behind a unified Embedder class. This design lets you switch between cloud APIs and local inference without changing application code.
Default Recommendation: Zhipu embedding‑3
The Zhipu embedding‑3 model (智谱AI) is declared as the RECOMMENDED_PRESET in skills/patent-oa/tools/config.py at lines 77‑86. This preset configures:
- Provider:
openai_compatible - Model name:
embedding-3 - Vector dimensions: 1024
- Base URL:
https://open.bigmodel.cn/api/paas/v4 - Authentication:
ZHIPUAI_API_KEYenvironment variable
The preset definition in config.py (lines 30‑38) follows the OpenAI‑compatible /v1/embeddings specification, enabling drop‑in replacement with other compatible services.
How the Embedding Layer Selects Models
The Embedder class in skills/patent-oa/tools/embed.py dynamically loads provider configuration via load_config (lines 41‑48). When provider == "openai_compatible", the _embed_openai method executes:
- POSTs text batches to the configured
base_url - Returns L2‑normalized vectors via NumPy (lines 83‑88)
from skills.patent_oa.tools.embed import Embedder
# Initialize with default config (Zhipu embedding‑3 preset)
embedder = Embedder()
texts = ["专利权利要求分析", "现有技术对比方法"]
vectors = embedder.embed_texts(texts) # numpy.ndarray, shape (2, 1024)
print(vectors.shape) # (2, 1024)
Alternative Presets in config.py
The same configuration module defines four additional ready‑to‑use presets. Switch between them by editing embedding.config.yaml or using environment variables.
| Preset | Provider | Model | Dimensions | Key Requirements |
|---|---|---|---|---|
| dashscope | openai_compatible | text-embedding-v3 | 1024 | DASHSCOPE_API_KEY (Alibaba Cloud) |
| openai | openai_compatible | text-embedding-3-small | 1536 | OPENAI_API_KEY |
| minimax | minimax | embo-01 | 1536 | MINIMAX_API_KEY + MINIMAX_GROUP_ID |
| local | sentence_transformers | BAAI/bge-small-zh-v1.5 | 512 | Runs offline, no API key needed |
Local Deployment with BAAI Models
The local preset uses the sentence-transformers library to run BAAI/bge-small-zh-v1.5 entirely on‑premises. This is defined in skills/patent-oa/tools/embed.py where the _embed_local method loads the model via SentenceTransformer and performs inference without network calls. Dependencies are listed in skills/patent-oa/tools/requirements-oa.txt.
CLI Inspection of Recommendations
You can verify the active recommendation without opening source files:
python skills/patent-oa/tools/config.py recommend
This outputs the full preset configuration including provider, model, dimensions, and rationale (referenced in INSTALL.md at line 177).
Summary
- Zhipu embedding‑3 is the default recommended vector embedding model for patent‑oa, configured in
config.pyas theRECOMMENDED_PRESET. - The
Embedderclass abstracts provider selection; implementation switches occur in_embed_openai,_embed_minimax, or_embed_localbased on config. - 1024 dimensions is the standard output size for Zhipu and DashScope presets; OpenAI and MiniMax use 1536, local BAAI uses 512.
- All presets support L2‑normalized output suitable for cosine similarity search in patent disclosure analysis pipelines.
Frequently Asked Questions
How do I switch from the default Zhipu model to OpenAI?
Set the embedding_provider field to "openai" in your embedding.config.yaml file, or export OPENAI_API_KEY with the appropriate base_url override. The Embedder class reloads configuration on instantiation without code changes.
What are the hardware requirements for the local BAAI preset?
The BAAI/bge-small-zh-v1.5 model requires approximately 400MB of disk space and runs efficiently on CPU with 4GB+ RAM. GPU acceleration is optional via PyTorch CUDA but not required for typical patent document batch sizes.
Why does Zhipu embedding‑3 use 1024 dimensions instead of 1536?
The dimension count is a model architecture decision by 智谱AI. The config.py preset explicitly sets "dimensions": 1024 to match the upstream API contract. This smaller size reduces storage overhead for vector databases while maintaining retrieval accuracy for Chinese patent text.
Can I use a custom embedding model not listed in the presets?
Yes. Create a new entry in skills/patent-oa/tools/config.py following the PRESETS dictionary structure, specifying provider as "openai_compatible" (if API‑based) or "sentence_transformers" (if Hugging Face‑based). The Embedder class will route to the appropriate handler based on your provider value.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →