Chapter 8 · Case Study 8

Databricks & JetBlue Optimization

A real-world example of optimizing customer service chatbots for speed and accuracy using DSPy on Databricks.

~15 min read

Business Challenge

JetBlue needed to reduce manual prompt engineering time and improve the response latency of their customer support chatbots.

Solution Architecture

Using DSPy, they built a multi-stage RAG pipeline. A key component was the automated optimization of retrieval queries and answers.

The Pipeline

Python
class JetBlueRAGPipeline(dspy.Module):
    def __init__(self):
        self.generate_query = ChainOfThought("context, question -> search_query")
        self.generate_answer = Predict("context, question -> answer")

    def forward(self, question, context=None):
        query = self.generate_query(context=context, question=question).search_query
        passages = self.retrieve(query).passages
        return self.generate_answer(context=passages, question=question)

Optimization with MIPROv2

Automated prompt optimization was the game changer. By defining an evaluation metric, they could let DSPy's optimizer find the best prompts, reducing engineering time from hours to zero.

Key Results

  • 2x Faster response time (2.4s to 1.2s)
  • 100% Reduction in manual prompt engineering
  • 17% Accuracy Gain (72% to 89%)