betaFeedback

WorksComputer Science

Generative Text Modelling and Language-Guided Visual Attention for Deciphering Palimpsests

Abstract

Recovering obscured text in palimpsests, i.e. the manuscripts where the original writing (under-text) was erased and overwritten for reuse, is vital for preserving lost information. Due to the nature of the material, such a task can be highly challenging and time-consuming. This paper presents an approach towards automated palimpsest handwritten text modeling for under-text recovery. We investigate generative models, including Generative Adversarial Networks (GANs) and diffusion models, and design a custom denoising diffusion model that learns structured noise patterns to reconstruct the under-text. The recovered text is subsequently processed by a fine-tuned, attention-based handwritten text recognition network. Furthermore, we investigate a language-guided recognition framework that leverages textual class descriptions as informative priors, enabling the text recognition model to distinguish meaningful features from noise. This is achieved by grounding task-specific descriptions, phrased in words or sentences, through visual attention maps generated by pretrained vision-language models like CLIP (Contrastive Language-Image Pre-training). To facilitate future research and benchmarking, we release new datasets for synthetic palimpsests (currently scarce), CLIP-compatible text descriptions, and pre-trained models with code.

Introduction

Palimpsests are historical manuscripts that contain a visible top layer of text and one or more hidden, erased layers beneath it. The original writings were scraped-off or overwritten to reuse the writing material (parchment). Restoring palimpsests and recovering the underlying handwriting is fundamentally an inverse problem, one that aims to reverse the processes of erasure and overwriting to reveal the lost text.

While multispectral and hyperspectral imaging can enhance contrast between inks and parchment, other factors such as spectral overlap, surface irregularities, and noise often obscure the faint signals of the under-text. Because these limitations constrain the effectiveness of imaging-based techniques, they have prompted exploration of data-driven approaches, such as deep learning. However, emerging deep learning approaches face their own limitations, due to the scarcity of annotated training data, poor generalisation across different manuscripts, and the risk of generating misleading reconstructions. The field remains significantly under-explored, and to the best of our knowledge, no existing method can reliably separate over-text from under-text across diverse manuscripts and perform accurate recognition. This gap highlights the need for standardised, reproducible workflows for manuscript restoration.

Recent advances in handwritten text recognition (HTR) have leveraged natural language processing (NLP) techniques to improve recognition accuracy ([17, 3]). Language models, textual priors, and semantic embeddings provide contextual information that helps disambiguate visually uncertain predictions, while vision-language frameworks enable grounding of textual descriptions in visual features. Integrating NLP with HTR transforms it into a multimodal problem, allowing models to distinguish relevant text from noise and better handle challenging scenarios such as palimpsests.

Our work builds on this line of research and examines the extent to which natural language guidance can improve the reconstruction and recognition of under-text in palimpsests using a deep learning framework. Our key contributions:

a) We examine how generative models, including Generative Adversarial Networks (GANs) and diffusion models, can enhance under-text extraction, and introduce a custom denoising diffusion model (cDDM) tailored to this problem.

  • b) We introduce a language-guided, attention-based recognition framework that leverages textual priors to guide HTR.

  • c) We explore a new distillation paradigm that transfers knowledge via guided attention and integrates CLIP-based vision-language grounding to align semantic text descriptions with visual features, enabling the model to distinguish handwriting from noise.

  • d) The proposed approach is model-agnostic and broadly transferable to any HTR framework that exposes intermediate activation maps and utilises a standard classification loss.

  • e) To address the scarcity of training data, we create and release synthetic palimpsest datasets, CLIP-compatible text descriptions, and pretrained models, providing resources for future research and benchmarking.

The source code for our implementation is publicly available at https://github.com/UU-VLL/GTM-LGHTR-Palimpsest. The dataset is available at https://doi.org/10.5281/zenodo.21902987.

Related Work

When it comes to palimpsest restoration, traditional approaches, such as colour space transformation Tonazzini [31], and statistical methods, such as Principal Component Analysis and Independent Component Analysis on multi-spectral imaging [25, 7], have long been the leading techniques for text extraction and layer separation. Recently, deep learning models, including Convolutional Neural Networks Perino et al. [22], generative inpainting Jampour et al. [14], latent diffusion models Jampour [13], and the increasingly popular GANs [30, 18], have begun to play a more important role in this field. In particular, Madi et al. [18] compared several GAN models and showed that their proposed models, Palimpsest Manuscripts Reconstruction (PMR)-GAN, and Pix2pix (also a GAN model), are among the top-performing approaches in restoration. Given the difficulty of obtaining ground truth images for training palimpsest restoration models, all the aforementioned deep learning methods generated synthetic data using various techniques.

Meanwhile, despite the general consensus that diffusion models may achieve better results than GANs in other fields [6, 20], there have been relatively few investigations of their application in palimpsest restoration. Latent diffusion models were investigated by Jampour [13], who also introduced the Synthetic Georgian Palimpsest datasets [14]. However, their evaluation was limited to only a few palimpsests, leaving it unclear how well the method generalises across diverse datasets.

Palimpsest (under-text) recognition remains an under-explored area, with the earliest studies emerging as late as 2017 [29], focusing primarily on character-level Optical Character Recognition (OCR). Subsequent works have also employed OCR/HTR accuracy as an indirect measure of restoration quality [30, 18]. To the best of our knowledge, no known studies have attempted word-level under-text HTR that generalises across diverse manuscripts, and existing approaches remain confined to specific manuscript types.

Because annotated palimpsest data are scarce, current studies rely on synthetic datasets that closely imitate real manuscripts. This approach enables supervised training and quantitative evaluation of text separation models. Synthetic generation also allows controlled creation of target masks for text separation and labels for recognition.

With the emergence of the CLIP model in vision-language tasks [24], its potential for vision-language alignment [23] has yet to receive substantial attention from researchers working on HTR and palimpsest recognition. Existing studies in Scene Text Recognition have demonstrated the latent OCR capabilities of CLIP, for example through the incorporation of CLIP-based cross-modal alignment plugins with existing detection heads (Yu et al., 2023) and the integration of CLIP encoders with multi-branch decoders (Zhao et al., 2024a). Other research exploring CLIP in OCR tasks has investigated innovative alignment and distillation techniques [35] as well as integration with large language models (Zhao et al., 2024b).

In this work, CLIP is employed as a guidance model whose text-conditioned activation maps, obtained via gradient-weighted attention rollout [2], are used to supervise the Grad-CAM Selvaraju et al., [26] attention of the HTR model (in our case the attention-based HTR model Kass and Vats, [16]), aiming to enhance modality alignment. This work also evaluates the Pix2pix GAN model, and designs a custom diffusion model for under-text retrieval and restoration tasks. Model generalisation and reproducibility are of critical importance; therefore, we conduct a comprehensive evaluation across three datasets: Synthetic MNIST, Synthetic Saint Gall, and Synthetic Georgian Palimpsest. One of the few well-known real palimpsest datasets is the Archimedes dataset Toth and Emery, [32]. However, while some under-text is visible, it lacks paired samples of overlapping and clean under-text, making it unsuitable for training our generative models.

It is important to note that no sample selection is performed in this work and the evaluations are conducted across the predefined data splits in accordance with the dataset guidelines and evaluation metrics. We believe this will greatly help facilitate future research and benchmarking.

Methodology

