Useful links
DSPy: A Revolutionary Framework for Programming LLMs: https://www.theaidream.com/post/dspy-a-revolutionary-framework-for-programming-llms
Building an AI Assistant with DSPy: https://towardsdatascience.com/building-an-ai-assistant-with-dspy-2e1e749a1a95
Herangehensweise
-
Gather Dataset: Assemble a selection of input-output examples (such as question-answer pairs) for refining your pipeline.
-
Develop DSPy Program: Craft the logic of your program using signatures and modules, detailing the flow of information to address your specific task.
-
Establish Validation Logic: Create criteria for enhancing your program based on a validation metric and an optimizer (teleprompter).
-
Compile with DSPy: Utilize the DSPy compiler, incorporating your training dataset, program, optimizer, and validation metric to enhance your program (for instance, through prompt optimization or fine-tuning).
-
Refine Continuously: Engage in an iterative cycle of refining your dataset, program, or validation logic to achieve the desired performance level of your pipeline.
Functions
-
dspy.Predict: This is the foundational prediction module that directly utilizes the signature without any alterations. It manages essential learning processes such as saving instructions, demonstrations, and updates to the LM.
-
dspy.ChainOfThought: This module guides the LM to process information in a sequential, step-by-step manner before generating a response aligned with the signature.
-
dspy.ProgramOfThought: It instructs the LM to produce code, the execution of which determines the response in accordance with the signature.
-
dspy.ReAct: Functions as an agent capable of employing tools to fulfill the requirements of the specified signature.
-
dspy.MultiChainComparison: This module is capable of evaluating multiple outcomes from the ChainOfThought process to arrive at a conclusive prediction.
There are also modules resembling functions, such as:
- dspy.majority: Executes a simple voting mechanism to identify and return the most common answer from a group of predictions.