This repository contains a Python script, dspy_LabeledFewShot.py
, that demonstrates how to use the dspy.teleprompt.LabeledFewShot
optimizer for sentiment analysis.
The script defines a simple DSPy program to classify the sentiment of a sentence as "Positive", "Negative", or "Neutral". It then uses LabeledFewShot
to "compile" this program by creating few-shot prompts from a small training set. Finally, it runs the compiled program on a new sentence and inspects the prompt sent to the Language Model (LLM) to show how the few-shot examples were included.
- Python 3.13+
- uv