What is LangChain to Anthropic’s Native LLM
LangChain to Anthropic’s Native refers to the shift from building AI applications with general-purpose orchestration frameworks like LangChain to using Anthropic’s native tools, APIs, and built-in capabilities directly. As Anthropic continues to expand its platform with features such as tool use, structured outputs, prompt caching, and agent capabilities, many developers are re-evaluating whether an external framework is still necessary for their use cases.
How LangChain to Anthropic’s Native LLM is Powerful in Summary-Level Extraction
Our Summary-Level Extraction (SLE) module of the SLR (Systematic Literature Review) platform processes complex clinical research PDFs to extract structured data with visual traceability. When users reported inconsistent traceability and extraction quality, we investigated our LangChain-based architecture and found fundamental limitations with our OCR dependency. This blog describes our migration to Anthropic’s native library, which eliminated external OCR services, reduced latency by 50.7%, and increased accuracy from 86% to 95.6%.
The Clinical Data Extraction Challenge
Challenges in Clinical Data Extraction
Clinical research documents contain critical data across multiple modalities: prose descriptions, statistical tables, participant demographics, and safety metrics. Our SLE module should extract this information with two key capabilities:
- Structured extraction: Converts unstructured PDFs into validated JSON schemas
- Visual traceability: Highlights the exact source location of each extracted value within the original PDF
This traceability is essential for regulatory compliance and validation workflows, where clinical data specialists verify that automated extractions match source documents.
The Bottlenecks
Users reported two critical issues during validation:
Case 1: Missing traceability for table data
Demographic information, such as age and sex, is extracted correctly, but without corresponding PDF highlights.
Case 2: Text extraction without visual mapping
The sentences are identified accurately, but the highlights failed to render in the PDF viewer.
These inconsistencies undermined trust in the system and forced manual re-validation, negating efficiency gains.
Architecture Analysis: Why OCR Was Not Working
Our initial architecture relied on a multi-stage pipeline:

