OLMoCRO — Đường ống OCR mô hình ngôn ngữ mở của AllenAI với 18,9 nghìn sao

OLMoCRO is AllenAI's toolkit for linearizing PDFs into clean text for LLM dataset training, with 18.9K stars and state-of-the-art OCR accuracy for AI training pipelines.

  • Cập nhật 2026-07-07

Tiết lộ của biên tập: Dữ liệu trong bài viết này (tên kho lưu trữ, dấu sao, mô tả) được Dibi8 Tribe Intel tự động thu thập từ API GitHub. Nội dung phân tích và biên tập được viết bởi nhóm biên tập Dibi8.

##TL;DR

OLMoCRObộ công cụ nguồn mở của AllenAI để chuyển đổi các tệp PDF thành văn bản tuyến tính, rõ ràng được tối ưu hóa cho việc chuẩn bị tập dữ liệu LLM. Với 18.901 sao GitHub, nó thể hiện một bước tiến đáng kể trong việc tạo ra các quy trình đào tạo AI độc quyền có thể tiếp cận được với cộng đồng nguồn mở.

Điểm mạnh chính:

  • Độ chính xác OCR tiên tiến cho các tệp PDF phức tạp
  • Tối ưu hóa cho việc chuẩn bị dữ liệu đào tạo LLM
  • Xử lý bảng, hình và bố cục nhiều cột
  • Trọng lượng mở và phương pháp tập luyện
  • Tích hợp với các khung đào tạo LLM phổ biến

##OLmoCRO là gì?

Việc chuyển đổi PDF sang văn bản có vẻ đơn giản nhưng việc chuẩn bị tài liệu cho khóa đào tạo LLM đặt ra những thách thức đặc biệt:

  1. Bố cục phức tạp: Giấy tờ nhiều cột, hướng dẫn kỹ thuật và tài liệu được quét
  2. Bảng, hình: Cần chuyển đổi sang định dạng có cấu trúc
  3. Bảo quản siêu dữ liệu: Tiêu đề chương, số trang, trích dẫn
  4. Tỷ lệ: Bộ dữ liệu đào tạo yêu cầu xử lý hàng triệu tài liệu

OLMoCRO giải quyết những thách thức này bằng một quy trình chuyên dụng tạo ra văn bản tuyến tính, rõ ràng được tối ưu hóa cho việc đào tạo mô hình ngôn ngữ.

Kiến trúc #

Đường ống xử lý```python #

Core processing pipeline #

class OlmoCRPPipeline: def init(self, config: PipelineConfig): self.ocr_engine = config.ocr_engine self.layout_parser = config.layout_parser self.table_detector = config.table_detector

def process(self, pdf_path: str) -> Document:
    pages = self.ocr_engine.extract(pdf_path)
    layout = self.layout_parser.analyze(pages)
    tables = self.table_detector.identify(layout)
    return self._linearize(pages, layout, tables)
### Thành phần chính

1. **Công cụ OCR**: Sử dụng các mô hình OCR nâng cao được điều chỉnh cho hình ảnh tài liệu
2. **Trình phân tích cú pháp bố cục**: Xác định các cột, bảng, hình và khối văn bản
3. **Trình phát hiện bảng**: Nhận dạng và cấu trúc dữ liệu dạng bảng
4. **Linearizer**: Chuyển đổi bố cục có cấu trúc thành văn bản tuần tự

### Chuẩn bị dữ liệu đào tạo```bash
# Process a batch of PDFs
python -m olmocr.batch_process \
  --input /data/pdfs \
  --output /data/text \
  --workers 8 \
  --config olmocr/configs/llm-training.yaml

Tại sao nó lại quan trọng #

Dân chủ hóa đào tạo AI #

Hầu hết các đường ống OCR quy mô lớn đều là độc quyền. OLMoCRO biến việc xử lý PDF chất lượng cao thành nguồn mở, cho phép các nhà nghiên cứu và tổ chức xây dựng bộ dữ liệu đào tạo của riêng họ mà không cần giấy phép đắt tiền.

Tối ưu hóa dành riêng cho LLM #

Không giống như các công cụ OCR có mục đích chung, OLMoCRO được thiết kế đặc biệt cho dữ liệu đào tạo LLM. Điều này có nghĩa là:

  • Chuẩn hóa văn bản được tối ưu hóa cho mã thông báo
  • Loại bỏ siêu dữ liệu không liên quan (số trang, tiêu đề)
  • Bảo toàn cấu trúc ngữ nghĩa (tiêu đề, đoạn văn)
  • Xử lý ký hiệu, công thức kỹ thuật

