When a program crashes, debuggers rarely read the failing run on its own. They find a passing run that is almost identical, subtract everything the two share, and look at what is left. This technique is called differential execution analysis. We propose to forecast corporate financial risk the same way. For each firm, we find peer firms whose numbers look nearly identical at the same point in time, meaning similar size, leverage, profitability, recent volatility and industry. We then diff the firm's disclosure text, such as its annual report or earnings-call answers, against those peers' texts. What survives the subtraction is the firm-specific narrative that the numbers do not already explain. We expect that narrative to carry most of the forward-looking signal. The language model that performs the diff is given a short domain pre-training stage. It learns from historical pairs of numerically matched firms whose outcomes later diverged: one suffered a severe drawdown and the other did not. From these pairs it learns which textual differences mattered.
This matters because the strongest current text-based risk models already compare documents, but they compare each firm to its own previous year. A year-over-year diff mixes firm-specific change with everything that hit the whole industry that year, including new regulation, a pandemic and sector-wide boilerplate updates. Software debugging has a well-known finding on this point: when the reference run is not a true near-miss, the diff fills up with differences that are not causes (Sumner et al. (2011)). Choosing the reference is the core problem, and financial forecasting has not treated it as a design choice.
Core Claim
We claim that, for text-based risk and earnings-surprise forecasting, what the text is diffed against matters more than the encoder that reads it. A cross-sectional near-miss reference should beat the prior-year reference used in current work, especially in years of shared shocks. Concretely, the reference is a small set of peers matched on the tabular state available at filing time, with only already-filed peer documents allowed. We further claim that a pre-training objective built on historical near-miss pairs adds signal beyond generic domain-contrastive pre-training. In these pairs, the inputs are matched and the realized outcomes diverge.
Where This Sits
The closest work is Learning to Compare Financial Reports for Financial Forecasting. It splits consecutive 10-K Management Discussion and Analysis (MD&A) sections into sentences, soft-aligns them with cross-attention, and pre-trains the sentence encoder with DiffCSE so that it becomes sensitive to small edits. It reaches a Risk F1 of 0.53, where Risk means a top-20% maximum drawdown in the following year. The Longformer baseline reaches 0.50. We reuse its alignment machinery, and in that sense this paper supplies the method. We change two things. First, the reference document: the paper mentions contrasting against peers, but the peers are not selected to match the target's numeric state. Second, the pre-training signal: DiffCSE is outcome-agnostic, while our pairs are defined by divergent realized outcomes within the training period.
The companion paper Financial Forecasting from Textual and Tabular Time Series fuses earnings-call and quarterly-report text with 15 firm characteristics and macroeconomic series to forecast standardized unexpected earnings, which is the gap between reported earnings and analyst consensus. It reaches an MSE of 1.42 and a net Sharpe ratio of 1.03. It motivates our focus on shocks, because its text channel held up in 2020 where numeric series failed. It also motivates our focus on unscripted text, which it found more predictive than formal filings, a finding shared by PRoFET. However, it pools each document whole and never subtracts a reference.
From software engineering we borrow two ideas and state their limits honestly. Causal testing finds minimally different passing and failing test pairs by input distance. Our peer matching is the input-closeness half of that idea. At forecast time the peer's outcome is unknown, so the outcome half appears only in pre-training. Easy over Hard shows that literally deleting log events that also appear in passing runs gives a strong, cheap diagnostic. That result constrains us: any neural diff must beat a lexical "diff with peer" first. On the pre-training side, FinBERT and A Comparative Study of PEFT Methods for Python Code Generation support the view that base-level domain adaptation matters more than the choice of fine-tuning technique. PIXIU warns that financial language models excel at comprehension but only modestly at prediction. We read that result as a reason to change what the model is trained to predict, not how big it is.
Research Program
The first component is near-miss peer retrieval. For target firm $i$ at filing date $t$, let $z_{i,t}$ be the standardized tabular state available at $t$. This includes the firm characteristics used by Koval et al., trailing return and volatility, and size. Candidate peers $j$ share the industry and must have filed their comparable document strictly before $t$, which prevents lookahead. We keep the $k$ nearest candidates under a Mahalanobis distance $d(i,j) = \sqrt{(z_{i,t}-z_{j,t})^\top \Sigma^{-1} (z_{i,t}-z_{j,t})}$, where $\Sigma$ is the covariance of $z$ estimated on training years. We also record the match distance, so we can test whether closer matches yield cleaner diffs, which is the debugging prediction.
The second component is the residual text representation. We reuse the cross-document sentence alignment of Koval et al. Each target sentence embedding $s$ attends over the pooled sentences of the $k$ peers to produce an aligned reference $\hat{s}$. The model then consumes the residual $r = s - \hat{s}$ together with an attention-derived "unmatched" score for each sentence. This is the soft analogue of subtracting shared execution steps. The prior-year diff is kept as a second, parallel channel, so the model can learn when temporal or cross-sectional differences matter. Residuals are pooled and fused with AR(1) and tabular features, following the late-fusion recipe of the earnings-surprise paper.
The third component is near-miss pre-training. Before the training cutoff, we construct pairs of firms that were closely matched on $z$ at the same date but whose following-year maximum drawdowns fell on opposite sides of the top-20% threshold. Starting from the DiffCSE-adapted encoder, we continue training on a pairwise objective. The model receives the two aligned documents, predicts which firm crashed, and must do so through the residual pathway only. An auxiliary term pulls together sentences that appear, with paraphrase, across many matched peers, so that boilerplate lands near its peer counterpart and cancels in the subtraction. All pairs come from 2010–2014 for the 10-K task, so pre-training sees no evaluation-period outcomes. The compute is a continuation of an existing financial encoder, not pre-training from scratch.
Baselines
The naive reference points are AR(1) alone and the traditional financial variables. On the 10-K risk task, traditional variables reach F1 0.45 (Learning to Compare Financial Reports). On the earnings-surprise task, the autoregressive strategy reaches a net Sharpe of 0.47 (Financial Forecasting from Textual and Tabular Time Series). Any text method that does not clear these fails outright.
The strongest existing method on the 10-K data is CDSA-FinDiffCSE, which diffs against the prior year. Reported figures are Risk F1 0.53, rising to 0.56 with AR(1), and Correlation Spearman 0.31, rising to 0.40 with AR(1). It is the right competitor because it already does alignment-based differencing with domain pre-training, so it isolates our change of reference. We will rerun it from its published recipe on the identical 2010–2014/2015/2016–2019 splits, with the same encoder size and the same hyperparameter search budget as our model. Beating it means exceeding its reproduced F1 by more than the standard deviation across five seeds and year-block bootstraps, both alone and combined with AR(1). We report our reproduction next to the published 0.53 and 0.56. For earnings surprise, the reference is the multimodal model at MSE 1.42 and net Sharpe 1.03, with the best single-modality model, earnings calls alone, at 1.60. For volatility on the Eikon transcripts, the reference is PRoFET at $r_{log} = 0.622$ against GARCH at 0.437 (PRoFET).
Three ablations isolate the key ingredients. The first swaps the matched peers for random same-industry peers at equal $k$, which tests whether near-miss matching matters. The second uses outcome-agnostic matched pairs in pre-training, the same pairs with shuffled outcome labels, which tests whether the divergent-outcome signal matters. The third drops the prior-year channel, which tests whether cross-sectional references alone suffice.
Why not just…?
Why not just delete sentences that also appear in peer or prior-year filings, then use any encoder? This is the NCChecker lesson, and it is a real threat. On software logs, "diff with pass" plus frequency weighting reached 71.9% F1 in 20ms against 55.0% for a learned model (Easy over Hard). Bag-of-words did poorly on the correlation task (Spearman 0.10), but that baseline did no subtraction, so it does not settle the question. We therefore run lexical deletion against matched peers, and fuzzy deletion by embedding similarity, in front of the same fusion head. If lexical deletion against near-miss peers matches our residual model, we will report that the reference choice is the whole contribution and the neural diff is unnecessary. That would still be a useful result.
Why not just neutralize features by industry, subtracting the peer-average embedding and demeaning tabular features? This is standard cross-sectional practice in finance and cheaper than alignment. It differs from our approach in two ways: it subtracts an average rather than near-miss matches, and it subtracts at the document level rather than the sentence level, which the Longformer result (0.50 F1, 0.18 Spearman) suggests washes out local changes. We run it directly, with industry-mean and matched-peer-mean document embeddings subtracted. The prediction specific to our proposal is that the gap over this baseline grows as match distance shrinks.
Why not just prompt or LoRA-tune a large financial LLM with both documents in context? PIXIU reports strong comprehension but modest gains on forward prediction, and Männistö finds that fine-tuning technique matters far less than base adaptation. We include a LoRA-tuned open model given target-plus-peer MD&A excerpts as a baseline under matched GPU-hours. We expect it to lose, but we do not assume it will.
Decisive Checks
Three experiments decide the proposal. First, on the 10-K risk and correlation tasks, the matched-peer residual model must beat reproduced CDSA-FinDiffCSE, industry-mean subtraction, and lexical peer deletion. The random-peer ablation must lose most of that gain. Second, gains must be monotone in match quality. Binning test firms by distance to their nearest peer, the advantage over the prior-year diff should be largest for the closest matches. This is the direct translation of the debugging claim that near-miss baselines give clean diffs. Third, a shock-period test: in 2020 on the earnings-surprise data, where shared shocks swamp year-over-year diffs, the cross-sectional channel should carry most of the attributed weight and the MSE advantage should widen. We also evaluate trading impact with the net Sharpe protocol of the earnings-surprise paper, since lower MSE need not translate into profit (Forecast-to-Trade). If the shuffled-outcome pre-training ablation matches the full model, we drop the pre-training claim and keep only the reference-selection claim.
References
- Selecting peers for execution comparison
- Learning to Compare Financial Reports for Financial Forecasting
- Financial Forecasting from Textual and Tabular Time Series
- PRoFET: Predicting the Risk of Firms from Event Transcripts
- Causal testing: understanding defects' root causes
- Easy over Hard: A Simple Baseline for Test Failures Causes Prediction
- FinBERT: A Pre-trained Financial Language Representation Model for Financial Text Mining
- A Comparative Study of PEFT Methods for Python Code Generation
- PIXIU: A Comprehensive Benchmark, Instruction Dataset and Large Language Model for Finance
- Forecast-to-Trade: Hierarchical Reinforcement Learning for Decision-Aware Financial Forecasting