Project Overview
This project provides a hands-on demonstration of a DevOps workflow designed to automate and test local development environments with seamless integration into cloud-based DevOps processes. The focus lies on functional and integration testing specifically involving Elasticsearch and Ollama, rather than isolated unit testing.
For the associated Terraform and Kubernetes deployment workflow, please refer to the companion project: https://github.com/kborovik/llmdoc-infra
Core Technology
The llmdoc
Python application employs a Retrieval-Augmented Generation (RAG) approach. It leverages a Large Language Model (LLM) to summarize search results retrieved from Elasticsearch document queries.
Key Dependencies
- spaCy: https://spacy.io/ library for text analysis tasks.
- Elasticsearch for document indexing and search.
- Ollama (or similar) Large Language Model
Workflow Summary
- Text Analysis:
llmdoc
uses spaCy to:- Break text into sentences.
- Generate lemmas (base word forms).
- Group related sentences and lemmas.
- Embedding Generation: An LLM creates text embeddings (numerical representations).
- Elasticsearch Indexing: Embeddings and associated text are stored in Elasticsearch.
Quick Start Guide
- Clone Repository: Get the code from GitHub.
- Environment Setup:
- Set the
ELASTIC_PASSWORD
environment variable. - Initialize your local environment using Docker Compose (Elasticsearch included).
- Set the
- Launch Containers: Start Docker Compose (this runs Elasticsearch, Kibana, and the Ollama LLM).
- Run Tests: Execute the end-to-end test suite.
git clone https://github.com/kborovik/llmdoc.git
cd llmdoc
echo "ELASTIC_PASSWORD=MyBigPass45" > .env
make init status
make test
make init status
Purpose: This pipeline verifies the core functionality of the llmdoc
.
Tested Components and Functionality
- Build Processes
- Successful creation of a Python Wheel package.
- Successful building of the Docker container image.
- Docker Deployment
- Correct configuration of Docker Compose for deployment.
- Search and Indexing
- Indexing of data into ElasticSearch using the
llmdoc
component. - Execution of valid ElasticSearch queries using
llmdoc
.
- Indexing of data into ElasticSearch using the
- LLM (Large Language Model) Integration
- LLM's ability to comprehend a topic without external search results.
- LLM's capability to accurately interpret provided search results.
- API Interactions
- Correct functionality of the
llmdoc
REST API endpoints.
- Correct functionality of the
make test
llmdoc search --query "Who is Count Von Kramm?" --debug
llmdoc index --file tests/test.txt --debug
The deployment was tested on Ubuntu 22.04 (linux/amd64 architecture). Although Windows Subsystem for Linux (WSL) could potentially support the deployment, compatibility in that environment was not verified firsthand.
Install:
Install NVIDIA apt
network repository for Ubuntu
Install NVIDIA Linux drivers
sudo apt install nvidia-headless-545
Install NVIDIA Container Runtime for Docker
sudo apt install nvidia-docker2
Configuration settings can be specified either by exporting environment variables in the command prompt (terminal) or by creating a .env
file. Configuration settings specified through environment variables or in the .env file are not case-sensitive. For example, ELASTIC_PASSWORD
and elastic_password
would be treated equivalently.
export ELASTIC_PASSWORD=MyBigPass45
echo "ELASTIC_PASSWORD=MyBigPass45" >> .env
The full list of supported configuration settings can be found in the llmdoc/config.py
file.
- Split text into sentences with spaCy library
- Lemmatize sentence with spaCy library
- Group sentences into ElasticSearch documents
- Generate embedding for KNN search with Large Language Model (LLM)
- Store documents in ElasticSearch index
- Generate embeddings for KNN search with LLM
- Send combined BM25+KNN query to ElasticSearch
- Construct LLM prompt with ElasticSearch query results
- Steam (or JSON) LLM prediction