betaFeedback

WorksMathematics

Where A Small Language Model Helps in Invoice Categorisation, Understood Through Embedding Geometry

Abstract

Categorising invoices into the correct General Ledger (GL) code underpins financial reporting and tax compliance. This is a skilled accounting judgement rather than a routine task: the correct category depends subtly on the nature of the purchasing business, the vendor and the invoice text. Whilst AI is increasingly being adopted across industries to automate tasks, including invoice categorisation, implementations built on in-house small language models (SLMs) can simultaneously reduce cost and improve data security, confidentiality, and interpretability. We investigate this approach by first analysing the pre-trained embedding geometry of a small sentence transformer (SBERT) and classic SLM (DeBERTa). The sentence-embedding space of this financial corpus is globally anisotropic but composed of locally isotropic clusters, extending prior token-level findings to sentence embeddings in a financial setting, and these clusters are strongly correlated with the vendor identity. SBERT fine-tuned on a single GPU reaches 0.96 accuracy on invoice classification, above both a zero-shot LLM and a vendor identity baseline, increasing performance for smaller, challenging categories and new clients. For this important generalisation problem, SBERT reaches 0.9 F1 with roughly 100 client-specific invoices, showing that an in-house SLM implementation is promising. Combining these results with geometric analysis shows that pre-trained embedding geometry is associated with classification performance and reveals a counterintuitive finding that a structured input that would help a human reader does not improve the SLM performance.

Introduction

Every invoice generated by a business needs to be assigned the correct General Ledger (GL) code.

This is a nuanced accounting task that requires specialised skills, and its success underpins financial reporting and tax compliance, under UK standards (FRS 105, FRS 102 Section 1A). A reduction of errors in invoice classification benefits small and medium enterprises (SMEs) through improved financial management, reduced compliance costs and exposure to risk through penalties. The UK tax gap is estimated around £59 billion, for which roughly half is attributed to errors or failure to take reasonable care ([21]). Hence, the motivation for this research is clear, as improving automated mapping of invoices to GL codes would improve compliance, benefiting HM Revenue and Customs (HMRC) through increased compliance and SMEs through reduced exposure to fines and compliance costs.

AI is increasingly adopted to automate exactly these types of tasks. Large language models (LLMs) are the default choice, and some could perform well on this task. However, we find that off-the-shelf zero-shot (small) LLMs are not well suited to this specialised task (Section 4.1).

On the other hand, in-house small language models (SLMs) are competitive in the financial domain ([7, 1, 16]) and offer concrete advantages. They mitigate serious concerns around data security and confidentiality ([12, ?]) for a regulated domain like accounting, and significantly reduce costs ([5]). Finally, SLMs improve interpretability ([3, 29]) through a large suite of tools available for encoder-only SLMs like BERT ([?]; [20, 11]), which are not available for closed external LLMs and which may eventually be required both for audit and regulatory purposes and for public trust.

Classification performance is a critical benchmark but an examination of the internal representation of data can offer a pathway towards intrinsic interpretability ([13]; rudin2019). For the end user, interpretability promises a quantification of uncertainty ([27]), increased robustness ([17]), control over associations with protected categories, and human-intuitive representation of semantic meaning (saxe2019). These properties can be derived in part from the intermediary of geometric properties, i.e. clustering, separability and manifold structure of the neural network ([15], [8], [31]) and can be linked to downstream behaviour ([34], [18]) relating to features and labels. We therefore complement classification metrics with a geometric analysis, not as an end in itself but as a foundation for developing reliable, auditable and interpretable SLMs.

Contribution. :

  1. We show where a language model can make a valuable contribution over a vendor-only baseline, i.e. in smaller and challenging categories, which informs deployment implementations.

  1. We show that a small sentence transformer, SBERT (∼22\sim22M parameters) (reimers2019), fine-tuned on a single GPU, reaches 0.96 accuracy, substantiating SLMs as a potentially reliable and cost-effective route for deployment-level classification.

  1. We extend prior token-level findings on globally anisotropic representation spaces with isotropic clusters to sentence embeddings; to the best of our knowledge, the first such result in a financial setting, and we show these clusters are highly associated with the vendors.

  1. We find that embedding geometry helps explain SBERT’s increased performance over larger token transformer DeBERTa (∼184\sim184M) ([19]): SBERT’s pre-trained space has a higher effective dimensionality and lower average cosine similarity than DeBERTa’s. And DeBERTa’s CLS sentence embedding collapses as the input grows richer.

  1. We find that on unseen clients the otherwise competitive vendor baseline collapses, and SBERT improves macro F1 over DeBERTa. This suggests that line-item text in learned representations with ‘good geometry’ carries semantic signal that transfers to unseen vendors. This is deployment-relevant as it directly measures client onboarding.

  1. The utility of geometric analysis is twofold. Firstly, for this financial corpus, pre-trained embedding geometry is consistent with downstream performance and robustness. Secondly, it guides input representation: a more costly structured input useful for human reading does not improve the SLM performance due to increased similarity in the embedding space, directly relevant for practitioners.

Related work. Several works have used machine learning in the accounting domain ([6], [9], [32]; tarawneh2019). Some specifically address the classification of invoices into GL codes, including frameworks based on static word embedding ([22], [24], [4]) or deep learning ([23], [30], [10], [28]). Only a few approaches exploited modern language models ([30], [10]). However, to the best of our knowledge, none of the existing works implements sentence-based SLMs and combines it with a thorough geometric investigation.

The geometry of language models’ representation spaces has been well studied ([14], [8]), with attempts to formalise these phenomena ([2], [15]). To the best of our knowledge, we are the first to use these geometric tools to offer insight into classification performance on a financial corpus of invoices.

Methods

Dataset

We analyse the problem of automatic invoice classification into GL codes. Our confidential dataset consists of real invoices from seven clients of a UK accountancy firm that span various business domains. The firm provides its clients with software that uses OCR to extract relevant textual information from a PDF or an image of the invoice; we take that OCR output as our input. Each invoice is associated with the correct accounting category, manually labelled by professional accountants.

The full dataset comprises 2,423 invoices over 42 categories (Figure A1), with an average of 75 tokens per invoice. The data exhibits the severe class imbalance typical of this domain: only 14 categories contain more than 20 samples, and the largest category (Purchases) accounts for 705 invoices. We restrict our experiments to wellpopulated categories: the 12 categories with more than 40 samples (2,168 invoices) defined in Table A1. These contain enough labelled data to train and evaluate reliably, and together they account for the majority of invoice volume.

![Bar chart titled “Number of data points in each category”, showing invoice counts across 42 accounting categories; the x-axis is “Category” and the y-axis is “Count”. Bars and counts: Purchases 705; Motor Repairs and Servicing 388; Petrol and Oil 260; Sub 217; Accountancy Fees 117; Subscriptions 108; Transport, Freight & Carriage 91; Directors Loan Account 74; Light, Heat & Power 55; Telephone, Fax & Internet 55; Cleaning of Premises 53; Stationery & Postage 45; Rent 37; Commissions & Renewals 32; Repairs & Renewals 19; Management & Consultancy Fees 17; Other 16; Legal and Professional Fees (Allowables) 15; Computer Expenses 13; Advertising 13; Motor Licenses and Insurance 12; Merchant Fee 12; General Travel Expenses 10; Computer Equipment 10; Professional and State? 9; Plant & Machinery 8; Repairs & Maintenance 7; Entertainment (Disallowable) 4; Rates of Water 4; Other Staff 3; Bank Charges 3; Donations 3; Vehicle Insurance 3; Repairs and Renewals 2; Vehicle Leasing Charges 2; Security 2; Plant Hire 2; Website Costs 2; Property Insurance 1; Other Premises Costs 1; General Insurance 1; Sundry Expenses 1; Storage 1. A dashed vertical line separates the categories included in the analysis.] bbox=0.18,0.12,0.66,0.34

Figure A1. Distribution of invoices across the 42 accounting categories in the full dataset; the categories before the dashed line are included in the analysis.

Account CategoryDefinition
PurchasesCost of goods, raw materials or components bought for resale or for consumption in production during the period. A profit-and-loss item forming part of cost of sales; it records the buying flow, not stock held. Excludes capital assets and overhead services.
Directors’ Loan AccountRelated-party control account for amounts a director personally lends to, or withdraws from, the company other than salary, dividend or reimbursed expenses. May be in credit (company owes the director — a liability) or overdrawn (director owes the company — an asset); overdrawn balances attract a s455 CTA 2010 charge and beneficial-loan implications.
Petrol and OilFuel and lubricant costs incurred in operating business motor vehicles.
SubAbbreviation for Subcontractor. Payments for subcontractor or subcontract labour directly attributable to revenue-generating work.
Motor Repairs and ServicingMaintenance, servicing and repair of company vehicles.
SubscriptionsRecurring professional-body memberships, journals and software or service subscriptions of an administrative nature.
Stationery & PostageOffice consumables, printing materials and postal or courier charges.
Cleaning of PremisesJanitorial costs of keeping premises clean — cleaning staff or contractors, services and cleaning consumables. Excludes repair and upkeep of premises, which is maintenance (see Repairs & Renewals).
Light, Heat & PowerUtility costs — electricity, gas, heating and power — consumed in operating business premises.
Telephone, Fax & InternetCommunication costs: telephone, broadband, internet access and related charges
Transport, Freight & CarriageInwards - Cost of transporting purchased goods or materials into the business. Added to the cost of purchases and therefore part of cost of sales. Outwards - Cost of delivering finished goods out to customers. A distribution/selling overhead, not cost of sales.
Accountancy FeeFees for preparation of statutory and/or management accounts, bookkeeping, tax compliance and related non-audit advisory services. Excludes statutory audit.

