models-and-embeddings
Guides Semantra embedding model selection, OpenAI and Hugging Face backends, pooling options, and backend troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- models-and-embeddings
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides Semantra embedding model selection, OpenAI and Hugging Face backends, pooling options, and backend troubleshooting.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md4.4 KB
- 参考文档references/model-selection.md5.1 KB
- 参考文档references/troubleshooting.md5.0 KB
- 脚本scripts/inspect_model_registry.py3.4 KB
03 SKILL.md 正文
Semantra Models and Embeddings
Use this sub-skill when the task is to choose, inspect, or troubleshoot the embedding model Semantra uses while indexing documents and running semantic queries.
Read first
- model-selection.md for preset model choices, custom Hugging Face commands, OpenAI privacy/cost tradeoffs, CUDA expectations, and pooling knobs.
- api-reference.md for verified Semantra model classes, registry defaults, and embedding helper methods.
- troubleshooting.md for OpenAI credentials and SDK compatibility, Hugging Face downloads, CUDA/memory, SGPT/SVM, and pooling failures.
- Run inspect_model_registry.py when you need to inspect the installed Semantra preset registry without instantiating models or downloading weights.
Route here when
- The user asks which
--modelvalue to use:mpnet,minilm,sgpt,sgpt-1.3B, oropenai. - The user wants a custom Hugging Face transformer with
--transformer-model. - The user asks whether Semantra can use a GPU or why it is slow on CPU.
- The user needs OpenAI setup, cost/privacy guidance, or an
OPENAI_API_KEYdiagnosis. - The user is tuning
--pool-size,--pool-count, document/query special tokens, or SGPT-style asymmetric query/document tokens. - The user sees errors from
torch,transformers,tiktoken,openai, or missingscikit-learnwhile using model-related options.
Route file preprocessing, cache artifacts, --windows, and --semantra-dir to
document-indexing. Route query arithmetic,
result tags, and local web UI behavior to
interactive-search.
Default decision flow
-
For private local search, start with a local transformer model. The default
mpnetis the documented quality-oriented default. Useminilmwhen speed and small memory footprint matter more than accuracy. -
For larger or more accurate local models, consider
sgptorsgpt-1.3B. SGPT presets are asymmetric: queries and documents are wrapped in different special tokens. Do not combine asymmetric models with--svm. -
For non-English or specialized domains, use a custom Hugging Face model:
semantra --transformer-model intfloat/multilingual-e5-base <files>Add
--query-token-pre,--query-token-post,--doc-token-pre, and--doc-token-postonly when the model documentation requires those tokens. -
Use
--model openaionly after the user accepts the privacy, network, API key, and cost implications. Semantra sends document windows and queries to OpenAI in that mode. -
Confirm the installed registry before a risky run:
python path/to/inspect_model_registry.py semantra --list-models
Backend expectations
Semantra's transformer backend asks PyTorch whether CUDA is available. If it is,
TransformerModel(..., cuda=None) moves the model and token tensors to CUDA;
otherwise CPU execution is used. CUDA is an acceleration path, not a requirement
for core Semantra behavior.
The first transformer run may download tokenizer/model files from Hugging Face unless they are already cached. Plan disk, network, and privacy constraints before indexing a large or sensitive corpus.
Known compatibility edges
- Semantra 0.1.12 imports
pkg_resources. Some modern Setuptools environments no longer provide it; see the root troubleshooting reference for thesetuptools<81workaround or code-update option. - Semantra 0.1.12 calls the legacy
openai.Embedding.createAPI. If a current OpenAI SDK reports anAPIRemovedInV1Proxyor similar error, use a compatibleopenai<1environment or update Semantra's OpenAI integration before relying on--model openai. --svmlazily importssklearn.svm, butscikit-learnis not declared in Semantra's package dependencies. Install it explicitly if that route is selected.
Validation signals
A model-selection answer should include:
- the exact command flags;
- whether model weights or API calls will cross the network;
- whether input text leaves the user's machine;
- expected memory/runtime tradeoffs;
- a safe check such as
semantra --list-modelsorinspect_model_registry.py --jsonbefore a costly indexing run.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).