Skip to main content
Open In ColabOpen on GitHub

Nuclia

Nuclia 自动化地从任何内部和外部源对您的非结构化数据进行索引,提供优化的搜索结果和生成的答案。它可以处理视频和音频转录、图像内容提取以及文档解析。

The Nuclia Understanding API 支持结构化数据的处理,包括文本、网页、文档以及音频/视频内容。它可以在需要时使用语音识别或OCR从任何地方提取文本,还能够提取元数据、嵌入文件(例如PDF中的图片)和网络链接。如果启用了机器学习功能,它将识别实体信息、提供内容摘要并为所有句子生成向量表示。

设置

要使用Nuclia Understanding API,您需要拥有一个Nuclia账户。您可以免费在https://nuclia.cloud创建一个,并然后生成一个NUA密钥

%pip install --upgrade --quiet  protobuf
%pip install --upgrade --quiet nucliadb-protos
import os

os.environ["NUCLIA_ZONE"] = "<YOUR_ZONE>" # e.g. europe-1
os.environ["NUCLIA_NUA_KEY"] = "<YOUR_API_KEY>"

示例

要使用 Nuclia 文档加载器,您需要实例化一个 NucliaUnderstandingAPI 工具:

from langchain_community.tools.nuclia import NucliaUnderstandingAPI

nua = NucliaUnderstandingAPI(enable_ml=False)
from langchain_community.document_loaders.nuclia import NucliaLoader

loader = NucliaLoader("./interview.mp4", nua)
API 参考:NucliaLoader

您现在可以将调用load放在循环中,直到获取到文档。

import time

pending = True
while pending:
time.sleep(15)
docs = loader.load()
if len(docs) > 0:
print(docs[0].page_content)
print(docs[0].metadata)
pending = False
else:
print("waiting...")

检索到的信息

Nuclia 返回以下信息:<br>

  • 文件元数据
  • 提取的文本
  • 嵌套文本(如嵌入图像中的文本)
  • 段落和句子分割(由其首尾字符位置定义,加上视频或音频文件的开始时间和结束时间)
  • links
  • a thumbnail
  • embedded files

注意:

Generated files (thumbnail, extracted embedded files, etc.) are provided as a token. You can download them with the /processing/download endpoint.

Also at any level, if an attribute exceeds a certain size, it will be put in a downloadable file and will be replaced in the document by a file pointer. This will consist of {"file": {"uri": "JWT_TOKEN"}}. The rule is that if the size of the message is greater than 1000000 characters, the biggest parts will be moved to downloadable files. First, the compression process will target vectors. If that is not enough, it will target large field metadata, and finally it will target extracted text.