Table A1. Definitions for accounting categories used in the dataset. There is no standardised UK nominal ledger and nominal ledger code numbers are a convention of the different accounting software. The UK firm that provided our data uses a custom accounting categorisation and proprietary software. When an invoice contains line items spanning multiple categories, the invoice is assigned to the category with the largest total value, as is standard practice in this UK firm.

From the OCR output, we construct three different textual inputs, with examples in Figure 1:

Fictitious example of the three input variants

Figure 1. Fictitious example of the three input variants.

(A) Vendor name, date, and price only, excluding the line-item descriptions.

(B) Vendor name, date, line-item descriptions, and price, as returned by the OCR.

(C) As (B) with an explicit label (Vendor Name:, Invoice Date:, Line Items:, Price:).

Experimental set up

We use the sentence transformer SBERT ([?]) (all-MiniLM-L6-v2), an encoder-only transformer designed and trained for sentence embedding with ≈22M parameters and 384 model dimension. Each invoice input is embedded from the last layer extracted with SBERT native pooling. We compare it to DeBERTa (microsoft/deberta-v3-base) with ≈184M parameters and 768 model dimensions. DeBERTa computes token embeddings which must be pooled to compute sentence embeddings. We consider the two most popular solutions: pooling using the ‘CLaSsification’ token embedding [CLS], vs pooling using the mean embedding of all tokens [mean], both in the last layer. The code can be found in this repository.

Geometric analysis

We analyse the pretrained embedding geometry along four diagnostics: effective dimensionality, global anisotropy, unsupervised clustering structure, and local isotropy.

Effective dimensionality

Inspired by [8], we first look at the effective dimensionality of the embedding spaces, via centred PCA. For each combination of model and input type, we start with the embedding matrix M∈Rn×mM \in\mathbb{R}^{n \times m}, where n=2,168n = 2{,}168 and m=384m = 384 for SBERT and 768 for DeBERTa. Let σ1≥σ2≥⋯≥σm\sigma_1 \ge\sigma_2 \ge\cdots\ge\sigma_m be the eigenvalues of MM’s covariance matrix, and define the explained variance ratio rk=∑i=1kσi∑i=1mσir_k = \frac{\sum_{i=1}^{k}\sigma_i}{\sum_{i=1}^{m}\sigma_i} and the ϵ\epsilon-effective dimension to be d(ϵ):=argmin⁡krk≥ϵd(\epsilon) := \underset{k}{\operatorname{argmin}} r_k \ge\epsilon. For each model and input type, we report d(0.8)d(0.8), the number of dimensions necessary to explain 80% of the variance in the embedding space, in Table 1.

ModelABCdmodeld_{\mathrm{model}}
SBERT426157384
DeBERTa mean1376768
DeBERTa CLS1011768

Table 1. Effective dimensionality (80% variance explained) by model and input type.

SBERT has higher effective dimensionality across all input types, as it’s trained to produce semantically rich embeddings. SBERT embeddings for input types B and C have a higher d(0.8)d(0.8) than A, reflecting the additional textual content, with little difference between B and C themselves.

Figure 2 shows the first 3 principal components of SBERT (B) embeddings. The embedding of Accountancy fee forms a tight cluster. Since every client in our dataset uses the same UK accountancy firm, these invoices are highly similar to each other. The rest of the data is distributed along an X-shaped manifold. The three biggest branches correspond to the three largest categories Purchases (green), Motor Repairs and Servicing (blue) and Petrol and Oil (orange). The fourth, smaller, branch is made up of Light, Heat & Power (red) Subscriptions (purple), Telephone, Fax & Internet (light green). Notably, SBERT, without any fine-tuning, picked up the semantic similarity that groups these last three categories as “recurring bills”. Figure A2 shows the association with Vendor ID.

Figure 2. Frozen transformer visualisation of the first three principal components of the representation space of pre-trained SBERT with input B. Note the overlap between Purchases (green) and Directors Loan Account (light purple).

Visualisation of the first three principal components of the representation space of pre-trained SBERT with input B

Figure A2. Visualisation of the first three principal components of the representation space of pre-trained SBERT with input B. Points coloured by Vendor name for the 20 most popular vendors, grey otherwise. Legend removed for data privacy.

DeBERTa has a larger embedding dimension with low effective dimension, especially for CLS pooling. This reflects the well-known fact that CLS embeddings tend to have semantically ‘meaningless’ dominant directions ([26]); here, the first PC is highly correlated (> 90%) with the norm of the embeddings for all input types.

Anisotropy

Extensive literature has demonstrated that, counter-intuitively, well-performing SLMs and LLMs do not use all of the embedding space; this is called anisotropy ([8]; [15]; [31]). We measure this globally using the cosine similarity between any two pairs of embeddings in Table 2 which quantifies the degree to which the embeddings exist along shared directions.

ModelABC
SBERT0.3650.2820.496
DeBERTa mean0.9730.9330.949
DeBERTa cls0.9990.9920.993

Table 2. Frozen transformers average cosine similarity between any embedding pairs by model and input type.

Consistent with the effective dimensionality results, both DeBERTa pooling strategies produce extremely high average cosine similarity, i.e. these sentence embeddings live in a narrow cone of the representation space. SBERT embeddings have substantially lower average cosine similarity, i.e., they are more homogeneously distributed, though still anisotropic (cosine similarity 0.3-0.5).

To analyse class-level structure, let CkC_k denote the set of indices in class kk, and define the within-class and between-class cosine similarity:

sˉw=1K∑k=1K1∣Ck∣(∣Ck∣−1)∑i,j∈Ck,i≠jcos⁡(Mi,Mj),\bar{s}_w = \frac{1}{K} \sum_{k=1}^{K} \frac{1}{\lvert C_k\rvert(\lvert C_k\rvert- 1)} \sum_{\substack{i,j \in C_k,\\ i \ne j}} \cos(M_i,M_j),
sˉb=1K∑k=1K1∣Ck∣(n−∣Ck∣)∑i∈Ck,j∉Ckcos⁡(Mi,Mj).\bar{s}_b = \frac{1}{K} \sum_{k=1}^{K} \frac{1}{\lvert C_k\rvert(n - \lvert C_k\rvert)} \sum_{\substack{i \in C_k,\\ j \notin C_k}} \cos(M_i,M_j).

Table 4 reports SBERT and DeBERTa-mean sˉw\bar{s}_w and sˉb\bar{s}_b with selected models, cluster definitions and origin; Table A2 shows every pairing, with example distributions in Figure A3.

TypeModelTrue labelsK-means clustering
UncenteredCentredUncenteredCentred
WithinBetweenWithinBetweenWithinBetweenWithinBetween
BSBERT0.4780.2490.0030.0000.7080.265-0.0150.000
BDeBERTa mean0.9380.9300.0130.0090.9420.8410.0020.001
CSBERT0.6410.4850.0030.0000.8230.476-0.0310.000
CDeBERTa mean0.9560.9480.0190.0110.9530.8640.0000.001

Table 4. Frozen transformer average within-class/cluster and between-class/cluster cosine similarity, using the true labels and the K-means clustering partition.

Within and between cosine similarity using SBERT Frozen transformer on input B for all-class average, Purchases, Accountancy Fee, and Light, Heat & Power

Figure A3. Within and between cosine similarity using SBERT Frozen transformer on input B, showing all-class average, Purchases, Accountancy Fee and Light, Heat & Power. With the exception of Accountancy Fee, they all overlap showing that the direction of the angular variation in embedding space is important for successful classification.

(a) Uncentered
TypeModelWithinBetween
ASBERT0.5030.348
ADeBERTa CLS0.9990.999
ADeBERTa mean0.9770.972
BSBERT0.4780.249
BDeBERTa CLS0.9950.993
BDeBERTa mean0.9380.930
CSBERT0.6410.485
CDeBERTa CLS0.9970.995
CDeBERTa mean0.9560.948
(b) Centred
TypeModelWithinBetween
ASBERT-0.0050.000
ADeBERTa CLS0.0000.000
ADeBERTa mean0.0000.002
BSBERT0.0030.000
BDeBERTa CLS0.0240.016
BDeBERTa mean0.0130.009
CSBERT0.0030.000
CDeBERTa CLS0.0410.029
CDeBERTa mean0.0190.011

