戴尔 PowerScale 文档加载器
Dell PowerScale 是一款企业级横向扩展存储系统,承载着行业领先的 OneFS 文件系统,可部署在本地或云端。
该文档加载器利用 PowerScale 的独特功能,能够识别自应用程序上次运行以来已修改的文件,并且只返回已修改的文件进行处理。这将消除重新处理(分块和嵌入)未更改文件的需要,从而改进整体数据摄取工作流。
此加载器需要启用 PowerScale 的 MetadataIQ 功能。更多信息请参见我们的 GitHub 仓库:https://github.com/dell/powerscale-rag-connector
概述
集成详情
类别 | 包 | 本地 | 可序列化 | JS 支持 |
---|---|---|---|---|
PowerScaleDocumentLoader | powerscale-rag-connector | ✅ | ❌ | ❌ |
PowerScaleUnstructuredLoader | powerscale-rag-connector | ✅ | ❌ | ❌ |
加载器功能
来源 | 文档延迟加载 | 原生异步支持 |
---|---|---|
PowerScaleDocumentLoader | ✅ | ✅ |
PowerScaleUnstructuredLoader | ✅ | ✅ |
设置
此文档加载器需要使用启用了 MetadataIQ 的 Dell PowerScale 系统。更多信息请参见我们的 GitHub 页面:https://github.com/dell/powerscale-rag-connector
安装
文档加载器位于一个外部 pip 包中,可以使用标准工具进行安装
%pip install --upgrade --quiet powerscale-rag-connector
初始化
现在我们可以实例化文档加载器
通用文档加载器
我们的通用文档加载器可以以下列方式逐步加载 PowerScale 中的所有文件
from powerscale_rag_connector import PowerScaleDocumentLoader
loader = PowerScaleDocumentLoader(
es_host_url="http://elasticsearch:9200",
es_index_name="metadataiq",
es_api_key="your-api-key",
folder_path="/ifs/data",
)
UnstructuredLoader 加载器
可选地,PowerScaleUnstructuredLoader
可用于定位更改的文件**并**自动处理文件以生成源文件的元素。这通过使用 LangChain 的 UnstructuredLoader
类完成。
from powerscale_rag_connector import PowerScaleUnstructuredLoader
# Or load files with the Unstructured Loader
loader = PowerScaleUnstructuredLoader(
es_host_url="http://elasticsearch:9200",
es_index_name="metadataiq",
es_api_key="your-api-key",
folder_path="/ifs/data",
# 'elements' mode splits the document into more granular chunks
# Use 'single' mode if you want the entire document as a single chunk
mode="elements",
)
字段
es_host_url
是 MetadataIQ Elasticsearch 数据库的端点es_index_index
是 PowerScale 写入其文件系统元数据的索引名称es_api_key
是您的 Elasticsearch API 密钥的**编码**版本folder_path
是 PowerScale 上要查询更改的路径
加载
在内部,所有代码都与 PowerScale 和 MetadataIQ 异步执行,并且 load 和 lazy load 方法将返回一个 Python 生成器。我们建议使用 lazy load 函数。
for doc in loader.load():
print(doc)
[Document(page_content='' metadata={'source': '/ifs/pdfs/1994-Graph.Theoretic.Obstacles.to.Perfect.Hashing.TR0257.pdf', 'snapshot': 20834, 'change_types': ['ENTRY_ADDED']}),
Document(page_content='' metadata={'source': '/ifs/pdfs/New.sendfile-FreeBSD.20.Feb.2015.pdf', 'snapshot': 20920, 'change_types': ['ENTRY_MODIFIED']}),
Document(page_content='' metadata={'source': '/ifs/pdfs/FAST-Fast.Architecture.Sensitive.Tree.Search.on.Modern.CPUs.and.GPUs-Slides.pdf', 'snapshot': 20924, 'change_types': ['ENTRY_ADDED']})]
返回对象
两种文档加载器都将跟踪以前返回给您的应用程序的文件。再次调用时,文档加载器将只返回自上次运行以来的新文件或已修改的文件。
- 返回的
Document
中的metadata
字段将返回 PowerScale 上包含已修改文件的路径。您将使用此路径通过 NFS(或 S3)读取数据并在您的应用程序中处理数据(例如:创建分块和嵌入)。 source
字段是 PowerScale 上的路径,不一定在您的本地系统上(取决于您的挂载策略);OneFS 将整个存储系统表示为以/ifs
为根的单个树。change_types
属性将告知您自上次更改以来发生了什么更改 — 例如:新增、修改或删除。
您的 RAG 应用程序可以使用 change_types
中的信息来添加、更新或删除您的分块和向量存储中的条目。
当使用 PowerScaleUnstructuredLoader
时,page_content
字段将填充来自非结构化加载器的数据
延迟加载
在内部,所有代码都与 PowerScale 和 MetadataIQ 异步执行,并且 load 和 lazy load 方法将返回一个 Python 生成器。我们建议使用 lazy load 函数。
for doc in loader.lazy_load():
print(doc) # do something specific with the document
返回的 Document
与 load 函数相同,并具有上述所有相同的属性。
附加示例
更多示例和代码可在我们的公共 github 网页上找到:https://github.com/dell/powerscale-rag-connector/tree/main/examples,其中提供了完整的可运行示例。
- PowerScale LangChain 文档加载器 - 我们标准文档加载器的工作示例
- PowerScale LangChain 非结构化加载器 - 使用非结构化加载器进行分块和嵌入的标准文档加载器的工作示例
- PowerScale NVIDIA Retriever 微服务加载器 - 使用 NVIDIA NeMo Retriever 微服务进行分块和嵌入的文档加载器工作示例
API 参考
有关所有 PowerScale 文档加载器功能和配置的详细文档,请访问 GitHub 页面:https://github.com/dell/powerscale-rag-connector/