back to home

PacktPublishing / LLM-Engineers-Handbook

The LLM's practical guide: From the fundamentals to deploying advanced LLM and RAG apps to AWS using LLMOps best practices

4,834 stars
1,158 forks
28 issues
PythonDockerfile

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing PacktPublishing/LLM-Engineers-Handbook in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/PacktPublishing/LLM-Engineers-Handbook)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

πŸ‘· LLM Engineer's Handbook Official repository of the LLM Engineer's Handbook by Paul Iusztin and Maxime Labonne Find the book on Amazon or Packt 🌟 Features The goal of this book is to create your own end-to-end LLM-based system using best practices: β€’ πŸ“ Data collection & generation β€’ πŸ”„ LLM training pipeline β€’ πŸ“Š Simple RAG system β€’ πŸš€ Production-ready AWS deployment β€’ πŸ” Comprehensive monitoring β€’ πŸ§ͺ Testing and evaluation framework You can download and use the final trained model on Hugging Face. > [!IMPORTANT] > The code in this GitHub repository is actively maintained and may contain updates not reflected in the book. **Always refer to this repository for the latest version of the code.** πŸ”— Dependencies Local dependencies To install and run the project locally, you need the following dependencies. | Tool | Version | Purpose | Installation Link | |------|---------|---------|------------------| | pyenv | β‰₯2.3.36 | Multiple Python versions (optional) | Install Guide | | Python | 3.11 | Runtime environment | Download | | Poetry | >= 1.8.3 and [!NOTE] > If you are experiencing issues while installing and running the repository, consider checking the Issues GitHub section for other people who solved similar problems or directly asking us for help. β€’ Clone the Repository Start by cloning the repository and navigating to the project directory: Next, we have to prepare your Python environment and its adjacent dependencies. β€’ Set Up Python Environment The project requires Python 3.11. You can either use your global Python installation or set up a project-specific version using pyenv. Option A: Using Global Python (if version 3.11 is installed) Verify your Python version: Option B: Using pyenv (recommended) β€’ Verify pyenv installation: β€’ Install Python 3.11.8: β€’ Verify the installation: β€’ Confirm Python version in the project directory: > [!NOTE] > The project includes a file that automatically sets the correct Python version when you're in the project directory. β€’ Install Dependencies The project uses Poetry for dependency management. β€’ Verify Poetry installation: β€’ Set up the project environment and install dependencies: This will: β€’ Configure Poetry to use Python 3.11 β€’ Install project dependencies (excluding AWS-specific packages) β€’ Set up pre-commit hooks for code verification β€’ Activate the Environment As our task manager, we run all the scripts using Poe the Poet. β€’ Start a Poetry shell: β€’ Run project commands using Poe the Poet: πŸ”§ Troubleshooting Poe the Poet Installation Alternative Command Execution If you're experiencing issues with , you can still run the project commands directly through Poetry. Here's how: β€’ Look up the command definition in β€’ Use with the underlying command Example: Instead of: Use the direct command from pyproject.toml: Note: All project commands are defined in the [tool.poe.tasks] section of pyproject.toml Now, let's configure our local project with all the necessary credentials and tokens to run the code locally. β€’ Local Development Setup After you have installed all the dependencies, you must create and fill aΒ  file with your credentials to appropriately interact with other services and run the project. Setting your sensitive credentials in a file is a good security practice, as this file won't be committed to GitHub or shared with anyone else. β€’ First, copy our example by running the following: β€’ Now, let's understand how to fill in all the essential variables within the file to get you started. The following are the mandatory settings we must complete when working locally: OpenAI To authenticate to OpenAI's API, you must fill out the env var with an authentication token. β†’ Check out this tutorial to learn how to provide one from OpenAI. Hugging Face To authenticate to Hugging Face, you must fill out the env var with an authentication token. β†’ Check out this tutorial to learn how to provide one from Hugging Face. Comet ML & Opik To authenticate to Comet ML (required only during training) and Opik, you must fill out the env var with your authentication token. β†’ Check out this tutorial to learn how to get started with Opik. You can also access Opik's dashboard using πŸ”—this link. β€’ Deployment Setup When deploying the project to the cloud, we must set additional settings for Mongo, Qdrant, and AWS. If you are just working locally, the default values of these env vars will work out of the box. Detailed deployment instructions are available in Chapter 11 of the LLM Engineer's Handbook. MongoDB We must change the env var with the URL pointing to your cloud MongoDB cluster. β†’ Check out this tutorial to learn how to create and host a MongoDB cluster for free. Qdrant Change to , with the URL point to your cloud Qdrant cluster, and with its API key. β†’ Check out this tutorial to learn how to create a Qdrant cluster for free AWS For your AWS set-up to work correctly, you need the AWS CLI installed on your local machine and properly configured with an admin user (or a user with enough permissions to create new SageMaker, ECR, and S3 resources; using an admin user will make everything more straightforward). Chapter 2 provides step-by-step instructions on how to install the AWS CLI, create an admin user on AWS, and get an access key to set up the and environment variables. If you already have an AWS admin user in place, you have to configure the following env vars in your file: AWS credentials are typically stored in . You can view this file directly using or similar commands: > [!IMPORTANT] > Additional configuration options are available in settings.py. Any variable in the class can be configured through the file. πŸ—οΈ Infrastructure Local infrastructure (for testing and development) When running the project locally, we host a MongoDB and Qdrant database using Docker. Also, a testing ZenML server is made available through their Python package. > [!WARNING] > You need Docker installed (>= v27.1.1) For ease of use,…