Close Menu
    Trending
    • Dispatch: Partying at one of Africa’s largest AI gatherings
    • Topp 10 AI-filmer genom tiderna
    • OpenAIs nya webbläsare ChatGPT Atlas
    • Creating AI that matters | MIT News
    • Scaling Recommender Transformers to a Billion Parameters
    • Hidden Gems in NumPy: 7 Functions Every Data Scientist Should Know
    • Is RAG Dead? The Rise of Context Engineering and Semantic Layers for Agentic AI
    • ChatGPT Gets More Personal. Is Society Ready for It?
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » Docling: The Document Alchemist | Towards Data Science
    Artificial Intelligence

    Docling: The Document Alchemist | Towards Data Science

    ProfitlyAIBy ProfitlyAISeptember 12, 2025No Comments15 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Why will we nonetheless wrestle with paperwork in 2025?

    in any data-driven organisation, and also you’ll encounter a bunch of PDFs, Phrase information, PowerPoints, half-scanned photographs, handwritten notes, and the occasional shock CSV lurking in a SharePoint folder. Enterprise and knowledge analysts waste hours changing, splitting, and cajoling these codecs into one thing their Python pipelines will settle for. Even the most recent generative-AI stacks can choke when the underlying textual content is wrapped inside graphics or sprinkled throughout irregular desk grids.

    Docling was born to unravel precisely that ache. Launched as an open-source mission by IBM Analysis Zurich and now hosted below the Linux Basis AI & Information Basis, the library abstracts parsing, format understanding, OCR, desk reconstruction, multimodal export, and even audio transcription behind one fairly easy API and CLI command.

    Though docling helps the processing of HTML, MS Workplace format information, Picture codecs and others, we’ll be largely taking a look at utilizing it to course of PDF information.

    As a knowledge scientist or ML engineer, why ought to I care about Docling?

    Typically, the actual bottleneck isn’t constructing the mannequin — it’s feeding it. We spend a big share of our time on knowledge wrangling, and nothing kills productiveness quicker than being handed a vital dataset locked inside a 100-page PDF. That is exactly the issue Docling solves, appearing as a bridge from the world of unstructured paperwork on to the structured sanity of Markdown, JSON, or a Pandas DataFrame. 

    However its energy extends past simply knowledge extraction, straight into the world of recent, AI-assisted growth. Think about pointing docling at an HTML web page of API specs; it effortlessly interprets that advanced net format into clear, structured Markdown — the right context to feed straight into AI coding assistants like Cursor, ChatGPT, or Claude.

    The place Docling got here from

    The mission originated inside IBM’s Deep Search staff, which was growing retrieval-augmented technology (RAG) pipelines for lengthy patent PDFs. They open-sourced the core below an MIT license in late 2024 and have been delivery weekly releases ever since. A vibrant group shortly shaped round its unified DoclingDocument mannequin, a Pydantic object that retains textual content, photographs, tables, formulation, and format metadata collectively so downstream instruments like LangChain, LlamaIndex, or Haystack don’t should guess a web page’s studying order.

    At present, Docling integrates visual-language fashions (VLMs), equivalent to SmolDocling, for determine captioning. It additionally helps Tesseract, EasyOCR, and RapidOCR for textual content extraction and ships recipes for chunking, serialisation, and vector-store ingestion. In different phrases: you level it at a folder, and also you get Markdown, HTML, CSV, PNGs, JSON, or only a ready-to-embed Python object — no additional scaffolding code required. 

    What we’ll do 

    To showcase Docling, we’ll first set up it after which use it with three totally different examples that display its versatility and usefulness as a doc parser and processor. Please be aware that utilizing Docling is kind of computationally intensive, so it is going to be useful when you have entry to a GPU in your system.

    Nonetheless, earlier than we begin coding, we have to arrange a growth setting.

    Organising a growth setting

    I’ve began utilizing the UV package deal supervisor for this now, however be at liberty to make use of whichever instruments you’re most snug with. Observe additionally that I’ll be working below WSL2 Ubuntu for Home windows and working my code utilizing a Jupyter Pocket book. 

    Observe, even utilizing UV, the code under took a few minutes to finish on my system, because it’s a fairly hefty set of library installs.

    $ uv init docling
    Initialized mission `docling` at `/residence/tom/docling`
    $ cd docling
    $ uv venv
    Utilizing CPython 3.11.10 interpreter at: /residence/tom/miniconda3/bin/python
    Creating digital setting at: .venv
    Activate with: supply .venv/bin/activate
    $ supply .venv/bin/activate
    (docling) $ uv pip set up docling pandas jupyter

    Now kind within the command,

    (docling) $ jupyter pocket book

    And you need to see a pocket book open in your browser. If that doesn’t occur mechanically, you’ll doubtless see a screenful of knowledge after working the Jupyter Pocket book command. Close to the underside, you can see a URL to repeat and paste into your browser to launch the Jupyter Pocket book.

    Your URL shall be totally different to mine, but it surely ought to look one thing like this:-

    http://127.0.0.1:8888/tree?token=3b9f7bd07b6966b41b68e2350721b2d0b6f388d248cc69d

    Instance 1: Convert any PDF or DOCX to Markdown or JSON

    The best use case can also be the one you’ll use a big share of the time:- flip a doc’s textual content into Markdown 

    For many of our examples, our enter PDF shall be one I’ve used a number of occasions earlier than for various checks. It’s a copy of Tesla’s 10-Q SEC submitting doc from September 2023. It’s roughly fifty pages lengthy and consists primarily of economic data associated to Tesla. The complete doc is publicly out there on the Securities & Trade Fee (SEC) web site and might be considered/downloaded utilizing this link.

    Right here is a picture of the primary web page of that doc to your reference.

    Picture from Tesla 10-Q PDF

    Let’s evaluation the docling code we have to convert into markdown. It units up the file path for the enter PDF, runs the DocumentConverter operate on it, after which exports the parsed outcome into Markdown format in order that the content material might be extra simply learn, edited, or analysed.

    from docling.document_converter import DocumentConverter
    import time
    from pathlib import Path
    
    inpath = "/mnt/d//tesla"
    infile = "tesla_q10_sept_23.pdf"
    
    data_folder = Path(inpath)
    
    doc_path = data_folder / infile
    
    converter = DocumentConverter()
    outcome    = converter.convert(doc_path)     # → DoclingResult
    
    # Markdown export nonetheless works
    markdown_text = outcome.doc.export_to_markdown()

    That is the output we get from working the above code (simply the primary web page).

    ## UNITED STATES SECURITIES AND EXCHANGE COMMISSION
    
    Washington, D.C. 20549 FORM 10-Q
    
    (Mark One)
    
    - x QUARTERLY REPORT PURSUANT TO SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934
    
    For the quarterly interval ended September 30, 2023
    
    OR
    
    - o TRANSITION REPORT PURSUANT TO SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934
    
    For the transition interval from _________ to _________
    
    Fee File Quantity: 001-34756
    
    ## Tesla, Inc.
    
    (Precise title of registrant as laid out in its constitution)
    
    Delaware
    
    (State or different jurisdiction of incorporation or group)
    
    1 Tesla Highway Austin, Texas
    
    (Deal with of principal govt workplaces)
    
    ## (512) 516-8177
    
    (Registrant's phone quantity, together with space code)
    
    ## Securities registered pursuant to Part 12(b) of the Act:
    
    | Title of every class   | Buying and selling Image(s)   | Identify of every change on which registered   |
    |-----------------------|---------------------|---------------------------------------------|
    | Frequent inventory          | TSLA                | The Nasdaq World Choose Market             |
    
    Point out by examine mark whether or not the registrant (1) has filed all studies required to be filed by Part 13 or 15(d) of the Securities Trade Act of 1934 ('Trade Act') in the course of the previous 12 months (or for such shorter interval that the registrant was required to file such studies), and (2) has been topic to such submitting necessities for the previous 90 days. Sure x No o
    
    Point out by examine mark whether or not the registrant has submitted electronically each Interactive Information File required to be submitted pursuant to Rule 405 of Regulation S-T (§232.405 of this chapter) in the course of the previous 12 months (or for such shorter interval that the registrant was required to submit such information). Sure x No o
    
    Point out by examine mark whether or not the registrant is a big accelerated filer, an accelerated filer, a non-accelerated filer, a smaller reporting firm, or an rising development firm. See the definitions of 'massive accelerated filer,' 'accelerated filer,' 'smaller reporting firm' and 'rising development firm' in Rule 12b-2 of the Trade Act:
    
    Massive accelerated filer
    
    x
    
    Accelerated filer
    
    Non-accelerated filer
    
    o
    
    Smaller reporting firm
    
    Rising development firm
    
    o
    
    If an rising development firm, point out by examine mark if the registrant has elected to not use the prolonged transition interval for complying with any new or revised monetary accounting requirements supplied pursuant to Part 13(a) of the Trade Act. o
    
    Point out by examine mark whether or not the registrant is a shell firm (as outlined in Rule 12b-2 of the Trade Act). Sure o No x
    
    As of October 16, 2023, there have been 3,178,921,391 shares of the registrant's frequent inventory excellent.

    With the rise of AI code editors and the usage of LLMs usually, this system has turn out to be considerably extra useful and related. The efficacy of LLMs and code editors might be considerably enhanced by offering them with acceptable context. Typically this can entail supplying them with the textual illustration of a selected software or framework’s documentation, API and coding examples.

    Changing the output of PDFs to JSON format can also be easy. Simply add these two traces of code. You might encounter limitations with the dimensions of the JSON output, so modify the print assertion accordingly.

    json_blob = outcome.doc.model_dump_json(indent=2)
    
    print(json_blob[10000], "…")

    Instance 2: Extract advanced tables from a PDF

    Many PDFs usually retailer tables as remoted textual content chunks or, worse, as flattened photographs. Docling’s table-structure mannequin reassembles rows, columns, and spanning cells, supplying you with both a Pandas DataFrame or a ready-to-save CSV. Our take a look at enter PDF has many tables. Look, for instance, at web page 11 of the PDF, and we are able to see the desk under,

    Picture from Tesla 10-Q PDF

    Let’s see if we are able to extract that knowledge. It’s barely extra advanced code than in our first instance, but it surely’s doing extra work. The PDF is transformed once more utilizing Docling’s DocumentConverter operate, producing a structured doc illustration. Then, for every desk detected, it transforms the desk right into a Pandas DataFrame and in addition retrieves the web page variety of the desk from the doc’s provenance metadata. If the desk comes from web page 11, it prints it out in Markdown format after which breaks the loop (so solely the primary matching desk is proven).

    import pandas as pd
    from docling.document_converter import DocumentConverter
    from time import time
    from pathlib import Path
    
    inpath = "/mnt/d//tesla"
    infile = "tesla_q10_sept_23.pdf"
    data_folder = Path(inpath)
    input_doc_path = data_folder / infile
    
    doc_converter = DocumentConverter()
    start_time = time()
    conv_res = doc_converter.convert(input_doc_path)
    
    # Export desk from web page 11
    for table_ix, desk in enumerate(conv_res.doc.tables):
        page_number = desk.prov[0].page_no if desk.prov else "Unknown"
        if page_number == 11:
            table_df: pd.DataFrame = desk.export_to_dataframe()
            print(f"## Desk {table_ix} (Web page {page_number})")
            print(table_df.to_markdown())
            break
    
    end_time = time() - start_time
    print(f"Doc transformed and tables exported in {end_time:.2f} seconds.")

    And the output is just not too shabby.

    ## Desk 10 (Web page 11)
    |    |                                        | Three Months Ended September 30,.2023   | Three Months Ended September 30,.2022   | 9 Months Ended September 30,.2023   | 9 Months Ended September 30,.2022   |
    |---:|:---------------------------------------|:----------------------------------------|:----------------------------------------|:---------------------------------------|:---------------------------------------|
    |  0 | Automotive gross sales                       | $ 18,582                                | $ 17,785                                | $ 57,879                               | $ 46,969                               |
    |  1 | Automotive regulatory credit          | 554                                     | 286                                     | 1,357                                  | 1,309                                  |
    |  2 | Power technology and storage gross sales    | 1,416                                   | 966                                     | 4,188                                  | 2,186                                  |
    |  3 | Companies and different                     | 2,166                                   | 1,645                                   | 6,153                                  | 4,390                                  |
    |  4 | Complete revenues from gross sales and providers | 22,718                                  | 20,682                                  | 69,577                                 | 54,854                                 |
    |  5 | Automotive leasing                     | 489                                     | 621                                     | 1,620                                  | 1,877                                  |
    |  6 | Power technology and storage leasing  | 143                                     | 151                                     | 409                                    | 413                                    |
    |  7 | Complete revenues                         | $ 23,350                                | $ 21,454                                | $ 71,606                               | $ 57,144                               |
    Doc transformed and tables exported in 33.43 seconds.

    To retrieve ALL the tables from a PDF, you would wish to omit the if page_number =… line from my code.

    One factor I’ve seen with Docling is that it’s not quick. As proven above, it took virtually 34 seconds to extract that single desk from a 50-page PDF.

    Instance 3: Carry out OCR on an picture.

    For this instance, I scanned a random web page from the Tesla 10-Q PDF and saved it as a PNG file. Let’s see how Docling copes with studying that picture and changing what it finds into markdown. Right here is my scanned picture.

    Picture from Tesla 10-Q PDF

    And our code. We use Tesseract as our OCR engine (others can be found)

    from pathlib import Path
    import time
    import pandas as pd
    
    from docling.document_converter import DocumentConverter, ImageFormatOption
    from docling.fashions.tesseract_ocr_cli_model import TesseractCliOcrOptions
    
    
    def major():
        inpath = "/mnt/d//tesla"
        infile = "10q-image.png"
    
        input_doc_path = Path(inpath) / infile
    
        # Configure OCR for picture enter
        image_options = ImageFormatOption(
            ocr_options=TesseractCliOcrOptions(force_full_page_ocr=True),
            do_table_structure=True,
            table_structure_options={"do_cell_matching": True},
        )
    
        converter = DocumentConverter(
            format_options={"picture": image_options}
        )
    
        start_time = time.time()
    
        conv_res = converter.convert(input_doc_path).doc
    
        # Print all tables as Markdown
        for table_ix, desk in enumerate(conv_res.tables):
            table_df: pd.DataFrame = desk.export_to_dataframe(doc=conv_res)
            page_number = desk.prov[0].page_no if desk.prov else "Unknown"
            print(f"n--- Desk {table_ix+1} (Web page {page_number}) ---")
            print(table_df.to_markdown(index=False))
    
        # Print full doc textual content as Markdown
        print("n--- Full Doc (Markdown) ---")
        print(conv_res.export_to_markdown())
    
        elapsed = time.time() - start_time
        print(f"nProcessing accomplished in {elapsed:.2f} seconds")
    
    
    if __name__ == "__main__":
        major()
    

    Right here is our output.

    --- Desk 1 (Web page 1) ---
    |                          |   Three Months Ended September J0,. | Three Months Ended September J0,.2022   | 9 Months Ended September J0,.2023   | 9 Months Ended September J0,.2022   |
    |:-------------------------|------------------------------------:|:----------------------------------------|:---------------------------------------|:---------------------------------------|
    | Value ol revenves         |                                 181 | 150                                     | 554                                    | 424                                    |
    | Analysis an0 developrent |                                 189 | 124                                     | 491                                    | 389                                    |
    |                          |                                  95 |                                         | 2B3                                    | 328                                    |
    | Complete                    |                                 465 | 362                                     | 1,328                                  | 1,141                                  |
    
    --- Full Doc (Markdown) ---
    ## Observe 8 Fairness Incentive Plans
    
    ## Different Pertormance-Based mostly Grants
    
    ("RSUs") und inventory optlons unrecognized stock-based compensatian
    
    ## Abstract Inventory-Based mostly Compensation Info
    
    |                          | Three Months Ended September J0,   | Three Months Ended September J0,   | 9 Months Ended September J0,   | 9 Months Ended September J0,   |
    |--------------------------|------------------------------------|------------------------------------|-----------------------------------|-----------------------------------|
    |                          |                                    | 2022                               | 2023                              | 2022                              |
    | Value ol revenves         | 181                                | 150                                | 554                               | 424                               |
    | Analysis an0 developrent | 189                                | 124                                | 491                               | 389                               |
    |                          | 95                                 |                                    | 2B3                               | 328                               |
    | Complete                    | 465                                | 362                                | 1,328                             | 1,141                             |
    
    ## Observe 9 Commitments and Contingencies
    
    ## Working Lease Preparations In Buffalo, New York and Shanghai, China
    
    ## Authorized Proceedings
    
    Between september 1 which 2021 pald has
    
    Processing accomplished in 7.64 seconds

    In the event you evaluate this output to the unique picture, the outcomes are disappointing. Lots of the textual content within the picture was simply missed or garbled. That is the place a product like AWS Textract comes into its personal, because it excels at extracting textual content from a variety of sources. 

    Nonetheless, Docling does present numerous choices for OCR, so if you happen to obtain poor outcomes from one system, you’ll be able to at all times change to a different.

    I tried the identical activity utilizing EasyOCR, however the outcomes weren’t considerably totally different from these obtained with Tesseract. In the event you’d prefer to attempt it out, right here is the code.

    from pathlib import Path
    import time
    import pandas as pd
    
    from docling.document_converter import DocumentConverter, ImageFormatOption
    from docling.fashions.easyocr_model import EasyOcrOptions  # Import EasyOCR choices
    
    
    def major():
        inpath = "/mnt/d//tesla"
        infile = "10q-image.png"
    
        input_doc_path = Path(inpath) / infile
    
        # Configure picture pipeline with EasyOCR
        image_options = ImageFormatOption(
            ocr_options=EasyOcrOptions(force_full_page_ocr=True),  # use EasyOCR
            do_table_structure=True,
            table_structure_options={"do_cell_matching": True},
        )
    
        converter = DocumentConverter(
            format_options={"picture": image_options}
        )
    
        start_time = time.time()
    
        conv_res = converter.convert(input_doc_path).doc
    
        # Print all tables as Markdown
        for table_ix, desk in enumerate(conv_res.tables):
            table_df: pd.DataFrame = desk.export_to_dataframe(doc=conv_res)
            page_number = desk.prov[0].page_no if desk.prov else "Unknown"
            print(f"n--- Desk {table_ix+1} (Web page {page_number}) ---")
            print(table_df.to_markdown(index=False))
    
        # Print full doc textual content as Markdown
        print("n--- Full Doc (Markdown) ---")
        print(conv_res.export_to_markdown())
    
        elapsed = time.time() - start_time
        print(f"nProcessing accomplished in {elapsed:.2f} seconds")
    
    
    if __name__ == "__main__":
        major()
    

    Abstract

    The generative-AI growth re-ignited an previous reality: rubbish in, rubbish out. LLMs can hallucinate much less solely once they ingest semantically and spatially coherent enter. Docling offers coherence (more often than not) throughout a number of supply codecs that your stakeholders can current, and does so domestically and reproducibly.

    Docling has its makes use of past the AI world, although. Contemplate the huge variety of paperwork saved in areas equivalent to financial institution vaults, solicitors’ workplaces, and insurance coverage firms worldwide. If these are to be digitised, Docling could present among the options for that.

    Its largest weak point might be the Optical Character Recognition of textual content inside photographs. I attempted utilizing Tesseract and EasyOCR, and the outcomes from each have been disappointing. You’ll most likely want to make use of a industrial product like AWS Textract if you wish to reliably reproduce textual content from these forms of sources.

    It can be gradual. I’ve a reasonably high-spec desktop PC with a GPU, and it took a while on most duties I set it. Nonetheless, in case your enter paperwork are primarily PDFs, Docling might be a useful addition to your textual content processing toolbox.

    I’ve solely scratched the floor of what Docling is able to, and I encourage you to go to their homepage, which might be accessed utilizing the next link to be taught extra.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleIf we use AI to do our work – what is our job, then?
    Next Article Building Research Agents for Tech Insights
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    Creating AI that matters | MIT News

    October 21, 2025
    Artificial Intelligence

    Scaling Recommender Transformers to a Billion Parameters

    October 21, 2025
    Artificial Intelligence

    Hidden Gems in NumPy: 7 Functions Every Data Scientist Should Know

    October 21, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Data Challenges in Conversational AI & How to Mitigate Common

    June 18, 2025

    Absolute Zero Reasoner: AI:n som lär sig själv utan mänsklig data

    May 15, 2025

    Googles imponerande och realistiska videoverktyg Veo 3

    May 26, 2025

    What Clients Really Ask for in AI Projects

    September 27, 2025

    Your ultimate guide to understanding LayoutLM

    September 5, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    What Does “Following Best Practices” Mean in the Age of AI?

    August 14, 2025

    In a first, Google has released data on how much energy an AI prompt uses

    August 21, 2025

    AI sparar lärare värdefull tid i klassrummet

    June 25, 2025
    Our Picks

    Dispatch: Partying at one of Africa’s largest AI gatherings

    October 22, 2025

    Topp 10 AI-filmer genom tiderna

    October 22, 2025

    OpenAIs nya webbläsare ChatGPT Atlas

    October 22, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

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