BUCKYVERSE

LLM-Based OCR Error Detection

Welcome to the documentation for Codexis's LLM-based OCR error detection system. This system uses locally-hosted Large Language Models (LLMs) via Ollama to detect and correct OCR errors (scannos) in digitized manuscripts.

What is Scanno Detection?

"Scannos" are OCR (Optical Character Recognition) errors that occur during the digitization process. Common examples include:

Traditional pattern-matching approaches catch many errors, but LLMs excel at detecting context-dependent errors that rule-based systems miss.

System Overview

Our LLM-based scanno detection system:

Documentation Structure

  1. Overview - System architecture and prerequisites
  2. Ollama Client - Interface for interacting with local LLMs
  3. LaTeX Processor - Extracts and prepares content for analysis
  4. Scanno Detector - Core detection engine
  5. Specialized Detectors - Handles math, LaTeX commands, bibliography
  6. Pattern Filter - Pre-filtering with known error patterns
  7. Result Aggregator - Combines and validates corrections
  8. Human Review - Interactive review interface
  9. Build Integration - Pipeline integration and automation
  10. Configuration - System configuration options
  11. Testing - Testing strategies and examples
  12. Troubleshooting - Common issues and solutions
  13. Product Requirement Document - Product plan

Quick Start

Prerequisites

  1. Install Ollama:

    # macOS
    brew install ollama
    
    # Linux
    curl -fsSL https://ollama.ai/install.sh | sh
    
  2. Pull required models:

    ollama pull qwen3.0:8b
    ollama pull deepseek-r1:8b
    
  3. Add dependencies to mix.exs:

    defp deps do
      [
        {:req, "~> 0.5.0"},
        {:jason, "~> 1.4"},
        {:nimble_pool, "~> 1.0"},
        {:flow, "~> 1.2"}
      ]
    end
    

Basic Usage

# Check a manuscript for OCR errors
{:ok, result} = Codexis.BuildManager.ScannoIntegration.check_manuscript_for_scannos(
  "manuscript.tex",
  model: "qwen3.0:8b",
  interactive: true
)

IO.puts("Corrections applied: #{result.corrections_applied}")

CLI Usage

# Check a manuscript with interactive review
mix codexis.check_scannos manuscript.tex

# Use specific model
mix codexis.check_scannos manuscript.tex --model deepseek-r1:8b

# Non-interactive mode
mix codexis.check_scannos manuscript.tex --no-interactive

Key Features

1. Multi-Model Support

2. Parallel Processing

3. Pattern-Based Pre-filtering

4. Interactive Review

5. Build Pipeline Integration

Performance Considerations

  1. Model Selection: Balance accuracy vs. speed
  2. Parallel Processing: Adjust concurrency based on hardware
  3. Caching: Enable for repeated processing
  4. Batch Size: Optimize for your content type

Best Practices

  1. Start with default configuration
  2. Test on small documents first
  3. Adjust confidence thresholds based on results
  4. Use interactive review for critical documents
  5. Enable caching for better performance
  6. Monitor resource usage

Next Steps

Support

If you encounter issues:

  1. Check the Troubleshooting Guide
  2. Review Common Issues below
  3. Contact the development team

Common Issues

Contributing

To contribute to the scanno detection system:

  1. Read the architecture documentation
  2. Follow Elixir coding standards
  3. Add comprehensive tests
  4. Update documentation

License

This system is part of the Codexis project and is licensed under the same terms.