Xuanjing Combines Feature-Based Query Expansion With Retrieval Filters
A technical report describes how Xuanjing improves RAG retrieval for small, specialized fortune-telling corpora by combining feature-based query expansion, module-level metadata filtering and similarity thresholds. Extracted features are appended to the user query before Chroma semantic retrieval, with core features repeated to emphasize them. The report also corrects an ordering bug in which later deduplication removed the intended repetition; the revised example is presented as a possible pull request and was not applied directly to the repository. The comparison table is illustrative, and the report says an offline comparison found combining the original query with the feature query more stable than using features alone, while a small-traffic online A/B test remains pending.
The report provides an implementation pattern for small vertical corpora in which feature-aware queries, structured metadata filters and similarity thresholds work together rather than relying on bare vector retrieval.
很多人上手 RAG 就是 collection.add + collection.query,然后发现「检索出来的东西跟我问的对不上」。玄镜在垂直命理领域踩过这个坑——最后没用裸向量检索,而是在检索前加了一层「特征加权」。
更准确地说,这是查询层面的特征注入 / 查询增强,不是检索分数的加权融合。下文会把边界讲清。 代码基于
oraclemind-ai/src/services/retrieval.py的真实实现整理。仓库当前函数名仍为_extract_features,且旧版存在dict.fromkeys整体去重问题;下方为修正后的示意实现,本文按行为重命名为_build_feature_query便于表意,未直接改动仓库源码。修正点可作为仓库 PR 的参考。
一、裸向量在垂直长尾领域为什么翻车
命理语料极小(单模块 14~20 条),而且术语高度正交:问「日主甲木喜水」和「日主庚金喜火」,在 embeddings 空间里可能都离某条「五行生克」通用条目很近,但真正该命中的是各自对应的专用条目。纯余弦相似度会把通用条目顶上来,专用条目反而沉底。