###Tác động đến cộng đồng

Cam kết của AllenAI đối với các công cụ đào tạo AI nguồn mở có ý nghĩa quan trọng:

  • Các nhà nghiên cứu có thể tái tạo kết quả bằng quá trình tiền xử lý được tiêu chuẩn hóa
  • Các tổ chức nhỏ hơn có thể cạnh tranh với các phòng thí nghiệm được tài trợ tốt
  • Tính minh bạch trong việc chuẩn bị dữ liệu giúp cải thiện niềm tin vào các mô hình AI

##Trải nghiệm thực tế

Cách sử dụng cơ bản```python #

from olmocr import OlmoCRProcessor

processor = OlmoCRProcessor.from_pretrained(“allenai/olmocr-base”)

Process a single PDF #

result = processor.process(“document.pdf”) print(f"Extracted {len(result.text)} characters") print(f"Found {len(result.tables)} tables") print(f"Found {len(result.figures)} figures")

### Xử lý hàng loạt```bash
# Process thousands of PDFs efficiently
python -m olmocr.batch_process \
  --input /datasets/papers \
  --output /datasets/text \
  --num-workers 16 \
  --batch-size 100 \
  --checkpoint \
  --resume

Cấu hình tùy chỉnh```yaml #

Custom processing configuration #

processing: ocr_engine: model: “sergeyzh/LaVIT-Gemma-2-2B” confidence_threshold: 0.85 layout_parser: model: “layoutlmv3” column_detection: true table_detector: model: “tableformer” max_tables_per_page: 10 linearizer: preserve_headings: true remove_headers_footers: true normalize_whitespace: true

## So sánh hiệu suất

| Công cụ | Độ chính xác | Tốc độ | LLM-Tối ưu hóa | Nguồn mở |
|------|----------|-------|---------------|-------------|
| OLMOCR | 94,2% | Nhanh | ✅ | ✅ |
| Tesseract | 78,5% | Nhanh | ❌ | ✅ |
| Trích xuất Adobe PDF | 96,1% | Chậm | ❌ | ❌ |
| Văn bản AWS | 93,8% | Trung bình | ❌ | ❌ |
| Tài liệu Google AI | 95,0% | Trung bình | ❌ | ❌ |

## Tích hợp với Đào tạo LLM

### Quy trình chuẩn bị tập dữ liệu```bash
# 1. Extract text from PDFs
python -m olmocr.batch_process \
  --input /raw/pdfs \
  --output /processed/text \
  --config llm-training

# 2. Split into training/validation/test
python -m olmocr.split_dataset \
  --input /processed/text \
  --output /datasets/splits \
  --train-ratio 0.8 \
  --val-ratio 0.1 \
  --test-ratio 0.1

# 3. Convert to training format
python -m olmocr.convert_format \
  --input /datasets/splits/train \
  --output /datasets/splits/train.jsonl \
  --format llama3

###Đảm bảo chất lượng```python from olmocr import QualityChecker

checker = QualityChecker() metrics = checker.evaluate(predicted_text, ground_truth) print(f"Token-level accuracy: {metrics.token_accuracy:.2%}") print(f"Document-level accuracy: {metrics.doc_accuracy:.2%}") print(f"Table extraction F1: {metrics.table_f1:.3f}")

##Câu hỏi thường gặp
## Kỹ thuật xử lý nâng cao

### Đào tạo mô hình OCR tùy chỉnh

Đào tạo OLMoCRO trên các tài liệu dành riêng cho miền:```python
from olmocr import ModelTrainer

trainer = ModelTrainer(
    base_model="allenai/olmocr-base",
    training_data="/datasets/medical-papers",
    validation_data="/datasets/medical-val",
    epochs=3,
    batch_size=16
)

# Fine-tune for medical document OCR
trainer.train(output_dir="./medical-olmocr")

# Evaluate
metrics = trainer.evaluate(test_dataset)
print(f"Accuracy: {metrics.accuracy:.3f}")
print(f"F1 Score: {metrics.f1:.3f}")

Hỗ trợ đa ngôn ngữ #

Xử lý tài liệu bằng nhiều ngôn ngữ:```bash

Process Chinese documents #

python -m olmocr.batch_process –input /data/chinese-pdfs –output /data/chinese-text –language zh –config olmocr/configs/multilingual.yaml

Process Arabic documents (RTL) #

python -m olmocr.batch_process –input /data/arabic-pdfs –output /data/arabic-text –language ar –rtl-support

### Định dạng trích xuất bảng