Original LangChain + Textract Architecture
Root Cause Analysis
Investigation revealed multiple OCR-related failure modes:
- Text Quality Issues
- Missing spaces between words (“meanvalue” vs “mean value”)
- Lost special characters (±, μ, %, superscripts)
- Incorrect table column alignment in multi-column layouts
- Structural Degradation
- Table cells are merged or split incorrectly
- The reading order is jumbled in complex layouts
- Reference citations detached from context
- Image Blindness
- No extraction from embedded charts or figures
- Loss of visual data representations
- Inability to process image-based tables
These issues cascaded through the pipeline: poor quality of OCR text → inaccurate LLM context → failed traceability mapping.
Alternative OCR Evaluation
We assessed three OCR solutions against our requirements:
AWS Textract (Tables)$10-15Existing integrationSpace merging, symbol loss, poor multi-column handlingMistral OCR (Tables)~$1Low latency, markdown outputBroken LaTeX syntax, complex deployment, structural integrity lossAzure Document Intelligence~$10Stable output, better symbolsMinor hyphenation issues still require preprocessing
AWS Textract (Tables)$10-15Existing integrationSpace merging, symbol loss, poor multi-column handlingMistral OCR (Tables)~$1Low latency, markdown outputBroken LaTeX syntax, complex deployment, structural integrity lossAzure Document Intelligence~$10Stable output, better symbolsMinor hyphenation issues still require preprocessing
| Service | Cost (per 1K pages) | Strengths | Critical Issues |
|---|---|---|---|
| AWS Textract (Tables) | $10-15 | Existing integration | Space merging, symbol loss, poor multi-column handling |
| Mistral OCR (Tables) | ~$1 | Low latency, markdown output | Broken LaTeX syntax, complex deployment, structural integrity loss |
| Azure Document Intelligence | ~$10 | Stable output, better symbols | Minor hyphenation issues still require preprocessing |
While Azure showed improvements, testing showed a fundamental insight: What if we bypassed OCR entirely? Modern vision-capable LLMs like Claude Sonnet can process PDF bytes directly. This realization initiated our architectural pivot.
LangChain to Anthropic’s Native LLM – The New Architecture: Direct PDF Inference
We redesigned SLE around Anthropic’s native library, eliminating the OCR preprocessing stage.
New Pipeline Design
┌────────────────────────┐
│ PDF Input (Base64) │
└────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Anthropic Native API │
│ (Sonnet 3.7 + Extended Thinking) │
└────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Enhanced Traceability Engine │
│ (Coordinate Mapping Logic) │
└────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Multi-threaded Execution │
│ (Parallel Document Processing) │
└────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Validated JSON + PDF Highlights │
└─────────────────────────────────────┘
Anthropic Native Architecture – Important Changes
1. Direct PDF Understanding
Instead of using Textract to extract text and pass it to the LLM, we now transform PDFs into Base64 format and send them directly to the Anthropic API. This model views the document as a visual and understands layout, tables, and text all in one go.
This eliminates three layers of potential failure:
- OCR text extraction errors
- Text parsing and cleaning logic
- Coordination between text chunks and original PDF coordinates
2. Extended Thinking Mode
We activated Claude’s extended thinking capability, which allows the model to perform internal chain-of-thought reasoning before generating the final extraction. This proves particularly valuable for:
- Disambiguating table data where column headers span multiple rows
- Cross-referencing values mentioned in text with tabular summaries
- Resolving inconsistencies between different sections of the document
The thinking process is transparent and can be reviewed during validation to help data teams understand how the model arrived at specific extractions.
3. Prompt Engineering for Native Format
We restructured our prompts to align with Anthropic’s best practices, focusing on:
- Clear specification of the required output structure
- Explicit instructions for traceability sentence extraction
- Prioritization of precision over completeness to reduce false positives
- Guidance on handling ambiguous cases (flag rather than guess)
The new prompt format emphasizes exact value matching and verbatim sentence extraction, which proved critical for regulatory compliance requirements.
4. Improved Traceability Logic
We rebuilt the coordinate mapping system to work with Anthropic’s response format. The new engine uses fuzzy matching with position-aware scoring to locate extracted sentences within the PDF, even when there are minor variations in spacing or line breaks.
The system now handles:
- Multi-line sentences that wrap across pages
- Table cells containing the extracted value
- Text within complex multi-column layouts
- Sentences that appear multiple times in the document
Implementation Deep Dive
Challenge 1: Managing Token Consumption
Direct PDF processing consumes significantly more tokens than preprocessed text. For a typical 30-page clinical trial PDF:
- Old approach: ~15K tokens (Textract text only)
- New approach: ~45K tokens (full PDF context)
To manage this, we implemented intelligent chunking for documents exceeding context limits. The system detects logical sections such as Methods, Results, and Discussion and creates chunks that preserve complete semantic units while respecting token budgets. Each chunk includes overlapping context from adjacent sections to maintain continuity.
Challenge 2: Preserving Table Structure
Clinical PDFs contain complex nested tables with merged cells, multi-row headers, and footnotes. We improved our prompts to specifically address table awareness:
The model now identifies table structures explicitly, preserves relationships between values, notes merged cells or nested structures, and references tables by their captions when available. This structured approach to table extraction greatly improved accuracy for tabular data.
Challenge 3: Parallel Processing
To maintain throughput despite higher per-document latency, we used multi-threaded execution. The system processes multiple PDFs concurrently with intelligent rate limiting to respect API constraints while maximizing utilization.
The parallel setup includes:
- Thread pool management with configurable worker counts
- Retry logic with exponential backoff for temporary failures
- Error isolation to prevent cascading failures
- Progress tracking and logging for better operational visibility
Challenge 4: Traceability Coordinate Mapping
The most technically challenging aspect was mapping extracted sentences back to precise PDF coordinates. The new system employs a multi-stage approach:
- Fuzzy text matching to find the extracted sentence in the PDF text layer
- Position-aware scoring that considers page numbers and approximate locations
- Bounding box calculation to determine exact highlight coordinates
- Validation to ensure highlights align with visible text
This approach handles edge cases like hyphenated words, ligatures, and text reflow while maintaining high precision.
Results and Validation
Accuracy Improvements
We tested the new SLE module on manually validated dermatology clinical trials for Tretinoin efficacy studies from our SME data team.
| Metric | New SLE (No Thinking) | New SLE (With Thinking) | Improvement |
|---|---|---|---|
| Completeness | 89.47% | 100.0% | +10.53% |
| Relevancy | 82.67% | 81.41% | -1.26% |
| Sentence Accuracy | 95.89% | 96.75% | +.14% |
| OCR Handling | 100.0% | 100.0% | 0% |
| Order Preservation | 100.0% | 100.0% | 0% |
Key Findings:
- Thinking mode provided a 2% boost over non-thinking, primarily in completeness
- OCR handling reached 100%, completely removing text quality issues
- Sentence accuracy improved slightly, but significantly reduced false extractions
- Order preservation reached perfect scores by using visual document understanding
Latency and Cost Trade-offs
Performance Benchmarks (7 documents, dermatology domain)
| Metric | Old SLE | New SLE | Improvement |
|---|---|---|---|
| Total Latency | 1,678.71s | 828.04s | -50.7% |
| Average Latency | 239.78s | 118.29s | 50.7% |
| Min Latency | 214.05s | 55.90s | -73.9% |
| Max Latency | 261.31s | 381.66s | +46.1% |
| Total Cost | 1$3.98 | $6.55 | +64.6% |
| Average Cost | $0.57 | $0.94 | +64.9% |
Analysis:
- Median latency improved significantly (50-74% reduction) by removing OCR preprocessing
- Maximum latency increased for complex documents that utilize extended thinking extensively
- Cost per document rose by ~65% due to higher token usage from full PDF processing
- Cost-performance ratio: 50% faster processing for 65% more cost represents a favorable trade-off given the accuracy improvements and simplified architecture
The latency reduction came from eliminating the Textract API call and subsequent text parsing, which accounted for 40-60% of total processing time in the old architecture.
Extended Validation Results
After initial success, our data team validated additional articles across multiple therapeutic areas:
| Metric | Accuracy | Traceability |
|---|---|---|
| Completeness | 73.62% | 83.79% |
| Relevancy | 86.99% | 89.96% |
| Sentence Accuracy | 97.86% | 97.84% |
| OCR Handling | 99.57% | 99.57% |
| Order Preservation | 97.44% | 99.57% |
| Average | 91.1% | 94.1% |
Observations:
- Traceability exceeded accuracy (94.1% vs 91.1%), validating our architectural focus on this capability.
- OCR handling stayed near-perfect (99.57%) across various document types and therapeutic areas.
- Lower completeness (73.62%) in broader validation suggests opportunities for domain-specific prompt tuning.
- Sentence accuracy remained consistently high (97.86%), demonstrating strong generalization.
LangChain to Anthropic’s Native – Lessons Learned
What Worked Well
- Eliminating preprocessing complexity
Removing the Textract → parsing → cleaning pipeline eliminated multiple failure points and simplified our codebase by ~40%. - Model-native capabilities
Claude’s vision understanding proved superior to OCR + text-based reasoning, particularly for:
- Complex table structures with merged cells and multi-level headers
- Documents with mixed fonts, sizes, and scientific notation
- Special characters (±, μ, %, superscripts) that Textract frequently corrupted
- Layout understanding in multi-column formats
- Extended thinking for ambiguous cases
For documents with unclear table references or cross-sectional data, thinking mode visibly improved extraction quality. - Operational simplicity
Moving from three services (Textract, LangChain, Bedrock) to one (Anthropic API) made monitoring, debugging, and deployment much easier.
Conclusion
Migrating our Summary-Level Extraction module from LangChain + AWS Textract to Anthropic’s native library delivered measurable improvements across all key metrics:
- Accuracy: Exceeded the benchmark >90%
- Latency: Improved by ~50-74%
- Traceability: 94% reliability in production
- OCR quality: Near-perfect (99.57%)
- Code complexity: -40% reduction
While costs per document rose approximately 65%, the combination of faster processing, removal of OCR errors, simplified architecture, and improved user trust justified the investment. More importantly, this architecture positions our SLR application to leverage future multimodal capabilities without reengineering our pipeline.
For teams building document intelligence systems, our key takeaway is: evaluate whether your LLM can fully replace your preprocessing stack. The cost of external OCR, parsing libraries, and text cleaning often exceeds the token cost of direct PDF inference while simultaneously introducing fragility and maintenance burden.
The architectural shift taught us valuable lessons about cloud service dependencies. By consolidating to a single LLM provider with native document understanding, we simplified operations, improved debugging, and gained access to rapid upgrades as the models advance.
Author’s Note: This article was supported by AI-based research and writing, with Claude 4.5 assisting in the creation of text and images.
Why did the team migrate their clinical data extraction workflow from LangChain to Anthropic’s native library?
The team needed to address significant inconsistencies in data traceability and extraction quality. The previous architecture relied on OCR (AWS Textract), which often struggled with complex document layouts and scientific symbols. Moving to a native Anthropic LLM-based architecture eliminated external OCR dependencies, resulting in a 9.6% increase in overall accuracy and reducing code complexity by approximately 40%.
What were the main limitations of using OCR tools like AWS Textract for clinical research documents?
Standard OCR tools often failed to process the unique structure of clinical research PDFs. Common issues included missing special scientific characters (like ±, μ, %), incorrect alignment of multi-column layouts, and an inability to interpret embedded charts or figures. These OCR errors cascaded through the pipeline, leading to poor context for the LLM and failed traceability mapping.
How does direct PDF inference improve clinical data extraction accuracy?
By bypassing OCR and sending PDFs directly to the model in Base64 format, the system gains “vision” capabilities. The LLM can view the document as a human would, understanding the layout, tables, and text simultaneously. This native approach eliminates three major points of failure: OCR text errors, manual parsing logic, and the difficulty of coordinating text chunks with original PDF coordinates.
How does the new architecture ensure visual traceability for extracted clinical data?
The new system utilizes an enhanced “Traceability Engine” that uses fuzzy text matching and position-aware scoring. Even when there are minor variations in spacing or line breaks, the engine can locate the exact sentence in the PDF layer, calculate the precise bounding box coordinates, and map the highlight back to the source document. This ensures that clinical data specialists can verify automated extractions against the source with 94% reliability.
Did migrating to a native LLM-based architecture improve processing speed for complex PDFs?
Yes, significantly. By removing the time-intensive OCR preprocessing step, the team achieved a 50.7% reduction in total latency. While complex documents requiring “Extended Thinking” can take slightly longer, the median processing time improved drastically, making the system much more efficient for high-volume clinical workflows.
What are the cost and performance trade-offs of switching to direct PDF processing?
While the new architecture is approximately 50-74% faster, the cost per document increased by roughly 65%. This is primarily due to higher token consumption associated with processing the full PDF context rather than just text chunks. However, the team considers this a favorable trade-off because it delivers near-perfect OCR handling (99.57%) and drastically reduces the need for manual re-validation.
What role does Anthropic’s "Extended Thinking" mode play in processing clinical research data?
Anthropic’s “Extended Thinking” mode allows the model to perform internal chain-of-thought reasoning before generating an output. This is crucial for resolving complex clinical data challenges, such as disambiguating table headers that span multiple rows or cross-referencing values between textual summaries and tabular data. This thinking process acts as a transparent audit trail that helps data teams understand exactly how the model arrived at a specific extraction.