> For the complete documentation index, see [llms.txt](https://nomadamas.gitbook.io/ragchain-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nomadamas.gitbook.io/ragchain-docs/ragchain-structure/file-loader/ocr/deepdoctection-loader.md).

# Deepdoctection Loader

## Overview

The `DeepdoctectionPDFLoader` class is a powerful tool for loading academic document PDF files. It leverages the capabilities of the Deepdoctection model, developed by deepdoctection, to provide an accurate conversion of academic papers from PDF format.

## Usage

### Run Deepdoctection API sever

You must run Deepdoctection API server for using this loader. You will need server with CUDA installed for running deepdoctection model properly. More detailed installation of deepdoctection, please go to [official github repo](https://github.com/deepdoctection/deepdoctection).

#### Use Docker (Recommend)

First, clone NomaDamas/deepdoctection repository to your machine, and move to docker/NomaDamas-api-server folder.

```bash
git clone https://github.com/NomaDamas/deepdoctection-api-server.git
cd deepdoctection-api-server/docker/NomaDamas-api-server
```

Then, build and run your docker container following this [instruction](https://github.com/NomaDamas/deepdoctection-api-server/tree/master/docker/NomaDamas-api-server).

#### Use Local Environment

First, clone NomaDamas/deepdoctection-api-server repository to your machine, and move to folder.

```bash
git clone https://github.com/NomaDamas/deepdoctection-api-server.git
cd deepdoctection-api-server
```

Then, run api server with this command.

```bash
python3 setup.py install
python3 app.py
```

### Initialization

After runs your Deepdoctection API server, you first need to create an instance by providing two parameters: `file_path` and `deepdoctection_host`.

* **file\_path**: This is a string representing the path to your PDF file.
* **deepdoctection\_host**: This is a string representing the host address where your Deepdoctection API server is running.

Example:

<pre class="language-python"><code class="lang-python"><strong>from RAGchain.preprocess.loader import DeepdoctectionPDFLoader
</strong>
<strong>loader = DeepdoctectionPDFLoader(file_path="path/to/your/file.pdf", deepdoctection_host="http://localhost:8000")
</strong></code></pre>

During initialization, it checks if it can establish a connection with the provided Deepdoctection server host. If it cannot establish a connection, it raises a ValueError.

### Loading Documents

The class provides two methods for loading documents: `load()` and `lazy_load()`.

Example:

```python
documents = loader.load()
```

or

```python
for doc in loader.lazy_load():
    # process each document here...
```

These methods return instances of Document objects that contain processed content from your PDF file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nomadamas.gitbook.io/ragchain-docs/ragchain-structure/file-loader/ocr/deepdoctection-loader.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
