微信扫码
添加专属顾问
我要投稿
大多数现有方法仅从检索语料库中检索短的连续块,限制了对整个文档上下文的整体理解。RAPTOR(Recursive Abstractive Processing for Tree-Organized Retrieval)引入了一种新方法,即递归嵌入、聚类和总结文本块,从下往上构建具有不同总结级别的树。在推理时,RAPTOR 模型从这棵树中检索,整合不同抽象级别的长文档中的信息。RAPTOR(Recursive Abstractive Processing for Tree-Organized Retrieval)比传统的检索增强型 LM 性能与绝对准确度上提高 20%。
# 安装,在使用 RAPTOR 之前,请确保已安装 Python 3.8+。克隆 RAPTOR 存储库并安装必要的依赖项:git clone https://github.com/parthsarthi03/raptor.gitcd raptorpip install -r requirements.txt# 开始使用 RAPTOR,请按照以下步骤操作:# 首先,设置您的 OpenAI API 密钥并初始化 RAPTOR 配置:import osos.environ["OPENAI_API_KEY"] = "your-openai-api-key"from raptor import RetrievalAugmentation# Initialize with default configuration. For advanced configurations, check the documentation. [WIP]RA = RetrievalAugmentation()# 将您的文本文档添加到 RAPTOR 进行索引:with open('sample.txt', 'r') as file:text = file.read()RA.add_documents(text)# 现在可以使用 RAPTOR 根据索引文档回答问题:question = "How did Cinderella reach her happy ending?"answer = RA.answer_question(question=question)print("Answer: ", answer)# 将构造好的树保存到指定路径:SAVE_PATH = "demo/cinderella"RA.save(SAVE_PATH)# 将保存的树重新加载到 RAPTOR 中:RA = RetrievalAugmentation(tree=SAVE_PATH)answer = RA.answer_question(question=question)
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-09-15
2025-09-02
2025-08-05
2025-08-18
2025-08-25
2025-08-25
2025-08-25
2025-09-03
2025-08-20
2025-09-08
2025-10-04
2025-09-30
2025-09-10
2025-09-10
2025-09-03
2025-08-28
2025-08-25
2025-08-20