Table A2. Average within-class and between-class cosine similarity, using the true labels.

As expected, the cosine similarity within classes is higher than that between classes (True labels, uncentered). Notably, Input C has both larger within and between cosine similarity than B (and A). This is not an artefact: the input texts in dataset C are genuinely more similar to one another, because the added field labels (Vendor name, Price, etc.) introduce seven identical words for each document. Unintuitively, Input C, the structured input, which would be helpful for a human reader, makes the inputs harder for a language model to distinguish.

Clustering

We now repeat the analysis of Section 3.2 with unsupervised clustering, instead of true labels. We perform K-means clustering of the embeddings and report the number of clusters ∣G∣\lvert G\rvert in Table 3 which yields the ‘most separable clusters’ as measured by mean silhouette score for G∈[1,60]G \in[1, 60]

ModelABC
SBERT545960
DeBERTa mean5222
DeBERTa CLS5222

Table 3. Frozen transformers number of KK-means clusters ∣G∣\lvert G\rvert selected by highest silhouette score, by model and input type.

The DeBERTa-CLS clustering on inputs B and C collapses to two tight (silhouette >0.6> 0.6) clusters, and cluster membership is highly correlated with embedding norm: the two clusters simply separate ‘large’ and ‘small’ embeddings. We discuss the collapse in more detail in Section 3.5.

SBERT embeddings are partitioned into a similar number of clusters for all input types, with tighter clusters for input A (silhouette score 0.5 vs. ∼0.3 for B and C). This clustering is strongly aligned with vendor identity: normalised mutual information (NMI) between vendor identity and cluster membership is >0.8> 0.8 across input types. NMI with true labels is lower (0.5-0.6), indicating some alignment between the clustering and the true labels. The clustering of input A is the most aligned with vendor identity as expected, since the vendor name is the only textual signal in input A. Inputs B and C clusterings are slightly more label-aligned, suggesting that adding the line-item text spreads the embeddings along directions aligned with the true accounting categories.

In the best-case scenario, SBERT with input B (SBERT-B), the clustering accounts for 61% of the uncertainty in the labels. Combined with the lowest average cosine similarity and the highest effective dimensionality (among SBERT variants), this shows that SBERT-B displays the best geometric properties, which we later show aligns with the classification results in Section 4.

Table 4 - clustering, uncentered - (full Table A3) reports the within- and between-cluster cosine similarity. Compared to the results with true labels, the within-cluster similarity is higher, while the between-cluster similarity is similar. This supports the hypothesis that the pre-trained embeddings identify the vendor name partition more sharply than the accounting category.

Local isotropy

Following [8], we recompute the within- and between-class (or cluster) after subtracting the class (or cluster) mean. In this local sense, the sentence embeddings are almost perfectly isotropic (Table 4).

[8] found local isotropy for token embedding. Our result extends theirs to sentence embeddings of invoices: the embedding space is a globally anisotropic manifold composed of locally isotropic clusters.

We further observe that centring by true labels and centring by KK-means clusters recover isotropy to a similar degree, suggesting that both partitions are, in a different way but to an equal degree, the cause of the anisotropy. This can be explained by the near-perfect many-to-one mapping between vendors and accounting labels. Businesses repeatedly purchase similar goods or services from each vendor, so the vendor partition and the label partition expose nearly the same directions of variation in the embedding space.

CLS collapse

DeBERTa CLS embeddings show a striking pattern across all diagnostics. Moving from input type A to B/C, the best number of clusters drops from 52 to 2, the effective dimensionality goes from 10 to 1, and the cosine similarity is >0.99> 0.99. The CLS embeddings exhibit a consistent and severe collapse under richer textual inputs (B/C). The first principal component and the clustering partition are highly correlated with the embedding norm: the CLS embeddings recover the norm rather than any semantic property ([26]).

A likely explanation is that the CLS token, unlike content tokens, attends nearly uniformly to all the other tokens in the sentence. As input length grows from A to B and C, the CLS representation is the result of iterated weighted averages over many high-dimensional embedding vectors, which completely dilutes the signal. Indeed, the sentence embedding constructed with mean pooling exhibits a less extreme but similar pattern. In the latter, the average is computed only once at the final layer rather than within every layer.

This collapse is consistent with the DeBERTa-CLS classifier degenerating to predicting only the larger classes (Section 4) while mean pooling retains some discriminative ability but still underperforms SBERT.

Classification

Frozen transformers and vendor baseline

For each model and input type, we freeze the encoder and train a linear classification head on top of the sentence embedding; for full implementation see A.1. In Section 3 we found that there was a strong association between the vendor identity and the labels, as businesses routinely repeat orders from the same suppliers. So we compare the language models to a parameter-free baseline that maps each vendor to its most frequent GL code in the training dataset and unseen vendors to the majority class. We also compare with a zero-shot open weight LLM Qwen3-4B baseline, for full implementation see A.1.

tbl:5 reports the results. Without any encoder training, the vendor mapping baseline outperforms both SBERT and DeBERTa and the LLM baseline on any input type. Although the pre-trained embedding space of both models is highly correlated with vendor identity, the linear head is not enough to learn the map. The vendor-to-label map is many-to-one: with hundreds of vendors grouped in 12 classes. While a single memorised vendor is enough for the baseline to classify a small category correctly, a linear head requires more samples to learn a reliable linear decision boundary.

Focusing on the transformers’ performance, we find that the geometric properties of Section 3 are associated with classification performance, with SBERT on input B substantially surpassing DeBERTa mean and CLS, respectively, and input B being the best across models. Unintuitively, the structured input (C), which would help a human learner, doesn’t improve the performance of a language model, due to the artificially increased within-corpus similarity described in Section 3.2. The full classification reports can be found in Table A4-tbl:A8. The classification layer trained on DeBERTa CLS embeddings ignores (∼0% accuracy) some of the smaller categories, consistent with the collapse highlighted in Section 3.5. SBERT on input B achieves F1 scores around 0.8 on all categories but one, regardless of the category size, showing that there is a genuine signal extractable from the embedding space, but not linearly accessible.

ClassInput A PInput A RInput A F1Input B PInput B RInput B F1Input C PInput C RInput C F1
Accountancy Fee0.91±0.020.91 \pm0.020.99±0.020.99 \pm0.020.95±0.010.95 \pm0.010.79±0.060.79 \pm0.060.99±0.020.99 \pm0.020.88±0.040.88 \pm0.040.64±0.060.64 \pm0.060.99±0.020.99 \pm0.020.78±0.050.78 \pm0.05
Cleaning of Premises0.74±0.090.74 \pm0.090.55±0.140.55 \pm0.140.63±0.130.63 \pm0.130.92±0.070.92 \pm0.070.65±0.080.65 \pm0.080.76±0.080.76 \pm0.080.93±0.100.93 \pm0.100.58±0.150.58 \pm0.150.71±0.140.71 \pm0.14
Directors’ Loan Account0.48±0.380.48 \pm0.380.11±0.080.11 \pm0.080.17±0.130.17 \pm0.130.53±0.360.53 \pm0.360.07±0.050.07 \pm0.050.12±0.080.12 \pm0.080.50±0.500.50 \pm0.500.00±0.060.00 \pm0.060.10±0.100.10 \pm0.10
Light, Heat & Power0.86±0.130.86 \pm0.130.71±0.240.71 \pm0.240.76±0.200.76 \pm0.200.94±0.070.94 \pm0.070.96±0.050.96 \pm0.050.95±0.020.95 \pm0.020.95±0.070.95 \pm0.070.95±0.080.95 \pm0.080.95±0.040.95 \pm0.04
Motor Repairs and Servicing0.77±0.040.77 \pm0.040.87±0.040.87 \pm0.040.82±0.040.82 \pm0.040.90±0.060.90 \pm0.060.91±0.030.91 \pm0.030.90±0.030.90 \pm0.030.92±0.020.92 \pm0.020.87±0.020.87 \pm0.020.90±0.020.90 \pm0.02
Petrol and Oil0.47±0.020.47 \pm0.020.81±0.040.81 \pm0.040.60±0.030.60 \pm0.030.81±0.070.81 \pm0.070.94±0.030.94 \pm0.030.87±0.040.87 \pm0.040.74±0.060.74 \pm0.060.92±0.020.92 \pm0.020.82±0.040.82 \pm0.04
Purchases0.86±0.040.86 \pm0.040.53±0.040.53 \pm0.040.66±0.040.66 \pm0.040.90±0.020.90 \pm0.020.89±0.030.89 \pm0.030.89±0.020.89 \pm0.020.90±0.030.90 \pm0.030.83±0.040.83 \pm0.040.86±0.030.86 \pm0.03
Stationery & Postage0.81±0.140.81 \pm0.140.69±0.090.69 \pm0.090.74±0.100.74 \pm0.100.91±0.130.91 \pm0.130.82±0.100.82 \pm0.100.85±0.060.85 \pm0.060.94±0.130.94 \pm0.130.71±0.100.71 \pm0.100.80±0.080.80 \pm0.08
Sub0.80±0.040.80 \pm0.040.70±0.070.70 \pm0.070.75±0.050.75 \pm0.050.93±0.010.93 \pm0.010.87±0.050.87 \pm0.050.90±0.030.90 \pm0.030.73±0.070.73 \pm0.070.94±0.030.94 \pm0.030.82±0.030.82 \pm0.03
Subscriptions0.59±0.060.59 \pm0.060.85±0.110.85 \pm0.110.70±0.080.70 \pm0.080.81±0.030.81 \pm0.030.82±0.090.82 \pm0.090.81±0.040.81 \pm0.040.90±0.040.90 \pm0.040.75±0.090.75 \pm0.090.81±0.070.81 \pm0.07
Telephone, Fax & Internet0.37±0.110.37 \pm0.110.73±0.170.73 \pm0.170.49±0.130.49 \pm0.130.76±0.110.76 \pm0.111.00±0.001.00 \pm0.000.86±0.070.86 \pm0.070.75±0.080.75 \pm0.080.96±0.050.96 \pm0.050.84±0.050.84 \pm0.05
Transport, Freight & Carriage0.60±0.110.60 \pm0.110.90±0.100.90 \pm0.100.72±0.110.72 \pm0.110.83±0.070.83 \pm0.070.89±0.090.89 \pm0.090.86±0.060.86 \pm0.060.94±0.080.94 \pm0.080.77±0.110.77 \pm0.110.84±0.070.84 \pm0.07

