LangChain classic: models, documents and vector stores
Chat models with OpenAI and Ollama, a first RAG app, document loaders, text splitters, embeddings, FAISS and Chroma.
Chat models from OpenAI, Google and Ollama; then retrieval-augmented generation (RAG), what it is and why agents rely on it, and each of its steps in turn: loading documents, cutting them into chunks, turning chunks into vectors, and searching them in FAISS and Chroma. Lesson 6.8, A Simple RAG App, puts every step in one script with Gemini, with the same app built cell by cell behind Explain boxes. The code uses LangChain's classic chains; module 09 covers the newer agent API. Run the notebook cells in order, and try each practice task before you open its solution.
Lessons
- 1Chat models, prompts and chainsInstall the module's packages, pick a provider (Gemini, OpenAI, Groq or a local Ollama model), call its chat model, write prompt templates, and chain prompt, model and output parser.
- 2Local models with OllamaInstall Ollama, choose and pull models (general, coding, reasoning, embeddings), run them in the terminal, call them from LangChain with ChatOllama, and stream the answer.
- 3Introduction to RAGWhy language models need RAG, the pipeline built up from first principles, its four stages and two phases, RAG compared with long prompts and fine-tuning, the main RAG architectures, how to improve and evaluate retrieval, and what goes wrong.
- 4Document loadersLoad text files, PDFs, web pages, arXiv papers and Wikipedia articles into Documents, and read their page_content and metadata.
- 5Splitting documents into chunksSplit text with RecursiveCharacterTextSplitter and CharacterTextSplitter, choose chunk size and overlap, and split HTML by headings and JSON by keys.
- 6EmbeddingsCreate embeddings with OpenAI, Ollama and Hugging Face models, tell embed_query from embed_documents, and choose between hosted and local models.
- 7Vector stores: FAISS and ChromaBuild FAISS and Chroma stores from chunks, search them with and without scores, use them as retrievers, save and reopen them, then see how vector search works inside and how to choose a store.
- 8A Simple RAG AppA complete RAG app in one script with Gemini, the points to remember for each step, how to run it, and which line changes for each alternative.