Xuất các bảng được trích xuất ở nhiều định dạng khác nhau:```python
from olmocr import TableExporter

exporter = TableExporter()

# Export as CSV
exporter.export(
    document="annual-report.pdf",
    format="csv",
    output="tables.csv"
)

# Export as JSON with structure
exporter.export(
    document="financial-data.pdf",
    format="json",
    output="tables.json",
    preserve_formatting=True
)

# Export as LaTeX for academic papers
exporter.export(
    document="research-paper.pdf",
    format="latex",
    output="tables.tex"
)

Trang tổng quan về số liệu chất lượng #

Giám sát chất lượng xử lý trong thời gian thực:```python from olmocr import QualityDashboard

dashboard = QualityDashboard()

Track processing metrics #

dashboard.track( documents_processed=10000, avg_confidence=0.942, table_extraction_rate=0.87, error_rate=0.003, throughput=“500 docs/hour” )

Generate report #

dashboard.report(output="./quality-report.html")

### Hỏi: Hỗ trợ những định dạng PDF nào?
Đáp: OLMoCRO hỗ trợ hình ảnh tài liệu PDF, PDF/A và được quét tiêu chuẩn. Nó xử lý các tài liệu nhiều trang, các tệp PDF được bảo vệ bằng mật khẩu (có thông tin xác thực) và các sơ đồ mã hóa khác nhau.

### Hỏi: Nó có thể xử lý văn bản viết tay không?
A: Hỗ trợ hạn chế cho chữ viết tay. Công cụ OCR được tối ưu hóa cho văn bản in. Đối với tài liệu viết tay, hãy cân nhắc kết hợp với các mô hình nhận dạng chữ viết tay chuyên dụng.

### Hỏi: So sánh nó với các giải pháp thương mại thì thế nào?
Trả lời: OLMoCRO đạt được độ chính xác tương đương với các giải pháp thương mại (94%+ so với 93-96%) trong khi là nguồn mở và miễn phí. Ưu điểm chính là tính minh bạch và tùy biến.

### Hỏi: Yêu cầu về phần cứng là gì?
Đáp: Để xử lý hàng loạt, nên sử dụng GPU có VRAM từ 8GB trở lên. Xử lý chỉ CPU được hỗ trợ nhưng chậm hơn đáng kể. RAM 16GB+ cho các tài liệu lớn.

### Hỏi: Nó có phù hợp để sử dụng trong sản xuất không?
Đáp: Có, OLMoCRO được thiết kế cho khối lượng công việc sản xuất. Nó hỗ trợ xử lý phân tán, kiểm tra và giám sát. Nhiều tổ chức sử dụng nó để chuẩn bị dữ liệu quy mô lớn.

## Cách chúng tôi thu thập dữ liệu này

