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

[Document Understanding] Can we support a new task on document understanding? #218

Closed
jlia0 opened this issue Jul 26, 2023 · 12 comments · Fixed by #987
Closed

[Document Understanding] Can we support a new task on document understanding? #218

jlia0 opened this issue Jul 26, 2023 · 12 comments · Fixed by #987
Labels
enhancement New feature or request

Comments

@jlia0
Copy link

jlia0 commented Jul 26, 2023

Document Understanding

Some example models:

  1. DiT: https://huggingface.co/microsoft/dit-large
  2. LayoutLMv3: https://huggingface.co/microsoft/layoutlmv3-large
  3. Donut: https://huggingface.co/docs/transformers/model_doc/donut

Reason for request

Document understanding is a very popular task which I couldn't find any supports for the web environment.

Some tasks include:

  1. Key Information Extraction (KIE)
  2. Document Layout Analysis (DLA)
  3. Document Question Answering (DQA)
  4. Optical Character Recognition (OCR)
@jlia0 jlia0 added the enhancement New feature or request label Jul 26, 2023
@xenova
Copy link
Collaborator

xenova commented Jul 26, 2023

Those do sound like quite interesting use-cases! Do you mind sharing example code for how you would use the models, as well as the inputs and expected outputs?

@jlia0
Copy link
Author

jlia0 commented Jul 26, 2023

Here's an example code using detectron2 and DiT on document layout analysis.

DiT Doc: https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/dit
HF Space: https://huggingface.co/spaces/imjliao/dit-document-layout-analysis/blob/main/app.py

@xenova
Copy link
Collaborator

xenova commented Jul 26, 2023

The repo you shared is private, but I assume I can use this one: https://huggingface.co/spaces/nielsr/dit-document-layout-analysis

@jlia0
Copy link
Author

jlia0 commented Jul 26, 2023

The repo you shared is private, but I assume I can use this one: https://huggingface.co/spaces/nielsr/dit-document-layout-analysis

Oh yes sorry! I forgot it's my private repo. But you're correct, I am using that one as well.

How do you think we can include this to transformer.js? Seems like there is a dependency issue of detectron2...

@xenova
Copy link
Collaborator

xenova commented Jul 26, 2023

Hmm, that might complicate things somewhat... Perhaps there is a JS library out there which is a suitable substitute?

@jlia0
Copy link
Author

jlia0 commented Jul 26, 2023

Hmm, that might complicate things somewhat... Perhaps there is a JS library out there which is a suitable substitute?

I don't see a JS library out there could do similar stuffs. But I found something that's worth checking out:

https://github.com/Unstructured-IO/unstructured-inference/blob/main/unstructured_inference/models/detectron2onnx.py

^^^ This is a working example of detectron2 using ONNXRuntime...

@xenova
Copy link
Collaborator

xenova commented Oct 30, 2023

Just an update on this:

The other tasks (Key Information Extraction and Document Layout Analysis) might be slightly more difficult to add (due the their additional dependencies)... but we'll get there eventually :)

@martinsomm
Copy link

Dear @xenova :) I'm trying to implement https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.DocumentQuestionAnsweringPipeline while importing transformers.js from cdn as described in https://huggingface.co/docs/transformers.js/main/en/tutorials/vanilla-js#step-2-javascript-setup.

I get error below

transformers:187 Uncaught Error: This pipeline is not yet supported in Transformers.js v3. at Function._call (transformers:187:16286) at e (transformers:214:134)

Wondering how to circumvent this issue..

Thanks and best regards
Martin

@xenova
Copy link
Collaborator

xenova commented Oct 23, 2024

Thanks @martinsomm for the report - this will be fixed by #987.

@martinsomm
Copy link

Hi @xenova and wow, thanks for the swift turnaround, very much appreciate your effort :) now I'm wondering when the change will be available on jsdelivr as I still get the same exception, even after "empty cache and hard refresh" in browser.

Best regards, Martin

@xenova
Copy link
Collaborator

xenova commented Oct 25, 2024

@martinsomm We've now published https://www.npmjs.com/package/@huggingface/transformers/v/3.0.1, so you can import it from jsdelivr using:

import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]';

@martinsomm
Copy link

martinsomm commented Oct 29, 2024

@xenova thanks again :) now I get updated version from jsdelivr.. this is probably the wrong channel to address another question.. I was wondering what it would take to make batch processing possible, so we can ask multiple questions per image. I can see a comment that currently only batch size of 1 is supported for the DocumentQuestionAnsweringPipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants