How ysymyth/react works
Project Type and Purpose
• This is a research‐oriented Python “tooling” project for prompting large language models (LLMs) on four benchmark tasks (HotpotQA, FEVER, AlfWorld, WebShop).
• It provides: (a) prompt templates, (b) environment wrappers, (c) data loading, and (d) evaluation pipelines via Jupyter notebooks that call the OpenAI API (and AlfWorld library).
Main Components
A. Notebooks (Orchestrator Layer)
– FEVER.ipynb, hotpotqa.ipynb, alfworld.ipynb, WebShop.ipynb
– Sequence: load config → load data → select prompt → invoke wrapper → evaluate.
B. Configuration
– base_config.yaml: global flags (e.g., model name, max tokens, number of examples).
C. Data Layer
– data/*.json(.jsonl): task datasets (train/dev/test).
D. Prompt Templates
– prompts/*.json: structured templates for each task (ReAct chains).
E. Wrapper & Environment Code
– wrappers.py: OpenAI‐API client abstraction, request/response logging, retry logic.
– wikienv.py: simulator for WebShop / interface to AlfWorld environments.
F. External Dependencies
– OpenAI API (via openai library)
– AlfWorld package
– Any logging or evaluation utilities you add
Relationships & Data Flow
1. Notebook loads base_config.yaml
2. Notebook reads the appropriate dataset from data/
3. Notebook reads the prompt template from prompts/
4. Notebook instantiates the environment (wikienv or AlfWorld wrapper)
5. Notebook calls wrappers.py to send prompt + context to OpenAI API → receives completion
6. Notebook code parses the model’s response, applies environment actions (for AlfWorld/WebShop), or scoring logic (for QA tasks)
7. Notebook aggregates metrics and outputs results
Architectural Patterns & Design Principles
• Pipeline Pattern: Each notebook implements a linear pipeline: Config → Data → Prompt → Inference → Evaluation.
• Separation of Concerns:
– Configuration is decoupled (YAML)
– Prompt definitions are stored separately (JSON)
– API‐interaction logic isolated in wrappers.py
– Environment simulators isolated in wikienv.py
• Extensibility: New tasks can be added by dropping new prompt JSONs and dataset JSONs, plus a notebook orchestration file.
Technologies & Frameworks
– Python 3.x
– openai Python SDK
– AlfWorld (third‐party simulation)
– Jupyter Notebooks
– YAML (configuration)
– JSON (datasets and prompts)