parth-1 commited on
Commit
308d067
·
unverified ·
1 Parent(s): 88c89bd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -4
README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MetaGuard: A Multi-App RL Environment for Enterprise Ad Policy Compliance
2
 
3
  > An OpenEnv-compatible reinforcement learning environment that forces an LLM agent
4
  > to do **real investigative work** across multiple enterprise APIs — not pattern-match.
@@ -7,6 +7,19 @@
7
  ![Python 3.9+](https://img.shields.io/badge/Python-3.9%2B-blue.svg)
8
  ![Framework: OpenEnv + GRPO](https://img.shields.io/badge/Framework-OpenEnv%20%2B%20GRPO-success.svg)
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
  ## TL;DR for Judges
@@ -41,6 +54,10 @@ Real compliance teams follow a **procedure**: check policy → inspect creative
41
  verify the advertiser → log the audit → only then decide. MetaGuard makes the
42
  agent learn that procedure end-to-end.
43
 
 
 
 
 
44
  ---
45
 
46
  ## Architecture
@@ -145,6 +162,33 @@ single-shot strategies provably under-perform a procedural agent.
145
 
146
  ---
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  ## Quick Start
149
 
150
  ### 1. Install
@@ -177,9 +221,9 @@ python inference.py
177
  python demo.py
178
  ```
179
 
180
- ### 5. (Optional) Train an agent with GRPO
181
- Requires a CUDA GPU. Trains a LoRA on top of `unsloth/Llama-3.1-8B-Instruct`
182
- using the env itself as the reward function.
183
  ```bash
184
  python grpo_train.py
185
  ```
@@ -217,6 +261,7 @@ meta-ad-policy-sandbox/
217
  - **Theme:** 3.1 Professional Tasks — Multi-Step Reasoning & Policy Compliance
218
  - **Bonus Track:** Scaler AI Labs — Multi-App RL Environment for Enterprise Workflows
219
  - **Team:** Parth Singhal, Mehakveer Kaur, Kartik Goyal
 
220
 
221
  ---
222
 
 
1
+ # MetaGuard: A Multi-App RL Environment for Ad Policy Compliance
2
 
3
  > An OpenEnv-compatible reinforcement learning environment that forces an LLM agent
4
  > to do **real investigative work** across multiple enterprise APIs — not pattern-match.
 
7
  ![Python 3.9+](https://img.shields.io/badge/Python-3.9%2B-blue.svg)
8
  ![Framework: OpenEnv + GRPO](https://img.shields.io/badge/Framework-OpenEnv%20%2B%20GRPO-success.svg)
9
 
10
+ ---
11
+
12
+ ## Quick links
13
+
14
+ | Asset | URL |
15
+ | --- | --- |
16
+ | **Hugging Face Space** (environment — MetaGuard) | [huggingface.co/spaces/parth-1/MetaGuard](https://huggingface.co/spaces/parth-1/MetaGuard) |
17
+ | **Hugging Face Space** (GRPO training — MetaGuard-Train) | [huggingface.co/spaces/parth-1/MetaGuard-Train](https://huggingface.co/spaces/parth-1/MetaGuard-Train) |
18
+ | **Fine-tuned model** (GRPO checkpoint on Hub) | [parth-1/metaguard-policy-agent-v1](https://huggingface.co/parth-1/metaguard-policy-agent-v1) |
19
+ | **Training notebook** (Colab — opens `grpo_train.ipynb` from this repo) | [Open in Colab](https://colab.research.google.com/github/Parth380/meta-ad-policy-sandbox/blob/main/grpo_train.ipynb) |
20
+ | **Blog post** (narrative write-up — publish on HF, then swap URL) | [Draft in repo (`docs/metaguard-blog.md`)](https://github.com/Parth380/meta-ad-policy-sandbox/blob/main/docs/metaguard-blog.md) |
21
+
22
+
23
  ---
24
 
25
  ## TL;DR for Judges
 
54
  verify the advertiser → log the audit → only then decide. MetaGuard makes the
55
  agent learn that procedure end-to-end.
56
 
57
+ ### Why it matters
58
+
59
+ **Trust & safety and ads integrity teams**, **enterprise compliance**, and **anyone shipping LLM agents against real APIs** care because mistakes are costly: bad approvals create legal and user-harm risk; over-blocking hurts revenue. A benchmark that enforces **procedure, traceability, and recovery from flaky tools** is a better proxy for production than single-shot classification.
60
+
61
  ---
62
 
63
  ## Architecture
 
162
 
163
  ---
164
 
165
+ ## Training & results
166
+
167
+ Training uses **[OpenEnv](https://github.com/openenv-ai/openenv)** as the environment (this repo’s FastAPI hub + reward logic), **[Unsloth](https://github.com/unslothai/unsloth)** for fast LoRA fine-tuning, and **[Hugging Face TRL](https://github.com/huggingface/trl)** (`GRPOTrainer` / `GRPOConfig`) for GRPO. Entry point: `grpo_train.py`. The trained weights are on the Hub as **[parth-1/metaguard-policy-agent-v1](https://huggingface.co/parth-1/metaguard-policy-agent-v1)** (fine-tuned from `unsloth/Llama-3.1-8B-Instruct`).
168
+
169
+ ### What changed after training?
170
+
171
+ After you complete a real run, summarize **before → after** in a few bullets and paste evidence below.
172
+
173
+ - **Baseline (optional):**
174
+ Prior to the RLHF fine-tuning process, the base meta-llama/Meta-Llama-3.1-8B-Instruct model was largely incompatible with the strict constraints of the compliance environment. It recorded a Mean Initial Reward of -0.30, driven primarily by consistent API rejections and qualitative failure modes. These failures included frequent JSON formatting hallucinations—such as unclosed brackets—and a fundamental inability to follow the required phase order, often attempting to submit audits before querying regulations. The model’s inability to adhere to the required schema also resulted in frequent timeout errors during execution.
175
+ - **After GRPO:**
176
+ Reward Stabilization: The model successfully moved from an initial negative mean reward (~ -0.5) to a consistent positive mean reward (~ 0.45).
177
+ Comparison: Initial runs exhibited significant policy instability around step 80, evidenced by a 4\times increase in GRPO loss and a corresponding crash in mean return. Subsequent tuning flattened these spikes, resulting in a more monotonic improvement in reward and fewer qualitative "relapses" into low-reward behavior.
178
+ Violation Rate: Success rate stabilized after step 40, with the model consistently hitting the reward ceiling despite injected variability.
179
+ - **Run metadata (optional):**
180
+ The training was conducted on an NVIDIA L4 (24GB VRAM) via Hugging Face Spaces using the unsloth/Llama-3.1-8B-Instruct base model, quantized to 4-bit and trained in bfloat16. The fine-tuning utilized a LoRA configuration with a Rank(r) of 32 and an alpha of 64, targeting all linear layers. Key hyperparameters in the GRPOConfig included a learning rate of 2*10^{-5} over 3 epochs, an effective batch size of 8 (via a per-device batch size of 1 and 8 gradient accumulation steps), and a max completion length of 128.
181
+
182
+ ### Loss and reward
183
+
184
+ ![Training loss — ](docs/plots/training_loss.png)
185
+
186
+ ![Mean reward (or return) ](docs/plots/reward_curve.png)
187
+
188
+ *If the images are not in the repo yet, add them under `docs/plots/` after training, or use absolute URLs to hosted assets.*
189
+
190
+ ---
191
+
192
  ## Quick Start
193
 
194
  ### 1. Install
 
221
  python demo.py
222
  ```
223
 
224
+ ### 5. Train an agent (Unsloth + TRL GRPO)
225
+ Requires a CUDA GPU. `grpo_train.py` fine-tunes a LoRA on `unsloth/Llama-3.1-8B-Instruct` with **Unsloth** and **TRL’s `GRPOTrainer`**, using this environment as the reward source. See [Training & results](#training--results) for plots and narrative after you train.
226
+
227
  ```bash
228
  python grpo_train.py
229
  ```
 
261
  - **Theme:** 3.1 Professional Tasks — Multi-Step Reasoning & Policy Compliance
262
  - **Bonus Track:** Scaler AI Labs — Multi-App RL Environment for Enterprise Workflows
263
  - **Team:** Parth Singhal, Mehakveer Kaur, Kartik Goyal
264
+ - **Checklist:** OpenEnv-based env, **Unsloth + TRL** training (`grpo_train.py`), **loss/reward plots** in [Training & results](#training--results), **HF Space + collateral** in [Quick links].
265
 
266
  ---
267