Table A4. Classification Report (precision, recall, F1) - SBERT. We report the mean±s.d. over 5 splits.

Fine Tuning

We fine-tune both language models by training the last 2, 4 or 6 layers with the classification head, both with and without adding the business-name prefix, e.g. ‘Fish and Chip restaurant’ or ‘Logistics and Transport’, to the inputs (+ b.n.). See A.1 for full implementation details. Results for input B are reported in Table 6 (Figure A4 shows the confusion matrix), and full classification reports for all inputs in Table A9-Table A13.

ModelAcc.M F1W F1
SBERT 2l0.945±\pm0.000.915±\pm0.010.944±\pm0.00
SBERT 4l0.950±\pm0.010.924±\pm0.020.950±\pm0.01
SBERT 6l0.950±\pm0.010.926±\pm0.010.949±\pm0.01
SBERT 2l b.n.0.961±\pm0.000.939±\pm0.010.960±\pm0.00
SBERT 4l b.n.0.961±\pm0.000.938±\pm0.020.961±\pm0.01
SBERT 6l b.n.0.961±\pm0.010.936±\pm0.020.960±\pm0.01
DeB. CLS 2l0.901±\pm0.020.855±\pm0.040.901±\pm0.02
DeB. CLS 4l0.381±\pm0.050.149±\pm0.040.323±\pm0.04
DeB. CLS 6l0.352±\pm0.100.131±\pm0.130.207±\pm0.04
DeB. CLS 2l b.n.0.913±\pm0.020.870±\pm0.030.915±\pm0.02
DeB. CLS 4l b.n.0.457±\pm0.190.210±\pm0.250.382±\pm0.24
DeB. CLS 6l b.n.0.344±\pm0.030.077±\pm0.040.256±\pm0.14
DeB. m 2l0.930±\pm0.010.894±\pm0.020.930±\pm0.01
DeB. m 4l0.779±\pm0.100.618±\pm0.190.757±\pm0.13
DeB. m 6l0.366±\pm0.060.192±\pm0.140.302±\pm0.14
DeB. m 2l b.n.0.950±\pm0.010.916±\pm0.020.950±\pm0.01
DeB. m 4l b.n.0.818±\pm0.040.673±\pm0.110.807±\pm0.05
DeB. m 6l b.n.0.480±\pm0.140.245±\pm0.040.389±\pm0.12

Table 6. Post fine-tuning accuracy, macro F1 and weighted F1 across fine-tuning configurations and number of unfrozen final layers (l) for input type B with/without business-nature prefix (+b.n.) reporting mean±\pms.d. over 5 splits. The best performance is in bold.

Figure A4. Confusion matrix for SBERT fine-tuned with 2 layers and business name/nature prefix.

ModelAcc.M F1W F1
SBERT - 2 l0.8800.8450.882
SBERT - 4 l0.8760.8450.874
SBERT - 6 l0.9170.8750.914
SBERT - 2 l + b.n.0.9030.8390.904
SBERT - 4 l + b.n.0.9310.8740.929
SBERT - 6 l + b.n.0.9290.8730.927
DeBERTa - 2 l0.8460.7740.842
DeBERTa - 4 l0.6640.4710.651
DeBERTa - 6 l0.4330.3090.411
DeBERTa - 2 l + b.n.0.8390.7660.843
DeBERTa - 4 l + b.n.0.4060.1080.302
DeBERTa - 6 l + b.n.0.3250.0410.159
DeBERTa mean - 2 l0.8690.8010.863
DeBERTa mean - 4 l0.6340.4420.601
DeBERTa mean - 6 l0.3250.0410.159
DeBERTa mean - 2 l + b.n.0.9220.8450.915
DeBERTa mean - 4 l + b.n.0.6840.4360.664
DeBERTa mean - 6 l + b.n.0.4420.1430.396

Table A9. Accuracy, macro F1 and weighted F1 across fine-tuning configurations and number of unfrozen final layers (l) for input type A with and without business- nature prefix (+b.n.), for a single split. The best performance is in bold.

PrecisionRecallF1
Accountancy Fee0.98±0.040.98 \pm0.040.99±0.020.99 \pm0.020.99±0.020.99 \pm0.02
Cleaning of Premises0.98±0.040.98 \pm0.040.99±0.020.99 \pm0.020.99±0.020.99 \pm0.02
Directors’ Loan Account0.77±0.060.77 \pm0.060.64±0.20.64 \pm0.20.68±0.090.68 \pm0.09
Light, Heat & Power1.00±0.001.00 \pm0.000.98±0.040.98 \pm0.040.99±0.020.99 \pm0.02
Motor Repairs and Servicing0.98±0.010.98 \pm0.010.95±0.020.95 \pm0.020.97±0.010.97 \pm0.01
Petrol and Oil0.98±0.030.98 \pm0.030.97±0.020.97 \pm0.020.98±0.020.98 \pm0.02
Purchases0.96±0.010.96 \pm0.010.99±0.010.99 \pm0.010.97±0.010.97 \pm0.01
Stationery & Postage0.86±0.100.86 \pm0.100.80±0.180.80 \pm0.180.82±0.130.82 \pm0.13
Sub0.96±0.050.96 \pm0.050.95±0.030.95 \pm0.030.95±0.020.95 \pm0.02
Subscriptions0.93±0.040.93 \pm0.040.95±0.050.95 \pm0.050.94±0.020.94 \pm0.02
Telephone, Fax & Internet0.96±0.100.96 \pm0.100.96±0.050.96 \pm0.050.96±0.050.96 \pm0.05
Transport, Freight & Carriage0.94±0.080.94 \pm0.081.00±0.001.00 \pm0.000.97±0.050.97 \pm0.05

Table A13. Classification Report (precision, recall, F1) - DeBERTa fine-tuned with 2 unfrozen layers + business name prefix. We report the mean±s.d. over 5 splits.

Fine-tuning substantially improves the performance over the head-only baselines, closing the gap and surpassing the vendor baseline.

Fine-tuning SBERT substantially improves performance in the Director’s loan account (DLA) category. DLA and Purchases are financially different categories for which invoices may be identical. Loosely, the difference does not lie in the goods or services bought, but in whether the director or the business paid, and whether the purchase is in furtherance of the business. The per-class F1 reaches 0.53 (6 layers no b.n.) and 0.71 adding the business name prefix (2 layers + b.n.), an improvement of 27 percentage points over vendor baseline. Similarly, fine-tuned SBERT improves by 10% on the vendor baseline on the Stationery & Postage category. In Section 4.1, we showed that vendor name does account for a large part of the variation in invoices, but the rich text description is essential on the long tail of ‘hard invoices’, which is significant in a domain with inherent high-class imbalance.

Despite being far larger, the zero-shot LLM (Qwen3-4B) baseline underperformed SBERT both with frozen encoder and especially after fine-tuning (+0.55 M F1). This is consistent with the literature ([7]), and corroborates our hypothesis that an in-house fine-tuned SLM is preferable to an off-the-shelf LLM in this computationally constrained setting.

DeBERTa is less robust, fine-tuning successfully only at depth 2. This is most likely due to the large number of DeBERTa parameters relative to our sample size. Similarly to the geometric properties,

