MCPcopy Index your code
hub / github.com/decodingai-magazine/llm-twin-course

github.com/decodingai-magazine/llm-twin-course @main sqlite

repository ↗ · DeepWiki ↗
486 symbols 2,039 edges 155 files 56 documented · 12%
README
<h2>LLM Twin Course: Building Your Production-Ready AI Replica</h2>
<h1>Learn to architect and implement a production-ready LLM & RAG system by building your LLM Twin</h1>
<h3>From data gathering to productionizing LLMs using LLMOps good practices.</h3>
<a href="https://trendshift.io/repositories/20253" target="_blank"><img src="https://trendshift.io/api/badge/repositories/20253" alt="decodingai-magazine%2Fllm-twin-course | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<i>by <a href="https://decodingai.com">Decoding AI</i>

Your image description

🎯 What you'll learn

By finishing the "LLM Twin: Building Your Production-Ready AI Replica" free course, you will learn how to design, train, and deploy a production-ready LLM twin of yourself powered by LLMs, vector DBs, and LLMOps good practices.

No more isolated scripts or Notebooks! Learn production ML by building and deploying an end-to-end production-grade LLM system.

📖 About this course

You will learn how to architect and build a real-world LLM system from start to finish - from data collection to deployment.

You will also learn to leverage MLOps best practices, such as experiment trackers, model registries, prompt monitoring, and versioning.

The end goal? Build and deploy your own LLM twin.

What is an LLM Twin? It is an AI character that learns to write like somebody by incorporating its style and personality into an LLM.

🪈 The architecture of the LLM Twin is split into 4 Python microservices

LLM Twin Architecture

The data collection pipeline

  • Crawl your digital data from various social media platforms, such as Medium, Substack and GitHub.
  • Clean, normalize and load the data to a Mongo NoSQL DB through a series of ETL pipelines.
  • Send database changes to a RabbitMQ queue using the CDC pattern.
  • Learn to package the crawlers as AWS Lambda functions.

The feature pipeline

  • Consume messages in real-time from a queue through a Bytewax streaming pipeline.
  • Every message will be cleaned, chunked, embedded and loaded into a Qdrant vector DB.
  • In the bonus series, we refactor the cleaning, chunking, and embedding logic using Superlinked, a specialized vector compute engine. We will also load and index the vectors to a Redis vector DB.

The training pipeline

  • Create a custom instruction dataset based on your custom digital data to do SFT.
  • Fine-tune an LLM using LoRA or QLoRA.
  • Use Comet ML's experiment tracker to monitor the experiments.
  • Evaluate the LLM using Opik
  • Save and version the best model to the Hugging Face model registry.
  • Run and automate the training pipeline using AWS SageMaker.

The inference pipeline

  • Load the fine-tuned LLM from the Hugging Face model registry.
  • Deploy the LLM as a scalable REST API using AWS SageMaker inference endpoints.
  • Enhance the prompts using advanced RAG techniques.
  • Monitor the prompts and LLM generated results using Opik
  • In the bonus series, we refactor the advanced RAG layer to write more optimal queries using Superlinked.
  • Wrap up everything with a Gradio UI (as seen below) where you can start playing around with the LLM Twin to generate content that follows your writing style.

Gradio UI

Along the 4 microservices, you will learn to integrate 4 serverless tools:

  • Comet ML as your experiment tracker and data registry;
  • Qdrant as your vector DB;
  • AWS SageMaker as your ML infrastructure;
  • Opik as your prompt evaluation and monitoring tool.

Decoding ML Logo

📬 Stay Updated

Join Decoding ML for proven content on designing, coding, and deploying production-grade AI systems with software engineering and MLOps best practices to help you ship AI applications. Every week, straight to your inbox.

Subscribe Now

👥 Who should join?

This course is ideal for: - ML/AI engineers who want to learn to engineer production-ready LLM & RAG systems using LLMOps good principles - Data Engineers, Data Scientists, and Software Engineers wanting to understand the engineering behind LLM & RAG systems

Note: This course focuses on engineering practices and end-to-end system implementation rather than theoretical model optimization or research.

🎓 Prerequisites

Category Requirements
Skills Basic understanding of Python and Machine Learning
Hardware Any modern laptop/workstation will do the job, as the LLM fine-tuning and inference will be done on AWS SageMaker.
Level Intermediate

💰 Cost structure

All tools used throughout the course will stick to their free tier, except:

  • OpenAI's API, which will cost ~$1
  • AWS for fine-tuning and inference, which will cost < $10 depending on how much you play around with our scripts and your region.

🥂 Open-source course: Participation is open and Free

As an open-source course, you don't have to enroll. Everything is self-paced, free of charge and with its resources freely accessible as follows: - code: this GitHub repository - articles: Decoding ML

📚 How will you learn?

The course contains 10 hands-on written lessons and the open-source code you can access on GitHub, showing how to build an end-to-end LLM system.

Also, it includes 2 bonus lessons on how to improve the RAG system.

You can read everything at your own pace.

Lessons

This self-paced course consists of 12 comprehensive lessons covering theory, system design, and hands-on implementation.

Our recommendation for each module: 1. Read the article 2. Run the code to replicate our results 3. Go deeper into the code by reading the src Python modules

[!NOTE] Check the INSTALL_AND_USAGE doc for a step-by-step installation and usage guide.

