dspy-haystack-integration

Solid

This skill should be used when the user asks to "integrate DSPy with Haystack", "optimize Haystack prompts using DSPy", "use DSPy to improve Haystack pipeline", mentions "Haystack pipeline optimization", "combining DSPy and Haystack", "extract DSPy prompt for Haystack", or wants to use DSPy's optimization capabilities to automatically improve prompts in existing Haystack pipelines.

AI & Automation 78 stars 10 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 90/100

Stars 20%
63
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# DSPy + Haystack Integration ## Goal Use DSPy's optimization capabilities to automatically improve prompts in Haystack pipelines. ## When to Use - You have existing Haystack pipelines - Manual prompt tuning is tedious - Need data-driven prompt optimization - Want to combine Haystack components with DSPy optimization ## Inputs | Input | Type | Description | |-------|------|-------------| | `haystack_pipeline` | `Pipeline` | Existing Haystack pipeline | | `trainset` | `list[dspy.Example]` | Training examples | | `metric` | `callable` | Evaluation function | ## Outputs | Output | Type | Description | |--------|------|-------------| | `optimized_prompt` | `str` | DSPy-optimized prompt | | `optimized_pipeline` | `Pipeline` | Updated Haystack pipeline | ## Workflow ### Phase 1: Build Initial Haystack Pipeline ```python from haystack import Pipeline from haystack.components.generators import OpenAIGenerator from haystack.components.builders import PromptBuilder from haystack.components.retrievers.in_memory import InMemoryBM25Retriever from haystack.document_stores.in_memory import InMemoryDocumentStore # Setup document store doc_store = InMemoryDocumentStore() doc_store.write_documents(documents) # Initial generic prompt initial_prompt = """ Context: {{context}} Question: {{question}} Answer: """ # Build pipeline pipeline = Pipeline() pipeline.add_component("retriever", InMemoryBM25Retriever(document_store=doc_store)) pipeline.add_component("prompt_builder", PromptBui...

Details

Author
OmidZamani
Repository
OmidZamani/dspy-skills
Created
5 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category