How to perform custom key-value extraction for pdf (similar to Azure Document Intelligence)? #3238
Replies: 1 comment
-
|
Hi @ranjith-3330! I'm Dosu and I’m helping the docling team. Docling doesn't have a train-and-annotate workflow like Azure Document Intelligence, but it does have something quite close for schema-based key-value extraction: the The user-facing API is from pydantic import BaseModel, Field
from docling.extraction.document_extractor import DocumentExtractor
class InvoiceSchema(BaseModel):
bill_no: str = Field(examples=["A123", "5414"])
total: float = Field(default=10.0, examples=[20.0])
vendor_name: str = Field(examples=["Acme Corp"])
extractor = DocumentExtractor()
result = extractor.extract("your_document.pdf", schema=InvoiceSchema)You can also use a simple dict or JSON string for the schema: schema = {"bill_no": "string", "total": "number", "vendor_name": "string"}The pipeline works by converting each page to an image, serializing your schema template, and then running the NuExtract-2B VLM to extract the structured data [2]. It supports hierarchical/nested Pydantic models for more complex extraction schemas as well [3]. There's a detailed example notebook at Key configuration options include model selection ( To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi team,
I am trying to build a custom document extraction pipeline using Docling and would appreciate your guidance.
Currently, I am using Azure Document Intelligence (Custom Extraction). In that workflow, we upload documents, define the required fields, and annotate values using bounding boxes. After training, the model is able to extract only the specific key-value pairs we need, while ignoring irrelevant text.
I would like to achieve a similar result using Docling, but I’m not sure where to start or which approach to follow.
Could you please suggest:
The right way to implement this in Docling.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions