Dell PowerScale 文档加载器
Dell PowerScale 是一种企业级横向扩展存储系统,搭载了行业领先的 OneFS 文件系统,可部署在本地或云端。
本段落利用PowerScale的独特能力,可以确定自应用程序上次运行以来哪些文件已被修改,并仅返回需要处理的已修改文件。这将消除重新处理(切片和嵌入)未更改文件的需求,从而改善整体数据摄取工作流程。
此加载器需要启用 PowerScale 的 MetadataIQ 功能。有关更多信息,请参阅我们的 GitHub 仓库:https://github.com/dell/powerscale-rag-connector
概览
集成细节
| Class | 包 | 本地 | 序列化 | JS支持 |
|---|---|---|---|---|
| PowerScaleDocumentLoader | powerscale-rag-connector | ✅ | ❌ | ❌ |
| PowerScaleUnstructuredLoader | powerscale-rag-connector | ✅ | ❌ | ❌ |
加载器功能
| 来源 | 文档延迟加载 | 原生异步支持 |
|---|---|---|
| PowerScaleDocumentLoader | ✅ | ✅ |
| PowerScaleUnstructuredLoader | ✅ | ✅ |
设置
此文档加载器需要使用启用了MetadataIQ的Dell PowerScale系统。有关更多信息,请参阅我们的GitHub页面:https://github.com/dell/powerscale-rag-connector
安装
The document loader lives in an external pip package and can be installed using standard tooling
%pip install --upgrade --quiet powerscale-rag-connector
初始化
现在我们可以实例化文档加载器:
Generic Document Loader
我们的通用文档加载器可以按照以下方式增量加载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",
)
未结构化加载器 加载器
Optionally, the PowerScaleUnstructuredLoader can be used to locate the changed files and automatically process the files producing elements of the source file. This is done using LangChain's UnstructuredLoader class.
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",
)
The fields:
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
The same Document 是返回的加载函数,并且具有上述所有相同属性。
附加示例
Additional examples and code can be found on our public github webpage: https://github.com/dell/powerscale-rag-connector/tree/main/examples that provide full working examples.
- PowerScale LangChain 文档加载器 - 标准文档加载器的工作示例
- PowerScale LangChain Un结构化加载器 - 我们标准文档加载器的使用示例,采用未结构化加载器进行分块和嵌入
- PowerScale NVIDIA Retriever Microservice Loader - Working example of our document loader with NVIDIA NeMo Retriever microservices for chunking and embedding
API 参考
详细介绍了所有PowerScale Document Loader功能和配置的文档,请访问github页面: https://github.com/dell/powerscale-rag-connector/