add_resource 函数在处理目录时是否会刻意将嵌套结构展平? #484
Replies: 3 comments
-
|
Great question! This is intentional design behavior, not a bug. Why flattening happensWhen How to preserve hierarchical semanticsIf your directory structure carries meaningful categorization, you have a few options: Option 1: Encode hierarchy in metadata viking.add_resource("papers/nlp/", metadata={"category": "nlp", "path_prefix": "papers/nlp"})Then filter by metadata at retrieval time. Option 2: Use separate namespaced resources Option 3: Preprocess documents The core insight: OpenViking's flat node model trades structural fidelity for retrieval efficiency. If hierarchy is semantically important for your use case, encoding it explicitly in metadata is the recommended approach rather than relying on folder structure implicitly. Hope this helps! Feel free to follow up if you have more questions. |
Beta Was this translation helpful? Give feedback.
-
|
感谢回答,但是我有几个问题。 |
Beta Was this translation helpful? Give feedback.
-
|
你指出的三点都是有效的批评,我来诚实回答。 Option 1:metadata 字段你是对的。LanceDB 支持存储 metadata 作为附加列,也支持 WHERE 过滤——但 OpenViking 当前的 这是一个值得提 Issue 的点:retrieval API 应该支持按 metadata 字段过滤。 Option 2:多级目录路径编码你的分析是正确的。把
我之前的回答在这一点上给了一个误导性的"解决方案",实际上只是很弱的 workaround。 Option 3:大量召回后过滤你的理解是正确的。当前目录级检索只能靠语义信号(目录名在 embedding 中的权重)做模糊相关性,或者大量召回后在应用层过滤。 诚实的结论OpenViking 当前的 目前最实际的路径:
感谢你的追问,这些问题确实暴露了我之前回答的局限性。 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
我们在 0.24 版上,用内部有目录层级结构的路径测试add_resource,发现保存后的文件把嵌套结构展平了。
不知道这是预期行为还是 bug?
我看到 #83
有‘目录间的组织关系(papers/、notes/、src/)与原始目录一致,单个文档(如 transformer.pdf)被 Parser 展开为子目录。’的设计。
把嵌套结构展平似乎在维护文档摘要时有更高的效率。但是有时用户的输入文档本来就是严格分类的。展平后丢失了目录层级结构本身的语义信息。
如果是预期结果,但我又想保留层级,推荐的做法是什么?
Beta Was this translation helpful? Give feedback.
All reactions