Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Docling reader and node parser #16406

Merged
merged 10 commits into from
Oct 8, 2024

Conversation

vagenas
Copy link
Contributor

@vagenas vagenas commented Oct 7, 2024

Description

Docling extracts PDF documents to a rich representation (incl. layout, tables etc.), which it can export to Markdown or JSON.
As outlined in the Docling Technical Report, Docling is based on two models developed by IBM Research, namely a DocLayNet-based layout analysis model and the TableFormer table recognition model.

This PR adds Docling support to LlamaIndex by introducing:

  • a Docling Reader (llama_index.readers.docling.DoclingReader, which can export to Markdown and JSON, and
  • a Docling Node Parser (llama_index.node_parser.docling.DoclingNodeParser), which can parse the above-mentioned JSON format to LlamaIndex nodes.

By using these extensions, LlamaIndex users will be able to leverage Docling's conversion quality as well as as the rich metadata it can extract — as showcased in the example notebook of this PR.

Dependencies

  • docling: Docling PDF conversion
  • docling-core: Document document data model and core transformations (e.g. chunking)

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
    • ⚠️ added docstrings & an example notebook, but docs deployment within MkDocs remains to be clarified
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 7, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@logan-markewich logan-markewich self-assigned this Oct 7, 2024
@vagenas
Copy link
Contributor Author

vagenas commented Oct 7, 2024

Thanks @logan-markewich for the quick reaction! 🙏

Regarding the unit tests, I guess it's still some silly path resolution glitch - or could it be there is something filtering out non-Python / test data files (e.g. JSON) on the fly? 🤔

Besides, Docling supports Python 3.10 and upwards & I see that e.g. the coverage GH Action is hard-coded to 3.9. Perhaps you have some idea how to handle this?

@vagenas
Copy link
Contributor Author

vagenas commented Oct 7, 2024

@logan-markewich
Do you folks take care of updating the docs separately?

Or otherwise can you guide how to best address the two points below?

I would namely also like to include the doc-related changes for:

  • docs/mkdocs.yml
  • docs/docs/api_reference/node_parser/docling.md
  • docs/docs/api_reference/readers/docling.md
  • docs/docs/modules_guides/loading/connector/modules.md

However I experienced some discrepancies when building docs locally:

  1. (some .md files were causing the build to fail (e.g. docs/docs/api_reference/tools/oracleai.md) so I had to remove them locally for it to work, and
  2. calling python docs/prepare_for_build.py to refresh docs/mkdocs.yml also adds other entries, not related to Docling.

@logan-markewich
Copy link
Collaborator

logan-markewich commented Oct 7, 2024

@vagenas we take care of docs manually, docs are manually published when a release of llama-index-core / llama-index is made (this is what /stable of the docs points to)

The prepare_for_build script takes care of everything, but I generally only run it before a release (hence it adding stuff unrelated to docling)

This usually happens every 3ish days

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 8, 2024
@logan-markewich logan-markewich merged commit 0b19dea into run-llama:main Oct 8, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants