N-gram Injection into Transformers for Dynamic Language Model Adaptation in Handwritten Text Recognition

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Meyer, Florent, Guichard, Laurent, Soullard, Yann, Coquenet, Denis, Gravier, Guillaume, Coüasnon, Bertrand
Formato: Preprint
Publicado: 2026
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866915848374976512
author Meyer, Florent
Guichard, Laurent
Soullard, Yann
Coquenet, Denis
Gravier, Guillaume
Coüasnon, Bertrand
author_facet Meyer, Florent
Guichard, Laurent
Soullard, Yann
Coquenet, Denis
Gravier, Guillaume
Coüasnon, Bertrand
contents Transformer-based encoder-decoder networks have recently achieved impressive results in handwritten text recognition, partly thanks to their auto-regressive decoder which implicitly learns a language model. However, such networks suffer from a large performance drop when evaluated on a target corpus whose language distribution is shifted from the source text seen during training. To retain recognition accuracy despite this language shift, we propose an external n-gram injection (NGI) for dynamic adaptation of the network's language modeling at inference time. Our method allows switching to an n-gram language model estimated on a corpus close to the target distribution, therefore mitigating bias without any extra training on target image-text pairs. We opt for an early injection of the n-gram into the transformer decoder so that the network learns to fully leverage text-only data at the low additional cost of n-gram inference. Experiments on three handwritten datasets demonstrate that the proposed NGI significantly reduces the performance gap between source and target corpora.
format Preprint
id arxiv_https___arxiv_org_abs_2603_03930
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle N-gram Injection into Transformers for Dynamic Language Model Adaptation in Handwritten Text Recognition
Meyer, Florent
Guichard, Laurent
Soullard, Yann
Coquenet, Denis
Gravier, Guillaume
Coüasnon, Bertrand
Computer Vision and Pattern Recognition
Transformer-based encoder-decoder networks have recently achieved impressive results in handwritten text recognition, partly thanks to their auto-regressive decoder which implicitly learns a language model. However, such networks suffer from a large performance drop when evaluated on a target corpus whose language distribution is shifted from the source text seen during training. To retain recognition accuracy despite this language shift, we propose an external n-gram injection (NGI) for dynamic adaptation of the network's language modeling at inference time. Our method allows switching to an n-gram language model estimated on a corpus close to the target distribution, therefore mitigating bias without any extra training on target image-text pairs. We opt for an early injection of the n-gram into the transformer decoder so that the network learns to fully leverage text-only data at the low additional cost of n-gram inference. Experiments on three handwritten datasets demonstrate that the proposed NGI significantly reduces the performance gap between source and target corpora.
title N-gram Injection into Transformers for Dynamic Language Model Adaptation in Handwritten Text Recognition
topic Computer Vision and Pattern Recognition
url https://arxiv.org/abs/2603.03930