Named entity recognition with an LLM, beyond stock labels
Named entity recognition with an LLM, compared with traditional NER: custom entity types, exam scores against Claude Opus and Haiku, and cost per document.
Updated
Named entity recognition with an LLM means a language model reads a document and marks the exact text for each thing you care about, such as a party, an amount, a date or an ID number. A model trained on your own entity types can beat a general prompt on that job, and it can cover types that stock NER tools were never built to find.
What is named entity recognition with an LLM?
Classic named entity recognition works from a fixed label set. The usual labels are person, organization, location, date and money. Those labels suit news articles. They suit a contract poorly, because a contract needs to know which party is the buyer, which amount is the liability cap and which date starts the notice period.
With an LLM, you describe the entity types in the prompt, or you train the model on examples of each type. The output is the span of text, copied from the document, plus its label. The span has to match the source exactly, or a reviewer marks it wrong.
LLM vs traditional NER: where each one wins
Traditional NER is cheap, fast and predictable. If your labels are the stock ones and your text is clean, it may be all you need. An LLM reads the sentence around each match. That helps when the same name appears as a party in a signature block and as a company mentioned in a recital. It also helps with dates written as phrases, like “the third business day after closing.” The cost is more compute per document. The output also needs checking, because a language model can return text that is not in the document at all. Long files add their own problems, covered in long-document extraction.
How do you extract names, dates and amounts from documents?
Start with a list of entity types. Define each one in a single line. A party is a legal entity that signs the agreement. An amount is a number with a currency, tied to a named obligation. A date is a calendar date, not a phrase like “promptly.”
Next, have a reviewer mark the spans in a set of real documents. Split that set by document, not by chunk, so the same contract never appears in both training and test. For the build steps, see building a test set. Score the model on the held-out documents. A value counts as right only if it matches the marked text.
Hypothetical example: suppose you label 100 contracts with 10 entity types each. That gives 1,000 labeled values. Keep 20 contracts aside for testing and train on the other 80. Those 20 hold 200 values. If the model gets 140 of them exactly right, your score is 0.7. That number is only useful if you compare it with the model you use today on the same documents.
Does fine-tuning for NER beat a prompted frontier model?
On a narrow task with good data, it can, and on the exam we ran it did. That is not a promise it always will. We tested this on CUAD, a public dataset of 510 commercial contracts with answers marked by lawyers. We picked 10 kinds of passage and asked each model to quote each one exactly. Every document was scored by a model that never saw it in training, using 5-fold cross-validation.
| Model | Exam score (1.0 is perfect) | Price per 1,000 documents |
|---|---|---|
| Our Accuracy model | 0.717 | $4.50 |
| Our Standard (fast) model | 0.650 | $3.54 |
| Claude Opus | 0.635 | $154.49 |
| Claude Haiku | 0.584 | $4.95 |
Our Accuracy model led Claude Opus by 0.082 and Claude Haiku by 0.133. Both gaps are larger than the margin of error. Our Accuracy model was ahead of both in all 5 groups of 102 documents.
Claude took the exam with one prompt, no examples and no training for the task. Our models were fine-tuned for this exam. That shows what training for one task does. It is not a legal product or legal advice, and it does not mean our model beats Claude at everything. The model assists the people who review its output. The full results are on the benchmark page.
How accurate is GPT at entity extraction?
We did not run GPT on this exam, so we have no score for it. Do not treat a vendor’s marketing number as a measure of your documents either. Build a small labeled set from your own files, run the model you use today against it, and count exact matches. Check OpenAI’s current pricing page for their prices, since they change.
At low volume a frontier API is often simpler, and a trained model is probably not worth the setup. It starts to pay when the same extraction runs thousands of times a day.
What does custom entity extraction cost at volume?
On the same text, our Accuracy model costs $0.31 per million tokens and our Standard model costs $0.24. Claude Haiku costs $0.34 and Claude Opus costs $10.53. At Claude list prices, Opus is $4 per million input tokens and $20 per million output tokens. Haiku is $0.10 input and $0.50 output for prompts up to 100K tokens. Anthropic’s Batch API is half price.
Per document on the exam, Claude Opus cost $0.155 and our model cost $0.0045. Hypothetical example: if your documents cost what the exam documents cost, 10,000 documents would come to about $1,550 at the Opus rate and about $45 on our Accuracy tier. Your documents will differ, so measure them.
One request at a time, our Accuracy tier writes about 90 output tokens per second and our Standard tier about 174. With 32 requests at a time, Standard handles 2.7x more documents an hour than Accuracy. Through the API, one request at a time on the same contract prompts, Claude Opus wrote about 114 output tokens per second and Claude Haiku about 200.
If your labels are the stock ones and your volume is small, keep traditional NER or a frontier API. If you need custom entity types at volume, a trained model in your own cloud account or on-prem is worth testing against your current setup. Estimate the bill with the cost calculator.
Start with the free AI cost audit to see what your code spends today. For a labeled test set built from your own documents, ask Own Weights for a call.
Questions
LLM vs traditional NER: which one fits my documents?
Traditional NER works well when your labels are the stock ones, such as person, organization, date and money, and your text is clean. An LLM is the better fit when you need entity types you define yourself, like the buyer, the liability cap or the notice date.
How accurate is GPT at entity extraction?
We did not run GPT on our exam, so we have no score to report for it. Score the model you use today on a labeled set from your own documents, then compare the exact matches.
Can fine-tuning improve named entity extraction?
It can, on a narrow task with good labeled data. On the public CUAD exam, our fine-tuned models scored ahead of Claude Opus and Haiku, which took the exam with one prompt and no training.
How do I extract names, dates and amounts from documents?
Define each entity type in one line, label a set of documents by hand, and split the set by document so no contract appears in both training and test. Score the output on exact matches of the marked text.
What does custom entity extraction AI cost at volume?
Cost depends on document length, the model tier and the output you need. On the exam, our Accuracy tier cost $4.50 per 1,000 documents and Claude Opus cost $154.49. Check your own documents before you decide.