This agent implements three core inference-time algorithms:
-
Dynamic Routing (Classifier)
- Level 1: The agent first analyzes the input to classify it into one of 5 domains: Math, Planning, Future Predictions or Common Sense
- Level 2: Within Common Sense the questions get classified into Comprehension, Multiple Choice, or Search.
-
RAG/ Tool Use
- Domain: Common Sense based questions
- Mechanism for Search: The agent checks what type of common sense question is presented during the routing. If an only if, the agent recognizes questions requiring external knowledge, the search function is called. I have used DuckDuckGo's free API to search the internet. Then the model uses information from the internet as context to get the best answer.
-
Chain-of-Thought with Logic Extraction
- Domain: Math & Planning
- Mechanism:
- Math: The model is instructed with few shot CoT to solve step-by-step but it must end with a specific delimiter (
#### <Answer>). The agent then extracts the final value. - Planning: The model simulates thinking before generating the plan. A Python-based regex filter then extracts only the valid actions, discarding the reasoning text to ensure correct formatting.
- Math: The model is instructed with few shot CoT to solve step-by-step but it must end with a specific delimiter (
-
Self Correction
- Domain: Coding
- The model generates a first draft of the code. Within the same function this first draft is fed in another call to check if the format requested and the overall correctness of the prompt is maintained or not.
Install the required Python packages using pip:
pip install -r requirements.txt-
Place Data File: Ensure the test data file is in the same directory as the script.
- Input Filename:
cse_476_final_project_test_data.jsonor usecse476_final_project_dev_data.json
- Input Filename:
-
Run the Agent:
python main.py
-
View Results:
- The script will print progress to the console and Domain detections.
- The final outputs will be saved to:
cse_476_final_project_answers.json.