Skip to main content
Open In ColabOpen on GitHub

Nuclia

Nuclia automatically indexes your unstructured data from any internal and external source, providing optimized search results and generative answers. It can handle video and audio transcription, image content extraction, and document parsing.

The Nuclia Understanding API supports the processing of unstructured data, including text, web pages, documents, and audio/video contents. It extracts all texts wherever they are (using speech-to-text or OCR when needed), it also extracts metadata, embedded files (like images in a PDF), and web links. If machine learning is enabled, it identifies entities, provides a summary of the content and generates embeddings for all the sentences.

设置

要使用 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 返回以下信息:

  • 文件元数据
  • 提取的文本
  • 嵌套文本(如嵌入图像中的文本)
  • 段落和句子拆分(由其首尾字符的位置定义,对于视频或音频文件还包括开始时间和结束时间)
  • 链接
  • 缩略图
  • 嵌入文件

Note:

生成的文件(缩略图、提取的嵌入文件等)以令牌形式提供。您可以使用 /processing/download 端点 下载它们。

此外,在任何层级,如果某个属性超过特定大小,它将被放入可下载文件中,并在文档中由文件指针替换。这将由 {"file": {"uri": "JWT_TOKEN"}} 组成。规则是:如果消息大小大于 1000000 个字符,最大的部分将被移至可下载文件。首先,压缩过程将针对向量;如果仍不足,则将针对大型字段元数据,最后针对提取的文本。