This project implements the Reflexion Pipeline from the paper , which allows for iterative task refinement and evaluation. this file can be used as a module in your own Directories just clone the repo and use the file path as a module(better keep this file in your directory where you are trying to import it) still a work in progress a lot of optimizations and work is in progress Feel free to suggest ideas/thoughts.
Here's a basic example of how to use the Reflexion Pipeline:
pythonCopyfrom reflexion import ReflexionPipeline # Initialize the pipeline with a model name reflexion = ReflexionPipeline(model_name) # Define your task task ="" # Run the reflexion loop final_task, final_output, final_evaluation = reflexion.reflexion_loop(task, max_iterations=5, criteria=0.9)
model_name
: The name of the model to use for the Reflexion Pipeline.<br>
task
: The initial task or prompt to refine and evaluate.<br>
max_iterations
: The maximum number of iterations for the reflexion loop (default is 5).<br>
criteria
: The exit criteria score (between 0 and 1) at which the loop will stop if reached before max_iterations (default is 0.9).
You can customize the Reflexion Pipeline by adjusting the following parameters:
max_iterations
: Set this to the number of reflexion iterations you want to perform.<br>
criteria
: Adjust this value to change the satisfactory score at which the loop will exit early.
The reflexion_loop
method returns three values:
final_task
: The refined task after iterations.<br>
final_output
: The final output generated for the task.<br>
final_evaluation
: The evaluation score for the final output.
Make sure to define your task
variable with an appropriate prompt or task description before running the reflexion loop.