DeBERTa CLSDeBERTa meanSBERTVendor baselineLLM baseline
ABCABCABC
Acc.0.39±\pm0.020.62±\pm0.020.45±\pm0.040.51±\pm0.020.63±\pm0.020.62±\pm0.020.70±\pm0.040.87±\pm0.010.83±\pm0.020.89±\pm0.010.52±\pm0.02
M F10.18±\pm0.080.55±\pm0.020.33±\pm0.060.39±\pm0.030.53±\pm0.040.49±\pm0.020.67±\pm0.060.80±\pm0.010.77±\pm0.020.87±\pm0.010.39±\pm0.02
W F10.31±\pm0.050.62±\pm0.020.44±\pm0.040.49±\pm0.010.63±\pm0.010.62±\pm0.020.69±\pm0.040.85±\pm0.010.82±\pm0.020.89±\pm0.010.52±\pm0.02

caption: tbl:5: Frozen Transformers accuracy, macro F1 and weighted F1 for classification with frozen transformers for each model and input type. The LLM baseline is zero-shot, and the transformers use a trained linear head. We report the mean±\pms.d. over 5 splits. The best performance is in bold, the second best is underlined.

:::

DeBERTa with mean pooling shows the same qualitative pattern as DeBERTa CLS but less extreme, and it still underperforms SBERT.

Figure 3 shows the first three principal components of the SBERT embeddings after fine-tuning the last two layers. Compared to the X shaped manifold of Figure 2, fine-tuning has ‘unravelled’ the manifold that now qualitatively resembles a simplex with vertices at Petrol & Oil (orange), Purchases (green), Motor Repairs and Servicing (blue), and the ‘recurring bills’ which includes for example Accountancy Fee, Subscriptions and Telephone, Fax & Internet. DLA, which is semantically close to Purchases, is now much better separated from it, consistent with the large per-class F1 improvement. A simplex geometry is considered to be ‘optimal’ for classification ([?]) because the classes fall on the vertices and irregularities pull points towards the centre, opening a pathway to uncertainty calibration ([25]), which we leave for future work.

Figure 3. Post fine-tuning visualisation of the first three principal components of the representation space of SBERT with input B. Compared to Figure 2, note that classes appear more distributed over the sphere, with Purchases (green) in the same direction but separated from Directors Loan Accounts (light purple).

Generalise to new clients

In Section 4.2, we stratified the training and testing data per category due to high class imbalance, so a given client’s data likely appeared in both sets. We now investigate performance for a previously unseen client. For practitioners, this simulates onboarding a new client.

We leave one client, the ‘test client’, out of our dataset at a time and split the remaining data 80/20 into training and validation sets, respectively. Then we repeat the experiment, injecting a fraction ϵ\epsilon of the ‘test client’ data in the train/val set (and removing it from the test set). We fine-tune from scratch the best configurations of SBERT and DeBERTa from Section 4.2 for ϵ∈[0,0.8]\epsilon\in[0, 0.8].

Figure 4 reports the average macro F1 score on the ‘testing client’ as a function of ϵ\epsilon. For a new client, the vendor baseline, which was competitive in-distribution, severely underperforms both models, since performance depends entirely on the overlap between the new client’s suppliers and those seen in training. Between SBERT and DeBERTa, the former reaches higher F1 across all values of ϵ\epsilon: at ϵ=0\epsilon= 0, corresponding to a fully unseen client, SBERT achieves an F1 10% higher than DeBERTa. This shows that the value of learned representations relies on their generalisation abilities: line-item text carries semantic signal that transfers to unseen vendors. The gap between SBERT and DeBERTa highlights the extent to which that signal is more easily recoverable from semantically meaningful representations with better geometry.

Left-out client experiment showing Macro F1 as a function of injection proportion

Figure 4. Left-out client experiment, Macro F1 for fine-tuned SBERT and DeBERTa as a function of the proportion of ‘new client’ data injected into the training set (solid line). The baselines (dashed lines) are from Section 4.2.

Both models need a warm-up period before reaching reliable performance; to achieve an F1 of 0.9 or higher, SBERT needs, on average, 100 client-specific data points, whereas DeBERTa needs ∼\sim75% more client-specific data (174 data points). Beyond the warm-up region, both SBERT and DeBERTa continue to improve with ϵ\epsilon and converge towards their fine-tuned baselines obtained in Section 4.2 (dashed lines in Figure 4).

This pattern is consistent with the geometric analysis and the overall findings of this paper. SBERT’s higher-dimensional, less anisotropic space utilises more independent directions where a client’s invoices can be separated from a few labelled examples. The generalisation gap at ϵ=0\epsilon= 0 and the faster warm-up confirm that SBERT is the more robust choice in our setting, corroborating that pre-trained embedding geometry is linked to fine-tuned accuracy and robustness.

Conclusion

Whilst this experiment uses a small dataset covering a subset of all existing categories, it is a promising result for an in-house deployment where cost, data confidentiality, and interpretability matter. We explored geometric properties which demonstrated that previous token-level findings, that embeddings are globally anisotropic with locally isotropic clusters, apply to the sentence embedding of invoices.

While exploiting vendor identity alone reaches respectable performance, SLM became truly useful once fine-tuned, especially on smaller categories and for newly onboarded clients. This improvement when using full invoice content implies that ‘line item’ text has been at least partially mapped to the label through semantic meaning. Moreover, whilst both models achieved similar high accuracy under naive comparison, sentence embedding produced more robust embedding that generalised better than token embeddings, consistent with the hypothesis that geometry relates to both performance and robustness.

Fine-tuned performance on the structured Input C is comparable to Input B, which is particularly relevant for practitioners. Since the structured input remains uninformative after fine-tuning, we conclude that omitting labelling of fields in the free text OCR is sufficient. This removes an additional human-in-the-loop step, resulting in a reduction in cost and complexity. Input B requires only a single human-in-the-loop at the end, which is irreducible to comply with regulations.

These results suggest a promising direction for future research towards an uncertainty-aware model to identify the data that is confidently assigned with interpretable reasons, focusing expert attention where it is most needed.

Limitations

Our study is based on a single confidential dataset from one UK accountancy firm, comprising 2,168 invoices across 12 categories from seven clients. Real, labelled invoice data of this kind is difficult to obtain, and this corpus reflects the access we were able to secure; we acknowledge that the sample is modest. Our results should be seen as evidence that an in-house SLM pipeline is viable in this setting, but they may not transfer directly to firms operating with different accounting conventions, in different domains or countries.

Our geometric analysis, and its connection to classification performance, is based on a comparison of two model families. To further explore this connection and make an explanatory claim, more model types and additional experiments should be analysed. We used a single set of standard training parameters for both SBERT and DeBERTa for a consistent comparison; however, this study doesn’t include an exhaustive search of the hyperparameter space.

Ethical considerations

The data analysed in this paper is confidential: it is commercially sensitive and may contain identifying information about businesses and their suppliers. The data has been used under the firm’s data-handling agreements, and it will not be released. Where representations are visualised, vendor identities and legends are removed for data privacy.

We do not advocate for a fully automated pipeline, and we stress the importance of humans-in-the-loop with professional accounting skills. This material is intended for academic and educational purposes only, and the authors and their institutions disclaim liability for any outcomes arising from its use.

We partially release the code, removing any identifying information and preserving part of the code to protect the firm’s IP.

Appendix

Experimental details

Frozen transformers. For each model and input type, we freeze the encoder and train a linear classification head on top of the sentence embedding. We use a cross-entropy loss weighted by inverse class frequency, the AdamW optimiser with 5e−55\mathrm{e}{-5} learning rate and linear rate, batch size 16, and up to 60 epochs with early stopping on validation weighted F1. The dataset is split 60/20/20 into train, validation and test sets with stratified sampling. For DeBERTa CLS, we use the model’s standard sequence-classification head; for both SBERT and DeBERTa, we use standard mean pooling.

LLM baseline. We implement a baseline for zero-shot classification using Qwen3-4B (Qwen Team, 2025), a small model matching the in-house deployment computation resources constraint. Due to data confidentiality we excluded API-hosted LLMs, which could improve performance. We classify each invoice independently with the following prompt: You are an expert UK bookkeeper assigning invoices to General Ledger categories. Choose exactly one category from the list. Definitions: {}. Invoice: {}. Only answer with the name of the category, do not answer with any other text. The category definitions were provided by the firm (see Table A1), and the invoice text is as in input B. We disable thinking mode and use greedy decoding for reproducibility. We used a deterministic parser to map the model outputs to a canonical label and count as error outputs that couldn’t be parsed to a category.

Fine tuning We fine-tune both language models by training the last 2, 4 or 6 layers with the classification head. We use a smaller learning rate of 1e−51\mathrm{e}{-5} for the transformer layers than for the classification head (5e−55\mathrm{e}{-5}), and optimise the two parameter groups jointly with AdamW and add 10% linear warm-up which helps DeBERTa to avoid early divergence. Each configuration is run with and without the business-name prefix (+ b.n.). The rest of the parameters are the same.

Computing resources. Fine-tuning was performed on an NVIDIA RTX PRO 500 Black with 6 GB VRAM, using CUDA 13.2 and driver version 595.71.05. Finetuning SBERT (2 layers + b.n.) took about 10 minutes for 46 epochs, and DeBERTa (2 layers + b.n.) took approximately 15 minutes for 31 epochs. An inference pass on the 434 test invoices for Qwen3-4B took approximately 5 minutes.

