Show HN: 便携式 RAG (开源)

2作者: cepstrum95 个月前
有些文本的规模介于上下文窗口的容量之外,但又不足以使用向量数据库。例如,一个代码库、一个笔记文件夹、或者一个 Slack 导出文件。我为此构建了一个名为 raglet 的小型库来解决这个问题。 你可以在 Python 中使用它,例如: ```python from raglet import RAGlet rag = RAGlet.from_files(["docs/", "notes.md"]) results = rag.search("我们对 API 设计的决定是什么?", top_k=5) rag.save("my-notes") ``` 在任何地方加载它: ```python rag = RAGlet.load("my-notes") ``` 它使用本地嵌入(sentence-transformers,无需 API 密钥),保存到一个你可以进行 git 提交的普通目录中。 基准测试结果比我预期的更有趣: * 1 MB(约 26.2 万个 token)| 构建时间 3.5 秒 | 搜索时间 3.7 毫秒 * 10 MB(约 260 万个 token)| 构建时间 35 秒 | 搜索时间 6.3 毫秒 * 100 MB(约 2600 万个 token)| 构建时间 6 分钟 | 搜索时间 10.4 毫秒 局限性:目前仅支持 .txt 和 .md 格式(接下来会支持 PDF/DOCX),没有文件更改检测,实际使用上限约为 100 MB,超过这个限制构建时间会变得难以接受。 这个工具对你的工作流程有什么帮助?
查看原文
There&#x27;s a class of text that&#x27;s too big for a context window but too small to justify a vector database. A codebase, a folder of notes, a Slack export. I built a small library - raglet - to solve this problem raglet for it.<p>You can use it in Python i.e<p>from raglet import RAGlet rag = RAGlet.from_files([&quot;docs&#x2F;&quot;, &quot;notes.md&quot;]) results = rag.search(&quot;what did we decide about the API design?&quot;, top_k=5) rag.save(&quot;my-notes&quot;)<p>Load it anywhere<p>rag = RAGlet.load(&quot;my-notes&quot;)<p>It uses local embeddings (sentence-transformers, no API keys), saves to a plain directory you can git commit.<p>The benchmark numbers were more interesting than I expected:<p>1 MB (~262K tokens) | 3.5s build | 3.7ms search 10 MB (~2.6M tokens) | 35s build | 6.3ms search 100 MB (~26M tokens) | 6min build | 10.4ms search<p>limitations: .txt and .md only right now (PDF&#x2F;DOCX is next), no file change detection, ~100 MB practical ceiling before build time gets unwieldy.<p>What would make this useful for your workflow?