Introduction to the “Retrieval Augmented Generation for Production with LlamaIndex and LangChain” Course
Activeloop, Towards AI, and the Intel Disruptor Initiative are excited to collaborate to bring Gen AI 360: Foundational Model Certification Course for aspiring Generative AI professionals, executives, and enthusiasts of tomorrow.
Following the success of our "LangChain & Vector Databases In Production" and "Training and Fine-tuning LLMs for Production” courses, we're excited to welcome you to the third and final part of the series: “Retrieval Augmented Generation for Production with LlamaIndex and LangChain.”
In this course, you'll learn how to build on RAG techniques learned in the first Langchain and Vector DBs in Production course. In particular, you will learn advanced RAG techniques with LlamaIndex and how to build RAG agents and RAG evaluation systems. This course will guide you on the optimal methods and practices for getting RAG production-ready with plenty of applied industry project examples. Let's get started!
Why This Course?
The “Retrieval Augmented Generation for Production with LlamaIndex and LangChain” course provides the theoretical knowledge and practical skills necessary to build advanced RAG products.
We think a large number of human tasks across various industries can be assisted with AI through a combination of LLMs, prompting, RAG, and fine-tuning workflows.
We are huge fans of RAG because it helps with 1) reducing hallucinations by limiting the LLM to answer based on existing documentation, 2) helping with explainability, error checking, and copyright issues by clearly referencing its sources for each comment, 3) giving private/specific or more up to date data to the LLM, 4) and not relying on more black box LLM training/fine tuning for what the models know and has memorized.
We touched upon basic RAG in our first Langchain and Vector DBs course, but building more advanced and reliable products requires more complex techniques and iterations of the model.
The 'RAG for production' course aims to provide you with both the theoretical knowledge and practical skills necessary to develop products and applications centered on RAG.
A fundamental pillar of our course is the focus on hands-on learning. We strongly believe that real-world application and experimentation are crucial for a deep understanding and effective use of RAG techniques.
In this course, you will move beyond basic RAG apps, develop these applications with more advanced techniques, build RAG agents, and evaluate the performance of RAG systems.
Who Should Take This Course?
This course is designed with a wide audience in mind, including beginners in AI, current machine learning engineers, students, and professionals considering a career transition to AI. Please know that prior knowledge of coding and Python is a prerequisite.
What You Will Learn
You will start by learning the basic RAG tools, such as loading, indexing, storing, and querying in both Langchain and LlamaIndex. We’ll also demystify the two libraries to help you select the right one when working with RAG or other LLM applications. You will then move towards more advanced RAG techniques aimed at surfacing and using more relevant information from the dataset. We cover techniques such as Query expansion, Transformation reranking, recursive retrieval, optimization, and production tips and techniques with LlamaIndex. We also introduce how better embedding management through something like Activeloop’s Deep Memory can be used to improve accuracy. We then progress to the exciting stuff: learning how to build RAG agents in Langchain and Llamaindex, as well as an introduction to OpenAI assistants and some other tools & models that can be used in RAG products. We conclude with a summary of RAG evaluation techniques in LlamaIndex together with an introduction to Langsmith in Langchain.
Is the Course Free?
Yes, the course is entirely free for everybody. However, running the project examples yourself will cost you some API and cloud credits.
Certification
By participating in this course and completing the quizzes at the end of each chapter, you will have the opportunity to earn a certification in using Deep Lake - a valuable addition to your professional credentials. This certification program, offered at no cost, forms part of the Deep Lake Foundational Model Certification Program in collaboration with Intel Disruptor Initiative and Towards AI.
Course Logistics
Here's everything you need to know about the course.
Course Hosting and Pace
This course is hosted by Activeloop. It is designed as a self-paced learning journey, allowing you to proceed at your own comfort. The online format provides flexibility to engage with the lessons whenever it best suits you.
At the end of each module, you can test your new knowledge with multiple-choice quizzes, which are mandatory to continue the course. You will receive your course certification after completing all the quizzes.
Community Support
Have questions about this course or specific lessons? Want to exchange ideas with fellow learners? We encourage active interaction in the dedicated forum in the Towards AI’s Learn AI Together Discord Community, a vibrant community of over 55,000 AI experts and enthusiasts. Our community has a dedicated channel for this course where you can ask questions and share insights.
For queries specifically related to Deep Lake, please join the Deep Lake Slack community, where experts and users will be ready to assist.
Required Platforms, Tools, and Cloud Tokens
The course involves practical projects and exercises that require various tools and platforms. These will be thoroughly guided in the individual lessons. However, the main platforms that you will use throughout the course are:
- Activeloop’s Deep Lake
- Open AI
- LlamaIndex
- Langchain
- Langchain’s Langsmith
What is Activeloop?
Activeloop is a tech company dedicated to building data infrastructure optimized for deep-learning applications. It offers a platform that seamlessly connects unstructured data types, like audio, video, and images, to machine learning models. Their main product, Deep Lake, ensures data streaming, scalable machine learning pipelines, and dataset version control. Such infrastructures are particularly beneficial when dealing with the demands of training and fine-tuning models for production.
What is Deep Lake?
Deep Lake is an open-source data lake designed for deep learning applications. It retains essential features of traditional data lakes, including SQL queries, ACID transactions, and dataset visualization. It specializes in storing complex data in tensor form, efficiently streaming data to deep learning frameworks. Built to be serverless on a columnar storage format, it also offers native version control and in-browser data visualization, complementing the needs of LLM training and deployment processes.
How to set up a Deep Lake account?
To set up a Deep Lake account, navigate to the app’s registration page and sign up. Follow the on-screen instructions and add the required details. Once you've verified your email and established a secure password, your account will be active and ready for use.
How to get the Deep Lake API token?
- After logging in, you should see your homepage. You should now see a “Create API token” button at the top of your homepage. Click on it, and you’ll get redirected to the “API tokens” page. This is where you can generate, manage, and revoke your API keys for accessing Deep Lake.
- Click on the "Create API token" button. You should see a popup asking for a token name and an expiration date. By default, the token expiration date is one year. Once you’ve set the token name and its expiration date, click the “Create API token” button.
- You should now see a green banner saying that the token has been successfully generated, along with your new API token, on the “API tokens” page. To copy your token to your clipboard, click the square icon on its right.
Coding Environment and Packages
Before starting this course, you need to ensure that you have the appropriate coding environment ready. Please make sure to use a Python version equal to or later than 3.8.1. You can set up your environment by choosing one of the following options:
- Having a code editor installed on your computer. A popular coding environment is Visual Studio Code.
- Using Python virtual environments to manage Python libraries.
- Alternatively, you could use Google Colab notebooks.
You will need the following packages to successfully execute the sample codes provided in each lesson. They can be installed using the pip
package manager.
deeplake==3.6.19
openai==0.27.8
tiktoken==0.4.0
transformers==4.32.0
torch==2.0.1
numpy==1.23.5
deepspeed==0.10.1
trl==0.7.1
peft==0.5.0
wandb==0.15.8
bitsandbytes==0.41.1
accelerate==0.22.0
tqdm==4.66.1
neural_compressor===2.2.1
onnx===1.14.1
pandas==2.0.3
scipy==1.11.2
While we strongly recommend installing the latest versions of these packages, please note that the codes have been tested with the versions specified in parentheses. Moreover, specific lessons may require the installation of additional packages, which will be explicitly mentioned. The following code will demonstrate how to install a package using pip.
pip install deeplake
# Or: (to install an specific version)
# pip install deeplake==3.6.5
Google Colab
Google Colaboratory, popularly known as Google Colab, is a free cloud-based Jupyter notebook environment. Data scientists and engineers widely use it to train machine learning and deep learning models using CPUs, GPUs, and TPUs. Google Colab comes with an array of features, such as:
- Free access to GPUs and TPUs for accelerated model training.
- A web-based interface for a service running on a virtual machine, eliminating the need for local software installation.
- Seamless integration with Google Drive and GitHub.
To use Google Colab, all you need is a Google account. You can run terminal commands directly in notebook cells by appending an exclamation mark (!) before the command. Every notebook created in Google Colab gets stored in your Google Drive for easy access.
A convenient way of using API keys in Colab involves:
- Saving them in a file named
.env
on your Google Drive. Here’s how the file should be formatted to save the Activeloop token and the OpenAI API key.
ACTIVELOOP_TOKEN=your_activeloop_token
OPENAI_API_KEY=your_openai_key
- Mounting your Google Drive on your Colab instance.
- Loading them as environment variables using the
dotenv
library, like in the following code.
from dotenv import load_dotenv
load_dotenv('/content/drive/MyDrive/path/to/.env')
Creating Python Virtual Environments
Python virtual environments offer an excellent solution for managing Python libraries and avoiding package conflicts. They create isolated environments for installing packages, ensuring that your packages and their dependencies are contained within that environment. This setup provides clean and isolated environments for your Python projects.
Begin by executing the python
command in your terminal to confirm that the Python version is either equal to or greater than 3.8.1. Then follow these steps to create a virtual environment:
- Create a virtual environment using the command
python -m venv my_venv_name
. - Activate the virtual environment by executing
source my_venv_name/bin/activate
. - Install the required libraries and run the code snippets from the lessons within the virtual environment.
Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries.
📝 Legal Note on Availability of Credits & Applicable Terms 📝
Availability of Credits:
- Validity: Credits acquired upon completion of the GenAI360 Foundational Model Certification Course must be redeemed within [12] months of the course completion date, after which they will become void.
- Usage: Credits are applicable for use across select programs, courses, workshops, or other specified opportunities offered by Activeloop and/or Cohere or Lambda and cannot be transferred to external platforms or exchanged for cash or other forms of payment.
Terms & Conditions:
- Eligibility: Credits are available only to qualifying participants who have successfully completed the GenAI360 Foundational Model Certification Course and have adhered to all course and evaluation criteria.
- Redemption: Credits can only be redeemed by the individual participant to whom they were issued and are non-transferable to other individuals or entities.
- Modification: Activeloop reserves the right to modify the availability, applicability, or value of credits without prior notice. Participants will be notified of any such changes via registered email.
- Verification: All participant details and attached documents will undergo a verification process. Any discrepancies or fraudulent information may result in the forfeiture of credits and possible exclusion from future programs.
- Data Protection: Participant data will be handled with utmost confidentiality and will only be used for the purpose of credit redemption in compliance with applicable data protection regulations.
- Limitation: The credits are not stackable and cannot be combined with other ongoing offers or discounts unless explicitly mentioned.
- Discrepancies: In case of any discrepancies or issues related to credit redemption, decisions made by Activeloop will be considered final.
- Communication: Participants agree to receive communications regarding the credit redemption process and other relevant information from GenAI360 and Cohere.
- Governing Law: The credit redemption process and associated terms are governed by the applicable laws in the jurisdiction of Activeloop’s registered location.
By redeeming the credits, participants acknowledge and agree to adhere to the aforementioned terms and conditions. Any violation of the same may result in appropriate actions as deemed suitable by Activeloop.