Configuration Parsing Warning:Config file config.json cannot be fetched (too big)

Configuration Parsing Warning:Config file tokenizer_config.json cannot be fetched (too big)

TexOCR_RL

TexOCR: Advancing Document OCR Models for Compilable Page-to-LaTeX Reconstruction [ACL 2026 Main]

This repository contains the reinforcement learning (RL) model based on TexOCR_OCR, further optimized with GRPO training.

Overview

  • Base Model: TexOCR_OCR
  • Training Method: GRPO (Reinforcement Learning)
  • Task: Compilable Page-to-LaTeX Reconstruction

Inference

You can use the following code to run inference with the fine-tuned TexOCR model.

import torch
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor

# Load the fine-tuned model
model = Qwen3VLForConditionalGeneration.from_pretrained(
    "chengyewang/TexOCR-RL",
    dtype="auto",
    device_map="auto"
)


processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-2B-Instruct")

# Input document page image
image_path = "path/to/your/document_page.png"

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "image": image_path,
            },
            {
                "type": "text",
                "text": (
                    "Convert this document page image into compilable LaTeX code. "
                ),
            },
        ],
    }
]

# Preparation for inference
inputs = processor.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_dict=True,
    return_tensors="pt"
)
inputs = inputs.to(model.device)

# Inference: generate LaTeX output
generated_ids = model.generate(
    **inputs,
    max_new_tokens=2048,
    do_sample=False
)

# Remove input tokens from the generated sequence
generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]

# Decode the generated LaTeX
latex_output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False
)

print(latex_output[0])
Downloads last month
58
Safetensors
Model size
2B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including chengyewang/TexOCR-RL