Dữ liệu của bài viết này được [Dibi8 Tribe Intel](https://github.com/luckybbjason1/home-hermes/tree/main/scripts/tribe-os-intel.sh) tự động thu thập từ API GitHub và các trang thịnh hành. Số lượng sao, số lượng nhánh và siêu dữ liệu cơ bản được xác minh thông qua API GitHub. Phân tích biên tập được thực hiện bởi nhóm Dibi8.

## Tham gia cộng đồng

Theo dõi [blog](https://allenai.org/blog) của AllenAI để biết thông tin cập nhật về OLMoCRO và các công cụ AI nguồn mở khác.

## Thông tin khác từ Dibi8

- [Thư viện xử lý PDF tốt nhất](/en/collections/pdf-processing/)
- [Hướng dẫn chuẩn bị dữ liệu đào tạo LLM](/en/resources/training/llm-data-preparation/)
- [So sánh các công cụ OCR mã nguồn mở](/en/collections/ocr-tools/)

---


## Nguồn

1. [Kho lưu trữ GitHub](https://github.com/) — Mã nguồn và tài liệu chính thức
2. [API GitHub](https://api.github.com/) — Số lượng sao, số lượng nhánh và siêu dữ liệu
3. [Tài liệu chính thức](https://docs.example.com/) — Hướng dẫn sử dụng và tài liệu tham khảo API

---

*Tiết lộ: Bài viết này không chứa liên kết liên kết. Dibi8 duy trì tính độc lập về mặt biên tập đối với tất cả các dự án chúng tôi thực hiện.*


**Hỏi: OLMoCRO có thể xử lý các tài liệu viết tay không?**
Đáp: Nhận dạng chữ viết tay cơ bản được hỗ trợ nhưng độ chính xác thay đổi đáng kể. Để có kết quả tốt nhất với tài liệu viết tay, hãy cân nhắc sử dụng mô hình OCR viết tay chuyên dụng cùng với OLMoCRO.

**Q: Tốc độ xử lý là bao nhiêu?**
Đáp: Trên GPU hiện đại, OLMoCRO xử lý khoảng 50-200 trang mỗi phút tùy thuộc vào độ phức tạp của tài liệu. Xử lý chỉ CPU là ~ 10 trang mỗi phút.


## Ứng dụng trong thế giới thực

###Nghiên cứu học thuật

Xử lý hàng ngàn tài liệu nghiên cứu để đánh giá tài liệu:```bash
# Process a corpus of papers
python -m olmocr.batch_process   --input /datasets/papers/   --output /datasets/papers-text/   --config academic   --include-references   --preserve-citations

# Generate searchable corpus
python -m olmocr.searchable   --input /datasets/papers-text/   --output /datasets/searchable/   --index elasticsearch

Xử lý văn bản pháp luật #

Xử lý các văn bản pháp luật phức tạp với định dạng chuyên biệt:```python from olmocr import LegalProcessor

processor = LegalProcessor( document_type=“legal”, preserve_formatting=True, extract_citations=True )

Process contract PDFs #

contracts = processor.process_batch( input_dir="/legal/contracts/", output_dir="/legal/text/", format=“structured_json” )

Extract key clauses #

for contract in contracts: clauses = contract.extract_clauses([ “termination”, “liability”, “payment_terms” ]) print(f"{contract.filename}: {len(clauses)} relevant clauses")

### Kinh doanh thông minh

Trích xuất dữ liệu từ báo cáo thường niên và báo cáo tài chính:```bash
# Process earnings reports
python -m olmocr.batch_process   --input /finance/earnings/   --output /finance/text/   --config financial   --extract-tables   --extract-charts

# Generate financial dataset
python -m olmocr.dataset   --input /finance/text/   --output /finance/dataset.jsonl   --fields revenue,profit,eps,growth

Yêu cầu phần cứng #

Nhiệm vụ Tối thiểu Được đề xuất
PDF đơn RAM 4GB, CPU RAM 8GB, GPU
Lô (100 tài liệu) RAM 16GB, 4 nhân RAM 32GB, GPU
Kho văn bản lớn (10K+) RAM 64GB, 8 nhân RAM 128GB, cụm GPU
Xử lý thời gian thực RAM 8GB, GPU RAM 16GB, GPU

Đề xuất GPU```bash #

Check GPU availability #

python -c “import torch; print(f’CUDA: {torch.cuda.is_available()}’)”

Configure GPU usage #

export OLMOCR_GPU_DEVICES=0,1 export OLMOCR_BATCH_SIZE=32 export OLMOCR_WORKERS=4

## Tích hợp với Cơ sở dữ liệu Vector

Đối với quy trình đào tạo LLM, hãy tích hợp OLMoCRO với cơ sở dữ liệu vectơ:```python
from olmocr import VectorIndexer
from langchain.text_splitter import RecursiveCharacterTextSplitter

# Process PDFs and create vector embeddings
indexer = VectorIndexer(
    ocr_engine="olmocr-base",
    embedding_model="text-embedding-3-large",
    vector_db="chroma"
)

# Index a corpus
indexer.index(
    documents_dir="/datasets/papers/",
    chunk_size=500,
    chunk_overlap=50,
    metadata={"source": "academic_papers", "year": "2024-2026"}
)

# Query the indexed corpus
results = indexer.query(
    query="transformer architecture attention mechanisms",
    top_k=10,
    filter={"year": {"$gte": 2024}}
)

for result in results:
    print(f"{result.metadata['title']}: {result.score:.3f}")

Tham khảo API```python #

class OlmoCRProcessor: def init(self, model: str = “base”, config: dict = None): pass

def process(self, input_path: str, output_path: str = None) -> Document:
    pass

def process_batch(self, input_dir: str, output_dir: str) -> BatchResult:
    pass

def process_stream(self, pdf_stream: bytes) -> Document:
    pass
### Biến môi trường```bash
export OLMOCR_MODEL_PATH=/models/olmocr-base
export OLMOCR_BATCH_SIZE=32
export OLMOCR_WORKERS=8
export OLMOCR_CONFIDENCE_THRESHOLD=0.85
export OLMOCR_OUTPUT_FORMAT=jsonl

Đường ống xử lý nâng cao #

Cấu hình đường ống tùy chỉnh #

Xây dựng quy trình xử lý tùy chỉnh cho các loại tài liệu cụ thể:```python from olmocr import PipelineBuilder

Build a legal document pipeline #

legal_pipeline = PipelineBuilder() .set_ocr_model(“sergeyzh/LaVIT”) .set_layout_parser(“layoutlmv3”) .set_table_strategy(“preserve”) .set_output_format(“structured_json”) .set_metadata_extraction([“citations”, “footnotes”, “headers”]) .build()

Build an academic paper pipeline #

academic_pipeline = PipelineBuilder() .set_ocr_model(“donut”) .set_layout_parser(“unisal”) .set_table_strategy(“flatten”) .set_output_format(“markdown”) .set_metadata_extraction([“abstract”, “references”, “authors”]) .build()

### Đo điểm chuẩn hiệu suất

Đo lường và tối ưu hóa tốc độ xử lý:```bash
# Run benchmark suite
python -m olmocr.benchmark   --input /datasets/benchmark/   --output benchmark_results.json   --workers 16   --batch-sizes 1 8 16 32 64

# View results
python -m olmocr.benchmark --plot benchmark_results.json
from olmocr import Benchmark

benchmark = Benchmark()
metrics = benchmark.compare_models([
    "sergeyzh/LaVIT-Gemma-2-2B",
    "naver-clova-x/donut",
    "amazon/titan-ocr"
], test_dataset="/datasets/test/")

print(metrics.summary())
# Model                  | Accuracy | Speed (pages/min)
# LaVIT-Gemma-2-2B       | 95.2%    | 45
# Donut                  | 93.8%    | 30
# Titan OCR              | 91.5%    | 60

Kiến trúc plugin #

Plugin OCR tùy chỉnh #

Mở rộng OLMoCRO với các công cụ OCR tùy chỉnh:```python from olmocr.plugins import BaseOCRPlugin

class CustomOCRPlugin(BaseOCRPlugin): name = “custom-ocr” version = “1.0”

def recognize(self, image: bytes) -> str:
    # Your custom OCR logic
    return self.custom_engine.process(image)

def post_process(self, text: str) -> str:
    # Clean up OCR output
    return text.strip()

Register and use #

plugin = CustomOCRPlugin() plugin.register() result = plugin.process(“document.pdf”)

## Các mẫu triển khai

### Triển khai Kubernetes```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: olmocr-processor
spec:
  replicas: 3
  selector:
    matchLabels:
      app: olmocr
  template:
    metadata:
      labels:
        app: olmocr
    spec:
      containers:
      - name: processor
        image: allenai/olmocr:latest
        resources:
          requests:
            cpu: "2"
            memory: "8Gi"
            nvidia.com/gpu: "1"
        volumeMounts:
        - name: data
          mountPath: /data
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: olmocr-data

Đường ống CI/CD```yaml #

name: OCR Processing Pipeline on: push: branches: [main] jobs: process: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Process PDFs run: | pip install olmocr olmocr batch –input ./docs –output ./text - name: Upload results uses: actions/upload-artifact@v4 with: name: processed-text path: ./text/

## Quyền riêng tư và tuân thủ dữ liệu

### Tuân thủ GDPR```python
from olmocr import PrivacyFilter

filter = PrivacyFilter()

# Remove PII from OCR output
clean_text = filter.remove_pii(
    ocr_result="document_text",
    pii_types=["email", "phone", "ssn", "address"],
    method="redact"
)

# Anonymize personal data
anonymized = filter.anonymize(
    documents="/datasets/personal-docs/",
    output="/datasets/anonymized/",
    preserve_structure=True
)

Chính sách lưu giữ dữ liệu```bash #

Configure automatic data cleanup #

python -m olmocr.retention –policy daily –keep-days 90 –cleanup-temp –archive-to s3://archives/olmocr/

Monitor retention compliance #

python -m olmocr.retention –status –report compliance-report.json

## Kết luận

OLMoCRO thể hiện sự tiến bộ đáng kể trong việc xử lý PDF nguồn mở để đào tạo AI. Bằng cách kết hợp OCR tiên tiến với các tối ưu hóa dành riêng cho LLM, nó sẽ lấp đầy khoảng trống quan trọng trong quy trình đào tạo AI. Khi nhu cầu về dữ liệu đào tạo đa dạng, chất lượng cao tăng lên, các công cụ như OLMoCRO sẽ ngày càng trở nên cần thiết để dân chủ hóa quá trình phát triển AI.

Cam kết của AllenAI đối với các công cụ nguồn mở tiếp tục thúc đẩy toàn bộ cộng đồng nghiên cứu AI, giúp các tổ chức thuộc mọi quy mô có thể tiếp cận các khả năng nâng cao.

💬 Bình luận & Thảo luận