Supplementary Figures

Supplementary Tables

(a) Uncentered
TypeModelWithinBetween
ASBERT0.8200.341
ADeBERTa CLS0.9990.999
ADeBERTa mean0.9910.970
BSBERT0.7080.265
BDeBERTa CLS0.9970.981
BDeBERTa mean0.9420.841
CSBERT0.8230.476
CDeBERTa CLS0.9980.986
CDeBERTa mean0.9530.864
(b) Centred
TypeModelWithinBetween
ASBERT-0.0050.000
ADeBERTa CLS0.0000.000
ADeBERTa mean0.0000.002
BSBERT0.0030.000
BDeBERTa CLS0.0240.016
BDeBERTa mean0.0130.009
CSBERT0.0030.000
CDeBERTa CLS0.0410.029
CDeBERTa mean0.0190.011

Table A3. Average within-cluster and between-cluster cosine similarity.

ClassInput A PInput A RInput A F1Input B PInput B RInput B F1Input C PInput C RInput C F1
Accountancy Fee0.15±0.150.15 \pm0.150.59±0.540.59 \pm0.540.23±0.230.23 \pm0.230.81±0.080.81 \pm0.080.97±0.020.97 \pm0.020.88±0.050.88 \pm0.050.61±0.240.61 \pm0.240.83±0.040.83 \pm0.040.68±0.170.68 \pm0.17
Cleaning of Premises0.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.56±0.270.56 \pm0.270.80±0.040.80 \pm0.040.62±0.170.62 \pm0.170.31±0.190.31 \pm0.190.71±0.220.71 \pm0.220.41±0.190.41 \pm0.19
Directors’ Loan Account0.01±0.020.01 \pm0.020.03±0.060.03 \pm0.060.01±0.030.01 \pm0.030.15±0.290.15 \pm0.290.04±0.060.04 \pm0.060.06±0.100.06 \pm0.100.20±0.450.20 \pm0.450.01±0.030.01 \pm0.030.03±0.060.03 \pm0.06
Light, Heat & Power0.22±0.440.22 \pm0.440.16±0.280.16 \pm0.280.10±0.140.10 \pm0.140.57±0.210.57 \pm0.210.65±0.100.65 \pm0.100.60±0.150.60 \pm0.150.10±0.190.10 \pm0.190.20±0.280.20 \pm0.280.13±0.210.13 \pm0.21
Motor Repairs and Servicing0.52±0.090.52 \pm0.090.65±0.140.65 \pm0.140.56±0.050.56 \pm0.050.78±0.050.78 \pm0.050.61±0.040.61 \pm0.040.68±0.030.68 \pm0.030.51±0.040.51 \pm0.040.55±0.060.55 \pm0.060.53±0.030.53 \pm0.03
Petrol and Oil0.05±0.110.05 \pm0.110.06±0.140.06 \pm0.140.05±0.120.05 \pm0.120.52±0.140.52 \pm0.140.83±0.080.83 \pm0.080.62±0.060.62 \pm0.060.44±0.100.44 \pm0.100.67±0.170.67 \pm0.170.51±0.070.51 \pm0.07
Purchases0.52±0.140.52 \pm0.140.55±0.210.55 \pm0.210.49±0.060.49 \pm0.060.86±0.030.86 \pm0.030.55±0.090.55 \pm0.090.67±0.060.67 \pm0.060.84±0.060.84 \pm0.060.43±0.070.43 \pm0.070.57±0.060.57 \pm0.06
Stationery & Postage0.16±0.230.16 \pm0.230.13±0.200.13 \pm0.200.13±0.180.13 \pm0.180.44±0.120.44 \pm0.120.29±0.130.29 \pm0.130.33±0.110.33 \pm0.110.05±0.070.05 \pm0.070.07±0.100.07 \pm0.100.06±0.080.06 \pm0.08
Sub0.29±0.290.29 \pm0.290.30±0.280.30 \pm0.280.29±0.270.29 \pm0.270.60±0.070.60 \pm0.070.80±0.070.80 \pm0.070.68±0.050.68 \pm0.050.53±0.100.53 \pm0.100.70±0.140.70 \pm0.140.59±0.050.59 \pm0.05
Subscriptions0.08±0.120.08 \pm0.120.07±0.140.07 \pm0.140.07±0.130.07 \pm0.130.44±0.100.44 \pm0.100.55±0.230.55 \pm0.230.46±0.100.46 \pm0.100.37±0.180.37 \pm0.180.25±0.220.25 \pm0.220.26±0.160.26 \pm0.16
Telephone, Fax & Internet0.42±0.530.42 \pm0.530.42±0.400.42 \pm0.400.34±0.380.34 \pm0.380.69±0.200.69 \pm0.200.67±0.050.67 \pm0.050.66±0.110.66 \pm0.110.33±0.240.33 \pm0.240.27±0.220.27 \pm0.220.26±0.160.26 \pm0.16
Transport, Freight & Carriage0.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.35±0.020.35 \pm0.020.40±0.180.40 \pm0.180.36±0.100.36 \pm0.100.21±0.190.21 \pm0.190.12±0.080.12 \pm0.080.14±0.090.14 \pm0.09

Table A5. Classification Report (precision, recall, F1) - DeBERTa CLS. We report the mean±s.d. over 5 splits.

ClassInput A PInput A RInput A F1Input B PInput B RInput B F1Input C PInput C RInput C F1
Accountancy Fee0.46±0.070.46 \pm0.071.00±0.001.00 \pm0.000.63±0.070.63 \pm0.070.34±0.050.34 \pm0.050.99±0.020.99 \pm0.020.51±0.050.51 \pm0.050.37±0.060.37 \pm0.060.92±0.100.92 \pm0.100.52±0.070.52 \pm0.07
Cleaning of Premises0.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.74±0.060.74 \pm0.060.36±0.090.36 \pm0.090.48±0.090.48 \pm0.090.85±0.220.85 \pm0.220.29±0.080.29 \pm0.080.43±0.110.43 \pm0.11
Directors’ Loan Account0.22±0.220.22 \pm0.220.04±0.040.04 \pm0.040.07±0.060.07 \pm0.060.23±0.200.23 \pm0.200.08±0.060.08 \pm0.060.11±0.080.11 \pm0.080.07±0.090.07 \pm0.090.03±0.040.03 \pm0.040.04±0.050.04 \pm0.05
Light, Heat & Power0.11±0.060.11 \pm0.060.18±0.110.18 \pm0.110.12±0.050.12 \pm0.050.55±0.170.55 \pm0.170.47±0.240.47 \pm0.240.50±0.210.50 \pm0.210.43±0.080.43 \pm0.080.58±0.220.58 \pm0.220.49±0.130.49 \pm0.13
Motor Repairs and Servicing0.62±0.070.62 \pm0.070.72±0.080.72 \pm0.080.66±0.030.66 \pm0.030.73±0.020.73 \pm0.020.69±0.070.69 \pm0.070.71±0.040.71 \pm0.040.69±0.050.69 \pm0.050.68±0.070.68 \pm0.070.68±0.030.68 \pm0.03
Petrol and Oil0.36±0.040.36 \pm0.040.46±0.050.46 \pm0.050.40±0.040.40 \pm0.040.65±0.060.65 \pm0.060.77±0.050.77 \pm0.050.70±0.030.70 \pm0.030.72±0.050.72 \pm0.050.74±0.050.74 \pm0.050.73±0.050.73 \pm0.05
Purchases0.60±0.060.60 \pm0.060.51±0.080.51 \pm0.080.55±0.040.55 \pm0.040.81±0.040.81 \pm0.040.64±0.050.64 \pm0.050.71±0.040.71 \pm0.040.80±0.020.80 \pm0.020.65±0.050.65 \pm0.050.72±0.030.72 \pm0.03
Stationery & Postage0.80±0.450.80 \pm0.450.20±0.160.20 \pm0.160.31±0.230.31 \pm0.230.78±0.220.78 \pm0.220.33±0.210.33 \pm0.210.43±0.190.43 \pm0.190.56±0.290.56 \pm0.290.20±0.090.20 \pm0.090.29±0.140.29 \pm0.14
Sub0.74±0.080.74 \pm0.080.43±0.050.43 \pm0.050.54±0.030.54 \pm0.030.85±0.040.85 \pm0.040.73±0.060.73 \pm0.060.78±0.030.78 \pm0.030.56±0.040.56 \pm0.040.76±0.050.76 \pm0.050.64±0.040.64 \pm0.04
Subscriptions0.40±0.110.40 \pm0.110.49±0.100.49 \pm0.100.43±0.060.43 \pm0.060.41±0.090.41 \pm0.090.55±0.060.55 \pm0.060.46±0.080.46 \pm0.080.55±0.090.55 \pm0.090.49±0.090.49 \pm0.090.52±0.080.52 \pm0.08
Telephone, Fax & Internet0.58±0.260.58 \pm0.260.53±0.150.53 \pm0.150.52±0.140.52 \pm0.140.67±0.160.67 \pm0.160.67±0.210.67 \pm0.210.66±0.160.66 \pm0.160.63±0.180.63 \pm0.180.64±0.210.64 \pm0.210.63±0.180.63 \pm0.18
Transport, Freight & Carriage0.59±0.140.59 \pm0.140.28±0.080.28 \pm0.080.37±0.090.37 \pm0.090.31±0.160.31 \pm0.160.26±0.120.26 \pm0.120.28±0.140.28 \pm0.140.26±0.100.26 \pm0.100.21±0.090.21 \pm0.090.23±0.090.23 \pm0.09

Table A6. Classification Report (precision, recall, F1) - DeBERTa mean. We report the mean±s.d. over 5 splits.

ClassPrecisionRecallF1-score
Accountancy Fee0.22±0.050.22 \pm0.050.23±0.050.23 \pm0.050.23±0.050.23 \pm0.05
Cleaning of Premises0.68±0.220.68 \pm0.220.33±0.080.33 \pm0.080.43±0.100.43 \pm0.10
Directors’ Loan Account0.00±0.000.00 \pm0.000.00±0.000.00 \pm0.000.00±0.000.00 \pm0.00
Light, Heat & Power0.29±0.020.29 \pm0.021.00±0.001.00 \pm0.000.45±0.030.45 \pm0.03
Motor Repairs and Servicing0.58±0.080.58 \pm0.080.36±0.050.36 \pm0.050.44±0.060.44 \pm0.06
Petrol and Oil0.93±0.040.93 \pm0.040.62±0.050.62 \pm0.050.75±0.040.75 \pm0.04
Purchases0.79±0.010.79 \pm0.010.85±0.030.85 \pm0.030.82±0.020.82 \pm0.02
Stationery & Postage0.67±0.200.67 \pm0.200.29±0.170.29 \pm0.170.37±0.170.37 \pm0.17
Sub0.47±0.450.47 \pm0.450.03±0.030.03 \pm0.030.05±0.050.05 \pm0.05
Subscriptions0.17±0.020.17 \pm0.020.46±0.090.46 \pm0.090.25±0.040.25 \pm0.04
Telephone, Fax & Internet0.82±0.170.82 \pm0.170.35±0.040.35 \pm0.040.48±0.060.48 \pm0.06
Transport, Freight & Carriage0.30±0.020.30 \pm0.020.50±0.070.50 \pm0.070.37±0.030.37 \pm0.03

Table A6.

ClassPrecisionRecallF1-score
Accountancy Fee1.00±0.001.00 \pm0.000.99±0.020.99 \pm0.021.00±0.011.00 \pm0.01
Cleaning of Premises0.88±0.160.88 \pm0.160.75±0.080.75 \pm0.080.80±0.090.80 \pm0.09
Directors’ Loan Account0.96±0.090.96 \pm0.090.29±0.120.29 \pm0.120.44±0.150.44 \pm0.15
Light, Heat & Power0.95±0.050.95 \pm0.050.98±0.040.98 \pm0.040.96±0.020.96 \pm0.02
Motor Repairs and Servicing0.99±0.010.99 \pm0.010.92±0.020.92 \pm0.020.95±0.010.95 \pm0.01
Petrol and Oil0.77±0.040.77 \pm0.040.88±0.030.88 \pm0.030.82±0.030.82 \pm0.03
Purchases0.82±0.020.82 \pm0.020.93±0.020.93 \pm0.020.87±0.010.87 \pm0.01
Stationery & Postage0.93±0.060.93 \pm0.060.82±0.170.82 \pm0.170.86±0.100.86 \pm0.10
Sub1.00±0.001.00 \pm0.000.90±0.040.90 \pm0.040.95±0.020.95 \pm0.02
Subscriptions0.98±0.030.98 \pm0.030.91±0.090.91 \pm0.090.94±0.050.94 \pm0.05
Telephone, Fax & Internet1.00±0.001.00 \pm0.000.91±0.090.91 \pm0.090.95±0.050.95 \pm0.05
Transport, Freight & Carriage1.00±0.001.00 \pm0.000.99±0.020.99 \pm0.020.99±0.010.99 \pm0.01

Table A7. Classification report for the LLM baseline, mean±s.d. over 5 splits.

tbl:A8: Classification report for the vendor baseline. We report the mean±s.d. over 5 splits.

ModelAcc.M F1W F1
SBERT - 2 l0.9420.8920.939
SBERT - 4 l0.9450.8940.938
SBERT - 6 l0.9380.8980.934
SBERT - 2 l + b.n.0.9400.8950.937
SBERT - 4 l + b.n.0.9590.9230.956
SBERT - 6 l + b.n.0.9590.9310.956
DeBERTa - 2 l0.8780.7760.872
DeBERTa - 4 l0.5350.2470.494
DeBERTa - 6 l0.3250.0410.159
DeBERTa - 2 l + b.n.0.8870.8120.884
DeBERTa - 4 l + b.n.0.5370.1810.448
DeBERTa - 6 l + b.n.0.3250.0410.159
DeBERTa mean - 2 l0.9170.8610.914
DeBERTa mean - 4 l0.7810.6710.783
DeBERTa mean - 6 l0.3530.0730.214
DeBERTa mean - 2 l + b.n.0.9330.8860.930
DeBERTa mean - 4 l + b.n.0.7930.5510.772
DeBERTa mean - 6 l + b.n.0.3850.1550.261

Table A10. Accuracy, macro F1 and weighted F1 across fine-tuning configurations and number of unfrozen final layers (l) for input type C with and without business- nature prefix (+b.n.), for a single split. The best performance is in bold.

PrecisionRecallF1
Accountancy Fee1.00±0.001.00 \pm0.000.99±0.020.99 \pm0.021.00±0.011.00 \pm0.01
Cleaning of Premises0.83±0.090.83 \pm0.090.91±0.110.91 \pm0.110.86±0.080.86 \pm0.08
Directors’ Loan Account0.86±0.050.86 \pm0.050.61±0.120.61 \pm0.120.71±0.070.71 \pm0.07
Light, Heat & Power0.92±0.090.92 \pm0.090.98±0.040.98 \pm0.040.95±0.040.95 \pm0.04
Motor Repairs and Servicing0.97±0.020.97 \pm0.020.96±0.010.96 \pm0.010.97±0.010.97 \pm0.01
Petrol and Oil0.96±0.020.96 \pm0.020.97±0.020.97 \pm0.020.96±0.010.96 \pm0.01
Purchases0.97±0.000.97 \pm0.000.98±0.010.98 \pm0.010.98±0.010.98 \pm0.01
Stationery & Postage0.94±0.080.94 \pm0.080.98±0.050.98 \pm0.050.96±0.040.96 \pm0.04
Sub0.96±0.020.96 \pm0.020.98±0.020.98 \pm0.020.97±0.020.97 \pm0.02
Subscriptions0.97±0.040.97 \pm0.040.98±0.020.98 \pm0.020.98±0.020.98 \pm0.02
Telephone, Fax & Internet0.95±0.070.95 \pm0.071.00±0.001.00 \pm0.000.97±0.040.97 \pm0.04
Transport, Freight & Carriage0.96±0.070.96 \pm0.070.99±0.020.99 \pm0.020.97±0.050.97 \pm0.05

Table A11. Classification Report (precision, recall, F1) - SBERT fine-tuned with 2 unfrozen layers + business name prefix. We report the mean±s.d. over 5 splits.

PrecisionRecallF1
Accountancy Fee1.00±0.001.00 \pm0.000.99±0.020.99 \pm0.021.00±0.011.00 \pm0.01
Cleaning of Premises0.83±0.130.83 \pm0.130.91±0.110.91 \pm0.110.86±0.080.86 \pm0.08
Directors’ Loan Account0.71±0.110.71 \pm0.110.44±0.140.44 \pm0.140.53±0.080.53 \pm0.08
Light, Heat & Power0.94±0.070.94 \pm0.071.00±0.001.00 \pm0.000.97±0.040.97 \pm0.04
Motor Repairs and Servicing0.99±0.010.99 \pm0.010.95±0.000.95 \pm0.000.97±0.010.97 \pm0.01
Petrol and Oil0.96±0.010.96 \pm0.010.97±0.020.97 \pm0.020.97±0.010.97 \pm0.01
Purchases0.94±0.020.94 \pm0.020.97±0.030.97 \pm0.030.95±0.010.95 \pm0.01
Stationery & Postage0.94±0.080.94 \pm0.080.98±0.050.98 \pm0.050.96±0.040.96 \pm0.04
Sub0.96±0.010.96 \pm0.010.99±0.010.99 \pm0.010.97±0.010.97 \pm0.01
Subscriptions0.98±0.020.98 \pm0.020.96±0.040.96 \pm0.040.97±0.030.97 \pm0.03
Telephone, Fax & Internet0.97±0.050.97 \pm0.051.00±0.001.00 \pm0.000.98±0.020.98 \pm0.02
Transport, Freight & Carriage0.96±0.040.96 \pm0.040.99±0.020.99 \pm0.020.97±0.020.97 \pm0.02

