数据转换丨向量
Turn a category list into embedding vectors — no API, but it needs one extra install
- 状态
- 结果信息
- 保存路径
- 类目数量
- 向量维度
- 分类JSON示例
The name makes it sound like an API call, but this one is all local and needs no key. ConvertDataToVectors takes a structured list of categories - each with a name, aliases, and keywords - runs them through a sentence-embedding model on your machine, and saves the result as vectors.npy plus a meta.json. It's the offline prep step for the pack's VectorMatcher node, which does semantic category matching: instead of exact-string matching, you're comparing meaning. In practice that means a workflow can classify a prompt or tag against a category list even when the wording doesn't literally match.
It lives in ComfyUI-QING's data-tools category (display name 数据转换丨向量). The model is loaded from your local models/embeddings directory via the sentence-transformers library - that's the key detail, because it's not in the pack's own requirements file, so this node will refuse to work until you install it yourself.
How it works. Point it at a JSON file that's a list of category objects. The schema (there's a storefront_categories.json.example in the pack showing it) is roughly:
[
{
"category_id": 1,
"category_name": "高端酒楼",
"level1_name": "餐饮行业",
"level2_name": "中式正餐",
"aliases": ["高端酒楼"],
"keywords": ["高端酒楼", "中式正餐"],
"scene_words": ["到店消费", "堂食"]
}
]
For each row it builds a candidate text from those fields, encodes the whole batch with the embedding model, normalizes if you want, and writes meta.json + vectors.npy to the save location. Outputs: 状态, 结果信息 (a JSON dump of what it did), 保存路径, 类目数量, 向量维度, and 分类JSON示例 (an example of the expected schema, so you don't have to guess). The dry_run flag is the wise first move - it validates your JSON and reports the schema and count without encoding anything.
The inputs that matter.
model_name_or_path- populated from the embedding models found in your ComfyUImodels/embeddingsdir; defaults tobge-base-zh-v1.5if nothing's there. That's a Chinese BGE model, and it has to exist locally - this node doesn't download it.categories_json_path- your category file. There's no working default in the pack (only a.example), so expect to supply this.batch_size,normalize_embeddings,overwrite,dry_run- the knobs; defaults (64, true, true, false) are fine.
How to install. ComfyUI-QING is a one-pack install - search "ComfyUI-QING" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Then, separately, install the embedding library this node needs (it's not in the pack's requirements):
pip install sentence-transformers
Restart afterward. The README's clone URL is typo'd (GAOSHI-QING, missing the H) - use the URL above or Manager.
Troubleshooting. Two honest gotchas, both from reading the source rather than the README. First: no sentence-transformers → the node errors with "未安装 sentence-transformers" (not installed) and returns nothing useful; the install above fixes it. Second: the default model bge-base-zh-v1.5 must be present in your embeddings folder or it fails - and if you're not doing Chinese text, swap the model for an English one available on your system, because BGE-zh is tuned for Chinese. If your JSON has a missing category_id or category_name, it fails with a per-row error telling you exactly which row. And when overwrite is false, an existing meta.json/vectors.npy will halt the write - flip it or clear the files.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name_or_path | COMBO | bge-base-zh-v1.5 | 1 options: bge-base-zh-v1.5 |
| categories_json_pathopt | STRING | — | |
| save_pathopt | STRING | — | |
| batch_sizeopt | INT | 641–512 | — |
| normalize_embeddingsopt | BOOLEAN | true | — |
| overwriteopt | BOOLEAN | true | — |
| dry_runopt | BOOLEAN | false | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| 状态 | STRING | — |
| 结果信息 | STRING | — |
| 保存路径 | STRING | — |
| 类目数量 | INT | — |
| 向量维度 | INT | — |
| 分类JSON示例 | STRING | — |