Unverified Commit 1f029b6a authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Adding doctest for document-question-answering (#20239)

* Adding doctest for doc qa.

* Adding doctest for doc qa.

* Fixup.
parent 443aaaa1
...@@ -106,6 +106,22 @@ class DocumentQuestionAnsweringPipeline(ChunkPipeline): ...@@ -106,6 +106,22 @@ class DocumentQuestionAnsweringPipeline(ChunkPipeline):
similar to the (extractive) question answering pipeline; however, the pipeline takes an image (and optional OCR'd similar to the (extractive) question answering pipeline; however, the pipeline takes an image (and optional OCR'd
words/boxes) as input instead of text context. words/boxes) as input instead of text context.
Example:
```python
>>> from transformers import pipeline
>>> document_qa = pipeline(model="impira/layoutlm-document-qa")
>>> result = document_qa(
... image="https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png",
... question="What is the invoice number?",
... )
>>> result[0]["answer"]
'1110212019'
```
[Using pipelines in a webserver or with a dataset](../pipeline_tutorial)
This document question answering pipeline can currently be loaded from [`pipeline`] using the following task This document question answering pipeline can currently be loaded from [`pipeline`] using the following task
identifier: `"document-question-answering"`. identifier: `"document-question-answering"`.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment