XRFormer: Multiscale Tokenization for XRF Representation Learning

Sofiane Daimellah, Sylvie Le Hégarat-Mascle, Clotilde Boust
7/7/2026
cs.CV

Official code: sofiane1010/XRFormer (0 stars, MIT, last commit 2026-04-15).

Abstract

X-ray fluorescence (XRF) spectroscopy is a key modality for material analysis in cultural heritage. However, automated learning from XRF spectra remains challenging: XRF spectra are complex one-dimensional signals composed of sharp elemental peaks, broader structures, and background variations that are not taken into account by existing learning-based models. This paper introduces XRFormer, a transformer architecture tailored to XRF spectra through a multiscale convolutional tokenizer that injects locality and multi-resolution inductive biases before global self-attention. The tokenizer progressively reduces spectral resolution while increasing embedding dimensionality, and the resulting token sequence is processed by a standard transformer encoder. We further investigate self-supervised pretraining for XRF representation learning using Masked Spectral modeling (MSM) and a physics-informed Peak Presence Prediction (PPP) objective. Experiments on the Pigments Checker STANDARD v.5 dataset for pigment identification and unmixing show that XRFormer consistently outperforms ViT, SpectralFormer (with and without CAF), and a 1D-CNN baseline for pigment identification. For pigment unmixing, XRFormer achieves robust abundance estimation while maintaining significantly higher parameter efficiency than SpectralFormer, operating at a lower token resolution (128 vs. 512 tokens) and with less than half the number of parameters (1.5M vs. 3.37M). MSM yields consistent gains across both tasks, while PPP further enhances performance for both identification and unmixing when tuned with an appropriate peak prominence. These results highlight multiscale, modality-aware tokenization as an effective and parameter efficient foundation for transformer-based XRF modeling under data-limited conditions. A GitHub repository is provided at https://github.com/sofiane1010/XRFormer.

View on arXivView PDF

Code Implementations(1)

MIT

This repository contains the official PyTorch implementation of the paper "XRFormer: Multiscale Tokenization for XRF Representation Learning".

00PythonFeb 11, 20266 months agoMIT

Similar Papers

Cite this paper

@article{daimellah2026xrformer,
  title  = {XRFormer: Multiscale Tokenization for XRF Representation Learning},
  author = {Sofiane Daimellah and Sylvie Le Hégarat-Mascle and Clotilde Boust},
  year   = {2026},
  eprint = {2607.06424},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2607.06424v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2607.06424.svg)](https://codeofpaper.com/paper/2607.06424)

Discussion