工具測試 - marker (Convert PDF to markdown + JSON quickly with high accuracy)

參考鏈接如下::

參考鏈接:https://github.com/datalab-to/marker?tab=readme-ov-file#llm-services

底層的OCR模型:https://github.com/datalab-to/surya

作用:開源免費🆓,多 GPU 推理、生成效果不錯,可結合 llm 進行優化,后續可以多試試,對比對比其他工具,目前工作中夠用就行,暫時還沒必要自己訓練。

1、測試和使用非常的簡單:只需要 2 行:

1.1 安裝:

pip install marker-pdf

1.2 使用: 全部默認配置的話是這樣的

marker_single ./2506.11763v1.pdf 

建議:

1、查看文檔配置相關參數,我這里因為是 32 頁文檔,沒有處理完成,處理了25 頁(1.4w字(word 統計)?用時152s ,每秒接近 92 個字,使用的是 4090 GPU 機器。);

2、對比看看表格情況怎樣?

原始 PDF: 感覺差不多夠用了,不夠后面可以再加 LLM 增強

3、還可以多 GPU 執行,大家可以多多探索下

官方 -> Usage

First, some configuration:

  • Your torch device will be automatically detected, but you can override this. For example,?TORCH_DEVICE=cuda.
  • Some PDFs, even digital ones, have bad text in them. Set?-force_ocr?to force OCR on all lines, or the?strip_existing_ocr?to keep all digital text, and strip out any existing OCR text.
  • If you care about inline math, set?force_ocr?to convert inline math to LaTeX.

Interactive App

I've included a streamlit app that lets you interactively try marker with some basic options. Run it with:

pip install streamlit streamlit-ace
marker_gui

Convert a single file

marker_single /path/to/file.pdf

You can pass in PDFs or images.

Options:

  • -page_range TEXT: Specify which pages to process. Accepts comma-separated page numbers and ranges. Example:?-page_range "0,5-10,20"?will process pages 0, 5 through 10, and page 20.
  • -output_format [markdown|json|html|chunks]: Specify the format for the output results.
  • -output_dir PATH: Directory where output files will be saved. Defaults to the value specified in settings.OUTPUT_DIR.
  • -paginate_output: Paginates the output, using?\\n\\n{PAGE_NUMBER}?followed by??* 48, then?\\n\\n
  • -use_llm: Uses an LLM to improve accuracy. You will need to configure the LLM backend - see?below.
  • -force_ocr: Force OCR processing on the entire document, even for pages that might contain extractable text. This will also format inline math properly.
  • -block_correction_prompt: if LLM mode is active, an optional prompt that will be used to correct the output of marker. This is useful for custom formatting or logic that you want to apply to the output.
  • -strip_existing_ocr: Remove all existing OCR text in the document and re-OCR with surya.
  • -redo_inline_math: If you want the absolute highest quality inline math conversion, use this along with?-use_llm.
  • -disable_image_extraction: Don't extract images from the PDF. If you also specify?-use_llm, then images will be replaced with a description.
  • -debug: Enable debug mode for additional logging and diagnostic information.
  • -processors TEXT: Override the default processors by providing their full module paths, separated by commas. Example:?-processors "module1.processor1,module2.processor2"
  • -config_json PATH: Path to a JSON configuration file containing additional settings.
  • config --help: List all available builders, processors, and converters, and their associated configuration. These values can be used to build a JSON configuration file for additional tweaking of marker defaults.
  • -converter_cls: One of?marker.converters.pdf.PdfConverter?(default) or?marker.converters.table.TableConverter. The?PdfConverter?will convert the whole PDF, the?TableConverter?will only extract and convert tables.
  • -llm_service: Which llm service to use if?-use_llm?is passed. This defaults to?marker.services.gemini.GoogleGeminiService.
  • -help: see all of the flags that can be passed into marker. (it supports many more options then are listed above)

The list of supported languages for surya OCR is?here. If you don't need OCR, marker can work with any language.

Convert multiple files

marker /path/to/input/folder
  • marker?supports all the same options from?marker_single?above.
  • -workers?is the number of conversion workers to run simultaneously. This is automatically set by default, but you can increase it to increase throughput, at the cost of more CPU/GPU usage. Marker will use 5GB of VRAM per worker at the peak, and 3.5GB average.

