LlamaIndex——与LangChain类似但更专注于数据处理的LLM框架

容器机器学习MySQL
欢迎来到LlamaIndex 🦙

LlamaIndex(前身为GPT Index)是一种用于LLM应用程序摄取、结构化和访问私有或领域特定数据的数据框架。

🚀为什么选择LlamaIndex?[1]

在它们的核心,LLMs提供了人类和推断数据之间的自然语言接口。广泛可用的模型预训练于大量公开可用的数据,从维基百科和邮件列表到教科书和源代码。 基于LLMs构建的应用通常需要使用私有的或特定领域的数据来增强这些模型。不幸的是,这些数据可能分布在不同的应用和数据存储中。它们可以是API后面的数据、SQL数据库中的数据,或者被困在PDF和幻灯片中。

这就是LlamaIndex 的作用所在。

🦙LlamaIndex可以如何帮助?[2]

LlamaIndex提供以下工具:

数据连接器 从其原生来源或格式中摄取您现有的数据。这些可以是API、PDF、SQL以及更多其他格式。 •数据索引 对您的数据进行结构化处理,生成对LLMs易于使用和高效的中间表示形式。 •引擎 为您的数据提供自然语言访问。例如:•查询引擎是用于知识增强输出的功能强大的检索接口。•对话引擎是用于与数据进行多消息、来回交互的对话界面。 •数据代理 是由LLM提供支持的知识工作者,通过各种工具进行增强,包括简单的辅助功能函数、API集成等等。 •应用集成 将LlamaIndex与您的生态系统其他部分进行连接。这可以是LangChain、Flask、Docker、ChatGPT,或者......任何其他东西! LlamaIndex是为谁设计的?

LlamaIndex为初学者、高级用户和介于两者之间的所有人提供工具。

我们的高级API允许初学者用户只需五行代码就可以使用LlamaIndex来进行数据摄取和查询。

对于更复杂的应用程序,我们的低级API允许高级用户自定义和扩展任何模块-数据连接器、索引、检索器、查询引擎、重新排序模块-以满足他们的需求。

入门[3]

pip install llama-index

我们的文档包含详细的安装说明[4]和一个入门教程[5],可以使用五行代码构建您的第一个应用程序! 一旦你启动并运行了,High-Level Concepts[6] 提供了 LlamaIndex 模块化架构的概述。想要更多实际操作示例,请查阅我们的端到端教程[7]或了解如何定制化[8]组件以适应你的特定需求。 注意 :我们也有一个TypeScript包! 仓库[9],文档[10]

🗺️ 生态系统

要下载或贡献代码,请在以下位置找到LlamaIndex:

•Github: https://github.com/jerryjliu/llama\_index •PyPi:•LlamaIndex: llama-index · PyPI[11].•GPT Index (duplicate): gpt-index · PyPI[12]. •NPM(Typescript/Javascript):•Github: GitHub - run-llama/LlamaIndexTS: LlamaIndex is a data framework for your LLM applications[13]•Docs: https://ts.llamaindex.ai/•LlamaIndex.TS: Downloads[14]

社区[15]

需要帮助吗?有功能建议吗?加入LlamaIndex社区:

•Twitter:https://twitter.com/llama\_index •Discord https://discord.gg/dGcwcsnxhU

相关项目[16]

•🏡 LlamaHub:https://llamahub.ai[17] | 一个庞大(且不断增长!)的自定义数据连接器集合 •🧪 LlamaLab:GitHub - run-llama/llama-lab[18] | 在LlamaIndex之上构建的雄心勃勃的项目

高级概念

LlamaIndex帮助您在自定义数据上构建基于LLM的应用程序(例如问答、聊天机器人和代理)。

在这个高级概念指南中,您将学习到:

•结合LLM与自定义数据的检索增强生成(RAG)范式。 •LlamaIndex中的关键概念和模块,用于组合自己的RAG流水线。 检索增强生成(RAG)

