Cloudflare has open-sourced updated versions of its Clairic and Clairic-flash AI models, focusing on improved data extraction from complex documents like images and PDFs. The article highlights an architectural redesign, specifically implementing parallel slot autoregressive generation, to boost accuracy and maintain low latency for various extraction use cases, demonstrating trade-offs between model size, performance, and cost.
Read original on Cloudflare BlogCloudflare's Clairic models, designed for data extraction, underwent a significant architectural overhaul from their preview release. Initially, the team gathered extensive user feedback, which emphasized the need for superior extraction from unstructured data, including images and PDFs. This led to a re-evaluation of the core design, aiming to maximize accuracy for diverse extraction tasks while maintaining performance efficiency.
A key architectural change implemented in the new Clairic models is the shift to parallel slot autoregressive generation for ordinary text and number extraction fields. Instead of a single forward pass, each field generates its tokens autoregressively, leveraging previously written tokens to determine the next one, and stopping at its unique end marker. All fields process concurrently within the serving batch, which is crucial for achieving fast per-request latency. This method significantly improved extraction accuracy across text and images, with the accuracy gains justifying a minor increase in latency.
Architectural Trade-offs
The decision to move to parallel slot autoregressive generation illustrates a common system design trade-off: optimizing for accuracy often comes with a performance cost. The key is to ensure the accuracy boost provides sufficient value to offset any latency increase, as Cloudflare found with Clairic.
To handle more complex extraction, computation, and estimation tasks (such as forecasts, durations, calculated dates, and arithmetic), the Clairic models were trained with specialized heads. This modular approach allows the model to efficiently process distinct types of information, demonstrating how a single model can be extended with specialized components to handle varied data requirements without compromising the core architecture's efficiency for simpler tasks.
| Eval Set | Clairic p50 / p95 | Clairic-flash p50 / p95 |
|---|
The table above, though missing data, in the original article demonstrates the latency characteristics. Clairic-flash, a lighter 9-billion-parameter model, consistently shows lower latencies (e.g., 155/328 ms for fresh text fields) compared to the 27-billion-parameter Clairic (e.g., 358/736 ms). This highlights the importance of model size and optimization for performance-critical AI deployments, where even small latency differences can impact user experience and cost.
Open-weight Strategy and API Consistency
Cloudflare's decision to release Clairic and Clairic-flash as open-weight models, hosted on Workers AI and Hugging Face, promotes community experimentation and development. Critically, despite the architectural redesign, the models maintain the original typed API interface, including confidence scores, character spans, and probabilities. This commitment to API consistency is vital for developers, ensuring backwards compatibility and minimizing integration effort for users adopting the updated models.