Convert multiple files on multiple GPUs

NUM_DEVICES=4 NUM_WORKERS=15 marker_chunk_convert ../pdf_in ../md_out
  • NUM_DEVICES?is the number of GPUs to use. Should be?2?or greater.
  • NUM_WORKERS?is the number of parallel processes to run on each GPU.

Use from python

See the?PdfConverter?class at?marker/converters/pdf.py?function for additional arguments that can be passed.

from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.output import text_from_renderedconverter = PdfConverter(artifact_dict=create_model_dict(),
)
rendered = converter("FILEPATH")
text, _, images = text_from_rendered(rendered)

rendered?will be a pydantic basemodel with different properties depending on the output type requested. With markdown output (default), you'll have the properties?markdown,?metadata, and?images. For json output, you'll have?children,?block_type, and?metadata.

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/93870.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/93870.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/93870.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

STM32HAL 快速入門(七):GPIO 輸入之光敏傳感器控制蜂鳴器

STM32HAL 快速入門(七):GPIO 輸入之光敏傳感器控制蜂鳴器 前言 大家好,這里是 Hello_Embed。上一篇我們用 GPIO 輸入模式實現了按鍵控制 LED,本篇將進階到 “光敏傳感器控制蜂鳴器”—— 通過讀取光敏傳感器的信號&…

windows環境,安裝kafka

步驟 1: 準備工作 確保已安裝 Java:Kafka 需要 Java 運行時環境 (JRE) 或 Java 開發工具包 (JDK) 來運行。請確認您的系統上已安裝了 Java,并且 JAVA_HOME 環境變量正確配置。 解壓 Kafka:將下載的 Kafka 壓縮包解壓到一個目錄,比…

機器翻譯60天修煉專欄介紹和目錄

文章目錄 第一章:機器翻譯基礎認知與語言學鋪墊 第二章:經典機器翻譯模型(統計機器翻譯) 第三章:神經網絡基礎與詞向量技術 第四章:神經機器翻譯(NMT)基礎架構 第五章:NMT模型進階與訓練實踐 第六章:預訓練模型與機器翻譯應用 第七章:研究前沿與綜合項目 導論:學習…

openwrt增加自定義網頁

一. 簡介 本文介紹在OpenWRT中使用Luci框架定制設備配置頁面的方法,包括添加靜態頁面和參數配置頁面的過程,以及如何利用lua腳本實現界面與功能的結合。 二. Luci介紹 UCI 是 Openwrt 中為實現所有系統配置的一個統一接口,英文名 Unified Configuration Interface,即統一…

微服務的編程測評系統11-jmeter-redis-競賽列表

提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔 文章目錄前言1. 退出登錄1.1 后端1.2 前端2. 獲取當前用戶信息3. C端用戶競賽列表功能3.1 后端3.2 Jmeter-基本操作3.3 數據版本性能測試-壓力測試3.4 redis版本-緩存結構設計…

海濱浴場應急廣播:守護碧海藍天的安全防線

海濱浴場應急廣播:守護碧海藍天的安全防線!海濱浴場,是人們休閑娛樂、親近自然的理想場所。然而,變幻莫測的海洋環境也潛藏著諸多安全隱患,如溺水、離岸流、海蜇蜇傷、極端天氣等。為了有效應對突發事件,保…

華曦達港股IPO觀察丨以創新研發為筆,構建AI Home智慧生活新藍圖

深圳市華曦達科技股份有限公司自創立伊始,便將敏銳的市場洞察與前沿技術追蹤視為生命線。通過構建一支卓越的研發團隊,公司專注于自主核心技術的深耕與積累,以精密的硬件與創新的軟件筑起堅實的技術壁壘。其精心打造的“技術創新-…

構建現代化的Web UI自動化測試框架:從圖片上傳測試實踐說起

構建現代化的Web UI自動化測試框架:從圖片上傳測試實踐說起如何設計一個可維護、可擴展的Web UI自動化測試框架?本文通過一個圖片上傳測試實例,詳細介紹專業測試框架的搭建與實踐。當前測試框架結構 首先,讓我們了解一下當前的測試…

Apache IoTDB:大數據時代時序數據庫選型的技術突圍與實踐指南

