Model reference · open weights

khmer-text-recognition

Available as managed deployment LLMs Darayut · community Image→text 1 variants 2k dl/mo

khmer-text-recognition is an open-weight language model from Darayut. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.

Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.

What it is

Released byDarayut
TypeLanguage models
TaskImage→text
Parameters (lead)18M
Runs withtransformers
Released2026-01-14
Popularity2k downloads / month
LicenceOpen weights

About

What khmer-text-recognition is

Introduction

This repository contains the implementation, datasets, and evaluation results for the Squeeze-and-Excitation Transformer Network, a high-performance Khmer Text Recognition model that utilizes a hybrid architecture combining Squeeze-and-Excitation blocks for feature extraction and BiLSTM smoothing for context smoothing, specifically designed to handle the complexity and length of Khmer script.

Overview

Khmer script presents unique challenges for OCR due to its large character set, complex sub-consonant stacking, and variable text line lengths. This project employs an enhanced pipeline that:

Read the full model card
  1. Chunks long text lines into manageable overlapping segments.
  2. Extracts Features using a Squeeze-and-Excitation Network (SE-VGG) that preserves horizontal spatial information.
  3. Encodes local spatial features using a Transformer Encoder.
  4. Merges the encoded chunks into a unified sequence.
  5. Smooths Context using a BiLSTM layer to resolve boundary discontinuities between chunks.
  6. Decodes the final sequence using a Transformer Decoder.

Datasets

The model was trained entirely on synthetic data and evaluated on real-world datasets.

Training Data (Synthetic)

We generated 200,000 synthetic images to ensure robustness against font variations and background noise.

Dataset TypeCountGenerator / SourceAugmentations
Document Text100,000Pillow + Khmer CorpusErosion, noise, thinning/thickening, perspective distortion.
Scene Text100,000SynthTIGER + Stanford BGRotation, blur, noise, realistic backgrounds.

Evaluation Data (Real-World + Synthetic)

DatasetTypeSizeDescription
KHOBReal325Standard benchmark, clean backgrounds but compression artifacts.
Legal DocumentsReal227High variation in degradation, illumination, and distortion.
Printed WordsSynthetic1,000Short, isolated words in 10 different fonts.

Methodology & Architecture

1. Preprocessing: Chunking & Merging

To handle variable-length text lines without aggressive resizing, we employ a "Chunk-and-Merge" strategy:

  • Resize: Input images are resized to a fixed height of 48 pixels while maintaining aspect ratio.
  • Chunking: The image is split into overlapping chunks (Size: 48x100 px, Overlap: 16 px).
  • Independent Encoding: Each chunk is processed independently by the CNN and Transformer Encoder to allow for parallel batch processing.

2. Model Architecture: Squeeze-and-Excitation Transformer Network

Our proposed architecture integrates sequence-aware attention and recurrent smoothing to overcome the limitations of standard chunk-based OCR. The model consists of six key modules:

  1. Squeeze-and-Excitation Network (SE-VGG):

    • A modified VGG backbone with 1D Squeeze-and-Excitation blocks after convolutional layer 3, 4, and 5.
    • Unlike standard SE, these blocks use vertical pooling to refine feature channels while strictly preserving the horizontal width (sequence information).
  2. Patch Module:

    • Projects spatial features into a condensed 384-dimensional embedding space.
    • Adds local positional encodings to preserve spatial order within chunks.
  3. Transformer Encoder:

    • Captures contextual relationships among visual tokens within each independent chunk.
  4. Merging Module:

    • Concatenates the encoded features from all chunks into a single unified sequence.
    • Adds Global Positional Embeddings to define the absolute position of tokens across the entire text line.
  5. BiLSTM Context Smoother:

    • A Bidirectional LSTM layer that processes the merged sequence.
    • Purpose: Bridges the "context gap" between independent chunks by smoothing boundary discontinuities, ensuring a seamless flow of information across the text line.
  6. Transformer Decoder:

    • Generates the final Khmer character sequence using the globally smoothed context.

Training Configuration

  • Epochs: 100
  • Optimizer: Adam
  • Loss Function: Cross-Entropy Loss
  • Learning Rate Schedule: Staged Cyclic
    • Epoch 0-15: Fixed 1e-4 (Rapid convergence)
    • Epoch 16-30: Cyclic 1e-4 to 1e-5 (Stability)
    • Epoch 31-100: Cyclic 1e-5 to 1e-6 (Fine-tuning)
  • Sampling: 50,000 images randomly sampled/augmented per epoch.

Quantitative Analysis

We benchmarked our proposed model against VGG-Transformer, ResNet-Transformer, and Tesseract-OCR.

Character Error Rate (CER %) - Lower is better

TABLE 1: Character Error Rate (CER in %) results on the KHOB, Legal Documents, and Printed Word

ModelKHOBLegal DocumentsPrinted Word
Tesseract-OCR6.2424.308.02
VGG-Transformer2.2710.273.61
ResNet-Transformer2.9811.572.80
Proposed Model1.879.132.46

Qualitative Analysis

TABLE 2: Failure cases on KHOB, Legal Documents, and Printed Word

TABLE 3: Example of our proposed model against all baseline compared with the ground truth. Errors in the predictions are highlighted in red.

Key Findings:

  • The Proposed Model achieves the highest accuracy on long, continuous text lines (KHOB), demonstrating that the BiLSTM Context Smoother effectively resolves the chunk boundary discontinuities that limit standard Transformer baselines.
  • On degraded and complex legal documents, the proposed model demonstrates superior robustness, significantly outperforming all baselines. This attributes to the Squeeze-and-Excitation blocks, which filter background noise while preserving character-specific features.
  • The Proposed Model still retains a slight advantage on short, isolated words even where global context is less critical,

From the published model card. Full card on the HuggingFace links in the sidebar.

How it works

How language models work

Your prompttext / messagesTransformerattention over tokensNext-token loopgenerate + streamResponsetext · tool callsA language model reads your tokens and predicts the next one, again and again, streaming the reply back.

Using it via the API

Call it like any OpenAI endpoint

Once AxForge deploys khmer-text-recognition for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (khmer-text-recognition below is illustrative; you get the exact model name on deployment.)

$ curl -sS https://api.axforge.ai/v1/chat/completions \
  -H "Authorization: Bearer $AXFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"khmer-text-recognition","messages":[{"role":"user","content":"Hello"}]}'

Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms