ps2181 commited on
Commit
f115995
·
1 Parent(s): 4890422

Remove BLOG_DRAFT.md and ROUND2_PROBLEM_STATEMENT.md

Browse files
Files changed (2) hide show
  1. BLOG_DRAFT.md +0 -216
  2. ROUND2_PROBLEM_STATEMENT.md +0 -182
BLOG_DRAFT.md DELETED
@@ -1,216 +0,0 @@
1
- # Invoice Processing Pipeline — Multi-Agent RL Environment for Financial Fraud Detection
2
-
3
- **Meta PyTorch OpenEnv Hackathon Grand Finale | April 25–26, 2026**
4
- **Team: Pritam Satpathy + Gnana Nawin T**
5
-
6
- ---
7
-
8
- ## The Problem
9
-
10
- Invoice fraud costs businesses an estimated **5% of annual revenue**. Finance teams manually process thousands of invoices every month — extracting vendor names, dates, line items, totals — and checking them against purchase orders for discrepancies. This is:
11
-
12
- - Slow (hours per batch)
13
- - Error-prone (typos, OCR noise, format chaos)
14
- - Gameable (phantom vendors, price gouging, duplicate submissions)
15
-
16
- We built an **RL training environment** that teaches LLMs to do this automatically — and improves itself when it finds its own blind spots.
17
-
18
- ---
19
-
20
- ## What We Built
21
-
22
- An OpenEnv-compatible environment deployed on HuggingFace Spaces:
23
- **https://ps2181-invoice-processing-pipeline.hf.space**
24
-
25
- ### 5-Agent Architecture
26
-
27
- ```
28
- Generator ──► Extractor ──► Auditor ──► Approver
29
- ▲
30
- Regulator
31
- (cross-episode)
32
- ```
33
-
34
- | Agent | Role | Reward Signal |
35
- |-------|------|--------------|
36
- | **Generator** | Creates clean or fraudulent invoices | Rewarded when fraud slips past Auditor (adversarial self-play) |
37
- | **Extractor** | Reads raw invoice text → structured JSON | 4 independent signals: format, field accuracy, math consistency, completeness |
38
- | **Auditor** | Reviews extraction, flags fraud | +0.99 correct detection, +0.90 clean clearance, 0.01 for miss or false positive |
39
- | **Approver** | Final approve/reject/escalate decision | +0.95 correct decision |
40
- | **Regulator** | Monitors Auditor blind spots **across episodes** | Precision + recall of blind spot predictions |
41
-
42
- ### The Key Innovation: The Regulator
43
-
44
- The Regulator is a **cross-episode meta-agent** — it watches the Auditor's decision history over 30 episodes and identifies systematic failure patterns:
45
-
46
- ```
47
- AUDITOR PERFORMANCE TRACKER (last 30 episodes)
48
-
49
- Fraud Type Detection Rate
50
- ─────────────────────────────────────
51
- phantom_vendor 31% ⚠ BLIND SPOT
52
- price_gouging 74% ✓ OK
53
- math_fraud 81% ✓ OK
54
- duplicate_submission 62% ✓ OK
55
-
56
- False Positive Rate: 12% ✓ OK
57
-
58
- REGULATOR VERDICT: Recommend retraining on phantom_vendor
59
- ```
60
-
61
- When the Regulator detects a blind spot, the **Generator automatically starts producing more of that fraud type** — closing the self-improvement loop without human intervention.
62
-
63
- This directly addresses **Theme #1 (Fleet AI Scalable Oversight)** and **Theme #4 (Self-Improvement)**.
64
-
65
- ---
66
-
67
- ## 7 Tasks (Progressive Difficulty)
68
-
69
- | Task | Difficulty | What the Agent Does |
70
- |------|-----------|---------------------|
71
- | `easy` | Easy | Extract fields from a single clean invoice |
72
- | `medium` | Medium | Clean + normalise a batch of messy invoices (typos, date chaos, currency symbols) |
73
- | `hard` | Hard | Extract + reconcile against purchase orders, flag discrepancies |
74
- | `expert` | Expert | Fraud audit: classify phantom_vendor / price_gouging / math_fraud / duplicate_submission |
75
- | `adversarial` | Hard | Extract from OCR-corrupted invoice with SUBTOTAL trap and FX noise lines |
76
- | `negotiate` | Medium | Ask clarification questions then submit extraction (bonus for ≤2 questions) |
77
- | `supply_chain` | Expert | Detect quantity shortfalls, price spikes, phantom deliveries in delivery records |
78
-
79
- ---
80
-
81
- ## Design Decisions
82
-
83
- ### 4 Independent Reward Functions (Anti-Hacking)
84
-
85
- Per the hackathon guide Section 7: *"use multiple independent reward functions — if you only have one reward signal, it is easier for the model to hack it."*
86
-
87
- ```python
88
- format_reward() # Are all 5 required JSON keys present? weight: 0.10
89
- field_reward() # Do vendor/date/currency/total match? weight: 0.40
90
- math_reward() # Does qty × unit_price = amount for all items? weight: 0.25
91
- completeness_reward() # Are all line items present (recall)? weight: 0.25
92
- ```
93
-
94
- During training we observed the model maximising `math_reward` (0.97) and `completeness_reward` (1.0) while `field_reward` stayed at 0.0 — the model learned to output arithmetic-consistent JSON while hallucinating values. **Our independent signals made this reward hacking immediately visible**, confirming the design choice.
95
-
96
- ### Adversarial Self-Play
97
-
98
- The Generator is rewarded when its fraud evades the Auditor:
99
- - Fraud fully undetected by Auditor + Approver approves → Generator reward: **0.85**
100
- - Auditor missed but Approver caught → Generator reward: **0.60**
101
- - Auditor caught it → Generator reward: **0.10**
102
-
103
- This creates evolutionary pressure: the Generator evolves harder-to-detect fraud patterns, forcing the Auditor to improve.
104
-
105
- ### Dynamic Difficulty
106
-
107
- The environment tracks recent agent scores per task (rolling window of 10 episodes) and adjusts generation parameters:
108
- - Agent scoring ≥ 0.85 → harder parameters (more invoices, more OCR noise, more discrepancies)
109
- - Agent scoring < 0.60 → easier parameters
110
- - In between → standard
111
-
112
- ### All Rewards Clamped to (0.01, 0.99)
113
-
114
- Rewards are never exactly 0 or 1 — avoids log(0) in policy gradient and prevents the model from getting stuck at boundaries.
115
-
116
- ---
117
-
118
- ## Tech Stack
119
-
120
- ```
121
- Environment: FastAPI + OpenEnv-core + Pydantic
122
- Deployment: HuggingFace Spaces (Docker, port 7860)
123
- UI: Gradio (mounted at /web)
124
- Training: TRL GRPOTrainer + Unsloth (Qwen2.5-1.5B-Instruct, 4-bit QLoRA)
125
- Model: unsloth/Qwen2.5-1.5B-Instruct r=16 LoRA
126
- Reward: 4 local signals + live /grader endpoint on HF Space
127
- ```
128
-
129
- ---
130
-
131
- ## Training Setup
132
-
133
- **GRPO (Group Relative Policy Optimization)** with:
134
- - `num_generations = 4` — 4 completions per prompt, compared within group
135
- - `max_steps = 200`
136
- - `learning_rate = 5e-6`
137
- - Live `/grader` endpoint on HF Space as environment verifier
138
-
139
- The training loop:
140
- ```
141
- Colab samples episode → HF Space /reset → gets live invoice
142
- Model generates JSON extraction
143
- HF Space /grader scores it against ground truth
144
- GRPO updates model toward higher-scoring completions
145
- ```
146
-
147
- ### Reward Curve
148
-
149
- | Step | Total Reward | Env Score | Format | Math |
150
- |------|-------------|-----------|--------|------|
151
- | 10 | 2.361 | 0.113 | 0.900 | 0.347 |
152
- | 20 | 2.595 | 0.282 | 0.900 | 0.413 |
153
- | 30 | 2.657 | 0.304 | 0.950 | 0.403 |
154
-
155
- Environment score rose **0.113 → 0.304 in 30 steps** — a 169% improvement in the model's ability to correctly extract invoice data as scored by the live environment grader.
156
-
157
- *[Add reward curve plot image here]*
158
-
159
- ---
160
-
161
- ## API Endpoints
162
-
163
- | Endpoint | Method | Description |
164
- |----------|--------|-------------|
165
- | `/health` | GET | Health check |
166
- | `/reset` | POST | Start new episode `{"task_id": "easy"}` |
167
- | `/step` | POST | Submit extraction, get reward + feedback |
168
- | `/grader` | POST | Score without consuming attempt |
169
- | `/state` | GET | Episode metadata |
170
- | `/tasks` | GET | List all 7 tasks with schemas |
171
- | `/ws` | WebSocket | Full episode over WebSocket (OpenEnv standard) |
172
- | `/web` | GET | Gradio interactive UI |
173
-
174
- ---
175
-
176
- ## What Makes This Novel
177
-
178
- 1. **Regulator agent** — no other OpenEnv environment has a cross-episode meta-agent that monitors another agent for systematic cognitive blind spots
179
-
180
- 2. **Closed self-improvement loop** — Regulator detects blind spot → Generator biases fraud generation toward that type → Auditor forced to improve → no human intervention required
181
-
182
- 3. **Adversarial Generator arms race** — Generator rewarded for evading Auditor creates evolutionary pressure on fraud detection
183
-
184
- 4. **Live environment as verifier** — training Colab directly calls `/grader` on deployed HF Space — the environment IS the reward function
185
-
186
- 5. **4 independent reward signals** — made reward hacking immediately visible during training (detected it at step 10)
187
-
188
- ---
189
-
190
- ## Theme Alignment
191
-
192
- | Theme | Alignment |
193
- |-------|-----------|
194
- | **#1 Multi-Agent** | 5 agents with conflicting incentives |
195
- | **#1 Sub: Fleet AI Oversight** (bonus) | Regulator monitors Auditor cross-episode |
196
- | **#3.1 Professional Tasks** | Invoice processing = core enterprise workflow |
197
- | **#3.1 Sub: Scaler AI Labs** (bonus) | Multi-agent RL for enterprise financial workflows |
198
- | **#4 Self-Improvement** | Generator adapts based on Regulator blind spot findings |
199
-
200
- ---
201
-
202
- ## Links
203
-
204
- - **Live Environment:** https://ps2181-invoice-processing-pipeline.hf.space
205
- - **Gradio UI:** https://ps2181-invoice-processing-pipeline.hf.space/web
206
- - **API Docs:** https://ps2181-invoice-processing-pipeline.hf.space/docs
207
- - **GitHub:** https://github.com/ps2181/invoice-processing-pipeline
208
- - **Training Colab:** *[add link after saving to GitHub]*
209
-
210
- ---
211
-
212
- ## Team
213
-
214
- **Pritam Satpathy** + **Gnana Nawin T**
215
- Meta PyTorch OpenEnv Hackathon Grand Finale
216
- Scaler School of Technology, Bangalore — April 25–26, 2026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ROUND2_PROBLEM_STATEMENT.md DELETED
@@ -1,182 +0,0 @@
1
- # Round 2 Problem Statement
2
-
3
- ## Title
4
-
5
- Autonomous Accounts Payable Control Tower
6
-
7
- ## Theme Alignment
8
-
9
- This environment intentionally covers more than one Round 2 theme:
10
-
11
- - Multi-Agent Interactions
12
- - Long-Horizon Planning and Instruction Following
13
- - World Modeling across professional tasks
14
- - Self-Improving agent systems
15
-
16
- ## Core Problem Statement
17
-
18
- Design an OpenEnv environment in which one or more AI agents operate as an accounts-payable control tower for a mid-sized company. The agent must transform noisy financial documents into reliable, auditable decisions across invoice extraction, normalization, reconciliation, fraud review, clarification, and downstream supply-chain checks.
19
-
20
- The real-world challenge is not simple OCR or single-step parsing. A strong agent must maintain working memory across turns, choose when to ask for clarification, compare multiple sources of truth, detect subtle inconsistencies, and maximize business-safe outcomes under limited attempts.
21
-
22
- In practical terms, the environment simulates the day-to-day work of finance operations teams, procurement reviewers, and audit analysts who must:
23
-
24
- - extract structured fields from raw invoices
25
- - normalize inconsistent or corrupted records
26
- - reconcile invoices with purchase orders
27
- - flag fraud and policy violations
28
- - investigate ambiguous cases through clarification
29
- - reason about upstream delivery anomalies that affect billing decisions
30
-
31
- ## Environment
32
-
33
- The environment is a realistic finance-operations workspace exposed through the standard OpenEnv `reset()`, `step()`, and `state()` API.
34
-
35
- At each episode reset, the environment generates a fresh synthetic business scenario containing some combination of:
36
-
37
- - raw invoice text rendered as clean OCR, messy OCR, or adversarial OCR
38
- - purchase order reference data
39
- - approved vendor registry and historical invoice records
40
- - delivery logs and supply-chain records
41
- - ambiguous fields that require clarification turns
42
-
43
- The environment models several constraints found in real operations:
44
-
45
- - incomplete or corrupted documents
46
- - multiple representations of the same entity
47
- - conflicting sources of truth
48
- - deceptive lines such as fake tax or subtotal entries
49
- - fraud patterns that require policy grounding, not just extraction
50
- - limited action budget with step penalties and attempt caps
51
-
52
- This makes the world state richer than a single-document benchmark and aligns well with OpenEnv’s focus on realistic agent behavior.
53
-
54
- ## Agent Capabilities
55
-
56
- The intended agent stack can be either a single frontier model or a coordinated set of specialists. A multi-agent version is especially compelling for this theme.
57
-
58
- Recommended agent roles:
59
-
60
- - Extractor Agent: converts raw text into structured invoice objects
61
- - Reconciliation Agent: compares invoices against purchase orders and flags mismatches
62
- - Audit Agent: checks vendor legitimacy, duplicate history, math fraud, and price gouging
63
- - Clarification Agent: decides whether a question is worth spending a turn on
64
- - Coordinator Agent: selects which sub-agent acts next and merges outputs into the final action
65
-
66
- Core capabilities expected from the agent system:
67
-
68
- - structured information extraction
69
- - entity normalization
70
- - cross-document comparison
71
- - anomaly and fraud detection
72
- - selective clarification and question asking
73
- - trajectory planning across multiple steps
74
- - adaptation using prior grader feedback
75
-
76
- ## Tasks
77
-
78
- The current environment already contains a natural difficulty ladder plus advanced variants:
79
-
80
- 1. Easy: Single Invoice Extraction
81
- Extract vendor, date, currency, total, and line items from one clean invoice.
82
-
83
- 2. Medium: Batch Invoice Cleaning
84
- Normalize multiple messy invoices with date-format chaos, vendor typos, mixed currencies, and arithmetic inconsistencies.
85
-
86
- 3. Hard: Invoice-PO Reconciliation
87
- Clean invoices and compare them against purchase orders to detect overcharges, extra items, and missing items.
88
-
89
- 4. Expert: Fraud Audit
90
- Use policy and reference data to classify phantom vendors, duplicate submissions, price gouging, and math fraud.
91
-
92
- 5. Adversarial: Trap-Resistant Extraction
93
- Ignore misleading subtotal, tax, adjustment, and FX lines while recovering the true invoice structure from OCR-corrupted text.
94
-
95
- 6. Negotiate: Clarification-then-Act
96
- Ask targeted questions before submitting the final extraction, with a reward bonus for solving accurately using few clarifications.
97
-
98
- 7. Supply Chain: Delivery Anomaly Detection
99
- Identify quantity shortfalls, price spikes, unauthorized substitutions, and phantom deliveries in logistics records that affect invoice trustworthiness.
100
-
101
- These tasks support both the minimum competition requirement and a stronger story around agentic reasoning breadth.
102
-
103
- ## Reward Model and Evaluation Logic
104
-
105
- The environment uses dense, trajectory-level reward rather than pure terminal success.
106
-
107
- Key evaluation properties:
108
-
109
- - scores are deterministic and normalized to `0.0–1.0`
110
- - reward is provided every step
111
- - partial credit is granted for partially correct structure and reasoning
112
- - repeated failure is penalized through capped attempts and end-of-episode multipliers
113
- - some tasks provide field-level or component-level breakdowns to support learning
114
-
115
- Illustrative reward design:
116
-
117
- - Extraction tasks score vendor, date, currency, total, and line-item accuracy separately
118
- - Batch tasks average per-document correctness across the batch
119
- - Reconciliation tasks combine extraction quality with discrepancy precision and recall
120
- - Fraud tasks grade both verdict quality and correct fraud-type assignment
121
- - Clarification tasks reward final correctness and add a bonus for solving with fewer questions
122
- - Supply-chain tasks reward exact and partial anomaly matching using precision and recall
123
-
124
- Why this is strong for judging:
125
-
126
- - clear task objectives
127
- - measurable, reproducible graders
128
- - meaningful partial progress signals
129
- - sensible episode boundaries
130
- - realistic penalties for wasteful or unsafe behavior
131
-
132
- ## Long-Horizon and Multi-Agent Story
133
-
134
- This environment is stronger than a one-shot extraction benchmark because good performance often requires a sequence of decisions:
135
-
136
- - inspect noisy evidence
137
- - choose whether to normalize or reconcile first
138
- - decide whether ambiguity warrants clarification
139
- - use feedback from the last failed attempt
140
- - compare several external references before acting
141
-
142
- That naturally creates a long-horizon control problem. In a multi-agent implementation, the coordinator can route subtasks to specialized workers and aggregate them into a single environment action. This gives the judges a concrete example of multi-agent interaction that is useful, realistic, and measurable.
143
-
144
- ## Post-Training and Self-Improvement Strategy
145
-
146
- The self-improvement loop should operate at both the environment level and the agent level.
147
-
148
- Environment-side self-improvement already fits well:
149
-
150
- - dynamic difficulty adjusts generation parameters based on recent agent performance
151
- - fresh synthetic scenarios prevent rote memorization
152
- - richer failure cases can be added over time from observed model mistakes
153
-
154
- Agent-side post-training strategy:
155
-
156
- - collect trajectories with observation, action, reward, and grader feedback
157
- - distill successful traces into task-specific demonstrations
158
- - finetune or preference-optimize the coordinator on high-reward trajectories
159
- - train specialist sub-agents on their own slices such as extraction, fraud, or reconciliation
160
- - mine common failure modes and convert them into targeted curriculum tasks
161
- - use reward breakdowns as auxiliary supervision for process improvement
162
-
163
- An especially strong hackathon implementation would add a memory or policy-improvement module that:
164
-
165
- - tracks recurrent failure categories per task
166
- - updates prompting or tool routing after each episode batch
167
- - increases confidence thresholds for high-risk actions
168
- - learns when asking a clarification question is economically justified
169
-
170
- ## Why This Submission Should Score Well
171
-
172
- Against the published judging criteria, this design is well positioned because it is:
173
-
174
- - real-world: finance operations, procurement, and audit teams perform these workflows every day
175
- - structured: tasks are concrete, typed, and easy to evaluate automatically
176
- - agentic: success depends on planning, comparison, recovery from feedback, and selective questioning
177
- - novel enough: it goes beyond invoice OCR into reconciliation, fraud, negotiation, and supply-chain reasoning
178
- - extensible: more vendors, fraud patterns, policies, and document sources can be added without changing the API
179
-
180
- ## Short Submission Pitch
181
-
182
- Autonomous Accounts Payable Control Tower is a real-world OpenEnv benchmark for training and evaluating AI agents on document-grounded finance operations. Agents must extract, normalize, reconcile, audit, question, and adapt across noisy multi-document workflows, receiving dense rewards and deterministic grading throughout. The environment supports single-agent and multi-agent systems, emphasizes long-horizon decision making, and includes a natural self-improvement loop through feedback-aware retries and adaptive difficulty.