检索增强生成(RAG)是一种用于增强自然语言语言模型(LLM)的范式,可以使用自定义数据进行增强。它一般包括两个阶段:

1.索引阶段 :准备知识库, 2.查询阶段 :从知识库中检索相关上下文,以帮助LLM回答问题。

picture.image

LlamaIndex提供了必要的工具集,使得这两个步骤变得非常容易。让我们详细探讨每个阶段。

索引阶段

LlamaIndex通过一套数据连接器和索引帮助您准备知识库。

picture.image

数据连接器 [19] :数据连接器(即 Reader )从不同的数据源和数据格式中导入数据,将其转化为简单的 Document 表示(文本和简单的元数据)。

【文档/节点】:文档/节点 [20]: Document是围绕任何数据源的通用容器,例如PDF、API输出或从数据库检索到的数据。 Node是LlamaIndex中的数据原子单位,代表源 Document的一个“块”。它是一个包含元数据和关系(到其他节点)的丰富表示,以实现准确和表达力强的检索操作。 数据索引:一旦您导入了数据,LlamaIndex将帮助您将数据索引到易于检索的格式中。在幕后,LlamaIndex将原始文档解析为中间表示形式,计算向量嵌入,并推断元数据。最常用的索引是VectorStoreIndex[21]。

查询阶段

在查询阶段,RAG管道根据用户查询检索出最相关的上下文,并将其与查询一起传递给LLM(语言模型),以合成响应。这为LLM提供了不在其原始训练数据中的最新知识(同时减少虚构)。查询阶段的关键挑战是检索、编排和推理(可能是多个)知识库。 LlamaIndex提供了可组合的模块,帮助您构建和集成用于Q&A(查询引擎),聊天机器人(聊天引擎)或作为代理的RAG流水线。这些构建块可以根据排名偏好进行定制,并以结构化方式进行推理,以处理多个知识库。

picture.image

构建块

检索器 [22]:检索器定义了在给定查询时如何从知识库(即索引)中高效检索相关上下文。针对不同的索引,具体的检索逻辑有所不同,最流行的是针对向量索引进行的密集检索。

节点后处理器 [23]:节点后处理器接收一组节点,然后对它们应用转换、过滤或重新排序的逻辑。 响应合成器 [24]:响应合成器根据用户查询和给定的检索到的文本块集合,从LLM生成响应。

管道[25]

查询引擎 [26]:查询引擎是一个端到端的流水线,允许您对数据提出问题。它接收一个自然语言查询,并返回一个回答,同时检索和传递给LLM的参考上下文。

聊天引擎 [27]:聊天引擎是一个端到端的流水线,用于与数据进行对话(而不仅仅是单个问题和答案的交互)。 Agents [28]: 代理是由LLM驱动的自动决策者,通过一组工具与世界进行交互。代理可以像查询引擎或聊天引擎一样使用。主要区别在于,代理动态地决定最佳的动作顺序,而不是按照预定逻辑进行操作。这使得它具有处理更复杂任务的额外灵活性。

• 文档问答[29]

• 聊天机器人[30]

• 代理[31]

• 知识图谱[32]

• 结构化数据[33]

• 全栈Web应用[34]

• 私有设置[35]

• 用于文本到SQL的Llama 2微调[36]

• 将GPT-3.5微调为GPT-4[37]

声明

本文由山行翻译整理自:https://gpt-index.readthedocs.io/en/latest/index.html,主要目的是进行AI技术知识学习和整理,有需要的同学请关注、点赞、收藏!

References

