Skip to main content

Ollama RAG Generator (German edition)

A tool to digest PDF files for Large Language Models and serving them via a REST API, including their source references.

The command line toolkit that provides methods:

  • ppf: to preprocess PDF files and create context augmented chunks that are stored into a Qdrant vector database collection.
  • ask: to send a query to the LLM engine
  • chat_server: to start a FastAPI chat server interface that uses the LLM engine to answer questions

Prerequisites

  1. Get your https://github.com/nlmatics/nlm-ingestor up and running:
docker run --rm -p 5010:5001 ghcr.io/nlmatics/nlm-ingestor:latest
  1. You need to have a running instance of Qdrant. You can use the following command to start a Qdrant instance:
docker run --rm -p 6333:6333 -p 6334:6334 -v /tmp/qdrant:/data qdrant/qdrant:latest
  1. You need to have a running instance of Ollama. You can use the following command to start a Ollama instance:
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

See more at documentation at Docker Hub

Run the preprocessor

Clone the repository and install the dependencies:

poetry install

and then run the preprocessor:

ppf --help

Output:

Usage: ppf [OPTIONS] FOLDER_PATH

  Process a folder of OLLAMA pdf input data.

Options:
  -llm, --llmsherpa_api_url TEXT  URL of the LLMSherpa API to use for
                                  processing the PDFs. Default is "http://loca
                                  lhost:5010/api/parseDocument?renderFormat=al
                                  l"
  -o, --output PATH               Output folder for the processed data.
                                  Default is "output".
  -f, --format [txt|raw|sections|chunks]
                                  Output format for the processed data.
                                  Default is "chunks"
  -r, --recursive                 Process the folder recursively, otherwise
                                  only the top level is processed.
  -db, --database TEXT            Store the processed data to "qdrant".
                                  Default collection is "rag"
  -si, --include_section_info     Include section information in the output.
  --help                          Show this message and exit.

In order to preprocess a folder of PDF input data, run the following command:

ppf '/mnt/OneDrive/Shared Files' -db rag -o '/tmp' -r

This reads the PDF files located in specified folder recursively and stores the processed data in the /tmp folder. Also, the processed data is stored in the rag collection in the qdrant database.

Ask questions

Run the chat server

To start the chat server, run the following command:

chat_server --help

Usage: chat_server [OPTIONS]

  Start the chat server with uvicorn.

Options:
  -h, --host TEXT        Host the server runs on. Default is `localhost`
  -c, --collection TEXT  Index collection name to use for the query.
                         Default is "rag".
  -p, --port INTEGER     Port to run the server on. (8000)
  -d, --debug            Run the server in debug mode.
  --help                 Show this message and exit.

Metadata

Release files for ollama-rag-de 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ollama-rag-de 0.1.0
File Size Uploaded
ollama_rag_de-0.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ollama-rag-de 0.1.0
File Interpreter ABI Platform
ollama_rag_de-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / ollama_rag_de-0.1.0.tar.gz

Download URL ollama_rag_de-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8302d9c96b389d6a720812e08d984540b9fb8ad241aa251cc324c1590a51e365
BLAKE2b-256 checksum
How to use checksums
4c63fab6ac5b1b66da317093559af2b873895b926408b526404e537d635ad6b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Linux/6.5.0-1017-azure

Release files / ollama_rag_de-0.1.0-py3-none-any.whl

Download URL ollama_rag_de-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db01b484e90daf69aa460d8fc6d407126e0822374c4109cd56dc65cb20b188b2
BLAKE2b-256 checksum
How to use checksums
5dcd4b6fe353a28b2e43ccbbe2ff7528243aa9a9dbf4d0414f21af4cbf683264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Linux/6.5.0-1017-azure

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page