Natural Language Processing in Finance: Reading Documents at Scale
Natural language processing means a component that takes text and returns a statement about that text. In finance the statement is nearly always one of three: the kind of document this is, the named things that appear in it, or what a given passage is about. Each is a claim about the text as written. None of the three is a claim about what the text requires anybody to do.
Here is the thing to hold on to before the numbers start. A component that reads was shown examples, and it learned the shapes it was shown. Financial documents arrive in a small number of shapes that repeat many thousands of times a month, and that repetition is the only reason reading them at scale works at all. Repetition is also why the standard way this goes wrong is a new shape turning up quietly through one channel. Every figure on the monthly pack still looks perfectly healthy while that happens.
What does it mean for a component to read text?
The word reading carries a lot of freight, so reading is best approached through what it is not. A reader of a pay slip takes in the characters, works out which kind of document it is, notices the employer and the net figure, and forms a view about whether the person named can afford a loan. Four different things, done so fast that they feel like one act. Natural language processingA component that takes text and returns a statement about that text, such as which kind of document it is or which named things appear in it. does not do all four. Natural language processing does one of the middle two, and does that one in isolation.
A reading component takes characters in and returns a statement out, and the statement is always about the text rather than about the world. This document is a pay slip. The employer named here is Karvani Textiles. The net figure here is Rs 45,000/-. Every one of those is checkable by pointing at the document. Whether the applicant can afford the loan is a different kind of claim entirely. The document does not contain it, and no reading component returns it.
A post room has the same shape. Somebody sorts the morning post into piles by what each envelope obviously is: bills here, statements there, circulars in the bin. The sorter is reading, and reading well, and has formed no view at all about whether the household can pay any of the bills. The missing view is not a shortcoming of the post room. Sorting is deciding what each thing is and stopping there.
Which three things is such a component actually asked to do?
Across the reading work a lender actually deploys, three tasks cover almost all of it. The three sound similar in a meeting and are completely different claims, made by separate components, failing in separate ways and needing separate checks.
Task one is document classificationDeciding which kind of document a piece of text is, chosen from a fixed list of kinds.: which kind of document is this text. The answer comes from a fixed list. Four kinds of document arrive on a retail personal loan file at Sumeru Bank Limited, an invented lender, so the list there has four entries: an identity document, an address proof, a pay slip and a bank statement. The component returns one of those four and nothing else. The component cannot return a fifth kind it was never shown, and that limitation matters more than anything else about it.
Task two is finding the named thingsSpecific entities inside the text, such as an employer, an amount, a date or an account number.: which specific entities appear in this text, and where. An employer, a date, an account number, an amount. The output is a list of items with the place each one was found. Sumeru's reading step pulls 14 such items from every file. Across 8,600 files a month that is 120,400 items. Notice the form the output takes. Not a judgement, a list. The judgement happens afterwards, somewhere else, in something else.
Task three is the passage subjectWhat a stretch of text is about, as distinct from what it actually says about that thing.: what is this stretch of text about. Is this paragraph about repayment, about security, about what happens on a missed instalment. Passage subject is the task people mean when they say a component understood a document, and the one Sumeru measured and did not deploy. Sumeru's measurement of that third task appears below.
What are the three things a text component in this chain is asked to do?
Where does each of the three sit in one deployed chain?
Order matters here more than anything about the components themselves. At Sumeru the reading work happens in a fixed sequence, and each step narrows what the next one has to consider. The classifier decides which kind of document it is. Everything after it then looks only for the items that kind of document is supposed to carry: a pay slip is searched for an employer and a net figure, a bank statement for credits and balances. By then the question has already been settled, so nobody hunts for a net pay line in an address proof.
Follow one item all the way through and the handover becomes obvious. The classifier says pay slip. The reading step pulls the net figure off it, Rs 45,000/-, and pulls the median monthly salary credit off the statement, Rs 38,000/-. Both are now just numbers on a list, and the reading work is finished. A written rule then compares the two and routes the file, and that rule is not reading anything: it is doing arithmetic on what the reading handed it. The reading step supplies the numbers and something else entirely decides what they mean. Every one of these chains is built on that division of labour.
Narrowing is what makes the sequence fast, and it is also what makes an error at the first step cost more than an error at any later one. Get the extraction wrong on one item and one item is wrong. Get the classification wrong and every step afterwards is searching for the wrong things in the right document. The mistake spreads rather than sitting still. A spreading mistake is the reason the classifier is measured on its own and watched harder than the step that follows it.
Why is a wrong answer at the classification step more expensive than a wrong answer at the extraction step?
What did a month of classification actually look like?
Numbers make this concrete faster than any amount of description. Sumeru Bank Limited sees 8,600 completed files reach its decision engine in a steady month, and 4 documents arrive on each one, so 34,400 documents a month pass through the classifier. On the four kinds it was fitted on, the deployed classifier returns the correct kind 96.2 per cent of the time. The 96.2 per cent is the bank's own measurement of its own deployment, taken on the four kinds the classifier was fitted on and on nothing else.
A percentage hides how many people are involved and a count does not, so turn the percentage into a count. 3.8 per cent of 34,400 documents is 1,307 documents given the wrong kind in a single month. On 1,307 separate occasions the chain held something about a document that was not true. A meeting never hears the count. The meeting hears 96.2 per cent and moves on to the next slide.
| The month, in documents | Count | Where it comes from |
|---|---|---|
| Files reaching the decision engine | 8,600 | One steady month |
| Documents on each file | 4 | Identity, address, pay slip, statement |
| Documents classified in the month | 34,400 | 8,600 times 4 |
| Classified correctly, at 96.2 per cent | 33,093 | 34,400 less the row below |
| Given the wrong kind | 1,307 | 3.8 per cent of 34,400 |
| Of those, caught by a later step at no cost | 1,224 | 93.6 per cent of the 1,307 |
| Of those, reaching a person at the exception desk | 83 | 1,224 plus 83 is 1,307 |
The split at the bottom of that table is the whole point of it. Two documents can be wrong in exactly the same way and cost amounts that differ by a factor few would guess. One is corrected by a step that was going to run anyway. The other becomes 19 minutes of somebody's morning.
1,307 documents were given the wrong kind in the month and 1,224 of them cost nobody anything. Why?
Where does a misread cost nothing, and where does it cost a person's morning?
The size of the mistake is not what separates the 1,224 from the 83. The separator is whether the mistake survives contact with the next step. Call that next step a downstream checkA later step that catches an earlier mistake on its own, without anybody having to look at the file.: it is whatever runs after the classifier and expects a particular set of items to be present.
A pay slip filed as an address proof is a loud mistake. The next step goes looking for an address and a date of issue, finds a gross pay line and a deduction line instead, and re-routes the document without asking anybody. Nothing was lost except a few milliseconds. An error that breaks the step after it announces itself, and an error that survives the step after it hides.
Now the quiet one. A pay slip from one employer filed as a pay slip from a different template, or a bank statement filed as a pay slip when the statement happens to carry a salary credit line: the items the next step wants are all present and all plausible. Nothing breaks. The file goes forward carrying an item taken from the wrong place, and the only thing that catches it is a person. At Sumeru that person sits on the exception desk, where the average file now takes 19 minutes. Assume each of the 83 sits in its own file and that is 1,577 minutes in the month, a little over 26 hours, from the same error that cost nothing 1,224 times.
Which misclassifications are the expensive ones?
What happens when a kind of document arrives that was never in the examples?
One failure shape is worth learning above all the others, and it arrives without a single alarm going off. At Sumeru a fifth kind of document began turning up through one channel. The classifier had been shown four kinds. A fifth kind was not on the list, so the classifier did what any component asked to choose from a fixed list does: it returned the nearest of the four it knew.
On that fifth kind the classifier returns the correct answer 71.0 per cent of the time, against 96.2 per cent on the four kinds it was fitted on, a gap of 25.2 points. Be precise about what that figure is a reading of. The 71.0 per cent is a reading on a kind of document, not on a place files come from, and those are two different measurements that must never be swapped for one another. The 71.0 belongs to the fifth kind wherever it arrives.
The everyday version is familiar enough. A shopkeeper who has spent ten years sorting four kinds of receipt can do it without looking. Handed a fifth kind he has never seen, he will not say he does not know. He will file it under whichever of his four it most resembles, confidently, and the pile will look exactly as tidy as it did yesterday. Nothing on the outside of the pile shows that anything has changed.
Why is a headline accuracy the wrong number to watch?
Because a headline accuracyOne accuracy figure covering every case at once, which averages away any group that is failing. is a weighted average, and a weighted average is designed to be moved by the big groups and not by the small ones. The fifth kind is 8 per cent of Sumeru's monthly documents. Work the average: 92 per cent of the documents read at 96.2 and 8 per cent read at 71.0 gives 94.2 per cent overall.
The headline moved 2.0 points while one sliceA group of cases sharing something in common, whose behaviour can differ sharply from the average. of the work sat 25.2 points worse than everything around it. Two points looks like a normal month. Nobody escalates two points. Meanwhile roughly one document in three of that fifth kind is being filed as something it is not, and every applicant sending that kind of document is having a materially worse experience than everyone else. The uneven fall of a model's errors across the people it touches is the idea Cathy O'Neil put at the centre of Weapons of Math Destruction, and this is what it looks like inside one month of one bank's post room.
What is worth watching instead of the overall accuracy figure?
Before the control below is moved. One kind of document reads 25.2 points worse than the rest and makes up 8 per cent of the month's documents. How far does the overall figure fall?
Move the failing slice and watch how little the headline notices
One control: what share of the month's 34,400 documents is made up of the kind the classifier was never fitted on, from 0 to 20 per cent. Three things redraw: the block of a hundred repaints to show the mix, the two bars move, and the monthly count of misread documents changes. The default is the bank's actual position, the fifth kind at 8 per cent, where the overall figure reads 94.2 per cent while that kind on its own reads 71.0 per cent. Push the control to 20 per cent and the overall figure still only reads 91.2 per cent.
The fifth kind at per cent of the month's documents
At 8 per cent of the month's documents, the overall reading is 94.2 per cent while that kind on its own reads 71.0 per cent, a distance of 23.2 points between the figure on the pack and the figure for the applicants sending that kind of document. Against a starting point of 96.2, the headline has moved 2.0 points.
Does reading the words amount to understanding the obligation?
No. Every one of the three tasks returns a claim about the text as written. The obligation the text creates is a different sort of claim altogether, and no amount of accuracy on the first sort produces the second.
Take a loan agreement. A reading component can return the borrower, the lender, the principal, the instalment amount, the first instalment date and the tenure, every one of them correct, every one of them checkable by pointing at a line. Ask instead what happens if the second instalment is late. The answer is not on any single line: it lives in how three clauses interact, in which of them takes precedence, and in what the agreement means by a working day. Finding what is written and working out what it commits anybody to are two different jobs, and only the first is what these components do.
The homely version makes the distinction stick. Somebody can read an electricity bill aloud, perfectly, every figure right, and still not be able to say whether the household is about to be disconnected. Reading it and knowing what it means for the household are not the same skill. The gap between reading and judging is what Ajay Agrawal, Joshua Gans and Avi Goldfarb set out in Prediction Machines: a learned component produces something a person still has to act on. The judgement did not move. Only the reading did.
A component returns every party, every amount and every date in a loan agreement. Has it established what the agreement requires?
Sumeru had 60 loan agreements summarised, then had every summary checked by hand against its agreement. How many summaries would be expected to have left out a condition that was in the agreement?
What did the summary trial measure, and what did it decide?
Sumeru ran one trial on the third task, the one about what a passage is about. Sixty loan agreements were put through a component that returned a short account of what each agreement contained, and every one of those accounts was then checked against its agreement by a person who read the agreement in full. Sixty agreements and one full reading of each is the whole design of the trial, and the counting is the entire point of it.
Nine of the sixty, 15.0 per cent, left out a condition that was present in the agreement. The other fifty one were correct. All sixty were fluent outputText that reads correctly and looks well made, which is a property of the writing and not of whether the content is right.: well ordered, correctly formatted, and reading exactly as though written by somebody who had gone through the document carefully. Fluency and correctness turned out to be two independent properties, and only one of them was visible without opening the agreement.
The error that gets made, and what it costs
The mistake is not trusting the component. The mistake is what a run of correct summaries does to the person checking them. A checker who has opened eleven agreements in a row and found the summary faithful every time reads the twelfth differently. Attention drops because the evidence says it can, and the evidence is not lying: 51 out of 60 really were correct.
An omission has no surface. A wrong figure sits on the summary and argues with the agreement. A missing condition sits nowhere. The only way to find it is to read the whole agreement. Reading the whole agreement is exactly the work the summary was brought in to remove, so a check that actually catches omissions costs the entire saving.
Sumeru did not deploy it. One number from one trial carried that decision, not an opinion about what such components can or cannot do, and that is why the meeting was short. No general rate of omission can be read off a sample of sixty. The trial settled one question at one bank and settled nothing wider.
How does a lender, a reviewer or a customer manager actually use this?
What each of them does with a reading figure
A single question about overall accuracy cannot be answered honestly, so a head of retail credit signing off a reading step does not ask it. She asks for the reading broken out by kind of document, and then for how the mix of kinds has moved since the last time she looked. Revathi Balan can act on two readings side by side. She can do nothing at all with 94.2 per cent.
A reviewer sizes the work by asking where a misread is caught. Where a downstream check exists, the misread is cheap and the review is about whether the check really runs on every path. Where no check exists, every misread lands on a person, and the question becomes whether the desk is staffed for the volume. Neelima Rao's version of this question was simple: show me the errors nothing downstream would notice.
A customer manager uses it to know which complaints have an answer she can give today. If a file waited because a document was filed as the wrong kind, Ismail Sheikh's desk can say exactly what happened and point at the document. If a file waited because a whole kind of document reads badly, the honest answer is that the applicant is in a group the chain handles worse than average, and that is a different conversation, one that belongs with the people who chose which kinds to fit on.
Who sets expectations where documents are read by a component
Where a bank in India reads a customer's documents by machine to support a lending decision, the expectations on that bank sit with the Reserve Bank of India. The Reserve Bank publishes its position on outsourcing, digital lending, customer data and consent at rbi.org.in. Where the deployer is a market intermediary rather than a lender, the Securities and Exchange Board of India sets the equivalent expectations at sebi.gov.in. Requirements, thresholds and effective dates change, and the position published at the issuing body's own site is the one that governs.
Sources
| Source | Document | Site |
|---|---|---|
| Reserve Bank of India | Expectations on a regulated lender covering outsourcing, digital lending, customer data and consent | rbi.org.in |
| Securities and Exchange Board of India | Expectations where the deployer reading customer documents is a market intermediary | sebi.gov.in |
| Bank for International Settlements | International supervisory material on the deployment of such systems by banks | bis.org |
| Cathy O'Neil | Weapons of Math Destruction, on a model's errors falling unevenly across the people it touches | Crown |
| Ajay Agrawal, Joshua Gans and Avi Goldfarb | Prediction Machines, on a learned component producing something a person still has to act on | Harvard Business Review Press |
Sumeru Bank Limited, Karvani Textiles, Revathi Balan, Ismail Sheikh and Neelima Rao are invented.
Educational material. Not advice on any investment, tax, budget or market position.
