00:00So, your company has 500 gigabytes of documents in their server and you're asked to connect an AI assistant just like chatpt to answer questions about these documents and you think to yourself, man, how am I supposed to get this done? From your experience, you know that typical chat applications can't accept more than a dozen files
00:16So, you have to use a different method to allow the AI to search, read, and understand the entire files
00:20But how? Maybe you think you can create a clever algorithm to search the title of the documents and its contents to rank them by relevance
00:28But you soon realize that that means that every time the user searches, it would need to search the entire 500 GB of documents
00:34And this is a very inefficient way to get it done
00:39So maybe you try to do something else by doing some pre-processing work before so that preemptively you summarize all documents into searchable chunks
00:45But you also realize in this case that it's not likely going to be an accurate way to get things done
00:50Let's try a different method
00:52Why don't we try to merge these two ideas together and get the best of both worlds? Starting with the large language model, we know that the core idea behind how LLMs actually take an input is word embedding
01:01Meaning human language is turned into numerical representation because computers can't think in words but in numbers
01:08So is it possible that instead of searching through the entire 500 GB of documents, we essentially store these documents by preserving the semantics which means meaning of those words into a vector embedding and store those into a database as vectors
01:22And if we can do that, maybe we can retrieve these faster by splitting the context into chunks in the vector database so that AI assistant can fit them into their context window and generate output from it
01:33This method is called rag or retrieval augmented generation
01:37Let's say one of the use cases for the company to use the AI assistant was to ask questions like can you tell me about last year's service agreement with codecloud
01:44In order to understand how rag works, we need to break them down into three different steps
01:50Retrieval, augmented, and generation
01:52Starting with retrieval, just like how we converted the documents into vector embeddings to store them into the database, we do the exact same step for the question that reads, "Can you tell me about last year's service agreement with CodeCloud?" Once the word embedding for the question is generated, the embedding for the question is compared against the embedding of the documents
02:10This type of search is called semantic search where instead of searching by static keywords to find relevant contents based on its matching the meaning and the context of the query is used to match against the existing document
02:22Moving on to augmentation
02:24Augmentation in rag refers to the process where the retrieved data is injected into the prompt at runtime
02:29And you might think why is this all that special? Typically AI assistants rely on what they learn during pre-training which is static knowledge that can become outdated really fast
02:38Instead, our goal here is to have the AI assistant rely on up-to-date information in the vector database
02:45So, on runtime, we need to be able to provide the AI assistant with important details that could help answer the question like above
02:53In the case of Rag, the semantic search results pend to the prompt that essentially serves as an augmented knowledge
02:59So, for your company, the AI assistant is given details about your company's documents that are real, up-to-date, and private data set
03:06All of this can occur without needing to fine-tune the AI model and modify the large language model
03:12The final step of rag is generation
03:14This step is where AI assistant generates the response given the semantic relevant data retrieved from the vector database
03:21And we have an upcoming video on vector database soon
03:25So make sure to subscribe to be notified when the video is out
03:27So the initial prompt that says, can you tell me about last year's service agreement with CodeCloud? The AI assistant will now demonstrate its understanding of your company's knowledge base by using the documents that relate to service agreements in codecloud
03:40And since the initial prompt specifies the criteria of last year, the generation step will use its own reasoning to wrestle with the data that was provided to get the best answer for the question
03:51Now, rack is a very powerful system that can instantly improve the depth of knowledge beyond its training data
03:58But just like any other system, learning how to calibrate is an acquired skill that needs to be learned to get better result
04:04For example, knowing how to chunk your data before storing them into the vector database is a critical decision that will determine the efficacy of rag
04:12In order to set up a rag system, you have to employ different strategies like chunking strategy where you determine the size and overlap of each chunk
04:22embedding strategy to decide which embedding model to use and to convert your documents into factor embeddings and retrieval strategy where you control the threshold of how similar the words need to be as well as additional filters that you might want to add in the data set
04:37Setting up a rack system will look different from one system to another because it heavily depends on the data set that you're trying to store
04:42For example, legal documents will require a different chunking strategy than say customer support transcript document
04:50This is because legal documents often have long structured paragraph that needs to be preserved
04:54While conversational transcript can be just fine with sentence level chunking with high overlap to preserve context
04:59Now that we covered the conceptual elements of rag, let's look at how it looks like on a practical level
05:05To better understand this, we can look over at this lab specifically geared towards how to use Rag
05:10When I open the lab, I'm dropped right into a real world mission
05:15500 GB of company dogs need to be turned into instant accurate answers through a ragged system
05:20Access the labs using the link in the description below and follow along with me
05:24In the first question, we're asked to set up a development environment
05:28I created a Python virtual environment, activated, install UV, and then pull in Chroma DV Sentence Transformers, OpenAI, and Flask
05:35A tiny marker that says ready confirms that I'm set
05:41The tests check V and V exist
05:41UV is available
05:44All four packages are installed nice and clean
05:46In the next question, we're asked to review TechC Corps document vault
05:50I skimmed the simulated repo of Markdown docs, employee handbook, product specs, meeting notes, and frequently asked questions
05:58The key takeaway is that we'll treat these like a real enterprise corpus and make them searchable by meeting, not just keywords
06:03Explore this question by yourself to get a real feel for the data set
06:08In the following question, we're asked to initialize our vector database
06:11I spin up Chromma DB locally using a persistent client and create a collection named tech corpse_docs
06:18The test verifies a chroma db directory exists and the initialization script is present
06:23This is our AI brain storage
06:25In the next question, we're asked to learn the chunking strategy
06:29I write a small script that chunks text with a size 500 and overlap 100
06:34This preserves context across boundaries and improve retrieval quality
06:39It prints chunk stats and writes a verification file with a chunk count
06:43The test checks the script exists and output file is valid
06:46Chunking is critical for accuracy
06:48In the next question, we're asked to understand embedding
06:51I load all mini LML L6V2 from sentence transformers, encode a few short sentences, and compute similarities
06:58The test checks that a result file exists and contains similarity values
07:02The big idea here is that questions and documents both become vectors
07:07So we can measure meaning not just words
07:09So dogs allowed and pets permitted have a high similarity
07:13However, remote work does not have similarity
07:15In the next question, we're asked to feed the AI brain
07:17This is where it comes together
07:19I iterate through Techqu's document chunking file size 500, stride 400, embed each chunk with all mini LML6V2, and store vectors plus metadata into the techp docs collection
07:32It logs per file progress and writes a summary
07:35documents are processed in total chunks
07:37The test confirm the ingest script exists
07:39The completion file is created and the format is valid
07:43This is our knowledge ingestion pipeline
07:46In the next question, we're asked to activate semantic search
07:49I built a tiny search engine script, load the collection, embed three CEO style queries, and fetch top results by semantic similarity
07:56It writes results to a file, prints structured output
08:01The test ensure the script exist, the result files exist, and all three queries ran
08:05Explore this question by yourself to read the results and see how well meaningbased search works
08:11In the following question, we're asked to launch a simple web interface
08:15I ask a flask app port 5000, then run a running marker
08:22[Music] [Music] We're asked to test like the CEO
08:45I open the app and try questions such as what's the pet policy? I watch the rag flow, retrieve, augment, generate with sources
08:55Then I mark the test as tested
08:58This is where demo value shines
08:58answers grounded in our private docs
09:00With retrieval plus augmentation plus generation in place, we're ready for a UI to ask questions
09:06We've got an end-to-end rack system that's fast, grounded, and extensible
09:10A few things I pay special attention to along this way
09:15The model is all mini LML6 V2, which is compact and effective
09:18For chunking, size 500 with overlap 400 for test, stride 400 in ingestion
09:23Both preserve context for better recall
09:26For storage, Chromma persists client with documents tech corpse_docs
09:33For web, simple flask app on port 5000 for quick evaluation
09:36For safety, similarity threshold keeps lowquality matches out, reducing hallucination
09:42Before wrapping up, explore these questions by yourself and notice how retrieval quality and answer helpfulness change with small tuning
09:48That's it
09:48We went from zero to working rag system backed by real tests, clean structure, and a demo interface
09:55Go and try it yourself
10:05[Music]