摘要:時序數據庫在大數據時代迎來爆發式增長,IoTDB作為Apache頂級開源項目展現出顯著優勢:1. 性能卓越:支持千萬級數據點/秒寫入,18:1高壓縮比,查詢延遲低至500ms;2. 創新架構:采用樹…

2025年8月16日(星期六):雨騎古蓮村游記

清晨,當第一縷微光還未完全驅散夜幕的靜謐,我們這群由校長領銜的騎行愛好者已整裝待發。咖啡節早市尚未開攤,空氣中彌漫著一種期待與寧靜交織的氛圍,仿佛連時間都在為我們即將開啟的旅程而放慢腳步。今天的目標是古蓮村&#xff0…

Pandas數據預處理中缺失值處理

一、缺失值的概念表現形式1.數據庫中常用null表示2.部分編程語言中用NA表示3.可能表現為空字符串(‘’)或特定數值4.在Pandas中統一用NaN表示(來自NumPy庫,NaN、NAN、nan本質一致)NaN的特性1.與任何值都不相等&#xf…

計算機網絡:(十五)TCP擁塞控制與擁塞控制算法深度剖析

> 當網絡變成"堵城",TCP如何化身智能交通指揮家?揭秘百萬級并發背后的流量控制藝術! ### 一、生死攸關:為什么需要擁塞控制? **真實災難案例**:1986年勞倫斯伯克利實驗室網絡大崩潰,因缺乏擁塞控制導致全網癱瘓36小時。TCP擁塞控制由此誕生,核心解決**資…

python中的單下劃線“_”與雙下劃線“__”的使用場景及“左右雙下劃線”(魔術方法:`__xxx__`)

在Python中,單下劃線“_”和雙下劃線“__”的使用場景和含義有顯著區別,主要體現在命名約定和語法 一、單下劃線“_”的使用場景 單下劃線更多是編程約定(而非強制語法),用于傳遞特定的“暗示”,不影響代碼…

我們為什么需要時序數據庫?

引言在當今數據驅動的世界中,時間序列數據正以前所未有的速度增長。從物聯網設備傳感器、金融交易記錄到應用程序性能監控,時間序列數據無處不在。傳統的關系型數據庫在處理這類數據時往往力不從心,這時時序數據庫(Time Series Database, TSD…

python-林粒粒的視頻筆記1

python的方法和函數指什么 可變類型和不可變類型 不可變類型,比如字符串通過方法調用后,字符串本身的值不改變 要改變需要重新賦值才能進行改變 比如可變數據類型類型,調用方法后可以直接改變原列表 因此,可變數據類型需要再重新賦…

CentOS 7的下載與安裝

一 、CentOS 7的下載與安裝 注意: CentOS 7 已于2024年6月30日停止維護! 1、下載 由于 centos 7 已經停止維護,部分鏡像網站移除了對centos 7的支持,這里找到了部分現在還可以使用的鏡像網站 阿里云開源鏡像站:http…

礦物分類系統開發筆記(二):模型訓練[刪除空缺行]

目錄 一、階段銜接與開發目標 二、數據準備 三、模型選擇與訓練 1. 邏輯回歸(LR) 2. 隨機森林(RF) 3. 高斯樸素貝葉斯(GNB) 4. 支持向量機(SVM) 5. AdaBoost 6. XGBoost 四…

通信方式:命名管道

一、命名管道 1. 命名管道的原理 有了匿名管道,理解命名管道就非常簡單了。 對于普通文件而言,兩個進程打開同一個文件,OS是不會將文件加載兩次的,這兩個進程都會指向同一個文件,那么,也就享有同一份 in…

如何將數據庫快速接入大模型實現智能問數,實現chatbi、dataagent,只需短短幾步,不需要配置工作流!

智能問數系統初始化操作流程 一、系統初始化與管理員賬號創建登錄與初始化提示:首次訪問系統登錄頁,若系統未初始化,會彈出 “系統未完成初始化,請初始化管理員賬號” 提示,點擊【去創建】。填寫管理員信息&#xff1a…

告別手寫文檔!Spring Boot API 文檔終極解決方案:SpringDoc OpenAPI

在前后端分離和微服務盛行的今天,API 文檔是團隊協作的“通用語言”。一份清晰、準確、實時同步的文檔,能極大提升開發和聯調效率。然而,手動編寫和維護 API 文檔(如 Word、Markdown 或 Postman)是一場永無止境的噩夢—…