Our primary objective is to recognise the under-text from a synthetic palimpsest. This can be approached in two ways: directly perform HTR on the partially visible under-text, or first carry out text layer separation to reconstruct the under-text image, then perform HTR on the reconstructed image. Experiments are conducted on both methods, with the results presented later in § 4.3. In this section we first introduce our text separation techniques, followed by the HTR methods.

A palimpsest image xx can be viewed approximately as a superposition of the over-text xoverx_{\mathrm{over}}, the under-text xunderx_{\mathrm{under}} and the background writing support xbgx_{\mathrm{bg}}. The text separation stage (§ 3.1) in our pipeline aims to leverage generative models to extract signals from the under-text as an image, and the recognition stage (§ 3.2) uses an HTR model to identify the text from such images with the guidance of the CLIP model. The overall architecture of the integrated pipeline is shown in Figure 1. The following subsections describe the text separation and HTR models.

Architecture of the proposed framework

Figure 1. Architecture of our proposed framework, consisting of two main stages: (i) Under-text separation, where a trained generative model is used to recover the target under-text from the palimpsest. (ii) Language-guided HTR, where an HTR model is trained using a standard CE loss between the predicted text and the ground truth. To enhance recognition, we introduce a language-guided supervision strategy, which aligns the HTR model’s Grad-CAM visual feature maps with text-image alignments derived from CLIP via an activation loss. The example palimpsest image originates from the Synthetic Saint Gall dataset, and the example under-text image is a reconstructed image using cDDM2.

Palimpsest Text Separation

The text separation process can be expressed as training a model that takes the palimpsest image xx as input, and reconstructs the under-text xunderx_{\mathrm{under}}. In the subsequent section we will denote the ground truth under-text xunderx_{\mathrm{under}} as the training target yy, and introduce the two text separation models implemented in this work.

Pix2pix

Pix2pix is a conditional GAN with skip connections, demonstrating state-of-the-art performance in text separation for palimpsests on synthetic data Madi et al., [18]. The architecture is well-suited for image-to-image translation, enabling the separation of under-text, over-text, and background. Traditional methods often fail in overlapping regions Starynska, [28], whereas Pix2pix preserves structural integrity through its U-Net generator and adversarial training, yielding higher-quality under-text reconstruction. The adversarial loss further enforces realism in the generated outputs Isola et al., [12], allowing conditional GANs to model inter-pixel dependencies absent in standard GANs.

Conditional GANs such as Pix2pix learn to map an input image xx to a target image y^\hat{y} through two competing networks: a generator GG and a discriminator DD. GG aims to produce y^\hat{y} indistinguishable from the target real image yy, while DD learns to differentiate between them. Their adversarial interplay leads both networks toward optimality.

Pix2pix employs a U-Net generator, an encoder-decoder architecture that first downsamples the input feature xx and then reconstructs through up-sampling. The forward pass can be expressed as

x→GEnc1f1→⋯→GEncnfn→GDec1fn+1→⋯→GDecny^(1)x \xrightarrow{G_{\mathrm{Enc}_1}} f_1 \xrightarrow{\cdots} \xrightarrow{G_{\mathrm{Enc}_n}} f_n \xrightarrow{G_{\mathrm{Dec}_1}} f_{n+1} \xrightarrow{\cdots} \xrightarrow{G_{\mathrm{Dec}_n}} \hat{y} \tag*{(1)}

where fnf_n denotes the bottleneck feature representation, GEnciG_{\mathrm{Enc}_i} and GDecjG_{\mathrm{Dec}_j} represent the iith encoder and the jjth decoder in the U-Net.

The discriminator DD is implemented as a Patch-GAN, dividing each image into local patches and predicting a real/fake probability per patch:

(x,y^)→DConv1f1→⋯→DConvn{pifake}i=1N,(2)(x,\hat{y}) \xrightarrow{D_{\mathrm{Conv}_1}} f_1 \xrightarrow{\cdots} \xrightarrow{D_{\mathrm{Conv}_n}} \{p_i^{\mathrm{fake}}\}_{i=1}^{N}, \tag*{(2)}
(x,y)→DConv1f1→⋯→DConvn{pireal}i=1N,(x,y) \xrightarrow{D_{\mathrm{Conv}_1}} f_1 \xrightarrow{\cdots} \xrightarrow{D_{\mathrm{Conv}_n}} \{p_i^{\mathrm{real}}\}_{i=1}^{N},

where Conv1…nConv_{1\ldots n} stands for convolutional layers whose final output is a map of real-valued patch scores pip_i, and NN stands for the number of patches in each image. The least-squares objectives below are applied to the patch scores directly, i.e. the loss is the mean over the NN patches of the perpatch squared errors, 1N∑i=1N(pi−c)2\frac{1}{N}\sum_{i=1}^{N}(p_i-c)^2 with target c∈{0,1}c \in\{0,1\}.

To stabilise training, Pix2pix applies the Least Squares GAN (LSGAN) loss [19], which replaces the binary cross-entropy (CE) loss [9] with a least-square objective for stronger gradient feedback.

The generator loss combines adversarial and reconstruction terms:

LG=Ex[(D(x,G(x))−1)2]+λEx,y[∥y−G(x)∥1],(3)\mathcal{L}_G = \mathbb{E}_x\left[(D(x,G(x))-1)^2\right] +\lambda\mathbb{E}_{x,y}\left[\lVert y-G(x)\rVert_1\right], \tag*{(3)}

where λ=10\lambda=10 balances the realism and pixel-level accuracy; note that this is a smaller reconstruction weight than the λ=100\lambda=100 used by Isola et al. [12]. The discriminator loss is defined as

LD=12Ex,y[(D(x,y)−1)2]+12Ex[(D(x,G(x)))2].(4)\mathcal{L}_D = \frac{1}{2}\mathbb{E}_{x,y}\left[(D(x,y)-1)^2\right] +\frac{1}{2}\mathbb{E}_x\left[(D(x,G(x)))^2\right]. \tag*{(4)}

Through this loss, DD learns to output values close to 1 for real samples and close to 0 for generated ones, ensuring effective adversarial training.

cDDM

Historical palimpsests are highly diverse and contain degraded script where the unwanted components (e.g., over-text and complex background noises) are highly structured and do not follow a Gaussian distribution. Therefore, standard Denoising Diffusion Probabilistic Models (DDPM) [11], which rely on stochastic Gaussian noise mapping, may discard relevant information when applied to palimpsests. In this work, we propose a custom conditional Denoising Diffusion Model (cDDM). Instead of using randomly sampled noise, cDDM adapts the diffusion architecture to invert a fixed, structured residual and operates as a deterministic diffusion process. This framing aligns with the generalised diffusion literature (e.g., Cold Diffusion [1]), which demonstrates that the diffusion framework can successfully invert arbitrary, non-probabilistic image degradations without relying on Gaussian assumptions.

In traditional DDPMs, the Gaussian noise ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0,I) is added in each time step via

xt=αtxt−1+βtϵ,(5)x_t=\alpha_t x_{t-1}+\sqrt{\beta_t}\epsilon, \tag*{(5)}

where αt\alpha_t controls the signal retention, βt\sqrt{\beta_t} controls the noise scale, and t=1:Tt=1:T indexes the diffusion steps (with x0x_0 denoting the clean image).

To address the structured, non-Gaussian artifacts in our case, we replace stochastic sampling with a deterministic residual between the raw palimpsest input xx and the target under-text yy.

xt=αtx+(1−αt)y=y+αtϵ,ϵ=x−y,(6)x_t=\alpha_t x+(1-\alpha_t)y=y+\alpha_t\epsilon,\quad\epsilon=x-y, \tag*{(6)}

i.e. a convex combination of the palimpsest xx and the target yy, which keeps the target yy and the full structured residual ϵ\epsilon present in every latent xtx_t. Because βt\beta_t is clipped to [10−4,2×10−2][10^{-4},2\times10^{-2}] (see Eq. 8), the coefficient αt=1−βt∈[0.990,1.000]\alpha_t=\sqrt{1-\beta_t}\in[0.990,1.000] varies only mildly with tt: every xtx_t remains close to the palimpsest image xx, and the model is trained, at all noise levels, to regress the complete structured residual ϵ=x−y\epsilon=x-y from an input that is approximately xx. The time step therefore acts primarily as an auxiliary conditioning signal (via the time embedding) rather than as an interpolation between yy and xx; this differs from standard DDPMs, in which xTx_T is (almost) pure noise. In particular, xtx_t never degenerates to pure noise, so the structured, non-Gaussian residual is available to the network at every step. Input images are normalised to [−1,1][-1,1] to capture fine differences, e.g., between two black texts.

The residual is defined in the raw pixel space, where yy denotes the clean target under-text image that the model is trained to recover from the palimpsest images xx. At each step, the noise ϵ\epsilon is given by x−yx-y, which represents the unwanted components in xx, such as the background and over-text that are treated as noise.

The rate at which the noise scale varies is controlled via a cosine noise scheduler [21]. The cosine scheduler is defined as

αˉt=f(t)f(0),f(t)=cos⁡2(t/T+s1+s⋅π2),(7)\bar{\alpha}_t=\frac{f(t)}{f(0)},\quad f(t)=\cos^2\left(\frac{t/T+s}{1+s}\cdot\frac{\pi}{2}\right), \tag*{(7)}

where s=0.008s=0.008 is a small offset that prevents βt\beta_t from becoming too small near t=0t=0 [21], and per-step noise scales

βt=clip⁡(1−αˉtαˉt−1,10−4,2×10−2),αt=1−βt,(8)\beta_t=\operatorname{clip}\left(1-\frac{\bar{\alpha}_t}{\bar{\alpha}_{t-1}},10^{-4},2\times10^{-2}\right),\qquad \alpha_t=\sqrt{1-\beta_t}, \tag*{(8)}

where the clipping bounds, adopted from the linear-schedule DDPM convention, cap the per-step noise change; for the small TT used in cDDM1 they are active at almost every step, so αt\alpha_t is nearly constant (≈0.99\approx0.99).

Subsequent to the forward process that progressively adds noise, the reverse process is designed to remove noise and reconstruct the original data, through training a deep learning model to approximate the noise and ultimately learn to remove it from a latent variable xtx_t. To do so, a U-Net is employed to train on (xt,Embedding(t))(x_t, \mathit{Embedding}(t)), where time tt is embedded into a vector to condition the model on the time state. The network flow of the model can be expressed as follows:

(xt,Embedding(t))→E1f1→⋯→Enfn→D1fn+1→⋯→Dnϵ^,(9)\begin{aligned} (x_t,\mathit{Embedding}(t)) &\xrightarrow{E_1} f_1 \xrightarrow{\cdots} \xrightarrow{E_n} f_n \\ &\xrightarrow{D_1} f_{n+1} \xrightarrow{\cdots} \xrightarrow{D_n} \hat{\epsilon}, \tag*{(9)} \end{aligned}

where E1…nE_{1\ldots n} and D1…nD_{1\ldots n} are the encoders and decoders of the U-Net, and ϵ^\hat{\epsilon} is the predicted noise. The model is then trained on minimising the L1L_1 loss:

L=Ex,y,t[∥ϵ^−ϵ∥1].(10)\mathcal{L} = \mathbb{E}_{x,y,t}\left[\lVert\hat{\epsilon}-\epsilon\rVert_1\right]. \tag*{(10)}

Note that, unlike in standard DDPMs, ϵ=x−y\epsilon=x-y is fully determined by the training pair (x,y)(x,y), so the expectation is taken over the data and the time step only. At each training iteration, tt is randomly sampled from a discrete uniform distribution: t∼Uniform⁡{1,…,T}t\sim\operatorname{Uniform}\{1,\ldots,T\} (the implementation uses the equivalent 0-based indices t−1∈{0,…,T−1}t-1\in\{0,\ldots,T-1\}).

In the inference stage, the trained U-Net f(⋅,⋅)f(\cdot,\cdot) is used to recover previously unseen under-texts directly from the palimpsest image xx, which is treated as the maximally noisy variable xTx_T, without access to yy. In this work we design two denoising methods, cDDM1 and cDDM2. In cDDM1, starting from xT=xx_T=x, the model re-estimates the noise from the current iterate at every step and removes it deterministically according to:

ϵ^t←f(xt,t),\hat{\epsilon}_t \leftarrow f(x_t,t),
xt−1←xt−βt⋅ϵ^tαt(t=T,…,2),x_{t-1} \leftarrow\frac{x_t-\sqrt{\beta_t}\cdot\hat{\epsilon}_t}{\alpha_t}\qquad(t=T,\ldots,2),
y^←x1−ϵ^1,(11)\hat{y}\leftarrow x_1-\hat{\epsilon}_1, \tag*{(11)}

i.e. the deterministic inversion of the standard per-step update (Eq. (5)) with βt=1−αt2\sqrt{\beta_t}=\sqrt{1-\alpha_t^2}, applied with the noise re-estimated from the current iterate, and with the predicted noise removed directly in the final step. Note that this reverse recursion is not the exact algebraic inverse of the forward construction in Eq. (6); because ϵ^\hat{\epsilon} is re-predicted from xtx_t at every step, the procedure acts as an iterative residual-removal scheme whose per-step magnitude follows the forward cosine schedule.

cDDM2 performs a single-step reverse process, predicting and directly removing noise in xTx_T. To improve denoising, a mask sets regions with high predicted noise to white, heuristically targeting over-text that is otherwise difficult to remove. process is:

ϵ^T←f(xT,T),y^=xT−ϵ^T,mi,j=I[mean⁡c(∣ϵ^T(i,j,c)∣)>δ],y^i,j=mi,j+(1−mi,j)⋅y^i,j,(12)\hat{\epsilon}_T \leftarrow f(x_T,T), \\ \hat{y}=x_T-\hat{\epsilon}_T, \\ m_{i,j}=\mathbb{I}\left[\operatorname{mean}_{c}\left(\left|\hat{\epsilon}_T(i,j,c)\right|\right)>\delta\right], \\ \hat{y}_{i,j}=m_{i,j}+(1-m_{i,j})\cdot\hat{y}_{i,j}, \tag*{(12)}

where I[⋅]\mathbb{I}[\cdot] is the indicator function, the predicted-noise magnitude is averaged over colour channels cc, mi,jm_{i,j} masks pixels whose value exceeds the threshold δ\delta (setting them to white), and y^\hat{y} is the final denoised image. The threshold is set per dataset to δ=0.5\delta=0.5 (Synthetic MNIST), 0.80.8 (Synthetic Saint Gall) and 0.90.9 (Synthetic Georgian), chosen on the training data. Unlike iterative cDDM1, noise scaling from the forward schedule is not applied in this single-step denoising approach.

To the best of our knowledge, this is the first diffusion-based approach applied directly in the raw pixel space for palimpsest text separation. While Jampour [13] focuses on computational efficiency, our cDDM is specifically designed to preserve high-frequency handwriting features, allowing us to benefit from diffusion’s noise removal capabilities without sacrificing fine detail.

Language-Guided Text Recognition

The palimpsest HTR learning problem can be formulated as follows. Given a palimpsest dataset for an HTR task TT, let each image contain some region of pixels that is irrelevant to the task (e.g. over-text, damages, degradations) and a region of pixels that is relevant (e.g. under-text). The goal is to recognise the under-text from certain regions in the under-text image (either the raw image or the reconstructed image from the text separation).

In this work, we propose language-guided HTR that leverages a vision-language model to guide a conventional HTR system by constraining it to focus on a more semantically grounded attention map. The architecture is shown in the right half of Figure 1, starting from the under-text image that has been recovered from a given input palimpsest image using the text separation model discussed in the previous section (Pix2pix or cDDM).

For every image yy (or retrieved image y^\hat{y}) and ground truth text label ylabely_{\mathrm{label}}, we create a natural language guiding text τ\tau that captures the key semantic concept relevant to TT. This guiding text is derived from the dataset’s ground truth label.

To ensure compatibility with a pretrained vision-language model like CLIP, τ\tau consists of descriptive phrases formatted similarly to CLIP’s default notation. For example, we prepend a structured prompt such as “A photo of a handwritten word label”, where the word label is extracted from the dataset’s ground truth text label ylabely_{\mathrm{label}}.

For an HTR model fθf_{\theta} with parameters θ\theta, we aim to learn an optimal HTR model that outputs a text prediction and an activation map for a given under-text image as input. To learn an optimal fθf_{\theta}, we can estimate a probability map over the latent space, where each entry corresponds to the probability that pixel is relevant to τ\tau. In this work, we build on the AttentionHTR model (Kass and Vats, [16]) (AHTR in short). In principle, any HTR model that can generate intermediate activation maps and support a standard classification loss could be used.

Next, we introduce language-guided supervision by generating ground truth activation maps from CLIP. We refer to the resulting model as G-AHTR (Guided-AttentionHTR). CLIP is a vision-language model that takes both an image and a text input and produces a similarity score in a shared embedding space. Although this score is global, gradient-based attribution allows us to propagate it through CLIP’s visual encoder to obtain pixel-level relevance maps (Petryk et al., [23]), enabling us to exploit CLIP’s text-image alignment without modifying the base HTR architecture. Since our CLIP visual encoder is a ViT-B/32 transformer, we compute these maps with gradient-weighted attention rollout (Chefer et al., [2]), accumulating the gradient-weighted attention of all transformer blocks into a relevancy map over the visual tokens.

Before extracting activation maps, we fine-tune the full CLIP ViT-B/32 model on the training split of the respective (reconstructed) dataset with the standard symmetric image–text contrastive loss (temperature 0.070.07), using AdamW with learning rate 10−610^{-6} and weight decay 10−410^{-4} for 20 epochs; the HTR-sized grayscale images are replicated to three channels and bilinearly resized to 224×224224\times224.

Given the under-text image yy and guiding text τ\tau, we feed both into CLIP (input resized to 224×224224\times224) and obtain a text-conditioned relevance map over the visual tokens, which for the ViT-B/32 encoder natively lies on a 7×77\times7 grid. This map is bilinearly upsampled to the image resolution, undergoes the same crop-and-pad preprocessing as the input image (§ 4.1), and is bilinearly re-sampled to the HTR input grid, yielding

ACLIP(y,τ):{1,…,32}×{1,…,100}→[0,1].\mathcal{A}^{\mathrm{CLIP}}(y,\tau):\{1,\ldots,32\}\times\{1,\ldots,100\}\to[0,1].

This map serves as the ground truth activation map, denoted Agt≡ACLIP\mathcal{A}^{\mathrm{gt}}\equiv\mathcal{A}^{\mathrm{CLIP}} in the following. Importantly, we do not use CLIP’s prediction itself, only its activation map to provide attention guidance. In parallel, we extract an activation map from the HTR model with Grad-CAM ([26]) at the last convolutional block of its feature extractor, using the summed logits of the ground truth character sequence as the class score (native resolution 4×264\times26), bilinearly interpolated and min-max normalised to the same grid:

AHTR(y):{1,…,32}×{1,…,100}→[0,1].\mathcal{A}^{\mathrm{HTR}}(y):\{1,\ldots,32\}\times\{1,\ldots,100\}\to[0,1].

The L1 activation loss is computed on this common 32×10032\times100 grid. Before entering the loss, the guidance map is affinely rescaled to the input value range, A~gt=2Agt−1∈[−1,1]\widetilde{\mathcal{A}}^{\mathrm{gt}}=2\mathcal{A}^{\mathrm{gt}}-1\in[-1,1], while the predicted map AHTR\mathcal{A}^{\mathrm{HTR}} remains in [0,1][0,1]. This asymmetric scaling serves two purposes: it amplifies the guidance gradients relative to matched-range maps, and, since the predicted map cannot attain the negative target values assigned to low-relevance regions, it persistently drives the predicted attention toward zero outside the text region, acting as a sharpening prior on the guidance.

The HTR model fθf_\theta is then trained on minimising two objectives: (i) the original CE loss between the predicted text and the ground truth transcription, and (ii) a complementary activation loss between the HTR and CLIP activation maps. The activation loss refers to the difference between the two activation maps, in the form of L1 norm. An unweighted sum of the two constitutes the final training objective:

L(y^label,ylabel,x,τ)=LHTR(y^label,ylabel)+Lactivation(A~i,jgt(y,τ),Ai,jHTR(y)).\mathcal{L}(\hat{y}_{\mathrm{label}},y_{\mathrm{label}},x,\tau)=\mathcal{L}^{\mathrm{HTR}}(\hat{y}_{\mathrm{label}},y_{\mathrm{label}})+\mathcal{L}^{\mathrm{activation}}\left(\widetilde{\mathcal{A}}^{\mathrm{gt}}_{i,j}(y,\tau),\mathcal{A}^{\mathrm{HTR}}_{i,j}(y)\right).

where y^label\hat{y}_{\mathrm{label}} is the predicted transcription, ylabely_{\mathrm{label}} is the ground truth text, xx is the input image, and τ\tau is the guiding text. Here, A~i,jgt(y,τ)\widetilde{\mathcal{A}}^{\mathrm{gt}}_{i,j}(y,\tau) denotes the rescaled ground truth activation map extracted from CLIP, and Ai,jHTR(y)\mathcal{A}^{\mathrm{HTR}}_{i,j}(y) is the activation map from the HTR model.

Experimental Results

The proposed methods are empirically evaluated on three synthetic datasets using standard evaluation metrics. This section is organised as follows. We begin by presenting the synthetic datasets and detailing the process to create them. Next, we describe the evaluation metrics used. Finally, we present the results for both text separation and recognition across three scenarios: (a) recognition from the original datasets (MNIST and Saint Gall) without overlapping text, serving as a baseline; (b) direct recognition of the partially visible under-text from palimpsest images; and (c) recognition following text layer separation, where the under-text is first reconstructed.

Datasets

Synthetic MNIST

We replicate the Synthetic MNIST dataset used by Starynska et al. [30] with both diversity and manageable file size in mind. The original MNIST digits ([5]) serve as target under-texts. To emulate palimpsest data, where backgrounds are typically lighter than text, each image I(x,y)I(x,y) is inverted, I(x,y)=255−I(x,y)I(x,y)=255-I(x,y), where x,yx,y denote pixel coordinates and intensities are in [0,255][0,255].

