LightOnOCR-2 是一个高效的端到端 10 亿参数视觉-语言模型,可将文档(PDF、扫描件、图像)直接转换为干净、自然顺序的文本,无需依赖脆弱的处理流水线。第二版在更大、更高质量的语料库上进行训练,增强了对法语文档、arXiv 论文和扫描件的覆盖能力,改进了 LaTeX 处理,并实现了更干净的归一化。LightOnOCR-2 在 OlmOCR-Bench 上达到当前最优性能,同时模型体积比竞品小约 9 倍,推理速度显著更快。
| 配套 | 版本 | 环境准备指导 |
|---|---|---|
| Python | Python 3.11.14 | - |
| torch | 2.9.0 | - |
| torch_npu | 2.9.0 | - |
| vLLM- Ascend | 0.14.0rc1 | |
| CANN | 8.2.RC1 |
整机:Atlas 800T A2
NPU:910B昇腾
部署方式:单卡部署
操作系统:openEuler 22.03 (LTS-SP2), ARM
参考官方链接https://docs.vllm.ai/projects/ascend/zh-cn/latest/installation.html中容器镜像安装方法, 使用镜像quay.io/ascend/vllm-ascend:v0.14.0rc1部署vllm-ascend框架。
以下操作使用的账号是在操作系统上自建的账号,也可以用root账号执行。
export DEVICE=/dev/davinci0
# Update the vllm-ascend image
# Atlas A2:
# export IMAGE=quay.io/ascend/vllm-ascend:v0.14.0rc1
# Atlas A3:
# export IMAGE=quay.io/ascend/vllm-ascend:v0.14.0rc1-a3
export IMAGE=quay.io/ascend/vllm-ascend:v0.14.0rc1
docker run --rm \
--name vllm-ascend \
--shm-size=1g \
--device $DEVICE \
--device /dev/davinci_manager \
--device /dev/devmm_svm \
--device /dev/hisi_hdc \
-v /usr/local/dcmi:/usr/local/dcmi \
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /root/.cache:/root/.cache \
-p 8000:8000 \
-itd $IMAGE bash
进入上一步启动的容器,命令:
docker exec -it vllm-ascend bash安装curl,命令:
apt-get update -y && apt-get install -y curl安装ModelScope,命令:
pip install modelscope下载模型,命令:
modelscope download --model lightonai/LightOnOCR-2-1BVLLM_USE_MODELSCOPE=true vllm serve lightonai/LightOnOCR-2-1B \
--limit-mm-per-prompt '{"image": 1}' --mm-processor-cache-gb 0 --no-enable-prefix-caching等待命令执行完成,回显“Application startup complete.”表示模型成功运行。

另起一个客户端进入容器执行测试用例,进入容器命令:
docker exec -it vllm-ascend bash安装python处理pdf的库pypdfium2,命令:
pip install pypdfium2进入python环境,命令:
python执行测试脚本,命令:
import base64
import requests
import pypdfium2 as pdfium
import io
ENDPOINT = "http://localhost:8000/v1/chat/completions"
MODEL = "lightonai/LightOnOCR-2-1B"
# Download PDF from arXiv
pdf_url = "https://arxiv.org/pdf/2412.13663"
pdf_data = requests.get(pdf_url).content
# Open PDF and convert first page to image
pdf = pdfium.PdfDocument(pdf_data)
page = pdf[0]
# Render at 200 DPI (scale factor = 200/72 ≈ 2.77)
pil_image = page.render(scale=2.77).to_pil()
# Convert to base64
buffer = io.BytesIO()
pil_image.save(buffer, format="PNG")
image_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
# Make request
payload = {
"model": MODEL,
"messages": [{
"role": "user",
"content": [{
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{image_base64}"}
}]
}],
"max_tokens": 4096,
"temperature": 0.2,
"top_p": 0.9,
}
response = requests.post(ENDPOINT, json=payload)
text = response.json()['choices'][0]['message']['content']
print(text)
这个用例将url为https://arxiv.org/pdf/2412.13663的pdf提取出文字,如下:
