# Training a model for a PDF with OCR - where to begin?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%3E%5C
**Category:** Beginners\
**Created:** [May 22, 2023, 11:29am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616 "2023-05-22T11:29:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![syedkhairi](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@syedkhairi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsyedkhairi)%5C
**Post date:** [May 22, 2023, 11:29am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%2F1 "2023-05-22T11:29:48Z")

</div>

Total newbie here when it comes to ML etc.

I have a pdf with pages that look like this which I can export to jpegs:

 ![IMG_2688](https://us1.discourse-cdn.com/hellohellohello/original/3X/6/7/674f2989c2ca818aee86ee6e6e74163a4653c16d.jpeg)

I want to train my model to be able to get the:

1. Question number
2. The question linked to the number
3. The number of marks linked to that question
4. Any diagrams linked to the question
5. Any answer spaces linked to the question

I’m having a go at using Label Studio to label the areas. Then train with Tensorflow? Is this correct first steps?

Once I labelled them, how do I know that it also extract or taking into account the actual text or content - not just ‘how it looks like’?

Extra: Once trained, how can I integrate my model into embeddings(?) so that I can use LLM (GPT etc) to query/chat bot etc?

Would appreciate any help or how you would approach this?

Many thanks in advance.

S

---

<div class="post-metadata">

**Author:** ![wsfung2008](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@wsfung2008](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fwsfung2008)%5C
**Post date:** [May 22, 2023, 1:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%2F2 "2023-05-22T13:06:19Z")

</div>

You may want to consider using an existing library.

This article gives a nice intro to the topic.

> **[Accelerating Document AI](https://huggingface.co/blog/document-ai)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

Google also recently released a model pix2struct.

---

<div class="post-metadata">

**Author:** ![syedkhairi](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@syedkhairi](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsyedkhairi)%5C
**Post date:** [May 22, 2023, 2:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%2F3 "2023-05-22T14:50:44Z")

</div>

This is massively helpful to get me started! I’ll take a look at Donut & pix2struct!

Thank you!

---

<div class="post-metadata">

**Author:** ![ThePie](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thepie/32/22087_2.png) [@ThePie](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FThePie)%5C
**Post date:** [December 13, 2023, 5:00am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%2F4 "2023-12-13T05:00:18Z")

</div>

Any updates on what was chosen? @syedkhairi @wsfung2008

---

<div class="post-metadata">

**Author:** ![prasantapanja](https://avatars.discourse-cdn.com/v4/letter/p/e9c0ed/32.png) [@prasantapanja](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fprasantapanja)%5C
**Post date:** [October 27, 2024, 10:26am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftraining-a-model-for-a-pdf-with-ocr-where-to-begin%2F40616%2F5 "2024-10-27T10:26:21Z")

</div>

Hope you guys are doing well. Do you have any update @syedkhairi @wsfung2008 regarding this use case? Interested to know how you finally cracked upon this as simple storing and retrieving of text embedding doesn’t solve this.
