Close Menu
AI News TodayAI News Today

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Apple’s new desktop computers are designed specifically for local AI development

    Where to preorder the updated Mac Mini and Mac Studio

    Uber launches live video streaming for teen accounts

    Facebook X (Twitter) Instagram
    • About Us
    • Contact Us
    Facebook X (Twitter) Instagram Pinterest Vimeo
    AI News TodayAI News Today
    • Home
    • AI News
    • AI Reviews
    • AI Tools
    • AI Tutorials
    • Chatbots
    • Free AI Tools
    • Artificial Intelligence
    AI News TodayAI News Today
    Home»AI Tools»One Document Type, a Million Files: Structured Extraction into the SQL Table RAG Queries
    AI Tools

    One Document Type, a Million Files: Structured Extraction into the SQL Table RAG Queries

    By No Comments17 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    One Document Type, a Million Files: Structured Extraction into the SQL Table RAG Queries
    Share
    Facebook Twitter LinkedIn Pinterest Email

    right now goes into letting a model discover the structure of a document collection: read every file, pull out the entities, infer the relations, and a graph comes out that nobody had to design. On five thousand copies of the same contract, there is nothing left to discover.

    Ask the person who files those contracts what they look things up by. The answer takes about ten seconds: client, effective date, product, premium, renewal date, policy number.

    Nobody found those six by reading the documents. They were designed years ago by whoever drew up the form, and every file since has been filled in against them. These files are the output of one repeatable process, and the process is what defines the fields.

    So the collection is a database nobody typed. Its schema lives in the head of the person who handles the files, and the work is to get it out and write it into a table.

    This article assumes the diagnostic in Article 14A (three kinds of corpus, and what building for the wrong one costs) already came back with this shape: one document type, many copies. It covers what to do next:

    • the interview that produces the columns, question by question
    • the two signals that tell a real column from a field that will break a filter later
    • the index as a table of contents for the collection, and why it keeps growing
    • what gets paid once per document, and what gets paid on every question
    • the arithmetic, at fifty questions a day, that says when the preparation pays for itself

    This article is part of Part IV of Enterprise Document Intelligence, a series that builds an enterprise RAG system from four bricks. Part IV is where the input stops being a file and becomes a folder, and this is the folder shape where a table is the right answer.

    🧭 New to the series? Start with the map: Prompt, Context, Loop sets out the three engineering layers every RAG system is built on, the prompt (the call itself), the context (what fills the model’s window), the loop (when the next call fires and when it stops), and walks the whole series through that lens, article by article. It is the shortest way to see what is covered and where this one sits.

    where this article sits: Part IV, the folder that becomes a table – Image by author

    📓 Run the column test on your own folder in the companion notebook: declare the six columns, fill them across a folder of look-alike PDFs, then print the fill rate per column and watch two of the fields that sounded like columns come back half empty. Repo → doc-intel/notebooks-vol1.

    The public companion-code repo at doc-intel/notebooks-vol1 – Image by author

    The worked example is an insurance portfolio, and it is fictional: the clients, policy numbers and amounts were authored for the series and match no real insured or insurer. Section 3.2 gives a public folder you can run the same test on.

    1. One document type, and the columns that came with it

    Two things to settle before the interview: what makes this shape recognisable, and where its columns come from.

    1.1. What the shape looks like on a shelf

    Twelve years of renewal notices for one motor product. Every purchase order a procurement team has issued since the ERP went in. The monthly statements of one fund. Each of those is thousands of files, and each file is the same document with different values in it.

    The count is not what matters. A hundred purchase orders behave like a hundred thousand of them: the questions people ask are about which ones, not about where inside one of them.

    Two things follow. Documents that came out of one process share a page-one layout, so the same value sits in roughly the same place every time. And the values themselves repeat: eleven products, forty-odd clients, four statuses. A column here has a small, stable set of values, which is what makes it worth filtering on.

    1.2. The columns existed before the corpus did

    A field like effective_date does not come from the text. It comes from whoever designed the form. A template has slots, a form has boxes, a back-office screen has required fields, and the PDF is that screen printed on paper.

    Nobody wrote that decision down. There is no data dictionary, and the person who designed the form left in 2014. What survives is the practice: the fields people fill in, and the ones they check before answering a customer. That knowledge sits with the handlers, so getting it out is a conversation rather than an extraction job.

    This is where the shape parts company with the folder in Article 14B (a collection whose documents share no field at all). There, no such decision was ever made, so there is nothing upstream to recover.

    2. The interview that gets you the columns

    One hour, two people, and a list of six to ten fields at the end of it.

    2.1. Who you ask, and in what order

    Ask the person who handles the documents, not the manager who owns the process. The manager describes the process as designed. The handler knows which field is blank on the older files and which one gets typed in wrong.

    Ask two handlers, separately. The second hour is there to catch one thing: a field they both name the same way and mean differently.

    Four questions, in this order. Each one is easier to answer once the previous one has been.

    four questions, and what each answer settles about the schema – Image by author

    What comes out is a list of names in the handler’s own words. Types and definitions come later.

    2.2. What tells you a column is real

    Two signals, and both are about the answer rather than about the field.

    It comes back without a pause. Ask what someone filters on and a real column arrives at conversational speed, with an example attached: “client, obviously, and the effective date, because that is how we know which version applies.” Take a field that needs thinking about. Nobody filters on it today, so nobody will keep it up to date either.

    Two handlers name it the same way. Same word, same meaning, same box on the page. The first signal cannot do this on its own, because a field can be named instantly by both handlers and still mean two different things to them.

    Neither signal needs a model or a sample. Both are settled in the room.

    three fields the business named, and the two that are not columns – Image by author

    2.3. Three answers that are not columns

    Two meanings in one word. One handler says date and means the day the contract was signed. The other says date and means the day the cover starts. Both answered fast, both used the same word, and the column that comes out of it holds two quantities mixed together. A query for policies in force in March then drops the rows carrying a signature date, and what comes back still looks like an answer. A missing field is safer, because a filter trusts what is there.

    Empty on half the documents. A field filled on 1,900 rows out of 5,000 is a subset with no name. Sometimes the subset is real, and then say so: the field belongs to a subtype, and the subtype is the column you were missing. Sometimes it is just a field that arrived in 2021, which is fine, as long as the filter reads a null as not recorded yet rather than as no.

    A judgement rather than a fact. “Is this client difficult?” is real knowledge and it is not printed anywhere. Ask a model to infer it and you get an opinion with a citation attached. Park those fields. Some come back later as something the business writes into the index by hand, which is not the same thing as extraction.

    There is an alternative to that hour, and it is popular for good reasons. Point a model at the corpus, let it pull out whatever entities and relations it finds, and a vocabulary comes back that nobody had to specify. On a collection where no business user can name a field, that is the only move available.

    Here the trade is different. You pay a full extraction pass over five thousand documents to rediscover a list two people produce in an hour, and the vocabulary that comes back is one the business did not choose and cannot correct in place. Article 16 (where the corpus vocabulary comes from, curated against extracted) puts the two side by side on cost, audit trail and freshness. The ordering is what matters here. Ask first, and if the answer arrives in ten seconds, there is nothing left to discover.

    3. The index is a table of contents for the collection

    The index has one job, and the quickest way to see it is to put it beside something every reader already uses.

    3.1. A map read before the content

    A table of contents is not part of a document’s content, it is a map of it. Six lines stand in for thirty-four pages, and a question about exclusions lands on section 4 before a page is read.

    The index does the same job one level up. It is not the content of the corpus either. Five columns stand in for five thousand files, and a question about one client’s fleet cover lands on one row before a file is opened.

    the same job at two scales: pick the section, pick the documents – Image by author

    Follow that comparison all the way, because it tells you what belongs in the index. A table of contents does not hold the text of section 4, it holds enough to decide whether section 4 is where to look. An index row holds enough to decide whether a document is a candidate. Once it starts holding answers it is a second copy of the corpus, and the second copy drifts.

    Rebuilding the map when a document ships none is a parsing job: Building Document Structure with Loop Engineering recovers an outline from body typography for a PDF that never encoded one.

    3.2. The row, written down

    Six fields, in the handler’s words, with types on them.

    class PolicyIndexRow(BaseModel):
        """One row of the corpus index: one policy, six business fields."""
        doc_id: str              # the file, so an answer can cite where it came from
        policy_number: str       # what the business types into its own systems
        client_name: str         # the party the policy is written for
        product: str             # one of eleven, and the list never changes
        effective_date: date     # the day the cover starts
        renewal_date: date       # the day it lapses if nobody acts
        premium_eur: float       # the number the finance team filters on

    Nothing in that declaration is a modelling decision. Every name came out of the interview. doc_id is the one field the business did not name, and it is there so an answer can point back at the file it was read from.

    Whether the table stays this flat once amendments and versions arrive is the subject of Article 15A (the schema a corpus gets written into), which replaces the single sheet with three tables and two date columns. How each field gets filled comes with the articles after it.

    Take a folder of arXiv papers if you want to try the shape without an insurance portfolio. Same thing: one document type, thousands of copies, and the first three columns come free. A file named 1706.03762v7.pdf gives you the identifier, the version, and the submission month, all three read off the filename before a page is parsed. The primary category is a fourth column and it costs one lookup, because the modern identifier does not encode it: it comes from the arXiv metadata. Then add the task and the datasets used, and the line between a printed field and a judgement shows up within a dozen files. The papers carry the arXiv non-exclusive distribution license declared on each abstract page.

    3.3. The index keeps growing, and that is the design

    A question turns up that the columns cannot answer. Which of these policies carry a war exclusion? There is no such column, so the question falls back to opening documents one at a time.

    Add the column, fill it on the documents it applies to, and every later question about war exclusions is a filter instead of a corpus scan. The cost is paid once and the benefit does not expire. On the naive path the same question pays full price every time somebody asks it.

    Two habits keep that growth honest. Run each new field through the two signals from section 2.2 first, because a column added under pressure from one urgent question is the kind that means three things a year later. And keep a citation on every value, so that a number in the index can be checked against the page it was read from.

    4. Paid once, or paid on every question

    Whether the preparation is worth its price is arithmetic. Here it is.

    4.1. Two phases, and only one of them grows with the questions

    The single-document pipeline does not change. It now sits inside two phases that cost very different things.

    the two phases, and the index they share – Image by author

    Ingestion runs once per document, when the file arrives and before anyone has asked anything. It parses, fills the agreed columns, keeps a page reference for each value, and appends a row. It runs again only when the file changes.

    Querying runs once per question. It reads the scope fields out of the question, filters the index down to the candidates, and runs the pipeline on what survives. Article 17 (querying a corpus, filter first and retrieve second) builds that half.

    Ingestion is bounded by the number of documents. Querying is bounded by the number of questions, and that is the number that keeps going up.

    4.2. Fifty questions a day, and what they add up to

    A claims handler uses a system like this about fifty times a day. That is the order of magnitude we keep seeing, and the exact number does not change what follows. Over a working year it is roughly twelve thousand questions from one person, and a team of six puts it past seventy thousand.

    Without preparation, every one of those questions is priced against the whole shelf. The system works out from scratch which documents are candidates, and it does that by comparing the question against passages from files that had no business being consulted.

    With preparation, the question opens with a filter over a table and the pipeline runs on what comes through. The work per question stops tracking the size of the corpus.

    what is paid once per document, and what is paid on every question – Image by author

    Ingestion is paid once per document and querying once per question. So as soon as the number of questions over the system’s life reaches the same order as the number of documents, the prepared version is ahead on compute. It was ahead earlier than that on two other counts: the answer comes from a document somebody chose, and the filter is something a business user can read and argue with.

    4.3. When the preparation is not worth it

    A document that gets read once, or never, does not justify a deep pass. Filling twelve columns on a one-off appendix costs more than reading the appendix when the question finally arrives, if it ever does.

    So tier the work. A standard policy template consulted thousands of times over a portfolio’s life justifies a deep ingestion, with every field extracted and every cross-reference resolved. The long tail gets the cheap version, which here is the filename, the file metadata and the document type. A document can be promoted later, when its query count says it earned the deeper pass.

    That is the same decision the generation brick makes about models: start cheap, and pay for the expensive path only where it changes the outcome. Loop engineering for RAG generation works that cascade out on the model side.

    5. Conclusion

    On a collection of one document type there is no schema to discover. There is a schema to write down, and it already exists in the practice of the people who handle the documents.

    The preparation starts with an hour of conversation and two signals: a field named without a pause, and two people naming it the same way. What passes both goes into the index. What fails is a subtype, a judgement, or a word that means two things, and each of those is cheaper to catch in the room than after a pass over five thousand files.

    Try the two signals on a folder of your own before writing any ingestion code. Ask the person who handles those files what they filter on, then ask a second one, and see how much of the schema comes back in the first ten seconds.

    Article 14B (the folder whose documents share no field) covers the collection with nothing to put in the columns. Article 14D (case files, one bundle about a single entity) covers the one where a row of the table is a case rather than a document.

    6. Further reading and sources

    Earlier in the series:

    What works, what breaks

    • Baseline Enterprise RAG, from PDF to highlighted answer. The four-brick pipeline end to end: PDF in, highlighted answer out.
    • Embeddings Aren’t Magic: The Predictable Failure Modes of RAG Retrieval. Where embedding similarity wins (synonyms, typos, paraphrase), where it predictably breaks (unknown terms, negation, term-vs-answer relevance), and how to use it anyway.
    • RAG is not machine learning, and the ML toolkit solves the wrong problem. Why chunk-size sweeps and finetuning optimize the wrong thing; route by question type instead.
    • From regex to vision models: which RAG technique fits which problem. Two axes, document complexity and question control, that pick the technique for each case.

    Document parsing

    Question parsing

    Generation

    One-document pipelines

    Also referenced above, listed here without links: Article 14A (three kinds of corpus, and what building for the wrong one costs), Article 14B (the folder whose documents share no field), Article 14D (case files, one bundle about a single entity), Article 15 (preparing a corpus, one column at a time), Article 16 (where the corpus vocabulary comes from, curated against extracted), and Article 17 (querying a corpus, filter first and retrieve second).

    External sources:

    • Darren Edge et al., From Local to Global: A Graph RAG Approach to Query-Focused Summarization, 2024 (arXiv 2404.16130). The opposite bet, stated properly: let a model extract the entities instead of asking the business to name the columns. Read it for the cases where discovery is the only option.
    • Jinyang Li et al., Can LLM Already Serve as A Database Interface? A Big Bench for Large-Scale Database Grounded Text-to-SQLs, 2023 (arXiv 2305.03111). What a question over a typed table looks like once the table exists, measured on 95 real databases.
    • Fatemeh Nargesian et al., Data Lake Management: Challenges and Opportunities, PVLDB 2019 (vldb.org). The same problem in data management, years earlier: a pile of files with no schema is not queryable, and the fix is metadata written at ingestion.
    • Scott Barnett et al., Seven Failure Points When Engineering a Retrieval Augmented Generation System, 2024 (arXiv 2401.05856). Field-measured failure points from three production systems; the missing-document and wrong-document ones are what an index filter removes at the source.
    • Text-to-SQL over a structured index, LlamaIndex documentation (docs.llamaindex.ai). The typed-corpus path as a shipped open-source component, useful for seeing how small the query side gets once the table is there.
    Document Extraction files million queries RAG SQL Structured Table type
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous Article‘The world seems to be ready’: An interview with OpenAI head of product Thibault Sottiaux
    Next Article Uber launches live video streaming for teen accounts
    • Website

    Related Posts

    AI Tools

    How to Master the Art of the AI Image Creator

    AI Tools

    How to Use an AI Text Generator Without Sounding Like a Robot

    AI Tools

    Adobe Firefly: Inside Adobe’s Generative AI Toolkit for Creators

    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Apple’s new desktop computers are designed specifically for local AI development

    0 Views

    Where to preorder the updated Mac Mini and Mac Studio

    0 Views

    Uber launches live video streaming for teen accounts

    0 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews
    AI Tutorials

    Quantization from the ground up

    AI Tools

    David Sacks is done as AI czar — here’s what he’s doing instead

    AI Reviews

    Judge sides with Anthropic to temporarily block the Pentagon’s ban

    Subscribe to Updates

    Get the latest tech news from FooBar about tech, design and biz.

    Most Popular

    Apple’s new desktop computers are designed specifically for local AI development

    0 Views

    Where to preorder the updated Mac Mini and Mac Studio

    0 Views

    Uber launches live video streaming for teen accounts

    0 Views
    Our Picks

    Quantization from the ground up

    David Sacks is done as AI czar — here’s what he’s doing instead

    Judge sides with Anthropic to temporarily block the Pentagon’s ban

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    Facebook X (Twitter) Instagram Pinterest
    • About Us
    • Contact Us
    • Terms & Conditions
    • Privacy Policy
    • Disclaimer

    © 2026 ainewstoday.co. All rights reserved. Designed by DD.

    Type above and press Enter to search. Press Esc to cancel.