Table A12. Classification Report (precision, recall, F1) - SBERT fine-tuned with 6 unfrozen layers. We report the mean±s.d. over 5 splits.

References

  1. [1]Aluffi Pietro Alessandro, Brandi Jess, Marya Bazzi, Kate Kennedy, Matt Arderne, Daniel Rodrigues, and Martin Lotz. 2025. Categorising SME bank transactions with machine learning and synthetic data generation. arXiv preprint arXiv:2508.05425.arxiv.org/abs/2508.05425
  2. [2]Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. 2019. A convergence theory for deep learning via over-parameterization. In International conference on machine learning, pages 242–252. PMLR.
  3. [3]Usman Anwar, Abulhair Saparov, Javier Rando, Daniel Paleka, Miles Turpin, Peter Hase, Ekdeep Singh Lubana, Erik Jenner, Stephen Casper, Oliver Sourbut, Benjamin L. Edelman, Zhaowei Zhang, Mario Günther, Anton Korinek, Jose Hernandez-Orallo, Lewis Hammond, Eric J Bigelow, Alexander Pan, Lauro Langosco, and 23 others. 2024. Foundational challenges in assuring alignment and safety of large language models. Transactions on Machine Learning Research. Survey Certification, Expert Certification.arxiv.org/abs/2404.09932
  4. [4]Chiara Bardelli, Alessandro Rondinelli, Ruggero Vecchio, and Silvia Figini. 2020. Automatic electronic invoice classification using machine learning models. Machine Learning and Knowledge Extraction, 2(4):617–629.
  5. [5]Peter Belcak, Greg Heinrich, Shizhe Diao, Yonggan Fu, Xin Dong, Saurav Muralīdharan, Yingyan Celine Lin, and Pavlo Molchanov. 2025. Small language models are the future of agentic ai. arXiv preprint arXiv:2506.02153.arxiv.org/abs/2506.02153
  6. [6]David Berghaus, Armin Berger, Lars Hillebrand, Kostadin Cvejoski, and Rafet Sifa. 2025. Multi-modal vision vs. text-based parsing: Benchmarking llm strategies for invoice processing. pages 2519–2526.arxiv.org/abs/2509.04469
  7. [7]Martin Juan José Bucher and Marco Martini. 2024. Fine-tuned’small’LLMs (still) significantly outperform zero-shot generative AI models in text classification. arXiv preprint arXiv:2406.08660.arxiv.org/abs/2406.08660
  8. [8]Xingyu Cai, Jiajia Huang, Yuchen Bian, and Kenneth Church. 2021. Isotropy in the contextual embedding space: Clusters and manifolds. In International conference on learning representations.
  9. [9]Yasheng Chen, Xian Huang, and Jing Cao. 2025. A framework for applying machine learning and natural language processing methods to accounting recognition. Accounting Horizons, 39(4):45–55.
  10. [10]Wei Wen Chi, Tiong Yew Tang, Narishah Mohamed Salleh, Muadh Mukred, Hussain AlSalman, and Muhammad Zohaib. 2024. Data augmentation with semantic enrichment for deep learning invoice text classification. IEEE Access, 12:57326–57344.DOI
  11. [11]Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D Manning. 2019. What does BERT look at? an analysis of BERT’s attention. In Proceedings of the 2019 ACL workshop BlackboxNLP: analyzing and interpreting neural networks for NLP, pages 276–286.
  12. [12]Badhan Chandra Das, M Hadi Amini, and Yanzhao Wu. 2025. Security and privacy challenges of large language models: A survey. ACM Computing Surveys, 57(6):1–39.
  13. [13]Finale Doshi-Velez and Been Kim. 2017. Towards a rigorous science of interpretable machine learning. arXiv preprint arXiv:1702.08608.
  14. [14]Kawin Ethayarajh. 2019. How contextual are contextualized word representations? comparing the geometry of BERT, ELMo, and GPT-2 embeddings. arXiv preprint arXiv:1909.00512.arxiv.org/abs/1909.00512
  15. [15]Jun Gao, Di He, Xu Tan, Tao Qin, Liwei Wang, and Tieyan Li. 2019. Representation degeneration problem in training natural language generation models. In International Conference on Learning Representations.arxiv.org/abs/1907.12009
  16. [16]Silvia Garcia-Mendez, Milagros Fernandez-Gavilanes, Jonathan Juncal-Martinez, Francisco Javier González-Castaño, and Óscar Barba Seara. 2020. Identifying banking transaction descriptions via support vector machine short-text classification based on a specialized labelled corpus. IEEE Access, 8:61642–61655.
  17. [17]Robert Geirhos, Jörn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias Bethge, and Felix A. Wichmann. 2020. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673.
  18. [18]Katharina Hämmerl, Alina Fastowski, Jindřich Libovický, and Alexander Fraser. 2023. Exploring anisotropy and outliers in multilingual language models for cross-lingual semantic sentence similarity. In Findings of the Association for Computational Linguistics: ACL 2023, pages 7023–7037.arxiv.org/abs/2306.00458
  19. [19]Pengcheng He, Jianfeng Gao, and Weizhu Chen. 2023. DeBERTaV3: Improving DeBERTa using ELECTRA-style pre-training with gradient-disentangled embedding sharing. Preprint, arXiv:2111.09543.arxiv.org/abs/2111.09543
  20. [20]John Hewitt and Christopher D Manning. 2019. A structural probe for finding syntax in word representations. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4129–4138.DOI
  21. [21]HM Revenue and Customs. 2026. Measuring tax gaps 2026 edition: tax gap estimates for 2024 to 2025.
  22. [22]Rasmus Kær Jørgensen and Christian Igel. 2021. Machine learning for financial transaction classification across companies using character-level word embeddings of text fields. Intelligent Systems in Accounting, Finance and Management, 28(3):159–172.
  23. [23]Diego Santos Kieckbusch, Geraldo Pereira Rocha Filho, Vinicius Di Oliveira, and Li Weigang. 2020. Towards intelligent processing of electronic invoices: The general framework and case study of short text deep learning in brazil. In International Conference on Web Information Systems and Technologies, pages 74–92. Springer.
  24. [24]Pakorn Kotepruchai and Yachai Limpiyakorn. 2024. Tree-based classifiers for smart general ledger code suggestion. In Proceedings of the 2024 13th International Conference on Informatics, Environment, Energy and Applications, pages 17–22.DOI
  25. [25]Meelis Kull, Miguel Perello-Nieto, Markus Kängsepp, Telmo Silva Filho, Hao Song, and Peter Flach. 2019. Beyond temperature scaling: obtaining well-calibrated multiclass probabilities with Dirichlet calibration. Curran Associates Inc., Red Hook, NY, USA.arxiv.org/abs/1910.12656
  26. [26]Yuxin Liang, Rui Cao, Jie Zheng, Jie Ren, and Ling Gao. 2021. Learning to remove: Towards isotropic pre-trained BERT embedding. In International conference on artificial neural networks, pages 448–459. Springer.arxiv.org/abs/2104.05274
  27. [27]Ziyi Liang, Yanfei Zhou, and Matteo Sesa. 2023. Conformal inference is (almost) free for neural networks trained with early stopping. In Proceedings of the 40th International Conference on Machine Learning, ICML’23. JMLR.org.arxiv.org/abs/2301.11556
  28. [28]Juan Liu, Lei Pei, Ying Sun, Heather Simpson, Jocelyn Lu, and Nhung Ho. 2021. Categorization of financial transactions in quickbooks. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pages 3299–3307.
  29. [29]Haoyan Luo and Lucia Specia. 2024. From understanding to utilization: A survey on explainability for large language models. arXiv preprint arXiv:2401.12874.arxiv.org/abs/2401.12874
  30. [30]Justin Munoz, Mahdi Jalili, and Laleh Tafakori. 2022. Hierarchical classification for account code suggestion. Knowledge-Based Systems, 251:109302.DOI
  31. [31]Vivi Nastase and Paola Merlo. 2025. Testing the assumptions about the geometry of sentence embedding spaces: the cosine measure need not apply. arXiv preprint arXiv:2509.01606.arxiv.org/abs/2509.01606
  32. [32]Sander Noels, Sébastien Viaene, and Tijl De Bie. 2024. TopoledgerBERT: Topological learning of ledger description embeddings using siamese BERT-networks. In Proceedings of the Eighth Financial Technology and Natural Language Processing and the 1st Agent AI for Scenario Planning, pages 63–72.
  33. [34]Sara Rajaee and Mohammad Taher Pilehvar. 2021. How does fine-tuning affect the geometry of embedding space: A case study on isotropy. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3042–3049.

Paper details

vlnc:W_feshd5v9
Version
v1 · latest
Published
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

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

  • Mathematics

Not recorded for this paper

View statement
Looking for related papers…
Contents