Video summary

What are Runnables in LangChain | Generative AI using LangChain | Video 8 | CampusX

Main summary

Key takeaways

Technology

Summary

The video explains LangChain Runnables: what they are, why LangChain introduced them, and how they make it easier to connect components into workflows.

Why LangChain Needed a Common Interface

LangChain initially offered components for tasks such as calling language models, formatting prompts, loading and splitting documents, creating embeddings, retrieving relevant text, and parsing outputs. Developers could combine these components to build applications, including simple LLM apps and PDF question-answering systems.

However, components used different methods. For example, prompt templates used format, while LLMs used predict. To connect components, LangChain had to provide many specialized chains, such as an LLM chain and a retrieval QA chain. As the number of chains grew, the codebase became harder to maintain and the library’s learning curve steeper.

What a Runnable Is

A Runnable is a unit of work: it accepts input, processes it, and returns output. Runnables follow a shared interface, so components can be connected without writing custom glue code for every combination.

The video highlights these common operations:

  • invoke: Run a component with an input and receive its output.
  • batch: Process multiple inputs.
  • Streaming: Receive output incrementally.

Because components share the same interface, the output from one Runnable can be passed directly to the next Runnable as input. A connected workflow is itself a Runnable, so workflows can be combined into larger workflows. The instructor compares this composability to connecting LEGO blocks.

Tutorial and Code Demonstrations

The video includes a from-scratch coding tutorial using simplified, mock components:

  1. Build basic components: Create dummy LLM, prompt-template, and output-parser classes.
  2. Show the problem with inconsistent interfaces: Manually call methods such as format and predict to connect the components.
  3. Standardize the components: Define an abstract Runnable class with an invoke method, then adapt the components to follow that interface.
  4. Compose workflows: Create a connector that invokes a sequence of Runnables, passing each step’s output to the next.
  5. Combine chains: Build a two-stage example that generates a joke from a topic, then passes the result to another step for an explanation.

The mock LLM returns preset responses rather than generating real language-model output. The examples demonstrate workflow structure, not model quality. The instructor also relates the concept to LangChain’s actual class hierarchy, where model classes inherit from Runnable-related base classes.

Other Examples and Context

The instructor recaps earlier material on sequential, parallel, and conditional chains. He also describes two application patterns:

  • A simple prompt-to-LLM application.
  • A PDF question-answering flow involving document loading, splitting, embeddings, vector storage, retrieval, and a final LLM response.

These examples illustrate the kinds of workflows that LangChain components and chains were designed to support.

Main speaker/source: Nitish (also rendered as “Nitesh” in the subtitles), CampusX instructor.

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video