张家港安监站网址,外贸营销网站建设方案,婚恋网站建设成本,qq查冻结网站怎么做文章目录 一、关于 Unstructured核心概念#x1f680; Beta 功能#xff1a;Chipper 模型 二、安装方式一#xff1a;使用 PYPI方式二#xff1a;使用源码本地安装安装依赖库测试 三、在Docker运行库添加shell构建自己的 Docker image交互运行 四、PDF文档解析示例 一、关于… 文章目录 一、关于 Unstructured核心概念 Beta 功能Chipper 模型 二、安装方式一使用 PYPI方式二使用源码本地安装安装依赖库测试 三、在Docker运行库添加shell构建自己的 Docker image交互运行 四、PDF文档解析示例 一、关于 Unstructured
官网https://unstructured.iogithub : https://github.com/Unstructured-IO/unstructured文档https://unstructured-io.github.io/unstructured/API 服务https://unstructured-io.github.io/unstructured/api.html https://unstructured.io/api-keyslack : https://short.unstructured.io/pzw05l7 unstructured库提供了用于 提取和预处理 图像和文本文档例如 PDF、HTML、Word 文档等的开源组件。 unstructured模块化功能 和 连接器形成一个内聚系统简化了数据提取和预处理使其能够适应不同的平台并有效地将非结构化数据转换为结构化输出。 核心概念
unstructured库包含用于 NLP 任务的分区、分块、清理和暂存原始文档的核心功能。 您可以从核心功能文档中查看可用函数的完整列表 以及如何使用它们。 一般来说这些功能分为几类
分区 Partitioning 将原始文档分解为标准的结构化元素。清理 Cleaning 从文档中删除不需要的文本例如样板文件和句子片段。暂存 Staging 函数格式化下游任务的数据例如 ML 推理和数据标记。分块 Chunking 功能将文档分割成更小的部分以便在 RAG 应用程序和相似性搜索中使用。嵌入Embedding 编码器类提供了一个接口可以轻松地将预处理的文本转换为向量。 Connectors 是unstructured预处理管道 和 各种数据存储平台 之间的重要链接。 它们允许跨各种来源包括云服务、存储库和本地目录对文档进行批处理。 每个连接器都是针对特定平台例如 Azure、Google Drive 或 Github量身定制的并附带独特的命令和依赖项。
要查看库中可用的连接器列表unstructured请查看连接器 GitHub 文件夹 和 文档 Beta 功能Chipper 模型
我们正在发布 Chipper 模型的测试版以在处理高分辨率、复杂文档时提供卓越的性能。 要开始在 API 请求中使用 Chipper 模型您可以使用 hi_res_model_namechipper 参数。 文档https://unstructured-io.github.io/unstructured/api.html#beta-version-hi-res-strategy-with-chipper-model 二、安装
方式一使用 PYPI
支持所有文档
pip install unstructured[all-docs] 支持不需要额外以来的文档类型如 plain text files, HTML, XML, JSON and Emails
pip install unstructured需要支持额外文档
pip install unstructured[docx,pptx]方式二使用源码本地安装
此处默认你已经安装python 并有 env
git clone https://github.com/Unstructured-IO/unstructured.gitmake install如果要安装用于 本地处理图像 和 PDF 的模型 和 依赖项
make install-local-inference对于处理图像文件tesseract是必需的。详见https://tesseract-ocr.github.io/tessdoc/Installation.html对于处理 PDF 文件tesseract和poppler是必需的。pdf2image 文档 包含poppler有关跨各种平台安装的说明。 安装依赖库
以下系统依赖项根据需要安装
libmagic-dev文件类型检测poppler-utils图像和 PDFtesseract-ocr图像和 PDF安装tesseract-lang以获得其他语言支持libreoffice微软 Office 文档pandocEPUB、RTF 和 Open Office 文档。请注意要处理 RTF 文件您需要版本2.14.2或更新版本。运行make install-pandoc或./scripts/install-pandoc.sh将为您安装正确的版本。有关如何在 Windows 上安装的建议以及了解其他功能的依赖关系请参阅此处的安装文档。 测试
此时您应该能够运行以下代码
from unstructured.partition.auto import partitionelements partition(filenameexample-docs/eml/fake-email.eml)
print(\n\n.join([str(el) for el in elements]))三、在Docker运行库
以下说明旨在帮助您启动并运行使用 Docker 来与unstructured。 如果您的计算机上尚未安装 docker请参阅 https://blog.csdn.net/lovechris00/article/details/122121369
注意我们构建多平台映像来支持 x86_64 和 Apple 芯片硬件。 docker pull应下载适合您的架构的相应映像但如果需要您可以使用--platform(eg --platform linux/amd64) 指定。
我们为所有推送构建 Docker 镜像main。 我们用相应的 short commit hash例如fbc7a69和应用程序版本例如0.5.5-dev1来标记每个镜像。 我们还用 标记最新的镜像latest。 要利用这一点docker pull请从我们的镜像存储库中获取。
docker pull downloads.unstructured.io/unstructured-io/unstructured:latest添加shell
拉取后您可以从此映像创建一个容器并为其添加 shell。
# create the container
docker run -dt --name unstructured downloads.unstructured.io/unstructured-io/unstructured:latest# this will drop you into a bash shell where the Docker image is running
docker exec -it unstructured bash构建自己的 Docker image
您还可以构建自己的 Docker 镜像。
如果您只计划解析一种类型的数据您可以通过注释掉其他数据类型所需的一些包/要求来加快构建映像的速度。 请参阅 Dockerfile 以了解您的用例需要哪些行。
make docker-build# this will drop you into a bash shell where the Docker image is running
make docker-start-bash交互运行
一旦进入正在运行的容器您就可以直接在 Python 解释器的交互模式下进行尝试。
# this will drop you into a python console so you can run the below partition functions
python3 from unstructured.partition.pdf import partition_pdfelements partition_pdf(filenameexample-docs/layout-parser-paper-fast.pdf) from unstructured.partition.text import partition_textelements partition_text(filenameexample-docs/fake-text.txt)四、PDF文档解析示例
以下示例展示了如何开始使用该unstructured库。 一行代码即可解析十多种文档类型 你可以使用此Colab 笔记本运行下面的示例。
解析非结构化文档的最简单方法是使用 partition函数。 如果您使用partition函数unstructured将检测文件类型并将其路由到适当的文件特定分区函数。 如果您正在使用partition功能您可能需要通过安装附加参数
pip install unstructured[local-inference]确保您首次使用此处libmagic列出的说明进行安装时将始终应用默认参数。 如果您需要高级功能请使用特定于文档的分区功能。
from unstructured.partition.auto import partitionelements partition(example-docs/layout-parser-paper.pdf)运行print(\n\n.join([str(el) for el in elements]))以获取输出的字符串表示形式如下所示
LayoutParser : A Unified Toolkit for Deep Learning Based Document Image AnalysisZejiang
... image classification [11,2024-04-10三