Spaces:
Running
Running
Docs: Simplify README to core technical specifications
Browse files
README.md
CHANGED
|
@@ -1,85 +1,70 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
| `summarize_artifact` | `artifact_id`, `ratio` | Compress an artifact to reduce token cost |
|
| 26 |
-
| `set_resolution_plan` | `plan` | Draft the operational plan before submission |
|
| 27 |
-
| `submit_report` | `answer` | Submit the final grounded memo and end the episode |
|
| 28 |
|
| 29 |
-
###
|
| 30 |
-
- **case_summary**: Real-world case context and background.
|
| 31 |
-
- **objective**: The specific deliverable the agent must produce.
|
| 32 |
-
- **workflow_stage**: Current phase (`triage`, `analysis`, `resolution`).
|
| 33 |
-
- **available_artifacts**: Summaries of all artifacts available for review.
|
| 34 |
-
- **token_budget**: Strict limit on the total tokens allowed in the working set.
|
| 35 |
-
- **progress_signals**: Partial performance metrics throughout the trajectory.
|
| 36 |
|
| 37 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
##
|
| 40 |
|
| 41 |
-
|
|
| 42 |
-
| :--- | :--- | :--- | :--- |
|
| 43 |
-
| `refund_triage_easy` |
|
| 44 |
-
| `cross_function_brief_medium` |
|
| 45 |
-
| `executive_escalation_hard` |
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
- `POST /optimize-step`: **[AI Helper]** Get a suggested action from a baseline policy.
|
| 56 |
-
- `POST /optimize-prompt`: **[AI Helper]** Rewrite prompts to fit budgets while preserving grounding.
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
```bash
|
| 64 |
-
|
| 65 |
-
```
|
| 66 |
|
| 67 |
-
|
| 68 |
-
Start the environment server:
|
| 69 |
-
```bash
|
| 70 |
-
python app.py
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
Launch the Streamlit dashboard for manual optimization:
|
| 74 |
-
```bash
|
| 75 |
-
streamlit run optimizer_ui.py
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
### Validation
|
| 79 |
-
Ensure full compliance with the benchmark specifications:
|
| 80 |
-
```bash
|
| 81 |
-
python validate.py
|
| 82 |
-
```
|
| 83 |
-
|
| 84 |
-
---
|
| 85 |
-
*Built for the Meta x Scaler Hackathon 2026*
|
|
|
|
| 1 |
+
# RAG Context Optimizer
|
| 2 |
|
| 3 |
+
A reinforcement learning environment for context optimization tasks including artifact inspection, prioritization, and summarization. This project simulates an operational workflow for handling structured data artifacts within token budgets.
|
| 4 |
|
| 5 |
+
## Project Structure
|
| 6 |
|
| 7 |
+
- `rag_optimizer_env/`: Core environment logic and task definitions.
|
| 8 |
+
- `rag_gc_env/`: (Legacy) Context pruning environment for Round 1.
|
| 9 |
+
- `app.py`: FastAPI implementation of the environment server.
|
| 10 |
+
- `inference.py`: Baseline inference script using an OpenAI-compatible interface.
|
| 11 |
+
- `optimizer_ui.py`: Streamlit-based dashboard for manual task execution.
|
| 12 |
+
- `validate.py`: Local validation script for environment compliance.
|
| 13 |
+
- `data/`: Corpus and task dataset files.
|
| 14 |
|
| 15 |
+
## Environment Interface
|
| 16 |
|
| 17 |
+
### Action Space
|
| 18 |
|
| 19 |
+
The agent interacts with the environment using the following actions:
|
| 20 |
|
| 21 |
+
- `inspect_artifact`: Review metadata for a chunk without committing to the context.
|
| 22 |
+
- `prioritize_artifact`: Add an artifact to the current context (working set).
|
| 23 |
+
- `summarize_artifact`: Compress a prioritized artifact according to a specified ratio.
|
| 24 |
+
- `set_resolution_plan`: Define an operational plan.
|
| 25 |
+
- `submit_report`: Submit the final grounded answer.
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
### API Endpoints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
- `POST /reset`: Initialize an episode for a given task.
|
| 30 |
+
- `POST /step`: Execute an action and return the observation, reward, and terminal state.
|
| 31 |
+
- `GET /state`: View the current episode state.
|
| 32 |
+
- `POST /optimize-step`: Request a suggested action from the baseline policy.
|
| 33 |
+
- `POST /optimize-prompt`: Optimize input prompts for grounding and length.
|
| 34 |
|
| 35 |
+
## Tasks
|
| 36 |
|
| 37 |
+
| Name | Difficulty | Steps | Token Budget |
|
| 38 |
+
| :--- | :--- | :--- | :--- |
|
| 39 |
+
| `refund_triage_easy` | Easy | 7 | 850 |
|
| 40 |
+
| `cross_function_brief_medium` | Medium | 8 | 620 |
|
| 41 |
+
| `executive_escalation_hard` | Hard | 10 | 360 |
|
| 42 |
|
| 43 |
+
## Setup and Execution
|
| 44 |
|
| 45 |
+
1. **Install dependencies**:
|
| 46 |
+
```bash
|
| 47 |
+
pip install -r requirements.txt
|
| 48 |
+
```
|
| 49 |
|
| 50 |
+
2. **Run server**:
|
| 51 |
+
```bash
|
| 52 |
+
python app.py
|
| 53 |
+
```
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
3. **Inference**:
|
| 56 |
+
```bash
|
| 57 |
+
python inference.py
|
| 58 |
+
```
|
| 59 |
|
| 60 |
+
4. **UI Dashboard**:
|
| 61 |
+
```bash
|
| 62 |
+
streamlit run optimizer_ui.py
|
| 63 |
+
```
|
| 64 |
|
| 65 |
+
5. **Validation**:
|
| 66 |
+
```bash
|
| 67 |
+
python validate.py
|
| 68 |
+
```
|
| 69 |
|
| 70 |
+
Built for the Meta x Scaler Hackathon 2026.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|