Abstract
We present ReaderLM-v2, a compact 1.5 billion parameter language model designed for efficient web content extraction. Our model processes documents up to 512K tokens, transforming messy HTML into clean Markdown or JSON formats with high accuracy—making it an ideal tool for grounding large language models. The model's effectiveness results from two key innovations: (1) a three-stage data synthesis pipeline that generates high-quality, diverse training data by iteratively drafting, refining, and critiquing web content extraction; and (2) a unified training framework combining continuous pre-training with multi-objective optimization. Intensive evaluation demonstrates that ReaderLM-v2 outperforms GPT-4o-2024-08-06 and other larger models by 15-20% on carefully curated benchmarks, particularly excelling at documents exceeding 100K tokens, while maintaining significantly lower computational requirements.
Introduction
Large Language Models (LLMs) are increasingly utilized as the core engines for Retrieval-Augmented Generation (RAG). However, the efficacy of these systems is fundamentally limited by the quality of the input data. Raw web content is notoriously "noisy," often cluttered with boilerplate, JavaScript, CSS, and non-standard HTML tags. Existing extraction solutions struggle with HTML complexity, extreme length variability, and the high inference costs associated with processing massive HTML strings through 70B+ parameter models.
ReaderLM-v2 addresses these challenges as a specialized 1.5 billion parameter model. By hyper-specializing on structural transformation rather than general reasoning, it achieves state-of-the-art performance in converting messy HTML into clean, structured Markdown or JSON, even outperforming proprietary models like GPT-4o on specific extraction benchmarks.
Methodology
ReaderLM-v2 is built upon the Qwen2.5-1.5B architecture and employs a sophisticated multi-stage training strategy to ensure high-fidelity extraction.
Training Framework
The model undergoes a progression from continuous pre-training to Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO). A key component is Self-play Iterative Tuning, which further polishes performance by allowing the model to learn from its own outputs and critiques generated by a larger teacher model (Qwen2.5-32B-Instruct).
Context Expansion and DRC Pipeline
To handle long-form content, the context window was scaled from 32K to 256K during training using Ring-Zag attention and RoPE frequency scaling, enabling extrapolation to 512K tokens during inference.
The core innovation is the Draft-Refine-Critique (DRC) pipeline. Instead of training on raw, noisy data, the authors utilized a three-step synthetic process:
- Draft: Generate an initial extraction.
- Refine: An LLM cleans the draft, ensuring formatting consistency and removing redundancy.
- Critique: A model evaluates the refined version, providing binary feedback and detailed explanations for failures to guide further optimization.
Data Synthesis and Datasets
The training corpus, WebMarkdown-1M, consists of one million web pages sampled from Common Crawl. From this base, the DRC pipeline generated specialized subsets to support the multi-stage training process, including 250,000 high-quality instruction pairs and 150,000 preference triplets for DPO.
Evaluation and Key Results
ReaderLM-v2 demonstrates that small, specialized models can outperform general-purpose giants in specific domains.
- Content Extraction: The model achieved a Rouge-L score of 0.86, representing a significant improvement over GPT-4o (0.69) and larger models like Qwen2.5-32B-Instruct.
- Long-Context Performance: It particularly excels at documents exceeding 100K tokens, where larger models often lose track of structural hierarchy or exceed their context limits.
- JSON Fidelity: While slightly behind GPT-4o in complex schema-guided extraction (0.81 vs 0.84 F1), it maintained a 99% pass rate for syntactically valid JSON, ensuring reliability for downstream applications.
- Efficiency: As a 1.5B parameter model, it offers significantly lower latency and computational overhead, making it suitable for local deployment and high-throughput processing.
Conclusion
ReaderLM-v2 establishes a new benchmark for efficient web content extraction. By combining a massive context window with a rigorous data synthesis pipeline, it provides a high-fidelity grounding tool for RAG systems. Future work will focus on extending support to more structured formats and incorporating multi-modal capabilities to capture visual elements like charts and images that are often lost in text-only HTML extraction.
Summary updated