liveBook · Manning

LangChain

As explained in Data Storytelling with Altair and AI

LangChain is a software framework for building applications that connect language models with prompts, external data sources, and other components.

LangChain is a framework for connecting language models with external sources and assembling context-aware applications. Its central idea is a chain: components from different modules working together. section 7.4.2

A chain can combine:

  • LLM wrappers for providers such as OpenAI and Hugging Face. section 7.4.2
  • Prompt templates for chatbot and question-answering tasks. section 7.4.2
  • Indexes that supply additional context from external data. section 7.4.2

Product-description RAG application

Load an HTML product page, split it into overlapping chunks, generate embeddings, persist the chunks in Chroma, and connect the store to a RetrievalQA chain. A prompt restricts answers to retrieved context, while ChatOpenAI generates the response and returns source documents.

Figure 7.13 A RAG-based system
figure

Architecture diagram for the retrieval-augmented generation system. section 7.4.2

How Data Storytelling with Altair and AI covers it

How deep it goes
Explains chains and components, then demonstrates loading, chunking, embedding, retrieval, prompting, and querying.
Examples
Uses a smartphone HTML page, Chroma collection, OpenAI embeddings, a constrained prompt, and a RetrievalQA query.
What it assumes
Assumes an HTML data source and access to an LLM, embeddings, and vector database components.
What you can do after
Build a retrieval-augmented application that answers product questions from indexed HTML context.
How it connects
Connects LLMs with prompt templates, indexes, embeddings, vector databases, retrieval, and retrieval-augmented generation.

Also explained in

Compare how 19 books explain LangChain →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Storytelling with Altair and AI. The section links point to the parts of the book it draws on.