跳到主要內容
Open In ColabOpen on GitHub

Dell PowerScale Document Loader

Dell PowerScale 是一個企業級橫向擴展儲存系統,託管業界領先的 OneFS 檔案系統,可以託管在本地部署或雲端部署。

此文件載入器利用 PowerScale 的獨特功能,可以確定自應用程式上次執行以來哪些檔案已被修改,並且僅返回修改後的檔案進行處理。這將消除重新處理(分塊和嵌入)未更改檔案的需求,從而改善整體數據導入工作流程。

此載入器需要啟用 PowerScale 的 MetadataIQ 功能。更多資訊請參閱我們的 GitHub 倉庫:https://github.com/dell/powerscale-rag-connector

概述

整合詳細資訊

類別套件本地可序列化JS 支援
PowerScaleDocumentLoaderpowerscale-rag-connector
PowerScaleUnstructuredLoaderpowerscale-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 欄位將填充來自 Unstructured Loader 的數據

延遲載入

在內部,所有程式碼都與 PowerScale 和 MetadataIQ 異步,並且 load 和 lazy load 方法將返回一個 python 生成器。我們建議使用 lazy load 函數。

for doc in loader.lazy_load():
print(doc) # do something specific with the document

返回與 load 函數相同的 Document,並具有上述所有相同的屬性。

其他範例

更多範例和程式碼可以在我們的公共 github 網頁上找到:https://github.com/dell/powerscale-rag-connector/tree/main/examples,其中提供了完整的工作範例。

API 參考文檔

有關所有 PowerScale 文件載入器功能和配置的詳細文檔,請前往 github 頁面:https://github.com/dell/powerscale-rag-connector/

  • 文件載入器概念指南
  • 文件載入器操作指南

此頁面是否對您有幫助?