A single laser spot on a mineral grain returns a few dozen element concentrations. Some of those numbers still record the magma or fluid the crystal grew from. Others were rewritten later, when hot fluids percolated through the rock and swapped ions in the crystal lattice, or when the laser accidentally hit a microscopic inclusion of another mineral. Geologists who try to infer how an ore deposit formed must separate these two kinds of numbers by hand. Current machine-learning models do not try. They treat each spot as one flat vector, and the papers that use them list hydrothermal alteration and spatial heterogeneity as unexplained failure modes.
We propose to borrow replaced token detection (RTD) from language-model pretraining. In RTD, a small model swaps some words in a sentence for plausible alternatives, and a second model learns to say, for every word, whether it is original or swapped. Mineral overprinting has the same structure: a fluid replaces some elemental values with plausible but foreign ones, and the question for each element is "primary or replaced?" Our main claim is that an RTD discriminator trained on geologically constrained corruptions of in-situ mineral analyses produces a per-element "alteration score." That score has two uses. It localizes overprinted and inclusion-contaminated channels better than reconstruction-error heuristics. And masking the flagged channels makes downstream genetic classifiers more robust when they are applied to a new region. We do not claim that a transformer beats tree ensembles at whole-sample classification. That fight is probably lost on datasets of a few thousand rows, and we design the evaluation around that expectation.
What exists and where this sits
The RTD objective comes from ELECTRA. ELECTRA trains a small masked language model, called the generator, by ordinary maximum likelihood to propose replacements, and trains a discriminator to label every position as original or replaced. It reports matching RoBERTa and XLNet on GLUE with under a quarter of the compute. It also shows two things that constrain our design: adversarially trained generators do worse, and generators that are too strong hurt the discriminator. Prompting ELECTRA argues that the discriminator learns to separate substitutions that are plausible in context but incompatible, which is exactly the distinction we need between a lattice-compatible primary value and a fluid-introduced one. Atacformer shows RTD transfers to non-text "bags of tokens," here chromatin regions in single cells. That is the closest methodological precedent, but its corruptions are generic, not physically meaningful.
On the tabular side, XTab pretrains transformers across tables and finds that masked-value reconstruction beats contrastive objectives. It reports a 71% win rate under light fine-tuning, but CatBoost still edges it out overall. XTab never tested RTD. Its result is also the main constraint on our work: reconstruction is a strong, simpler competitor, so we must test against it directly.
On the geology side, Tan et al. classify 5,776 apatite analyses from 374 intrusions as fertile or barren for skarn tungsten. They use centered log-ratio (clr) transforms, GAN augmentation of the minority class, Random Forest and SVM classifiers, and SHAP attributions. They name fluid metasomatism and spatial heterogeneity as limitations, and they do nothing to locate which channels were altered.
The field studies supply the physical ground truth we reuse. Zhibo magnetite separates primary MagI (V, Cr, Ni rich) from hydrothermal MagII (W, Ta, Nb, Sr, Sn, Y, Zr enriched) and flags laser ablation of micro-inclusions as a contamination source. Liba pyrite defines four pyrite generations, from sedimentary Py0 to late hydrothermal Py3. Fang'an pyrite and Xiahekou add staged sulfide trace elements with independent isotopic constraints.
The research file found no work applying RTD to mineral geochemistry. What is new here is not only "ELECTRA on a geochemistry table." It is the use of the discriminator's per-element output as an alteration detector, trained with corruptions that imitate real overprinting and inclusion physics, and checked against labeled mineral generations.
Core Claim
Represent each analytical spot as an unordered set of tokens, one per element. Each token combines an element-identity embedding with an embedding of the element's clr-transformed value, discretized into quantile bins.
Corruptions come from three sources. The first is a small masked generator, ELECTRA's standard recipe. The second is a cross-generation transplant generator: a generator trained only on secondary-phase spots, such as MagII or Py2–Py3, fills masked elements of a primary-phase spot. Its replacements therefore look like real fluid overprint rather than generic noise. The third is inclusion injection: we add a stoichiometric spike of a known inclusion phase (galena, native gold, silicate) to a subset of channels, with magnitudes drawn from the ranges the Zhibo and Fang'an studies describe.
A discriminator trained to label each element as original or replaced then yields, for each spot $s$ and element $e$, a probability $p(e \mid s)$ that the value is not primary. The hypothesis is that $p$ tracks real overprinting. If the discriminator is nothing more than a disguised conditional-density estimate, the generator's own reconstruction residual should do just as well. We treat that outcome as a real possibility and test for it explicitly.
Research Program
The first step is a data compilation. It pools in-situ LA-ICP-MS and EPMA spot analyses of magnetite, pyrite, and apatite from the cited studies and from any public compilations we can obtain. Spots keep their mineral-generation labels (MagI/MagII, Py0–Py3) wherever the source paper assigns them. The Tan et al. apatite set, if it is released, provides the largest single pool.
Where core-to-rim traverses are reported, we add a positional token so the model can see zoning. We treat this as a secondary extension, not the core claim.
The pretraining labels never use the generation labels. Those labels are held out entirely for evaluation. This matters because the transplant generator does use phase membership. To avoid leakage, transplant generators are trained only on deposits that are excluded from the evaluation deposits.
The downstream test is a gated classifier. We use the discriminator's scores to mask channels with $p(e \mid s) > \tau$ and fit the same Random Forest Tan et al. used, on the remaining clr features with missing values imputed. We then compare its out-of-region accuracy against the ungated classifier.
Baselines
The naive reference point is no alteration modeling at all: a Random Forest on all clr features, exactly as in Tan et al.. Tan et al. report about 93% test accuracy, F1 around 0.93, and fertile-class recall of 0.97–0.98 on the global apatite set, and 90% accuracy on an independent set of 10 Nanling Range rock samples. We will rerun their pipeline on the same splits, with the same threshold-adjustment procedure, before comparing anything. For element-level overprint localization there is no reported result found on Lacuna, so that comparison is entirely internal.
The strongest existing competitor for whole-sample classification is CatBoost, which XTab identifies as the top tabular model. We will tune it with the same hyperparameter-search budget as every deep model.
The strongest competitor for the alteration-detection question is a masked-reconstruction model in the style of XTab. It is pretrained on identical data with identical parameter count and number of training steps. Its per-element score is the negative log-likelihood of the observed value when that element is masked. We pair it with a leave-one-out conditional Gaussian score in clr space, a classical geochemistry-style outlier test, as a non-neural reference.
Three ablations isolate the proposal's key ingredient. The first trains the discriminator on uniformly random value replacements. The second uses only ELECTRA's standard masked generator. The third reads the alteration score from the generator's likelihood instead of the discriminator. Together they separate the effect of the corruption design from the effect of the discriminative objective.
Beating the baselines means two things. On held-out deposits, the alteration score must be higher on secondary-phase spots than on primary ones, measured by the area under the ROC curve (AUROC) for MagII vs. MagI and Py2–Py3 vs. Py0. The discriminator must exceed the masked-reconstruction score on this AUROC with non-overlapping deposit-level bootstrap intervals. And the gated Random Forest must not fall below the ungated one in-distribution while improving out-of-region accuracy.
Why not just…?
Why not just use Random Forest or CatBoost, which already reach 93%? For whole-sample fertility classification we expect trees to stay competitive, and we do not plan to argue otherwise. The proposal instead asks a question trees do not answer: which channels of a spot are primary. The trees remain the downstream classifier. The test is whether removing flagged channels before classification improves transfer to the Nanling samples, where Tan et al. themselves attribute errors to heterogeneity and alteration. If gating does not help there, the downstream half of the claim fails.
Why not just use masked reconstruction error as the alteration score? This is the real threat. The generator in RTD is itself a masked model, and its likelihood residual is a direct per-element anomaly score. ELECTRA's argument for discrimination concerns sample efficiency and representation quality, not anomaly localization. On a few thousand rows, sample efficiency may matter less than it does for text. The generator-likelihood ablation and the XTab-style baseline settle the question. If they match the discriminator, we will report that the physically designed corruptions, not RTD itself, carry the value. In that case the cheaper reconstruction model is the recommended tool.
Why not just run isotopes and geochronology? The Dahongshan albite study and Xiahekou show that these methods resolve genesis decisively when they are available. But they are expensive, they need specific datable phases, and they can give mixed signals: δ³⁴S ranges at Liba and Xiahekou overlap between possible sources. We use these studies' isotope-based conclusions as external labels. We do not try to replace them. The model's target is the high-throughput trace-element screening stage that precedes isotope campaigns.
Why not just train a GAN, as Tan et al. did? ELECTRA reports that adversarial generators trained by policy gradient underperform maximum-likelihood ones. Tan et al. also note that their synthetic samples may not capture geological complexity. Our transplant generator is trained by maximum likelihood on real secondary-phase spots, which avoids both problems.
Proposed Experiments
The first experiment is overprint localization on labeled generations. We pretrain on all deposits except one and score that held-out deposit's MagI/MagII spots (Zhibo) or Py0–Py3 spots (Liba, Fang'an, Xiahekou). We report spot-level AUROC for every scoring method.
At the element level, we check whether the elements with the highest scores in MagII spots are the ones the Zhibo study names (W, Ta, Nb, Sn, and others) rather than V, Cr, and Ni. For Liba, we check whether Au and As behavior differs between the lattice-bound early stages and the late nanoparticle stages.
The second experiment is a controlled inclusion recovery test. We inject held-out, real inclusion signatures into clean spots at graded magnitudes and measure per-element precision-recall for every scoring method. This is the only test with exact element-level ground truth.
The third experiment is downstream transfer. We train the gated Random Forest on the global apatite set and evaluate it on the Nanling samples against the 90% reported baseline, with rock-level bootstrap intervals. These intervals will be wide given only 10 rocks. We will also run leave-one-region-out evaluation on the global set.
The decisive check is the comparison between the discriminator and the generator-likelihood score in the first two experiments. If the discriminator wins, RTD earns a place in geochemistry. If it ties, the contribution is reduced to the corruption design, and we will say so.
References
- ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
- Pre-trained Token-replaced Detection Model as Few-shot Learner
- Atacformer: A transformer-based foundation model for analysis and interpretation of ATAC-seq data
- XTab: Cross-table Pretraining for Tabular Transformers
- Machine Learning Reveals Magmatic Fertility of Skarn-Type Tungsten Deposits
- Textures and Chemical Compositions of Magnetite from Zhibo Submarine Volcanic Iron Oxide Deposit, Xinjiang, China: Implications for Re-Equilibration Processes
- Characteristics and genesis of gold-bearing sulfide in the Liba gold deposit, West Qinling.
- Typomorphic Characteristics of Gold-Bearing Pyrite and Its Genetic Implications for the Fang’an Gold Deposit, the Bengbu Uplift, Eastern China
- Genesis of the Xiahekou gold deposit in the Yalujiang Gold Metallogenic Belt, Liaodong Peninsula: Evidence from geology, S-Pb-He-Ar isotopes and trace elements of sulfide
- Geological and Geochemical Characteristics of Albite within the Manganghe Formation, Dahongshan Deposit, Yunnan Province, China: Implication for the Ore Genesis