← Master Index
Vol. 14 Module 14.3 Lecture Capstone

Haystack

LangChain & Orchestration Frameworks

How This Lesson Fits the Module & Volume

Haystack (by deepset) is Volume 14’s orchestration capstone: production-minded pipelines and components for NLP and RAG—retrievers, readers, rankers, generators—composable as explicit graphs. It sits beside LangChain and LlamaIndex as a battle-tested search/RAG framework.

After this lecture you leave Vol. 14 with retrieval + stores + orchestration literacy, ready for Volume 15 AI Agents.

Learning Objectives

By the end of this lesson, students should be able to:

  • Describe Haystack pipelines as directed graphs of components.
  • Wire a minimal RAG pipeline (embedder, retriever, generator).
  • Contrast Haystack pipelines with LangChain LCEL and LangGraph agents.
  • Explain document stores and component I/O contracts.
  • Synthesize a Vol. 14 stack choice: store + orchestration + agent path.
  • Articulate how Vol. 14 skills feed Volume 15 agent design.
Definition

Haystack is an open-source framework for building production search and RAG systems. Applications are pipelines: components (embedders, retrievers, rankers, generators, routers) connected so data flows through an explicit, testable graph.

Framework Capstone Comparison

FrameworkBest mental modelVol 15 bridge
LangChainRunnable app glueTools + chains → agents
LangGraphStateful agent graphsDirect agent control plane
LlamaIndexIndexes & query enginesRetrieval inside agents
CrewAI / AutoGenMulti-agent teams/chatsMulti-agent systems
PydanticAITyped agent I/OReliable tool contracts
HaystackSearch/RAG pipelinesRetrieval subgraphs for agents

Minimal RAG Pipeline Sketch

from haystack import Pipeline from haystack.components.embedders import ( SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder, ) from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever from haystack.components.generators import OpenAIGenerator from haystack.components.builders import PromptBuilder from haystack.document_stores.in_memory import InMemoryDocumentStore from haystack.components.writers import DocumentWriter from haystack import Document document_store = InMemoryDocumentStore() docs = [ Document(content="SSO is configured under Admin > Security.", meta={"product": "auth"}), Document(content="Invoices live under Workspace > Billing.", meta={"product": "billing"}), ] indexing = Pipeline() indexing.add_component("doc_embedder", SentenceTransformersDocumentEmbedder()) indexing.add_component("writer", DocumentWriter(document_store)) indexing.connect("doc_embedder", "writer") indexing.run({"doc_embedder": {"documents": docs}}) prompt = """Answer using the context. Context: {% for doc in documents %}{{ doc.content }}{% endfor %} Question: {{ query }} """ rag = Pipeline() rag.add_component("text_embedder", SentenceTransformersTextEmbedder()) rag.add_component("retriever", InMemoryEmbeddingRetriever(document_store)) rag.add_component("prompt", PromptBuilder(template=prompt)) rag.add_component("llm", OpenAIGenerator(model="gpt-4o-mini")) rag.connect("text_embedder.embedding", "retriever.query_embedding") rag.connect("retriever", "prompt.documents") rag.connect("prompt", "llm") out = rag.run({ "text_embedder": {"text": "Where do I configure SSO?"}, "prompt": {"query": "Where do I configure SSO?"}, }) print(out["llm"]["replies"][0])

Volume 14 → Volume 15 Bridge

14.1 RAG

Chunks & retrieval

14.2 Stores

Vectors at scale

14.3 Orch.

Pipelines & agents

15 Agents

Loops, tools, memory

Haystack pipelines are excellent retrieval subgraphs inside larger agents: an agent (LangGraph/PydanticAI/Crew) can call a Haystack RAG pipeline as a tool, then plan next actions with Volume 15 patterns—memory, reflection, multi-agent handoffs.

Strengths

  • Explicit, testable pipelines
  • Strong IR/RAG heritage
  • Clear component contracts
  • Production search mindset

Tradeoffs

  • Less “agent playground” than CrewAI
  • Pipeline design overhead
  • Need document store ops
  • Ecosystem overlaps others
Common Misconception

“One orchestration framework must do everything.” Mature stacks mix: Haystack or LlamaIndex for retrieval pipelines, LangGraph for agent control, PydanticAI for typed tool I/O, Qdrant/Milvus for vectors. Composition beats monoculture.

Knowledge Check

  1. Short Answer: What is a Haystack pipeline? Answer: A graph of components connected to process data for search/RAG.
  2. True/False: Components have defined inputs/outputs you connect. Answer: True.
  3. Multiple Choice: Haystack is especially associated with: (a) only CSS, (b) production search/RAG pipelines, (c) CUDA drivers. Answer: (b).
  4. Short Answer: Name one component type in a RAG pipeline. Answer: Embedder, retriever, ranker, prompt builder, generator (any).
  5. True/False: Haystack replaces the need for Volume 15 agent concepts. Answer: False.
  6. Multiple Choice: A good Vol 15 pattern is to treat RAG pipelines as: (a) illegal, (b) tools/subgraphs for agents, (c) only batch ETL. Answer: (b).
  7. Short Answer: Why prefer explicit pipelines? Answer: Testability, clarity, production debugging.
  8. Short Answer: Name two other 14.3 frameworks and their focus. Answer: e.g. LangGraph=state graphs; CrewAI=role crews; PydanticAI=typed agents (any two).
  9. Multiple Choice: Mixing frameworks is: (a) always forbidden, (b) often pragmatic, (c) only for CNNs. Answer: (b).
  10. True/False: Volume 14 ends by bridging into AI Agents (Vol. 15). Answer: True.

Key Takeaways

  • Haystack builds explicit RAG/search pipelines from composable components.
  • It caps Vol. 14 orchestration beside LangChain, LlamaIndex, and agent frameworks.
  • Retrieval pipelines become tools inside Volume 15 agents.
  • Choose stores (14.2) and orchestrators (14.3) by control, scale, and typing needs.
  • Next volume: AI Agent—loops, tools, memory, multi-agent systems.
Trainer’s Guide

Capstone: Teams propose a full stack—one vector DB from 14.2 + one primary orchestrator from 14.3 + how an agent in Vol 15 will call RAG as a tool. 5-minute architecture pitches.

Lab: Implement the indexing + RAG pipelines above on a 10-document corpus; swap InMemory for a Module 14.2 store if time allows.

Recap: Haystack pipelines close Volume 14’s orchestration story. Continue to Volume 15 — AI Agent.