Cette page est affichée en anglais. Une traduction française est en cours.
SkillsMar 30, 2026·2 min de lecture

Haystack — AI Orchestration for Search & RAG

Open-source AI orchestration framework by deepset. Build production RAG pipelines, semantic search, and agent workflows with modular components. 25K+ GitHub stars.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Haystack — AI Orchestration for Search & RAG
Commande d'installation directe
npx -y tokrepo@latest install 761bd107-7156-4c62-b268-62a3fb9818dc --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
A Python framework by deepset for building production RAG pipelines and semantic search with composable components.
§01

What it is

Haystack is an open-source Python framework by deepset for building AI applications focused on retrieval-augmented generation (RAG) and semantic search. It provides a pipeline architecture where you compose components (document stores, retrievers, generators, readers) into end-to-end workflows. Haystack handles the plumbing between components: data serialization, error propagation, and execution ordering.

The framework supports multiple LLM providers (OpenAI, Anthropic, Cohere, local models), multiple document stores (Elasticsearch, Qdrant, Pinecone, Weaviate, ChromaDB), and multiple embedding models. This flexibility lets you swap backends without rewriting pipeline logic.

§02

How it saves time or tokens

Building a RAG pipeline from scratch involves connecting a document store, embedding model, retriever, prompt builder, and LLM generator. Each connection requires data transformation, error handling, and configuration. Haystack provides pre-built components for each step and a pipeline abstraction that handles data flow between them.

The framework also includes production-critical features that developers often forget to build: document deduplication, metadata filtering, hybrid retrieval (combining semantic and keyword search), and evaluation tools for measuring pipeline quality. These features prevent the common failure mode where a RAG system works in demos but fails in production due to poor retrieval quality.

§03

How to use

  1. Install Haystack:

```bash

pip install haystack-ai

```

  1. Build a simple RAG pipeline:

```python

from haystack import Pipeline

from haystack.components.generators import OpenAIGenerator

from haystack.components.builders import PromptBuilder

prompt = PromptBuilder(

template='Answer: {{query}}\nContext: {{documents}}'

)

generator = OpenAIGenerator(model='gpt-4o')

pipeline = Pipeline()

pipeline.add_component('prompt', prompt)

pipeline.add_component('generator', generator)

pipeline.connect('prompt', 'generator')

```

  1. Add a document store and retriever for full RAG.
§04

Example

Complete RAG pipeline with document indexing and retrieval:

from haystack import Pipeline, Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.embedders import (
    OpenAIDocumentEmbedder,
    OpenAITextEmbedder,
)
from haystack.components.retrievers.in_memory import (
    InMemoryEmbeddingRetriever,
)
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders import PromptBuilder

# 1. Index documents
doc_store = InMemoryDocumentStore()
embedder = OpenAIDocumentEmbedder()
docs = [
    Document(content='Haystack is a RAG framework by deepset.'),
    Document(content='Pipelines compose components into workflows.'),
]
embedded = embedder.run(documents=docs)
doc_store.write_documents(embedded['documents'])

# 2. Build query pipeline
query_pipeline = Pipeline()
query_pipeline.add_component('embedder', OpenAITextEmbedder())
query_pipeline.add_component('retriever',
    InMemoryEmbeddingRetriever(document_store=doc_store))
query_pipeline.add_component('prompt', PromptBuilder(
    template='Context: {{documents}}\nQuestion: {{query}}\nAnswer:'))
query_pipeline.add_component('generator', OpenAIGenerator())

query_pipeline.connect('embedder.embedding', 'retriever.query_embedding')
query_pipeline.connect('retriever', 'prompt.documents')
query_pipeline.connect('prompt', 'generator')

result = query_pipeline.run({
    'embedder': {'text': 'What is Haystack?'},
    'prompt': {'query': 'What is Haystack?'},
})
print(result['generator']['replies'][0])
§05

Related on TokRepo

§06

Common pitfalls

  • Confusing Haystack 1.x with 2.x APIs. Version 2.0 was a complete rewrite with a new pipeline architecture and component API. Tutorials and code from version 1.x will not work with 2.x. Always check that examples match your installed version.
  • Using in-memory document stores for production. InMemoryDocumentStore is great for development but loses all data on restart. For production, use a persistent backend like Elasticsearch, Qdrant, or Pinecone.
  • Not evaluating retrieval quality. A RAG pipeline is only as good as its retriever. Haystack includes evaluation components to measure retrieval recall and answer quality. Use these before deploying to catch poor retrieval performance.

Questions fréquentes

What is the difference between Haystack and LangChain?+

Haystack is focused on search, retrieval, and RAG pipelines with deep document store integrations. LangChain is a broader toolkit for building LLM applications including agents, chains, and memory. Haystack provides stronger abstractions for document processing and retrieval evaluation. LangChain provides more flexibility for general-purpose LLM workflows.

Which document stores does Haystack support?+

Haystack supports Elasticsearch, OpenSearch, Qdrant, Pinecone, Weaviate, ChromaDB, Milvus, and an in-memory store for development. Each store has a dedicated integration package. The pipeline abstraction means you can swap stores by changing one component without modifying the rest of the pipeline.

Does Haystack support streaming responses?+

Yes. Generator components in Haystack support streaming, delivering tokens to the caller as they are generated. This is important for chat-like interfaces where users expect to see the response build incrementally rather than waiting for the full response.

Can I use Haystack with local LLMs?+

Yes. Haystack supports local models through Ollama, Hugging Face Transformers, and any OpenAI-compatible API endpoint. For local embeddings, use sentence-transformers models. This enables fully local RAG pipelines with no external API dependencies.

How do I deploy a Haystack pipeline to production?+

Haystack pipelines can be serialized to YAML for reproducible deployment. Deploy the pipeline as a REST API using FastAPI or Flask, containerize with Docker, and serve behind a load balancer. deepset also offers Haystack Cloud for managed pipeline deployment.

Sources citées (3)
🙏

Source et remerciements

Created by deepset. Licensed under Apache 2.0. deepset-ai/haystack — 25,000+ GitHub stars

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires