

## Getting started with the model

To run these examples, you must have [PIL](https://pillow.readthedocs.io/en/stable/installation.html), [pytesseract](https://pypi.org/project/pytesseract/), and [PyTorch](https://pytorch.org/get-started/locally/) installed in addition to [transformers](https://huggingface.co/docs/transformers/index).

```python
from transformers import pipeline

nlp = pipeline(
    "document-question-answering",
    model="impira/layoutlm-document-qa",
)

nlp(
    "https://templates.invoicehome.com/invoice-template-us-neat-750px.png",
    "What is the invoice number?"
)
# {'score': 0.9943977, 'answer': 'us-001', 'start': 15, 'end': 15}

nlp(
    "https://miro.medium.com/max/787/1*iECQRIiOGTmEFLdWkVIH2g.jpeg",
    "What is the purchase amount?"
)
# {'score': 0.9912159, 'answer': '$1,000,000,000', 'start': 97, 'end': 97}

nlp(
    "https://www.accountingcoach.com/wp-content/uploads/2013/10/income-statement-example@2x.png",
    "What are the 2020 net sales?"
)
# {'score': 0.59147286, 'answer': '$ 3,750', 'start': 19, 'end': 20}
```

**NOTE**: This model and pipeline was recently landed in transformers via [PR #18407](https://github.com/huggingface/transformers/pull/18407) and [PR #18414](https://github.com/huggingface/transformers/pull/18414), so you'll need to use a recent version of transformers, for example:

```bash
pip install git+https://github.com/huggingface/transformers.git@2ef774211733f0acf8d3415f9284c49ef219e991
```
{"language": ["pt", "en"], "license": "apache-2.0", "library_name": "adapter-transformers", "tags": ["document-question-answering", "pdf"], "pipeline_tag": "document-question-answering", "widget": [{"text": "Qual \u00e9 o n\u00famero da fatura?", "src": "https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"}, {"text": "Qual \u00e9 o valor da compra?", "src": "https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/contract.jpeg"}]}
adapter-transformers pytorch tf safetensors layoutlm document-question-answering pdf pt en license:apache-2.0 has_space region:us
TAGS
#adapter-transformers #pytorch #tf #safetensors #layoutlm #document-question-answering #pdf #pt #en #license-apache-2.0 #has_space #region-us 



## Getting started with the model

To run these examples, you must have PIL, pytesseract, and PyTorch installed in addition to transformers.



NOTE: This model and pipeline was recently landed in transformers via PR #18407 and PR #18414, so you'll need to use a recent version of transformers, for example:


## Getting started with the model

To run these examples, you must have PIL, pytesseract, and PyTorch installed in addition to transformers.



NOTE: This model and pipeline was recently landed in transformers via PR #18407 and PR #18414, so you'll need to use a recent version of transformers, for example:
TAGS
#adapter-transformers #pytorch #tf #safetensors #layoutlm #document-question-answering #pdf #pt #en #license-apache-2.0 #has_space #region-us 
 ## Getting started with the model

To run these examples, you must have PIL, pytesseract, and PyTorch installed in addition to transformers.



NOTE: This model and pipeline was recently landed in transformers via PR #18407 and PR #18414, so you'll need to use a recent version of transformers, for example: