# LLM model for table data

**URL:** <https://discuss.huggingface.co/t/llm-model-for-table-data/44230>\
**Category:** Languages at Hugging Face\
**Created:** [June 22, 2023, 9:41pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230 "2023-06-22T21:41:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iamexperimenting](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@Iamexperimenting](https://discuss.huggingface.co/u/Iamexperimenting)\
**Post date:** [June 22, 2023, 9:41pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/1 "2023-06-22T21:41:51Z")

</div>

Hi,

I’m currently working on building Question answering model using LLM(LLama). My data source is pdfs, I have 200 pdf files and I use PyPDF2 to extract data, while extracting the table inside the pdf file is also getting extracted but extracted table structure is messed up. when I tested with model with that messed table data, model isn’t able to answer my question.

So, can anyone recommend any better method to tackle this scenario?

or is there any Large Language model to query table data?

please find the sample table data inside pdf file

sample questions will be like : what is the specification for network data?

 ![mobile_spec](https://us1.discourse-cdn.com/hellohellohello/original/3X/5/7/5715619327470dbcc2576fffa7312dbb7ccc3bfe.png)

#Languages at Hugging Face #🤗Transformers #Beginners

---

<div class="post-metadata">

**Author:** ![guruprasadnk7](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@guruprasadnk7](https://discuss.huggingface.co/u/guruprasadnk7)\
**Post date:** [July 7, 2023, 6:24pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/2 "2023-07-07T18:24:30Z")

</div>

I think your problem is two-fold - (1) Extracting the table data correctly and then (2) Querying on it using an LLM.

For the latter, there are models specifically trained to convert table data to text (such as [RUCAIBox/mtl-data-to-text · Hugging Face](https://huggingface.co/RUCAIBox/mtl-data-to-text)) that could be used to generate natural language text from your tables before querying them?

---

<div class="post-metadata">

**Author:** ![raf-madrigal](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@raf-madrigal](https://discuss.huggingface.co/u/raf-madrigal)\
**Post date:** [August 14, 2023, 1:19am UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/3 "2023-08-14T01:19:24Z")

</div>

I am encountering the same problem. Would you have any thoughts on how to extract the tables correctly? I tried using [UNSTRUCTURED.IO](http://UNSTRUCTURED.IO) but it wasnt able to extract nor detect the tables

Thanks!

---

<div class="post-metadata">

**Author:** ![Fatima19](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@Fatima19](https://discuss.huggingface.co/u/Fatima19)\
**Post date:** [August 22, 2023, 7:52am UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/4 "2023-08-22T07:52:15Z")

</div>

Have you tried _img2table_: [https://betterprogramming.pub/extracting-tables-from-images-in-python-made-easy-ier-3be959555f6f](https://betterprogramming.pub/extracting-tables-from-images-in-python-made-easy-ier-3be959555f6f).

It performes well, even if you have many tables in one page it extacts them and save them in a single execl sheet, in sperate pages.

---

<div class="post-metadata">

**Author:** ![markowanga](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/markowanga/32/19172_2.png) [@markowanga](https://discuss.huggingface.co/u/markowanga)\
**Post date:** [September 4, 2023, 7:26am UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/5 "2023-09-04T07:26:03Z")

</div>

Last time I saw pandoc [https://pandoc.org](https://pandoc.org) , tool can convert documents between many formats. The constant format that connect others by readers and writers are JSON structure. Now I explore the quality of this solution – how works on various documents.

---

<div class="post-metadata">

**Author:** ![sgowdaks](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sgowdaks](https://discuss.huggingface.co/u/sgowdaks)\
**Post date:** [September 12, 2023, 4:14pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/6 "2023-09-12T16:14:24Z")

</div>

Came across [this](https://gpt-index.readthedocs.io/en/latest/examples/query_engine/pdf_tables/recursive_retriever.html) from LlamaIndex and found it helpful.

---

<div class="post-metadata">

**Author:** ![cungnlp](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cungnlp](https://discuss.huggingface.co/u/cungnlp)\
**Post date:** [February 1, 2024, 3:11pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/7 "2024-02-01T15:11:10Z")

</div>

I have read how you shared. But there is a problem: when I install the libraries, it gives me an error, conflicting versions. Can you give me the versions of the necessary libraries?

---

<div class="post-metadata">

**Author:** ![cungnlp](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cungnlp](https://discuss.huggingface.co/u/cungnlp)\
**Post date:** [February 1, 2024, 3:12pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/8 "2024-02-01T15:12:08Z")

</div>

I have read how you shared. But there is a problem: when I install the libraries, it gives me an error, conflicting versions. Can you give me the versions of the necessary libraries? I look forward to your response

---

<div class="post-metadata">

**Author:** ![shivamtripathi0508](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@shivamtripathi0508](https://discuss.huggingface.co/u/shivamtripathi0508)\
**Post date:** [July 21, 2024, 7:43pm UTC](https://discuss.huggingface.co/t/llm-model-for-table-data/44230/11 "2024-07-21T19:43:51Z")

</div>

See You Problem is very simple.

1. Use Python Module Called “Camelot” to extract only tables from pdfs. ([Camelot: PDF Table Extraction for Humans — Camelot 0.11.0 documentation](https://camelot-py.readthedocs.io/en/master/)).

2. export that data into CSV, xlsx, etc.

3. use Pandas.AI to query on data. this requires OpenAI API, or any LLMs Like LLama-3, Mistral, Ollama, Local-LLM, etc.  
(link - [Introduction to PandasAI - PandasAI](https://docs.pandas-ai.com/intro))

please don’t forget to use ChatGPT for Code generation and modification.

---------------- Jai Shree Ram ------------------