The target images are randomly rotated by θ∼Uniform⁡(−20∘,20∘)\theta\sim\operatorname{Uniform}(-20^\circ,20^\circ) using bi-cubic resampling:

I′(x′,y′)=I(Rθ−1(x′,y′)),I'(x',y')=I\left(R_{\theta}^{-1}(x',y')\right),
\begin{bmatrix}x'\\y'\end{bmatrix} = \begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix} \begin{bmatrix}x-x_c\\y-y_c\end{bmatrix} + \begin{bmatrix}x_c\\y_c\end{bmatrix}. \tag*{(13)}\end{bmatrix}

The target text is assigned a random low-intensity uniform colour i∼Uniform⁡(0,50)i\sim\operatorname{Uniform}(0,50) in RGB channels:

ICRGB(x,y)=[i,i,i],(14)I_{\mathrm{CRGB}}(x,y)=[i,i,i], \tag*{(14)}

and a fourth transparency channel preserves the original MNIST pixel intensities:

ICα(x,y)=1−I(x,y)255.(15)I_{\mathrm{C}\alpha}(x,y)=1-\frac{I(x,y)}{255}. \tag*{(15)}

Backgrounds with parchment-like colours are generated with channel-wise uniform noise:

ICR(x,y)∼Uniform⁡(200,250),I_{\mathrm{CR}}(x,y)\sim\operatorname{Uniform}(200,250),
ICG(x,y)∼Uniform⁡(220,230),I_{\mathrm{CG}}(x,y)\sim\operatorname{Uniform}(220,230),
ICB(x,y)∼Uniform⁡(150,190).(16)I_{\mathrm{CB}}(x,y)\sim\operatorname{Uniform}(150,190). \tag*{(16)}

Under-texts are extracted using a threshold I(x,y)<200I(x,y) < 200 and centred on the background. Over-texts consist of random Latin characters (A–Z) with random font, size (20-25), colour (Eq. (14)), and rotation (Eq. (13)). Finally, additional noise n∼Uniform⁡(1,10)n \sim\operatorname{Uniform}(1,10) is applied:

NC(x,y)∼Uniform⁡(−n,n),IC′(x,y)=IC(x,y)+NC(x,y).(17)N_C(x,y) \sim\operatorname{Uniform}(-n,n), \\ I'_C(x,y) = I_C(x,y) + N_C(x,y). \tag*{(17)}

The dataset contains 60 000 training and 10 000 test samples, following MNIST’s original split.

Synthetic Saint Gall

The Saint Gall dataset (Fischer et al., [8]) originates from a 9th century Latin manuscript and comprises 60 pages of Carolingian minuscule script by a single scribe. It contains 1 410 text lines and 11 597 words. Images were binarised, normalised, and paired with sentence-level labels. Its historical significance, complex script, and ink-on-parchment characteristics make it a valuable benchmark for HTR models.

A synthetic version was generated to introduce real historical text and extend processing to larger images with longer words. Under-text was extracted at the word level using provided bounding boxes, separated from the background with a threshold of 100, and placed on a transparent 350×350350 \times350 canvas. Words exceeding 350 pixels in width were skipped. Under-text colour and rotation followed Eq. (14) and Eq. (13).

Backgrounds were generated similarly to the synthetic MNIST dataset with 350×350350 \times350 pixel canvases, using Eq. (16) for color, uniform noise n∼Uniform⁡(1,50)n \sim\operatorname{Uniform}(1,50) (Eq. (17)), salt-and-pepper noise ∼Uniform⁡(0,0.04)\sim\operatorname{Uniform}(0,0.04), and Gaussian noise with 50% probability, σ∼Uniform⁡(1,3)\sigma\sim\operatorname{Uniform}(1,3). Under-text was centred and images resized to 224×224224 \times224 to reduce computation while preserving quality. Over-texts consisted of random Latin strings with random fonts, size 30-40, overlaid on under-text.

Prior to recognition, all images are dynamically cropped to ensure a text-focused region and prevent geometric distortion. Since our HTR model has a fixed 100×32100 \times32 input resolution, directly resizing the original 224×224224 \times224 images severely compressed the text due to excess vertical white space. To address this, we use Otsu’s thresholding to detect the ink pixels and establish a bounding box. This box is then padded with background pixels to exactly match the target 100×32100 \times32 aspect ratio

before final resizing, ensuring the morphological features of the handwriting remain strictly undistorted. The final synthetic dataset comprises 6 514 training and 1 050 test images; for HTR training, the training images are further split 90/10 into training and validation subsets, with the validation subset used for model selection.

Synthetic Georgian Palimpsest dataset

The synthetic Georgian dataset (Jampour et al., [14]), used in this work, simulates multi-spectral samples from the real Georgian palimpsest (Sinai-Project, [27]). Under-texts consist of 7th-8th century Caucasian Albanian text from Sinai Georgian NF 13 and 55, while backgrounds were cropped from text-free areas of the real palimpsest and prepared via stitching and cleaning. Random over-text was added, but only under-texts are considered in this work.

Targets with white backgrounds were generated by extracting under-texts using a channel-wise threshold, as in Eq. (18):

MC(x,y)={1,if ⌊2050⌋≤IC(x,y)≤⌊255100⌋,0,otherwise,M_C(x,y) = \begin{cases} 1, & \text{if } \left\lfloor\frac{205}{0} \right\rfloor\le I_C(x,y) \le\left\lfloor\frac{255}{100} \right\rfloor,\\ 0, & \text{otherwise,} \end{cases}
IC(x,y)=MC(x,y)⋅ICorig(x,y)+(1−MC(x,y))⋅255.(18)I_C(x,y) = M_C(x,y) \cdot I_C^{orig}(x,y) + (1-M_C(x,y)) \cdot255. \tag*{(18)}

Original images were 2100×\times2800 pixels, too large for training. Both combined and under-text images were split into 48 patches of 350×350350 \times350, then resized to 224×224224 \times224 pixels to preserve readability. Full-image resizing rendered text unreadable. Examples are shown in Figure 2, with rare cases of slight over-extraction due to red intensity in the background.

Combined and under-text patches from the processed synthetic Georgian dataset

Figure 2. Combined and under-text patches from the processed synthetic Georgian dataset.

The final synthetic Georgian dataset used in this work has 43 200 patches of training data and 4 800 patches of testing data.

Evaluation Metrics

Text separation: To assess image quality for the text separation models Pix2pix and cDDM, we use standard metrics: Structural Similarity Index Measure (SSIM), Peak Signal-to-Noise Ratio (PSNR), and the Fréchet Inception Distance (FID).

SSIM [33] quantifies local similarity between generated images y^\hat{y} and target images yy based on luminance, contrast, and structure:

SSIM⁡(y^,y)=(2μy^μy+C1)(2σyy^+C2)(μy^2+μy2+C1)(σy^2+σy2+C2).\operatorname{SSIM}(\hat{y},y)=\frac{(2\mu_{\hat{y}}\mu_y+C_1)(2\sigma_{y\hat{y}}+C_2)}{(\mu_{\hat{y}}^2+\mu_y^2+C_1)(\sigma_{\hat{y}}^2+\sigma_y^2+C_2)}.

Here, μy^,μy\mu_{\hat{y}},\mu_y denote image means (luminance), σy^,σy\sigma_{\hat{y}},\sigma_y their standard deviations (contrast), σyy^\sigma_{y\hat{y}} the covariance (structure), and C1,C2C_1,C_2 are small constants that stabilise the division. SSIM takes values in [−1,1][-1,1], where 1 indicates perfect similarity.

PSNR [34] measures reconstruction quality using the mean squared error (MSE):

MSE⁡(y^,y)=1nm∑i=1n∑j=1m[y(i,j)−y^(i,j)]2,\operatorname{MSE}(\hat{y},y)=\frac{1}{nm}\sum_{i=1}^{n}\sum_{j=1}^{m}[y(i,j)-\hat{y}(i,j)]^2,
PSNR⁡(y^,y)=10log⁡10(L2MSE⁡(y^,y)).\operatorname{PSNR}(\hat{y},y)=10\log_{10}\left(\frac{L^2}{\operatorname{MSE}(\hat{y},y)}\right).

where LL is the maximum pixel value, and n,mn,m is the image dimensions. Higher PSNR indicates better fidelity; values above 40 suggest high-quality reconstruction.

FID [10] measures similarity between feature distributions extracted from the 2048-d pool3 features of a pretrained Inception-v3 network (pytorch-fid), assuming Gaussian statistics:

FID⁡(Xy,Xy^)=∥μy−μy^∥22+Tr⁡(Σy+Σy^−2(ΣyΣy^)1/2).\operatorname{FID}(X_y,X_{\hat{y}})=\lVert\mu_y-\mu_{\hat{y}}\rVert_2^2+\operatorname{Tr}\left(\Sigma_y+\Sigma_{\hat{y}}-2(\Sigma_y\Sigma_{\hat{y}})^{1/2}\right).

Lower FID values indicate that generated images are closer to the real image distribution.

Text recognition: Recognition performance for AHTR and G-AHTR is measured using Word Accuracy (WAcc), computed as:

WAcc⁡(%)=100−WER⁡(%),\operatorname{WAcc}(\%)=100-\operatorname{WER}(\%),

where, since recognition is performed at the isolated-word level, the Word Error Rate (WER) is the percentage of test words that are not recognised exactly. We also compute Normalised Edit Distance (NormED) and Character Error Rate (CER) to further analyse model performance.

NormED is defined as

NormED⁡=1N∑n=1NEditDistance⁡(y(n),y^(n))∣y(n)∣,\operatorname{NormED}=\frac{1}{N}\sum_{n=1}^{N}\frac{\operatorname{EditDistance}(y^{(n)},\hat{y}^{(n)})}{\lvert y^{(n)}\rvert},

where y(n)y^{(n)} and y^(n)\hat{y}^{(n)} here denote the ground truth and predicted transcriptions of the nnth test sample (character sequences, in contrast to their use as images elsewhere), EditDistance⁡(⋅)\operatorname{EditDistance}(\cdot) is the Levenshtein distance, ∣⋅∣\lvert\cdot\rvert denotes sequence length, and samples with an empty ground truth or prediction contribute zero. CER quantifies character-level recognition errors at the corpus level, CER⁡=∑nEditDistance⁡(y(n),y^(n))/∑n∣y(n)∣\operatorname{CER}=\sum_n\operatorname{EditDistance}(y^{(n)},\hat{y}^{(n)})/\sum_n\lvert y^{(n)}\rvert.

Results

Experimental results for text separation and recognition are reported across three scenarios highlighted in § 4, as follows.

a. Baseline results: Table 1 presents the baseline recognition performance for the original MNIST and Saint Gall datasets. Since these datasets contain no overlapping texts, only recognition performance is reported. For each experiment, we performed 10 independent training runs and report the average model performance.

DatasetMNISTSaint Gall
MethodWAcc(%) ↑\uparrowWAcc(%) ↑\uparrowCER(%) ↓\downarrowNormED ↓\downarrow
AHTR99.34 (±\pm0.05)94.64 (±\pm0.51)1.26 (±\pm0.12)0.0127 (±\pm0.0013)
G-AHTR99.37 (±\pm0.06)94.40 (±\pm0.37)1.31 (±\pm0.10)0.0131 (±\pm0.0009)

Table 1. Baseline recognition performance on the original MNIST and Saint Gall datasets, reported in WAcc(%) for MNIST and WAcc(%), CER(%), NormED for Saint Gall. Results are averaged over 10 runs with standard deviation (±\pm).

The recognition of the Synthetic Georgian palimpsest is not considered here because its texts overlap, which makes a reliable baseline unavailable. Moreover, performing HTR on the Synthetic Georgian dataset is not feasible due to the lack of annotations, transcriptions, and training labels.

b. Direct recognition from overlaid palimpsest: We then evaluate the performance of HTR methods in recognising the under-texts directly from the overlaid images in synthetic palimpsest datasets, following the exact same pipeline as we used in scenario (a). The results are reported in WAcc, CER, and NormED, listed in rows under scenario “Overlaid” in Table 3.

DatasetSynthetic MNISTSynthetic Saint Gall
MethodsScenarioWAcc (%) ↑WAcc (%) ↑WER (%) ↓CER (%) ↓Norm ED ↓
[30]91.90----
AHTROverlaid97.71 (±0.12)79.63 (±1.48)20.37 (±1.48)5.75 (±0.43)0.0612 (±0.0054)
Pix2pix96.83 (±0.12)62.25 (±1.87)37.75 (±1.87)12.40 (±0.68)0.1430 (±0.0075)
cDDM297.83 (±0.11)91.70 (±0.73)8.30 (±0.73)1.95 (±0.25)0.0210 (±0.0030)
G-AHTROverlaid97.68 (±0.15)78.30 (±1.38)21.70 (±1.38)6.18 (±0.48)0.0660 (±0.0055)
Pix2pix96.81 (±0.11)61.58 (±0.86)38.42 (±0.86)12.59 (±0.50)0.1450 (±0.0070)
cDDM297.97 (±0.08)91.78 (±0.83)8.22 (±0.83)1.98 (±0.24)0.0218 (±0.0027)

Table 3. Comparison of the average performance of AHTR and G-AHTR on Synthetic MNIST and Synthetic Saint Gall over 10 runs with standard deviation (±). Results are shown for direct recognition from the “overlaid” palimpsest images and for recognition after text separation using Pix2pix and cDDM2. cDDM1 is omitted due to its consistently lower separation performance compared to cDDM2.

As can be observed in Table 3, performing HTR directly on synthetic palimpsests without first separating the text layers is, as expected, challenging due to the partial visibility of the under-text. However, evaluating the performance of our HTR models in this setting provides valuable insights and highlights the need for effective text separation, discussed below.

c. Recognition with text separation: Furthermore, we integrate the text separation stage into the HTR pipeline, where Pix2pix and cDDMs are used to reconstruct the under-text from the palimpsest images. The models are trained on the respective training splits of each dataset, with hyperparameters (such as learning rate, epochs, and cDDM denoising steps) optimised to obtain the best models. The saved model checkpoints are then used to perform reconstructions on the test sets.

The separation results are evaluated using the three metrics introduced in § 4.2: SSIM, PSNR, and FID, as reported in Table 2.

DatasetSynthetic MNISTSynthetic Saint GallSynthetic Georgian
MethodsSSIM ↑PSNR ↑FID ↓SSIM ↑PSNR ↑FID ↓SSIM ↑PSNR ↑FID ↓
[30]-17.781-------
[13]--------144.68*
Pix2pix0.938323.2423.8490.985527.77111.0660.991337.61920.367
cDDM10.887921.63420.0540.980426.23821.2850.950927.57449.942
cDDM20.941923.2383.8370.993932.75319.6780.975031.38431.055

Table 2. Text separation results on synthetic palimpsest datasets using Pix2pix and cDDMs. Results from related works are included for comparison. *Note that Jampour [13] reported three document-level FID values, we therefore use their median in our table.

Overall, cDDM2 achieves the best performance on Synthetic MNIST and Synthetic Saint Gall, obtaining the highest SSIM on both datasets, together with the lowest FID and near-best PSNR on Synthetic MNIST and the highest PSNR on Synthetic Saint Gall (where Pix2pix retains the lowest FID), demonstrating the effectiveness of our proposed custom noise mechanism. Its performance on Synthetic Georgian is slightly lower than that of Pix2pix, primarily due to colour discrepancies. This can be observed in the examples in Figure 3, where the cDDM reconstructions appear lighter than those of Pix2pix; however, the under-text shapes are clearly revealed and do not hinder recognition.

Examples of text separation results from different models, shown alongside the input palimpsest image and the ground truth under-text

Figure 3. Examples of text separation results from different models, shown alongside the input palimpsest image and the ground truth under-text. The examples are drawn from the Synthetic MNIST, Synthetic Saint Gall, and Synthetic Georgian datasets (top to bottom).

The MNIST results (first row of Figure 3) further reveal an interesting difference: Pix2pix often behaves more rigidly than cDDM by attempting to forcefully recover all visible details, such as the black dot above the true under-text “9”, originating from the over-text “T”. This rigidity contributes to Pix2pix’s consistently low FID. However, because FID assumes a Gaussian distribution—and, as discussed in § 3.1.2 palimpsest noise is not always Gaussian, FID may be statistically biased [4, 15]. Moreover, this tendency to reproduce irrelevant or misleading artifacts may negatively affect the downstream recognition stage.

The reconstructed under-text images are then used as inputs for HTR training and testing. Table 3 reports the performance when text separation is applied prior to HTR. Since AHTR is designed for Latin characters only, its results are not compared with previous works involving other scripts, such as Greek, Syriac, and Hebrew [18]. As a baseline observation, integrating under-text separation substantially improves recognition accuracy over direct HTR on raw palimpsests, particularly on the highly challenging Saint Gall dataset. Among the evaluated pipelines, our proposed cDDM2 + G-AHTR framework achieves the best overall performance, yielding the highest mean WAcc and lowest mean WER on both the Synthetic MNIST and Synthetic Saint Gall datasets, although the margins over cDDM2 + AHTR lie within one standard deviation of the ten runs. In particular, when paired with cDDM2 reconstructions, G-AHTR yields small improvements in word-level metrics (WAcc/WER), while CER does not improve (1.98 vs. 1.95 on Synthetic Saint Gall); with Overlaid and Pix2pix inputs, G-AHTR performs on par with or slightly below AHTR, suggesting that the guidance is most useful when the reconstructed under-text is of high quality.

AHTR performs on par with or slightly below AHTR, suggesting that the guidance is most useful when the reconstructed under-text is of high quality. This disparity is expected, as the high variability and ambiguity inherent in handwritten text make character-level recognition more challenging. It is worth noticing that the language guiding mechanism comes at no cost on training stability, since the standard deviations of G-AHTR results are around the same level as those of AHTR.

While the absolute performance gains provided by the language-guided supervision are modest, we hypothesise that the performance ceiling is constrained by the following primary factors: i) the inherent limitations of CLIP in fine-grained handwriting recognition, which become more obvious when the intermediate recovered under-text remains highly degraded; ii) gradient competition between the primary CE loss and the auxiliary activation constraint, as strict spatial alignment with CLIP’s feature maps can be partially orthogonal to the optimal feature representations needed for pure character decoding.

To further illustrate the contribution of the vision-language (CLIP) component, Figure 4 visualises the ground truth activation map from the fine-tuned CLIP model, and Table 4 shows the activation maps computed from AHTR and G-AHTR during training on an arbitrarily selected example. These maps show that the CLIP-guided activation constraint encourages G-AHTR to focus more strongly on the under-text regions while suppressing irrelevant artifacts and noise. This shift in activation toward semantically meaningful regions provides more interpretable model behaviour and, in the cDDM2 setting, coincides with small word-level accuracy gains. In particular, in challenging cases where AHTR hallucinates the word endings, G-AHTR tends to make more reasonable predictions (see Table 5).

Epoch 1Epoch 4Epoch 7Epoch 10Epoch 13Epoch 16
AHTR
G-AHTR

Table 4. Comparison of activation maps on example under-text “itaq” obtained from AHTR and G-AHTR during training, on every third epoch (i.e. epochs 1, 4, 7, 10, 13 and 16). The activation maps from G-AHTR show clear signs of convergence toward the CLIP map.

Under-text image from cDDMActivation map from CLIP

Figure 4. Under-text image from cDDM and the activation map from CLIP for “itaq”.

Original labelAHTRG-AHTR
impossibileimpossibilitieimpossibile
solitudinissolitudiiissolitudinis
solatiumsolattu umsolatium
construensconstruenininininininininconstrueni
linealineamalinea

Table 5. Example predictions from Synthetic Saint Gall (in Latin) show G-AHTR is less likely to hallucinate than AHTR, highlighting the advantage of language-guided HTR.

These findings deepen the understanding of how automatic methods could be applied and interpreted when developing and evaluating palimpsest reconstructions. Our G-AHTR method introduces a new paradigm in cross-modal regularisation by anchoring the HTR model’s visual attention to CLIP’s vision-language alignments via GALS (Guiding visual Attention with Language Specification) [23]. This framework offers a foundational guidance mechanism that can be extended across diverse domains.

Conclusion

This work advances automated palimpsest recovery by integrating structured noise modelling, generative reconstruction, and language-grounded recognition. We design a custom denoising diffusion model to capture layered degradation, explore Pix2pix GANs for restoration, and incorporate textual priors from vision-language attention maps for under-text recognition. Experiments demonstrate improved performance across diverse benchmarks. In particular, the cDDM2 + G-AHTR pipeline achieves the best word-level results and competitive overall scores, while yielding more interpretable attention behaviour. Performance variations across the synthetic MNIST, Saint Gall, and Georgian datasets stem from differences in ink properties, script complexity, and background noise, influencing the suitability of the GAN, diffusion, and HTR components. To support future research and standardised benchmarking, we release synthetic datasets, CLIP-compatible annotations, and pre-trained models.

Future work includes exploring other HTR architectures and generalisation, though we used AHTR for its ease of use and reproducible code. We plan to extend evaluations from word-level to line- and page-level, test on real palimpsests such as the Archimedes dataset, and fine-tune the CLIP model on large-scale handwriting corpora. Finally, we aim to establish a comprehensive benchmark for palimpsest research, including curated datasets, methods, and evaluation metrics.

Acknowledgments

This research was supported by the Kjell and Märta Beijer Foundation, and the Wallenberg AI, Autonomous Systems and Software Program (WASP) funded by the Knut and Alice Wallenberg Foundation. Computational resources were provided on the Berzelius system funded by the Knut and Alice Wallenberg foundation and operated by NAISS. The authors thank Prashant Singh and Anna Starynańska for valuable discussions and feedback, and the Action Editor and reviewers for their constructive comments.

References

  1. [1]Arpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie Li, Hamid Kazemi, Furong Huang, Micah Goldblum, Jonas Geiping, and Tom Goldstein. 2023. Cold diffusion: Inverting arbitrary image transforms without noise. Advances in Neural Information Processing Systems, 36:41259–41282.arxiv.org/abs/2208.09392
  2. [2]Hila Chefer, Shir Gur, and Lior Wolf. 2021. Generic attention-model explainability for interpreting bi-modal and encoder-decoder transformers. In 2021 IEEE/CVF International Conference on Computer Vision (ICCV), pages 387–396. IEEE.arxiv.org/abs/2103.15679
  3. [3]Yung-Hsin Chen and Phillip B Ströbel. 2024. Trocr meets language models: An end-to-end post-correction approach. In International Conference on Document Analysis and Recognition, pages 12–26. Springer.
  4. [4]Min Jin Chong and David Forsyth. 2020. Effectively unbiased fid and inception score and where to find them. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 6070–6079.arxiv.org/abs/1911.07023
  5. [5]Li Deng. 2012. The mnist database of handwritten digit images for machine learning research [best of the web]. IEEE signal processing magazine, 29(6):141–142.DOI
  6. [6]Prafulla Dhariwal and Alexander Nichol. 2021. Diffusion models beat gans on image synthesis. Advances in neural information processing systems, 34:8780–8794.
  7. [7]Roger L. Easton, William A. Christens-Barry, and Keith T. Knox. 2011. Spectral image processing and analysis of the archimedes palimpsest. In 2011 19th European Signal Processing Conference, pages 1440–1444.
  8. [8]Andreas Fischer, Volkmar Fรinken, Alicia Fornés, and Horst Bunke. 2011. Transcription alignment of latin manuscripts using hidden markov models. In Proceedings of the 2011 workshop on historical document imaging and processing, pages 29–36.
  9. [9]2014. Generative adversarial networks. In Advances in Neural Information Processing Systems, volume 27. NeurIPS.arxiv.org/abs/1406.2661
  10. [10]Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. 2017. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30.
  11. [11]Jonathan Ho, Ajay Jain, and Pieter Abbeel. 2020. Denoising diffusion probabilistic models. Advances in neural information processing systems, 33:6840–6851.arxiv.org/abs/2006.11239
  12. [12]Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. 2017. Image-to-image translation with conditional adversarial networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 1125–1134.arxiv.org/abs/1611.07004
  13. [13]Mahdi Jampour. 2025. Revealing palimpsests with latent diffusion models: A generative approach to image inpainting and handwriting reconstruction. In Proceedings of the Winter Conference on Applications of Computer Vision, pages 279–286.DOI
  14. [14]Mahdi Jampour, Hussein Mohammed, and Jost Gippert. 2024. Enhancing the readability of palimpsests using generative image inpainting. In ICPRAM, pages 687–694.
  15. [15]Sadeep Jayasumana, Srikumar Ramalingam, Andreas Veit, Daniel Glasner, Ayan Chakrabarti, and Sanjiv Kumar. 2024. Rethinking fid: Towards a better evaluation metric for image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9307–9315.arxiv.org/abs/2401.09603
  16. [16]Dmitrijs Kass and Ekta Yats. 2022. Attention-htr: Handwritten text recognition based on attention encoder-decoder networks. In International Workshop on Document Analysis Systems, pages 507–522. Springer.DOI
  17. [17]Hongliang Li, Dezhi Peng, and Lianwen Jin. 2025. Ego-lm: An efficient, generic, and out-of-the-box language model for handwritten text recognition. Pattern Recognition, 159:111130.DOI
  18. [18]Boraq Madi, Reem Alaasam, Raed Shammas, and Jihad El-Sana. 2023. Scheme for palimpsests reconstruction using synthesized dataset. International Journal on Document Analysis and Recognition (IJDAR), 26(3):211–222.DOI
  19. [19]Xudong Mao, Qing Li, Haoran Xie, Raymond YK Lau, Zhen Wang, and Stephen Paul Smolley. 2017. Least squares generative adversarial networks. In Proceedings of the IEEE international conference on computer vision, pages 2794–2802.arxiv.org/abs/1611.04076
  20. [20]Gustav Müller-Franzes, Jan Moritz Niehues, Firas Khader, Soroosh Tayebi Arasteh, Christoph Haarburger, Christiane Kuhl, Tianci Wang, Tianyu Han, Teresa Nolte, Sven Nebelung, et al. 2023. A multimodal comparison of latent denoising diffusion probabilistic models and generative adversarial networks for medical image synthesis. Scientific Reports, 13(1):12098.
  21. [21]Alexander Quinn Nichol and Prafulla Dhariwal. 2021. Improved denoising diffusion probabilistic models. In International conference on machine learning, pages 8162–8171. PMLR.arxiv.org/abs/2102.09672
  22. [22]Michela Perino, Michele Ginolfi, Anna Candida Felici, and Michela Rosellini. 2023. A deep learning experiment for semantic segmentation of overlapping characters in palimpsests. arXiv preprint arXiv:2311.01130.arxiv.org/abs/2311.01130
  23. [23]Suzanne Petryk, Lisa Dunlap, Keyan Nasseri, Joseph Gonzalez, Trevor Darrell, and Anna Rohrbach. 2022. On guiding visual attention with language specification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18092–18102.arxiv.org/abs/2202.08926
  24. [24]Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. 2021. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR.arxiv.org/abs/2103.00020
  25. [25]Emanuele Salerno, Anna Tonazzini, and Luigi Bedini. 2007. Digital image analysis to enhance underwritten text in the archimedes palimpsest. International Journal of Document Analysis and Recognition (IJDAR), 9(2):79–87.DOI
  26. [26]Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. 2017. Grad-cam: Visual explanations from deep networks via gradient-based localization. In Proceedings of the IEEE international conference on computer vision, pages 618–626.
  27. [27]Sinai-Project. 2025. Ucla sinai library project.
  28. [28]Anna Starynska. 2023. Text Restoration in Palimpsested Historical Manuscripts Using Deep Learning Methods. Ph.D. thesis, Rochester Institute of Technology.
  29. [29]Anna Starynska, Roger L Easton Jr, and David Messinger. 2017. Methods of data augmentation for palimpsest character recognition with deep neural network. In Proceedings of the 4th International Workshop on Historical Document Imaging and Processing, pages 54–58.DOI
  30. [30]Anna Starynska, David Messinger, and Yu Kong. 2021. Revealing a history: palimpsest text separation with generative networks. International Journal on Document Analysis and Recognition (IJDAR), 24(3):181–195.DOI
  31. [31]Anna Tonazzini. 2010. Color space transformations for analysis and enhancement of ancient degraded manuscripts. Pattern Recognition and Image Analysis, 20(3):404–417.DOI
  32. [32]Mike Toth and Doug Emery. 2008. Archimedes palimpsest digital release.
  33. [33]Zhou Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli. 2004. Image quality assessment: from error visibility to structural similarity. IEEE Transactions on Image Processing, 13(4):600–612.pubmed.ncbi.nlm.nih.gov/15376593
  34. [34]Zhou Wang and Alan C. Bovik. 2009. Mean squared error: Love it or leave it? a new look at signal fidelity measures. IEEE Signal Processing Magazine, 26(1):98–117.DOI
  35. [35]Zixiao Wang, Hongtao Xie, Yuxin Wang, Jianjun Xu, Boqiang Zhang, and Yongdong Zhang. 2023. Symmetrical linguistic feature distillation with clip for scene text recognition. In Proceedings of the 31st ACM international conference on multimedia, pages 509–518.arxiv.org/abs/2310.04999

Paper details

vlnc:W_sga47kbv
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 6

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents