This repository is an extension of the SELF-DISCOVER repository by Kailash Prasannakumar, which implements the ideas from the following original paper:
SELF-DISCOVER: Large Language Models Self-Compose Reasoning Structures Link to the paper
The original paper was written by Pei Zhou with Google DeepMind, while the SELF-DISCOVER repository is an implementation of that paper by Kailash Prasannakumar.
-
Clone this repository:
git clone https://github.com/ashokchhetri7/self-discover.git
-
Install the required libraries:
pip install -r requirements.txt
-
create a .env file
-
Open the
.env
file in a text editor. -
Add the following line to the
.env
file:GOOGLE_API_KEY= add_your_api_key_here_no_quotation_needed
Replace
your_google_api_key_here
with your actual Google API key obtained from google makersuite. Your can also use OPENAI_API_KEY as well
- Modify the
reasoning_modules
variable inprompts.py
to add, remove, or modify reasoning modules. - Adjust the prompts in
prompts.py
to customize the user interaction flow.
- As mentioned in the paper
For Stage 2, where we use the self-discovered structure to solve the task instances, we start with the prompt: “Follow the
step-by-step reasoning plan in JSON to correctly solve the task. Fill in the values following the keys by reasoning specifically
about the task given. Do not simply rephrase the keys.”, followed by the reasoning structure, and finally the task instance.
- Based on the above reasoning structure and step I have given the following structure to get the final output. No need to run this. (It's not runnable)
Follow the step-by-step reasoning plan in {reasoning_structure} to correctly solve the task.
Fill in the values following the keys by reasoning specifically about the task given.
Do not simply rephrase the keys. And finally provide the "final_answer" of the given question.
For the given task;
<Task>
{Task}
</Task>
Given reasoning steps;
{reasoning_structure}
Expected Output:
{
"final_answer": {
...
}
}
Simply run the command below:
python self_discover.py
python streamlit run app.py
You can see the ouptut of the select, adapt, implement as well as final ouptut in the web using this command.