[1] Permalink to this heading: https://gpt-index.readthedocs.io/en/latest/index.html#why-llamaindex
[2] Permalink to this heading: https://gpt-index.readthedocs.io/en/latest/index.html#how-can-llamaindex-help
[3] 此标题的永久链接: https://gpt-index.readthedocs.io/en/latest/index.html#getting-started
[4] 安装说明: https://gpt-index.readthedocs.io/en/latest/getting\_started/installation.html
[5] 入门教程: https://gpt-index.readthedocs.io/en/latest/getting\_started/starter\_example.html
[6] High-Level Concepts: https://gpt-index.readthedocs.io/en/latest/getting\_started/concepts.html
[7] 端到端教程: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/use\_cases.html
[8] 定制化: https://gpt-index.readthedocs.io/en/latest/getting\_started/customization.html
[9] 仓库: https://github.com/run-llama/LlamaIndexTS
[10] 文档: https://ts.llamaindex.ai/
[11] llama-index · PyPI: https://pypi.org/project/llama-index/
[12] gpt-index · PyPI: https://pypi.org/project/gpt-index/
[13] GitHub - run-llama/LlamaIndexTS: LlamaIndex is a data framework for your LLM applications: https://github.com/run-llama/LlamaIndexTS
[14] Downloads: https://www.npmjs.com/package/llamaindex
[15] Permalink to this heading: https://gpt-index.readthedocs.io/en/latest/index.html#community
[16] Permalink to this heading: https://gpt-index.readthedocs.io/en/latest/index.html#associated-projects
[17] https://llamahub.ai: https://llamahub.ai/
[18] GitHub - run-llama/llama-lab: https://github.com/run-llama/llama-lab
[19] 数据连接器 : https://gpt-index.readthedocs.io/en/latest/core\_modules/data\_modules/connector/root.html
[20] 文档/节点 : https://gpt-index.readthedocs.io/en/latest/core\_modules/data\_modules/documents\_and\_nodes/root.html
[21] VectorStoreIndex: https://gpt-index.readthedocs.io/en/latest/core\_modules/data\_modules/index/vector\_store\_guide.html
[22] 检索器 : https://gpt-index.readthedocs.io/en/latest/core\_modules/query\_modules/retriever/root.html
[23] 节点后处理器 : https://gpt-index.readthedocs.io/en/latest/core\_modules/query\_modules/node\_postprocessors/root.html
[24] 响应合成器 : https://gpt-index.readthedocs.io/en/latest/core\_modules/query\_modules/response\_synthesizers/root.html
[25] Permalink to this heading: https://gpt-index.readthedocs.io/en/latest/getting\_started/concepts.html#pipelines
[26] 查询引擎 : https://gpt-index.readthedocs.io/en/latest/core\_modules/query\_modules/query\_engine/root.html
[27] 聊天引擎 : https://gpt-index.readthedocs.io/en/latest/core\_modules/query\_modules/chat\_engines/root.html
[28] Agents : https://gpt-index.readthedocs.io/en/latest/core\_modules/agent\_modules/agents/root.html
[29] 文档问答: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/question\_and\_answer.html
[30] 聊天机器人: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/chatbots.html
[31] 代理: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/agents.html
[32] 知识图谱: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/graphs.html
[33] 结构化数据: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/structured\_data.html
[34] 全栈Web应用: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/apps.html
[35] 私有设置: https://gpt-index.readthedocs.io/en/latest/end\_to\_end\_tutorials/privacy.html
[36] 用于文本到SQL的Llama 2微调: https://medium.com/llamaindex-blog/easily-finetune-llama-2-for-your-text-to-sql-applications-ecd53640e10d
[37] 将GPT-3.5微调为GPT-4: https://colab.research.google.com/drive/1vWeJBXdFEObuihO7Z8ui2CAYkdHQORqo?usp=sharing

0
0
0
0
关于作者
关于作者

文章

0

获赞

0

收藏

0

相关资源
大规模高性能计算集群优化实践
随着机器学习的发展,数据量和训练模型都有越来越大的趋势,这对基础设施有了更高的要求,包括硬件、网络架构等。本次分享主要介绍火山引擎支撑大规模高性能计算集群的架构和优化实践。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论