Lesson Article Category Description Source Code
1 An End-to-End Framework for Production-Ready LLM Systems System Design Learn the overall architecture and design principles of production LLM systems. No code
2 Data Crawling Data Engineering Learn to crawl and process social media content for LLM training. src/data_crawling
3 CDC Magic Data Engineering Learn to implement Change Data Capture (CDC) for syncing two data sources. src/data_cdc
4 Feature Streaming Pipelines Feature Pipeline Build real-time streaming pipelines for LLM and RAG data processing. src/feature_pipeline
5 Advanced RAG Algorithms Feature Pipeline Implement advanced RAG techniques for better retrieval. src/feature_pipeline
6 Generate Fine-Tuning Instruct Datasets Training Pipeline Create custom instruct datasets for LLM fine-tuning. src/feature_pipeline/generate_dataset
7 LLM Fine-tuning Pipeline Training Pipeline Build an end-to-end LLM fine-tuning pipeline and deploy it to AWS SageMaker. src/training_pipeline
8 LLM & RAG Evaluation Training Pipeline Learn to evaluate LLM and RAG system performance. src/inference_pipeline/evaluation
9 Implement and Deploy the RAG Inference Pipeline Inference Pipeline Design, implement and deploy the RAG inference to AWS SageMaker. src/inference_pipeline
10 Prompt Monitoring Inference Pipeline Build the prompt monitoring and production evaluation pipeline. src/inference_pipeline
11 Refactor the RAG module using 74.3% Less Code Bonus on RAG Optimize the RAG system. src/bonus_superlinked_rag
12 Multi-Index RAG Apps Bonus on RAG Build advanced multi-index RAG apps. src/bonus_superlinked_rag

Decoding ML Logo

📬 Stay Updated

Join Decoding ML for proven content on designing, coding, and deploying production-grade AI systems with software engineering and MLOps best practices to help you ship AI applications. Every week, straight to your inbox.

Subscribe Now

🏗️ Project Structure

At Decoding ML we teach how to build production ML systems, thus the course follows the structure of a real-world Python project:

llm-twin-course/
├── src/                     # Source code for all the ML pipelines and services
│ ├── data_crawling/         # Data collection pipeline code
│ ├── data_cdc/              # Change Data Capture (CDC) pipeline code
│ ├── feature_pipeline/      # Feature engineering pipeline code
│ ├── training_pipeline/     # Training pipeline code
│ ├── inference_pipeline/    # Inference service code
│ └── bonus_superlinked_rag/ # Bonus RAG optimization code
├── .env.example             # Example environment variables template
├── Makefile                 # Commands to build and run the project
├── pyproject.toml           # Project dependencies

🚀 Install & Usage

To understand how to install and run the LLM Twin code end-to-end, go to the INSTALL_AND_USAGE dedicated document.

[!NOTE] Even though you can run everything solely using the INSTALL_AND_USAGE dedicated document, we recommend that you read the articles to understand the LLM Twin system and design choices fully.

💡 Questions and troubleshooting

Have questions or running into issues? We're here to help!

Open a GitHub issue for: - Questions about the course material - Technical troubleshooting - Clarification on concepts

🥂 Contributing

As an open-source course, we may not be able to fix all the bugs that arise.

If you find any bugs and know how to fix them, support future readers by contributing to this course with your bug fix.

We will deeply appreciate your support for the AI

Core symbols most depended-on inside this repo

get_logger
called by 19
src/core/logger_utils.py
find
called by 14
src/core/db/documents.py
load
called by 9
src/bonus_superlinked_rag/server/runner/executor/app/service/data_loader.py
get_logger
called by 7
src/bonus_superlinked_rag/utils/logging.py
register
called by 7
src/bonus_superlinked_rag/server/runner/executor/app/service/persistence_service.py
get_bucket
called by 6
src/bonus_superlinked_rag/server/runner/poller/app/resource_handler/local/local_resource_handler.py
generate
called by 5
src/inference_pipeline/llm_twin.py
patch_localhost
called by 5
src/core/config.py

Shape

Method 250
Class 158
Function 73
Route 5

Languages

Python100%

Modules by API surface

src/core/db/documents.py16 symbols
src/feature_pipeline/data_logic/dispatchers.py14 symbols
src/bonus_superlinked_rag/server/runner/executor/app/router/management_router.py12 symbols
src/training_pipeline/finetune.py11 symbols
src/feature_pipeline/generate_dataset/generate.py11 symbols
src/feature_pipeline/data_flow/stream_output.py11 symbols
src/data_crawling/crawlers/linkedin.py10 symbols
src/core/rag/prompt_templates.py10 symbols
src/core/mq.py10 symbols
src/bonus_superlinked_rag/superlinked_client.py10 symbols
src/bonus_superlinked_rag/mq.py10 symbols
src/bonus_superlinked_rag/llm/prompt_templates.py10 symbols

Dependencies from manifests, versioned

accelerate0.33.0 · 1×
bitsandbytes0.43.3 · 1×
comet-ml3.44.3 · 1×
datasets2.20.0 · 1×
flash-attn2.3.6 · 1×
peft0.12.0 · 1×
torch2.4.0 · 1×
transformers4.43.3 · 1×
trl0.9.6 · 1×
unsloth2024.9.post2 · 1×

Datastores touched

articlesCollection · 1 repos
postsCollection · 1 repos
repositoriesCollection · 1 repos
usersCollection · 1 repos
(mongodb)Database · 1 repos
twinDatabase · 1 repos

For agents

$ claude mcp add llm-twin-course \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact