Package: llama-index-readers-docugami
Docugami LoaderThis loader takes in IDs of PDF, DOCX or DOC files processed byDocugamiand returns nodes in a Document XML Knowledge Graph for each document. This is a rich representation that includes the semantic and structural characteristics of various chunks in the document as an XML tree. Entire sets of documents are processed, resulting in forests of XML semantic trees.Pre-requisitesCreate a Docugami workspace:http://www.docugami.com(free trials available)Add your documents (PDF, DOCX or DOC) and allow Docugami to ingest and cluster them into sets of similar documents, e.g. NDAs, Lease Agreements, and Service Agreements. There is no fixed set of document types supported by the system, the clusters created depend on your particular documents, and you canchange the docset assignmentslater.Create an access token via the Developer Playground for your workspace. Detailed instructions:https://help.docugami.com/home/docugami-apiExplore the Docugami API athttps://api-docs.docugami.comto get a list of your processed docset IDs, or just the document IDs for a particular docset.UsageTo use this loader, you simply need to pass in a Docugami Doc Set ID, and optionally an array of Document IDs (by default, all documents in the Doc Set are loaded).fromllama_index.coreimportdownload_loaderDocugamiReader=download_loader("DocugamiReader")docset_id="tjwrr2ekqkc3"document_ids=["ui7pkriyckwi","1be3o7ch10iy"]loader=DocugamiReader()documents=loader.load_data(docset_id=docset_id,document_ids=document_ids)This loader is designed to be used as a way to load data intoLlamaIndexand/or subsequently used as a Tool in aLangChainAgent. Seeherefor examples.See more information about how to use Docugami with LangChain in theLangChain docs.Advantages vs Other Chunking TechniquesAppropriate chunking of your documents is critical for retrieval from documents. Many chunking techniques exist, including simple ones that rely on whitespace and recursive chunk splitting based on character length. Docugami offers a different approach:Intelligent Chunking:Docugami breaks down every document into a hierarchical semantic XML tree of chunks of varying sizes, from single words or numerical values to entire sections. These chunks follow the semantic contours of the document, providing a more meaningful representation than arbitrary length or simple whitespace-based chunking.Structured Representation:In addition, the XML tree indicates the structural contours of every document, using attributes denoting headings, paragraphs, lists, tables, and other common elements, and does that consistently across all supported document formats, such as scanned PDFs or DOCX files. It appropriately handles long-form document characteristics like page headers/footers or multi-column flows for clean text extraction.Semantic Annotations:Chunks are annotated with semantic tags that are coherent across the document set, facilitating consistent hierarchical queries across multiple documents, even if they are written and formatted differently. For example, in set of lease agreements, you can easily identify key provisions like the Landlord, Tenant, or Renewal Date, as well as more complex information such as the wording of any sub-lease provision or whether a specific jurisdiction has an exception section within a Termination Clause.Additional Metadata:Chunks are also annotated with additional metadata, if a user has been using Docugami. This additional metadata can be used for high-accuracy Document QA without context window restrictions. See detailed code walk-through inthis notebook.