LangWatch DSPy Visualization allows you to start tracking your DSPy experiments in real-time and easily follow the progress, track costs and debug each step.

1. Install the Python library

!pip install langwatch

2. Login to LangWatch

Import and authenticate the LangWatch SDK:

import langwatch

langwatch.login()

Be sure to login or create an account on the link that will be displayed, then provide your API key when prompted.

3. Start tracking

Before your DSPy program compilation starts, initialize langwatch with your experiment name and the optimizer to be tracked:

# Initialize langwatch for this run, to track the optimizer compilation
langwatch.dspy.init(experiment="my-awesome-experiment", optimizer=optimizer)

compiled_rag = optimizer.compile(RAG(), trainset=trainset)

Follow your experiment

Open the link provided when the compilation starts or go to your LangWatch dashboard to follow the progress of your experiments:

Wrapping up

With your experiments tracked on LangWatch, now it’s time to explore how is the training going, take a look at the examples, the llm calls, the different steps and so on, so you can understand and hypothesize where you could improve your DSPy program, and keep iterating!

For any questions or issues, feel free to contact our support, join our channel on Discord or open an issue on our GitHub.