返回顶部
热门问答 更多热门问答
技术文章 更多技术文章

MinerU-利用专用LLM模型提取PDF内容的工具实测

[复制链接]
链载Ai 显示全部楼层 发表于 昨天 21:13 |阅读模式 打印 上一主题 下一主题
机器学习及大模型微调中,数据处理是不得不面对的比较繁琐的问题。很多数据内容以pdf文档、word文档等形式存在,需要做预处理。今天尝试了一款开源处理工具MinerU:

MinerU是一款将PDF转化为机器可读格式的工具(如markdown、json),可以很方便地抽取为任意格式。 MinerU诞生于书生-浦语的预训练过程中。开源地址:

https://github.com/opendatalab/MinerU


ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">安装

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">建议一开始就在有GPU的机器上安装,纯CPU会比较慢

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">裸机安装,以 conda 隔离环境为例,依次执行如下命令:

condacreate-nmineru'python=3.12'-ycondaactivateminerupipinstall-U"magic-pdf[full]"-ihttps://mirrors.aliyun.com/pypi/simplepipinstallmodelscopewgethttps://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py-Odownload_models.pypythondownload_models.py

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">其中下载的模型放在这里:

#du-sh~/.cache/modelscope/hub/models/*1.8G	/root/.cache/modelscope/hub/models/opendatalab681M	/root/.cache/modelscope/hub/models/ppaanngggg

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">应该是一个专为文档识别训练的小模型。

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">以上都是官方文档的安装步骤,下面是需要适配的部分:

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">mac下可能需要降级 Numpy 库到 1.x, 否则执行命令会有报错:

pipuninstall numpy -ypipinstall numpy==1.26.4

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">安装 libreoffice

#mac环境:brewinstalllibreoffice#ubuntu环境:aptinstalllibreoffice-y

ingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: justify;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;">安装后可以修改生成的配置文件: ~/magic-pdf.json,可以修改其中LLM辅助部分的配置:

"llm-aided-config":{"formula_aided":{"api_key":"your_api_key","base_url":"https://dashscope.aliyuncs.com/compatible-mode/v1","model":"qwen2.5-7b-instruct","enable":false},"text_aided":{"api_key":"your_api_key","base_url":"https://dashscope.aliyuncs.com/compatible-mode/v1","model":"qwen2.5-7b-instruct","enable":false},"title_aided":{"api_key":"your_api_key","base_url":"https://dashscope.aliyuncs.com/compatible-mode/v1","model":"qwen2.5-32b-instruct","enable":false}},

可以将里面的 enable 改为 true,并配置上自己能用的模型API接口。

如果要使用 GPU,修改其中的 device-mode 值为 cuda:

#grepdevice~/magic-pdf.json"device-mode":"cuda",

运行

命令样例:

magic-pdf\-p"./GAOKAO-2025-CME/2025年高考全国1卷数学高考真题解析(完整版)/"\-oGAOKAO-2025-CME-mineru/math

我们来看数学前3题的解析结果:

# 2025 年普通高等 (新 1 卷)家学习生活愉
意事项:
1.答卷前, 上 .用2B 铅笔将试卷类型和考生号填涂在 答题相应位置上2.选择题每小题选出答案后,用2B 铅 案不能答在试卷上.3.非选择题必须用黑色字迹的钢笔或案,不一 选择题:本大题共8小题,每小题5分,共计40分.每小题上.
1. 的虚部为( )
A. B.0C.1D.6
【】答案】C【】解析】【】分析】【】详解】因为$\left(1+5\mathrm { i } \right) \mathrm { i } = \mathrm { i } +5\mathrm { i } ^ {2} = -5+ \mathrm { i }$,所以其虚部为1,故选:C.
2. 设全集$U= x { \big | }$0□9□□ ,集合$\scriptstyle A = \{1,3,5\}$,则 中元素个数为(
A.0B.3C.5D.8
【】答案】C【】解析】【】分析】【】详解】因为 ,所以$\Dot { \mathfrak { Q } } , A =2,4,5,7,8$, 中的元素个数为 ,故选:C.
3. 若双曲线$C$的虚轴长为实轴长的$\sqrt {7}$倍,则 C 的离心率为( )
A. B.2C. D.
## 【】答案】D
【】解析】【】分析】由题可知双曲线中 的关系,结合$\boldsymbol { a } ^ { z } + \boldsymbol { b } ^ { z } = \boldsymbol { c } ^ { z }$和离心率公式求解【】详解】 ,焦距分别为$\mathsf { Z } a , \mathsf { Z } b , \mathsf { Z } c _ { \perp }$由题知,$b= \sqrt {7} a \prod$于是$a^ {2} + b ^ {2} = c ^ {2} = a ^ {2} +7a ^ {2} =8a ^ {2}$,则$c=2\sqrt {2} a \ D$$\begin{array} {r} { \underline { \sf U } ^ { e } = \frac { c } { a } =2\sqrt {2} . } \end{array}$故选:D

结果不太理想。题干有丢失内容。选项有莫名其妙的字符

这个文档是 word 的,下面是转化为pdf后再解析的结果,好很多了:

# 2025 年普通高等学校招生全国统一考试(新 1 卷)
★祝大家学习生活愉快★
## 注意事项:
1.答卷前,考生务必用黑色字迹的钢笔或签字笔将自己的姓名和考生号,试室号,座位号填写在答题卡上.用2B 铅笔将试卷类型和考生号填涂在答题卡相应位置上.2.选择题每小题选出答案后,用2B 铅笔把答题卡上对应的题目选项的答案信息点涂黑:如需改动,用橡皮擦干净后,再填涂其他答案.答案不能答在试卷上.3.非选择题必须用黑色字迹的钢笔或签字笔作答,答案必须写在答题卡各题目指定区域内相应位置上:如需改动,先划掉原来的答案,然后再写上新的答案,不准使用铅笔和涂改液.不按以上要求作答的答案无效.
## 一、选择题:本大题共 8 小题,每小题 5 分,共计 40 分.每小题给出的四个选项中,只有一个选项是正确的.请把正确的选项填涂在答题卡相应的位置上.
1.$(1+5\mathrm { i } ) \mathrm { i }$的虚部为( )
A.-1B.0C.1D.6
【答案】C【解析】
【分析】根据复数代数形式的运算法则以及虚部的定义即可求出.
【详解】因为$\left(1+5\mathrm { i } \right) \mathrm { i } = \mathrm { i } +5\mathrm { i } ^ {2} = -5+ \mathrm { i }$,所以其虚部为1,故选:C.
2. 设全集$U= { \Big \{ } x { \Big | } x$罂租谗9\$%窭窦},集合$A= \{1,3,5\}$,则$_U { \cal A }$中元素个数为( )
A.0B.3C.5D.8
【答案】C【解析】
【分析】根据补集的定义即可求出
【详解】因为$U= \left\{1,2,3,4,5,6,7,8\right\}$,所以$_{ U } A = \{2,4,6,7,8\}$,$_U { \cal A }$中的元素个数为5,故选:C
3. 若双曲线$C$的虚轴长为实轴长的$\sqrt {7}$倍,则$C$的离心率为( )
A.$\sqrt {2}$B.2C.$\sqrt {7}$D.22
【答案】D【解析】
【分析】由题可知双曲线中$^ { a , b }$的关系,结合$a^ {2} + b ^ {2} = c ^ {2}$和离心率公式求解
【详解】设双曲线的实轴,虚轴,焦距分别为$2a ,2b ,2c$,由题知,$b= { \sqrt {7} } a$,于是$a^ {2} + b ^ {2} = c ^ {2} = a ^ {2} +7a ^ {2} =8a ^ {2}$,则$c=2{ \sqrt {2} } a$,即$e= { \frac { c } { a } } =2{ \sqrt {2} }$.故选:D

另一个pdf版本:


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

链载AI是专业的生成式人工智能教程平台。提供Stable Diffusion、Midjourney AI绘画教程,Suno AI音乐生成指南,以及Runway、Pika等AI视频制作与动画生成实战案例。从提示词编写到参数调整,手把手助您从入门到精通。
  • 官方手机版

  • 微信公众号

  • 商务合作

  • Powered by Discuz! X3.5 | Copyright © 2025-2025. | 链载Ai
  • 桂ICP备2024021734号 | 营业执照 | |广西笔趣文化传媒有限公司|| QQ