Information Extraction from Electricity Invoices with General-Purpose Large Language Models
This study demonstrates that for general-purpose Large Language Models extracting information from Spanish electricity invoices without fine-tuning, prompt engineering quality is the critical factor driving performance, with few-shot strategies significantly outperforming zero-shot baselines to achieve F1-scores exceeding 96%.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a huge stack of electricity bills from various companies. Some are neat and clean, others are messy, and all look slightly different. Your goal is to extract specific numbers and names (such as "Total Cost" or "Customer Name") from each individual bill and enter them into a neat table.
For years, computers struggled with this. Old programs were like rigid robots: if a bill looked even the tiniest bit different from what they had been trained on, they became confused and failed.
This article is about teaching a new type of "superintelligent robot" (a so-called Large Language Model, or LLM) to read these bills without needing to be retrained for every single new design. The researchers asked: Can we simply give these intelligent robots the right instructions, and will they figure it out themselves?
Here is a summary of their findings, using some everyday analogies:
1. The "Recipe" is more important than the "Chef's Hat"
The researchers tested two different "chefs" (AI models): Gemini 1.5 Pro (a huge, complex chef) and Mistral-small (a smaller, faster, and more efficient chef).
They also tried adjusting the "cooking settings" (technical parameters like temperature and randomness). They expected that perhaps the larger chef or the perfect cooking settings would make the biggest difference.
The Surprise: It made almost no difference which chef they used or how they adjusted the settings. The difference in results was tiny – like the difference between a cake that is 99% perfect and one that is 99.5% perfect.
The Real Winner: The Prompt (the instructions given to the AI).
Think of the prompt as the recipe.
- Zero-Shot (No Recipe): Simply saying "Read this bill and give me the numbers" is like telling a chef to cook without a recipe. The results were okay (about 78% accuracy), but not great.
- Few-Shot (With Examples): Giving the AI a few examples ("Here is a bill, and here are the data points I need") is like giving the chef an example dish to copy. Accuracy jumped to over 96%.
The Lesson: It's not about having the most expensive chef or the most modern oven; it's about writing a really good recipe.
2. The "Copy" Strategy Works Best
The researchers tried various ways of providing examples:
- The "One-Shot" Method: Showing one example. Good, but not the best.
- The "Cross-Validation" Method: This is the champion. They showed the AI three different types of bills (e.g., one tabular, one list-like, and one complex) and then asked it to read a fourth type it had never seen before.
- Result: The AI became a master copier. It learned the concept of an electricity bill, not just the appearance of a specific bill. It achieved 97.6% accuracy with Gemini and 96.1% with Mistral.
3. The "Translation" Problem
Before the AI could read the bills, the researchers had to convert the PDF files into text (Markdown).
- The Analogy: Imagine trying to read a handwritten note that was copied through a dirty window. If the note is in a clean table, the text comes out clearly. If the note is squeezed into a messy, multi-column layout, the text gets jumbled.
- The Insight: The AI was only as good as the text it received. If the bill had a clean, table-like layout, the AI was nearly perfect. If the bill had a messy, dense design, the AI struggled because the "translation" from PDF to text had lost important clues.
4. The "Hallucination" Trap
They identified a personality difference between the two chefs:
- Gemini (The Cautious Chef): If it wasn't sure where a number was, it said, "I don't see it." It was very accurate but sometimes missed things.
- Mistral (The Confident Chef): If it wasn't sure, it guessed a number anyway. It found almost everything (high "recall" rate) but also invented some numbers that didn't exist (low "precision" rate).
- The Conclusion: If you need to be 100% sure the number is real, you want the cautious chef. If you want to find everything and can check the answers later, the confident chef is fine.
5. The Old Robots Fall Short
The article compares these new AI chefs with the old "robots" (traditional machine learning).
- The Old Robot: If trained on Bill Type A, it could read Bill Type A perfectly (91% accuracy). But if given Bill Type B, it crashed and failed (accuracy dropped to 67%). It had memorized the appearance of the paper, not the meaning.
- The New AI: It did not need to be trained on Bill Type B. Because it understood the meaning of an electricity bill, it read the new types with over 95% accuracy. It generalized the ability instead of memorizing the pattern.
Summary
The article concludes that to get a computer to read business documents perfectly, you don't need to build a unique brain for every single document type. Instead, you simply need to write better instructions and show it a few good examples.
The "secret recipe" is not the size of the AI model or the complex mathematical settings; it is the quality of the prompt (the instructions) and how well the document is converted into text so the AI can read it.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.