非結構化數據的開源預處理工具
unstructured庫提供了用於攝入和預處理圖像和文本文檔的開源組件,例如PDFS,HTML,Word Docs等。 unstructured的用例圍繞精簡和優化LLM的數據處理工作流程。 unstructured模塊化功能和連接器形成了一個凝聚系統,可簡化數據攝入和預處理,使其適應不同的平台,並有效地將非結構化數據轉換為結構化輸出。
尋找更好的預處理性能和更少的設置?查看我們的新無服務器API!非結構化的無服務器API是我們迄今為止最出色的API,它提供了一種更快的生產級解決方案,以更好地滿足您的業務和LLM需求。前往我們的註冊頁面,免費入門。
有幾種使用unstructured庫的方法:
conda安裝的,請參考文檔以下說明旨在幫助您使用Docker與unstructured交互。如果您還沒有在計算機上安裝Docker,請參閱此處。
注意:我們構建多平台圖像以支持X86_64和Apple Silicon硬件。 docker pull應該下載架構的相應圖像,但是您可以使用--platform (例如--platform linux/amd64 )指定。
我們為所有推送到main構建了Docker圖像。我們使用相應的簡短提交哈希(例如fbc7a69 )和應用程序版本(例如0.5.5-dev1 )標記每個圖像。我們還使用最新圖像標記latest 。為了利用這一點, docker pull 。
docker pull downloads.unstructured.io/unstructured-io/unstructured:latest拉動後,您可以從此圖像創建一個容器,然後將其掩蓋到其上。
# 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映像。請注意,基本圖像是wolfi-base ,它會定期更新。如果您在本地構建圖像,則可能由於docker-build wolfi-base的上游變化而可能會失敗。
如果您僅計劃解析一種數據,則可以通過評論其他數據類型所需的一些軟件包/要求來加快構建圖像的速度。請參閱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_pdf
>>> elements = partition_pdf(filename= " example-docs/layout-parser-paper-fast.pdf " )
>>> from unstructured.partition.text import partition_text
>>> elements = partition_text(filename= " example-docs/fake-text.txt " )使用以下說明與unstructured並測試安裝。
安裝Python SDK以使用pip install "unstructured[all-docs]"來支持所有文檔類型
pip install unstructuredpip install "unstructured[docx,pptx]"如果系統尚未在系統上可用,請安裝以下系統依賴項。根據您正在解析的文檔類型,您可能不需要所有這些。
libmagic-dev (Filetype檢測)poppler-utils (圖像和PDF)tesseract-ocr (圖像和PDF,安裝tesseract-lang以獲得其他語言支持)libreoffice (MS Office Docs)pandoc (EPUB,RTF和開放式文檔)。請注意,要處理RTF文件,您需要2.14.2版或更新版本。運行make install-pandoc或./scripts/install-pandoc.sh將為您安裝正確的版本。有關如何在窗口上安裝並了解其他功能的依賴項的建議,請參見此處的安裝文檔。
此時,您應該能夠運行以下代碼:
from unstructured . partition . auto import partition
elements = partition ( filename = "example-docs/eml/fake-email.eml" )
print ( " n n " . join ([ str ( el ) for el in elements ]))如果您打算為該項目做出貢獻,則旨在幫助您在本地使用unstructured本地啟動和運行。
建議使用pyenv管理Virtualenv,但不是必需的
brew install pyenv-virtualenvpyenv install 3.10創建一個虛擬的工作並激活它,例如,一個名為unstructured人:
pyenv virtualenv 3.10 unstructured
pyenv activate unstructured
運行make install
選修的:
make install-local-inference 。tesseract 。請參閱此處以獲取安裝說明。tesseract和poppler 。 PDF2Image文檔有有關在各個平台上安裝poppler的說明。此外,如果您打算為unstructured做出貢獻,我們為您提供一個可選的pre-commit配置文件,以確保您的代碼與unstructured中使用的格式和覆蓋標準匹配。如果您希望在每個提交之前都不要將代碼更改自動介紹,則可以使用make check來查看是否應應用任何貼有或格式化更改,並make tidy應用它們。
如果使用可選的pre-commit ,則只需安裝pre-commit install即可安裝掛鉤,因為在上面提到的make install中安裝了pre-commit軟件包。最後,如果您決定使用pre-commit您也可以使用pre-commit uninstall 。
除了在您的本地操作系統中開發外,我們還提供了一個助手,可以使用提供開發環境的Docker:
make docker-start-dev這啟動了一個docker容器,並將您的本地存儲庫安裝到/mnt/local_unstructured 。此Docker映像使您可以開發不擔心操作系統與存儲庫及其依賴關係的兼容性。
有關更全面的文檔,請訪問https://docs.unstructured.io。您還可以在文檔頁面(包括我們的SaaS API)上了解有關我們的其他產品的更多信息。
以下是開源文檔頁面中的幾頁,這些頁面有助於新用戶審查:
unstructured開源軟件包以下示例顯示瞭如何開始使用unstructured庫。在非結構化中解析文檔的最簡單方法是使用partition功能。如果使用partition功能, unstructured將檢測到文件類型並將其路由到適當的文件特定分區功能。如果您使用的是partition功能,則可能需要安裝每個文檔類型的其他依賴項。例如,要安裝DOCX依賴項,您需要運行pip install "unstructured[docx]" 。有關更多詳細信息,請參見我們的安裝指南。
from unstructured . partition . auto import partition
elements = partition ( "example-docs/layout-parser-paper.pdf" )運行print("nn".join([str(el) for el in elements]))以獲取輸出的字符串表示,看起來像:
LayoutParser : A Unified Toolkit for Deep Learning Based Document Image Analysis
Zejiang Shen 1 ( (cid:0) ), Ruochen Zhang 2 , Melissa Dell 3 , Benjamin Charles Germain Lee 4 , Jacob Carlson 3 , and
Weining Li 5
Abstract. Recent advances in document image analysis (DIA) have been primarily driven by the application of neural
networks. Ideally, research outcomes could be easily deployed in production and extended for further investigation.
However, various factors like loosely organized codebases and sophisticated model configurations complicate the easy
reuse of important innovations by a wide audience. Though there have been ongoing efforts to improve reusability and
simplify deep learning (DL) model development in disciplines like natural language processing and computer vision, none
of them are optimized for challenges in the domain of DIA. This represents a major gap in the existing toolkit, as DIA
is central to academic research across a wide range of disciplines in the social sciences and humanities. This paper
introduces LayoutParser, an open-source library for streamlining the usage of DL in DIA research and applications.
The core LayoutParser library comes with a set of simple and intuitive interfaces for applying and customizing DL models
for layout detection, character recognition, and many other document processing tasks. To promote extensibility,
LayoutParser also incorporates a community platform for sharing both pre-trained models and full document digitization
pipelines. We demonstrate that LayoutParser is helpful for both lightweight and large-scale digitization pipelines in
real-word use cases. The library is publicly available at https://layout-parser.github.io
Keywords: Document Image Analysis · Deep Learning · Layout Analysis · Character Recognition · Open Source library ·
Toolkit.
Introduction
Deep Learning(DL)-based approaches are the state-of-the-art for a wide range of document image analysis (DIA) tasks
including document image classification [11,
有關如何使用特定文件分區功能的選項和說明的完整列表,請參見我們文檔中的分區部分。
有關如何報告安全漏洞的信息,請參見我們的安全策略。
遇到一個錯誤?請創建一個新的GitHub問題,並使用我們的錯誤報告模板來描述問題。為了幫助我們診斷該問題,請使用python scripts/collect_env.py命令來收集系統的環境信息並將其包括在報告中。您的幫助有助於我們不斷改進我們的軟件 - 謝謝!
| 部分 | 描述 |
|---|---|
| 公司網站 | 非結構化。 oio產品和公司信息 |
| 文件 | 完整的API文檔 |
| 批處理處理 | 通過非結構化攝入文檔批次 |
我們已經與圍巾(https://scarf.sh)合作,以收集匿名用戶統計信息,以了解我們社區正在使用哪些功能以及如何在將來確定產品決策的優先級。要了解有關我們如何收集和使用此數據的更多信息,請閱讀我們的隱私政策。要選擇退出此數據集合,您可以在運行任何unstructured命令之前設置環境變量SCARF_NO_ANALYTICS=true 。