This article describes how software can assign accounts to a cost type when the account number alone is not enough: in the cost-abstraction mapper (in German), which transfers a DATEV trial balance into the 24 nodes of the book's cost-type plan, and in the CostEngine (in German), which works with a condensed 19-node scheme all the way to the machine-hour rate. It is aimed at technically interested readers; to use the tools you need to know none of this.
The first edition (07/2026) was imprecise on two points: which texts are classified at all — account names or posting texts — and which model actually runs in the tool. Both are corrected. New are the sections on measuring properly (Ch. 7) and a case study of two models that never ran (Ch. 8). Added in November 2026: the measurement of an embedding model against text matching and its integration into the CostEngine as a second opinion.
1 · The problem: texts are chaotic — but which texts?
Before talking about models, one question must be settled: which text is actually available in live operation? Accounting has two very different sources, and they are often confused.
A trial balance or P&L contains exactly one text per account: the account name assigned by the tax adviser or the client. A posting journal, by contrast, contains every single posting with its posting text. The mapper and the CostEngine read trial balances, so their text is the account name. Posting texts exist only if the journal is exported as well.
Both are chaotic. With account names the problem is that clients rename accounts and use them differently from what the chart of accounts intends — the number then says something different from the name:
| Account | SKR03 standard | Name at the client | What the name suggests |
|---|---|---|---|
| 4508 | vehicle costs (range) | “Kfz-Kosten Gabelstapler” (forklift) | fleet, not personnel |
| 4806 | hardware/software maintenance | “Instandhaltung Büromaschinen” (office machines) | IT or maintenance — a matter of policy |
| 4986 | — | “Rep./Instandh. Anl.+Masch (Kühlschmier)” (coolant system) | maintenance rather than tooling |
Posting texts vary even more, because they arise in day-to-day work without any scheme:
| Original posting texts | Intended cost type |
|---|---|
| “Nachschliff Fräser 12mm” · “Fräser Schliff” · “WZ Aufbereitung” · “Schleifen VHM” · “Werkzeug Reparatur Fräser” | Consumable tools node 05 |
| “Strom Halle” · “Energie Nov.” · “EL Verbrauch” · “Strom+Wärme” · “Gas Heizung Produktion” | Energy costs node 07 |
| “Wartung BAZ” · “Instandh. Maschine” · “Rep. CNC Fräsen” · “IH Drehzentrum” | Maintenance node 08 |
| “Gehalt Meister” · “Lohn Einrichter” · “Bezüge Schichtführer” · “Vergütung Fertigungsleitung” | Production overhead node 06 |
A model trained on posting texts is useless if the tool only ever receives trial balances. That is exactly what happened to the CostEngine (Ch. 8). The question “Is this input available in live operation?” belongs at the beginning, not at the end.
Node numbers follow the 24-node cost-type plan from Chapter 4.5 of the book, which the mapper also uses. The CostEngine condenses it into 19 nodes (for example, administrative, sales and other overheads into one node); the principle stays the same.
2 · The architecture: rule before model
The most important design principle: the model is the last resort, not the first. Whatever a fixed rule can decide reliably, the rule decides. This is how a row passes through the mapper:
Two things matter here. First, the classifier acts alone only where no account-number rule exists, and even then only above 85% confidence. Second, it also runs on accounts that do have a rule — as a cross-check. If it disagrees with the rule at 65% confidence or more, a conflict is flagged. This is the real added value: the number knows the chart of accounts, the name knows how the client actually uses the account.
The CostEngine refines the cross-check with one condition: a hint appears only if the client has renamed the account. If an account carries its standard name, the rule is binding. This keeps the list short — across 202 cost rows from seven real annual accounts there were five hints.
The original Python prototype had a second layer of about 200 keyword rules for posting texts between rule and model. There, rows split into roughly 75% account number, 15% keywords and 8% model; the remaining 2% or so had no reliable assignment and went to manual review.
The vast majority of rows is handled by rules that can be read, checked and corrected. The model only handles the difficult remainder. The part of the system that remains inherently unexplainable is small and contained — and a model error can distort the overall result only to a limited extent. Whoever does it the other way round and hands everything to the model has built a system whose results can no longer be justified. In cost accounting that is disqualifying.
3 · Which model — and why local
The task “assign a short German text to one of 24 categories” does not need a model with hundreds of billions of parameters. Often it does not need a language model at all. The range runs from a weight table in the browser to a fine-tuned language model:
The mapper currently uses a linear classifier (logistic regression over words, word pairs and character trigrams), trained on the official DATEV account names and real manufacturing P&Ls. The weights fit into 0.45 MB and are evaluated in the browser with about 30 lines of JavaScript. For account names, which are often close to the standard, that goes a surprisingly long way. A language model of the 0.5-billion class (in the prototype: Qwen2-0.5B) understands more variation but is about a thousand times larger.
In between sits a class of models that is often the better choice for assignment tasks: embedding models. They do not generate text; they translate a term into a meaning vector. “Stromkosten” and “Energie” (electricity costs, energy) then end up close together although they share no letters. Such a model (for example multilingual-e5-small with 118 million parameters) fits into about 120 MB once quantized and needs no training for a first version. The measurement in Chapter 7 shows: on its own it does not beat simple text matching — as a second opinion it does.
| Criterion | Linear classifier | Local model (0.1–0.5 bn) | Cloud model |
|---|---|---|---|
| Data leaving the company | none — runs in the browser | none — runs offline | accounting data leaves the house |
| Hardware | any, < 1 MB | CPU, under 2 GB RAM | none of your own needed |
| Cost per query | €0.00 | €0.00 | API fee per row |
| Availability | independent | independent of network and vendor | dependent on both |
| Language understanding | word and character patterns only | synonyms, abbreviations | much better |
| Adapting to your own data | retraining in seconds | LoRA, low effort | usually not possible |
| Explainability | weight per feature readable | via most similar examples | hardly |
Data protection is not a side issue. A trial balance contains salary totals, supplier relationships and margin data. Transferring it to an external service raises questions of data-processing agreements that simply do not arise when processing never leaves the computer.
4 · LoRA: fine-tuning without a data centre
A base model knows nothing about cost accounting. It has to learn that “Nachschliff” (regrinding) belongs to node 05 and “Gewerbesteuer” (trade tax) to the neutral abstraction. The classic route would be to retrain all model weights — expensive and unrealistic for a small team.
LoRA (Low-Rank Adaptation) works differently. The original weights stay frozen. Instead, small additional matrices are trained that sit beside the existing layers and shift their behaviour. The mathematical trick: this adjustment can be expressed as the product of two very narrow matrices — instead of one full matrix with millions of entries, two with a few thousand suffice.
W0 stays unchanged — only B·A is trained
In practice: training runs on an ordinary graphics card rather than a cluster. The result is an adapter of a few megabytes, not a new full model. LoRA works for language models and embedding models alike — so one can start with an untrained embedding model and train an adapter only once the measurement justifies it.
The laborious part is not training but labelling: every name needs the correct cost type — according to the same posting rules a person applies. Whoever works sloppily here trains in their own mistakes. A model is only ever as good as the system you show it.
The most elegant way to good training data is to let it arise in daily work. Both tools turn every correction into a labelled example: the mapper via the export “corrections as training data”, the CostEngine via a per-client correction memory that is applied automatically on the next import. A correction only feeds into the name matching once the user marks it as generally valid or two clients have corrected the same name the same way — so one company's quirk does not become everyone's rule.
5 · Quantization: from gigabytes to megabytes
A trained model usually stores its weights as 16- or 32-bit floating-point numbers. For an assignment task this precision is wasted. Quantization maps the weights to coarser number formats: to 8 bits or — block-wise with their own scaling factors so the error stays small — to about 4 bits.
| Format | Bits/weight | Size (0.5B model) | Practice |
|---|---|---|---|
| FP16 training format | 16 | ~1.0 GB | reference for quality comparisons |
| INT8 usual with ONNX | 8 | ~0.5 GB | quality loss in classification usually not measurable |
| Q4 4-bit block-wise, GGUF/llama.cpp | ~4.5 | ~300 MB | proven compromise for text generation on the CPU |
The effect is twofold: the model fits into the memory of an ordinary office PC, and it gets faster — because at these model sizes the bottleneck is not compute but memory bandwidth. Fewer bytes per weight means shorter response times directly. Whether quality holds is shown only by measuring on the same test data before and after quantization.
6 · ONNX: freeing the model from the training framework
A model is developed in a training framework but is meant to run inside an application — ideally without that application dragging the whole training environment along. ONNX (Open Neural Network Exchange) is a vendor-neutral exchange format: the trained model — including the merged LoRA adapter — is exported as a computation graph and executed by a lean runtime.
For a tool that is to be installed in a company, this is the decisive step towards maintainability: one model file, one runtime library, no Python dependency chains that break with the next update. It only gets simpler without a model file: the mapper's classifier is a weight table embedded in the HTML page itself.
7 · Measuring properly
For the Python prototype with a language model, measurement used 80 posting rows that were not part of the training:
| Metric | Result | Meaning |
|---|---|---|
| Accuracy | 93.7% | 75 of 80 rows assigned correctly |
| Avg. confidence | 87.3% | basis of the 85% threshold for manual review |
| False-neutral rate | 0.0% | no genuine cost item wrongly excluded |
80 examples are a proof of function, not robust statistics. The dataset comes from one type of business; with a different account structure or posting practice the values can differ considerably. The most telling figure is the third: that no genuine cost item was classified as neutral matters more than overall accuracy — because excluded costs are missing from the hourly rate later and nobody notices. A re-measurement using the method described below is still outstanding.
The most common trap: variants on both sides
Training data for cost types often consists of variants of the same term: “Strom Halle”, “Strom Halle Jan”, “STROM HALLE”. If the data is split randomly into training and test, variants of the same term end up on both sides. In the test the model then merely recognises what it has already seen — and accuracy measures recognition rather than generalisation.
The remedy is simple: split training and test by account, so all variants of an account land on the same side. Only then does the test show what happens with an unknown client.
Precision and coverage belong together
A single accuracy figure hides how often the method says anything at all. Raising the threshold yields fewer but more reliable hints. For the CostEngine name matching this was measured on 1,568 labelled account names from 116 accounts — five-fold, split by account. Three methods were compared: text matching, an embedding model (multilingual-e5-small, INT8, untrained) and the combination that only reports when both see the same node.
| Method | correct overall | coverage at ≥ 90% correct | size | ms per name |
|---|---|---|---|---|
| Text matching (TF-IDF) | 78.5% | 71.5% | 0.26 MB | 1.5 |
| Embedding model alone | 76.2% | 61.7% | 118 MB | 3.3 |
| both agree | — | 78.8% at 91.0% | 118 MB | ≈ 5 |
Three things stand out. First, the model alone does not pay off: at very strict thresholds it is more precise, but then covers only one account in three; as soon as it has to reach more than 60% of accounts it falls below text matching, because it also sees “similar” where only the topic is related. Second, as a second opinion it adds measurably: at the same coverage, 91 instead of 88% of hints are correct. Third, the largest jump came not from the model but from clean data: once the reference names were labelled according to one consistent rule set, text matching rose from 87% correct at 44% coverage to 94% at 53%.
Which setting is right is not a technical question but an operational one — how expensive is a wrong hint, how expensive a missed one? One limitation remains: the test set essentially comes from a single company. A robust verdict needs data from further clients.
8 · Case study: two models that never ran
Up to version 11.8 the CostEngine contained two fine-tuned classifiers based on Qwen2.5-0.5B with a LoRA adapter, exported as ONNX: one checked whether a posting text matches the account, the other whether a posting is an expense or a reduction. Both reported 100% accuracy in the training report. A review in October 2026 found:
| Finding | Measurement | Consequence |
|---|---|---|
| Input in live operation | 0 posting texts in P&L and trial balance | neither check ran on a single file |
| Label “expense/reduction” | in 5,295 of 5,295 examples = sign of the amount | the model learned the sign — a rule can do that |
| “Text matches account” | text similarity alone separates 99.0% | hardly more than a character comparison |
| Data basis | 986 distinct texts in 5,295 examples | variants on both sides — hence the 100% |
| Memory | ≈ 940 MB for both models | loaded without ever producing a hint |
The method was not to blame: LoRA, quantization and ONNX all worked. The models had been trained for a task whose input did not exist, on data that posed no real challenge. The consequence in version 11.9: both models were removed. In their place came a name matching without a model that works with the input every P&L has — the account name. It needs about a millisecond per account. Only then was an embedding model measured against this baseline (Fig. 6) and built into version 11.11 as a second opinion: optional, local, 118 MB, and only with hints that never change a number. A LoRA adapter for this model will follow only once corrections from more than one company exist — with a single company's data it would mostly learn that one company by heart.
High accuracy in a training report proves nothing as long as three questions remain open: Does the input exist in live operation? What does a simple method achieve on the same data? Were training and test separated so that the test is genuinely new? Answering these questions honestly replaced almost a gigabyte of model in the CostEngine with a method that can be traced line by line.
9 · The limits — and why they should stay
There are three things this system cannot do, and for two of them it would be a mistake to try:
- 1It does not decide. Assigning an account to a cost type is a business decision with consequences for costing and price. The tool suggests; responsibility stays with the person. Every assignment must be overridable.
- 2It does not calculate. Language models are unsuited to number crunching — they produce plausible-looking results without a calculation path. All amounts come from deterministic code, not from the model. The model assigns, nothing more.
- 3It does not know your company. Whether a foreman's salary is production overhead or administration depends on the organisation. Such decisions belong in the rule set or the correction memory — where they are documented and justifiable.
The value of this technology is not in replacing the cost accountant but in taking the mechanical pre-sorting off their hands — so they spend their time on the cases that truly require judgment. Whoever starts out expecting the system to take over cost accounting will be disappointed. Whoever uses it as a pre-sorter with a review obligation gains real time.
10 · Effort and benefit — soberly
Building such a system costs primarily time for labelling, rule maintenance and measurement, not money for hardware; an ordinary office PC suffices. The time saved in ongoing use amounts, for a monthly abstraction, to a few hours — appreciable, but not an order of magnitude that saves a position.
Robust ROI figures are difficult here: they depend on the number of accounts, the account structure and how cleanly the work was done beforehand. Whoever presents a three-digit return extrapolates from a handful of assumptions. More realistic is the view that the effort pays off through consistency: an abstraction performed every month by the same rules, with documented assignments, is worth more than a few hours saved — because it is what makes comparability across periods possible in the first place.
11 · Five principles
- 1Input before training. First establish which text exists in live operation — account name or posting text.
- 2Rule before model. What the account number decides reliably, the account number decides.
- 3Baseline before model. Every model competes against a simple method. Only the gap justifies the effort.
- 4Measure split by account, and report precision and coverage together.
- 5A person decides — and every correction becomes a training example.
This article summarizes the technical chapters from Part VI of the book. The methodological framing remains in the book (Chapter 18); the implementation details are here because they date faster than the cost-accounting part. First edition 07/2026, revised 10/2026, measurement added 11/2026.