Upload 3 files
Browse files- .gitattributes +1 -0
- MINIBLOG.md +137 -0
- Overview.png +0 -0
- trajectory.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
trajectory.png filter=lfs diff=lfs merge=lfs -text
|
MINIBLOG.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Closed-Loop RL for Enterprise LLM Agents
|
| 2 |
+
|
| 3 |
+
Modern LLM agent systems are often evaluated in static settings: fixed prompts, fixed datasets, and fixed labels. That setup is useful for measuring narrow capabilities, but it does not capture how enterprise workflows actually behave in production. In real organizations, actions affect the world state, constraints evolve over time, and decision quality must be evaluated over sequences rather than isolated steps.
|
| 4 |
+
|
| 5 |
+
This project introduces a closed-loop reinforcement learning framework in which an LLM learns to operate inside a simulated enterprise environment. Instead of predicting answers on pre-collected data, the agent acts through tools, receives feedback, and gradually improves its policy through repeated interaction. The result is a training loop that is closer to real organizational decision-making under uncertainty.
|
| 6 |
+
|
| 7 |
+
<img src="Overview.png" alt="Closed-Loop RL System Overview" width="100%" />
|
| 8 |
+
|
| 9 |
+
## Problem Setting
|
| 10 |
+
|
| 11 |
+
The core objective is to train an LLM-based agent to manage enterprise operations with long-horizon consequences. The environment models organizational factors such as:
|
| 12 |
+
|
| 13 |
+
- project progress and deadlines,
|
| 14 |
+
- team workload and utilization,
|
| 15 |
+
- client satisfaction trajectories,
|
| 16 |
+
- operational penalties and delayed failures.
|
| 17 |
+
|
| 18 |
+
At each timestep, the agent receives a partial observation and selects a tool-based action (for example, assigning tasks, querying status, or updating project plans). Because the environment is partially observable and outcomes can be delayed, the policy must reason beyond immediate rewards.
|
| 19 |
+
|
| 20 |
+
Formally, the setup is a partially observable Markov decision process (POMDP):
|
| 21 |
+
|
| 22 |
+
**𝓜 = (𝓢, 𝓐, 𝓞, P, R, γ)**
|
| 23 |
+
|
| 24 |
+
where sₜ ∈ 𝓢 is the latent state, oₜ ∈ 𝓞 is the observed context, aₜ ∈ 𝓐 is the selected tool action, and γ is the discount factor.
|
| 25 |
+
|
| 26 |
+
## Environment and Interaction Design
|
| 27 |
+
|
| 28 |
+
Unlike static evaluation suites, the environment is stateful and non-stationary at episode scale. Every action can alter future feasibility and reward density. For example, a locally optimal assignment may reduce near-term backlog while creating downstream overload that decreases delivery quality and client confidence.
|
| 29 |
+
|
| 30 |
+
The interaction loop is:
|
| 31 |
+
|
| 32 |
+
**oₜ → aₜ ∼ πθ(aₜ | oₜ) → (sₜ₊₁, rₜ, oₜ₊₁)**
|
| 33 |
+
|
| 34 |
+
This mechanism generates training data online from behavior itself:
|
| 35 |
+
|
| 36 |
+
**𝓓 = {(oₜ, aₜ, rₜ, oₜ₊₁)} for t = 1..T**
|
| 37 |
+
|
| 38 |
+
rather than relying on external, manually labeled trajectories.
|
| 39 |
+
|
| 40 |
+
<img src="trajectory.png" alt="Example Trajectory with Delayed Penalty" width="100%" />
|
| 41 |
+
|
| 42 |
+
## Multi-Objective Reward Modeling
|
| 43 |
+
|
| 44 |
+
A central challenge is reward design. Enterprise decisions are rarely single-objective, so reward should be computed from interpretable event variables rather than fixed ad-hoc constants.
|
| 45 |
+
|
| 46 |
+
Define binary or bounded event terms at step t:
|
| 47 |
+
|
| 48 |
+
- eₜ^success ∈ {0,1}: action advances the active objective,
|
| 49 |
+
- eₜ^quality ∈ [0,1]: quality of tool output or plan update,
|
| 50 |
+
- eₜ^eff ∈ [0,1]: efficiency term (fewer wasted actions, better utilization),
|
| 51 |
+
- eₜ^violation ∈ {0,1}: hard constraint violation (overload, conflict, invalid update),
|
| 52 |
+
- eₜ^delay ∈ [0,1]: delayed negative impact signal.
|
| 53 |
+
|
| 54 |
+
Then use an event-weighted reward:
|
| 55 |
+
|
| 56 |
+
**rₜ = wₛ·eₜ^success + w_q·eₜ^quality + wₑ·eₜ^eff − wᵥ·eₜ^violation − w_d·eₜ^delay**
|
| 57 |
+
|
| 58 |
+
where wₛ, w_q, wₑ, wᵥ, w_d ≥ 0 are calibrated coefficients. A fair default is to give penalties a slightly higher weight than any single positive term so unsafe behavior is consistently discouraged.
|
| 59 |
+
|
| 60 |
+
To stabilize optimization, clip step rewards to a bounded range:
|
| 61 |
+
|
| 62 |
+
**r̃ₜ = clip(rₜ, -1, 1)**
|
| 63 |
+
|
| 64 |
+
The episode return is:
|
| 65 |
+
|
| 66 |
+
**Gₜ = Σ from k=0 to (T−t) of γᵏ · r̃ₜ₊ₖ**
|
| 67 |
+
|
| 68 |
+
For reporting, map return to a normalized score so runs are comparable:
|
| 69 |
+
|
| 70 |
+
**Score(ep) = 100 · (Gₜ − G_min) / (G_max − G_min + ε)**
|
| 71 |
+
|
| 72 |
+
where G_min and G_max are empirical bounds from evaluation scenarios. This creates a fair 0-100 metric tied directly to reward dynamics instead of arbitrary raw totals.
|
| 73 |
+
|
| 74 |
+
## PPO-Based Policy Optimization
|
| 75 |
+
|
| 76 |
+
Training uses Proximal Policy Optimization (PPO), selected for stability and practical performance in high-dimensional policy learning. The LLM serves as the policy backbone (for example, Qwen or Mistral variants), and optimization is performed on interaction rollouts.
|
| 77 |
+
|
| 78 |
+
The PPO clipped objective is:
|
| 79 |
+
|
| 80 |
+
**L_clip(θ) = Eₜ[min(rₜ(θ)Âₜ, clip(rₜ(θ), 1−ε, 1+ε)Âₜ)]**
|
| 81 |
+
|
| 82 |
+
with probability ratio:
|
| 83 |
+
|
| 84 |
+
**rₜ(θ) = πθ(aₜ | oₜ) / πθ_old(aₜ | oₜ)**
|
| 85 |
+
|
| 86 |
+
and Âₜ denotes estimated advantage. In practice, this constrains overly large policy updates while still allowing consistent improvement.
|
| 87 |
+
|
| 88 |
+
Advantage estimation can be implemented with generalized advantage estimation (GAE):
|
| 89 |
+
|
| 90 |
+
**Âₜ = Σ from l=0 to ∞ of (γλ)ˡ · δₜ₊ₗ, and δₜ = rₜ + γV(oₜ₊₁) − V(oₜ)**
|
| 91 |
+
|
| 92 |
+
which improves credit assignment in long-horizon enterprise scenarios.
|
| 93 |
+
|
| 94 |
+
## Behavioral Evolution During Training
|
| 95 |
+
|
| 96 |
+
A key result in this setup is qualitative policy evolution:
|
| 97 |
+
|
| 98 |
+
- **Early phase:** action selection is noisy, reactive, and myopic.
|
| 99 |
+
- **Middle phase:** policy begins recognizing tool-action context and immediate constraint structure.
|
| 100 |
+
- **Later phase:** agent exhibits strategic sequencing, better workload balancing, and lower delayed penalties.
|
| 101 |
+
|
| 102 |
+
This shift is visible in reward trajectories, action distribution changes, and reduced conflict rates in behavioral logs. Importantly, improvements are not limited to immediate reward spikes; the policy becomes more consistent in avoiding future failure modes.
|
| 103 |
+
|
| 104 |
+
**[Figure Placeholder 3: Training curve - episodic reward with moving average]**
|
| 105 |
+
**[Figure Placeholder 4: Action distribution shift from early to late training]**
|
| 106 |
+
|
| 107 |
+
## Implementation Notes for the Project
|
| 108 |
+
|
| 109 |
+
To keep the system aligned with reproducible ML workflows, the training pipeline is organized around:
|
| 110 |
+
|
| 111 |
+
- simulator-driven rollout generation,
|
| 112 |
+
- trajectory buffering for PPO updates,
|
| 113 |
+
- policy/value optimization across epochs,
|
| 114 |
+
- periodic evaluation on held-out scenario seeds,
|
| 115 |
+
- logging of reward components and failure cases.
|
| 116 |
+
|
| 117 |
+
Recommended implementation details to include in the repository and report:
|
| 118 |
+
|
| 119 |
+
1. explicit state and observation schema,
|
| 120 |
+
2. tool-action schema (including invalid-action handling),
|
| 121 |
+
3. reward coefficient table and delayed-penalty logic,
|
| 122 |
+
4. PPO hyperparameters (clip range, learning rate, batch size, epochs, γ, λ),
|
| 123 |
+
5. evaluation protocol (seeds, episode length, metrics, confidence intervals if available).
|
| 124 |
+
|
| 125 |
+
## Why This Matters
|
| 126 |
+
|
| 127 |
+
The broader contribution is methodological: moving from static automation to adaptive agent learning. In enterprise settings, reliable behavior depends on handling uncertainty, delayed effects, and operational trade-offs. A closed-loop RL framework provides a principled way to train for exactly those properties.
|
| 128 |
+
|
| 129 |
+
This project demonstrates that LLM agents can be optimized not only for local correctness, but for long-term decision quality in dynamic environments. That makes it a practical step toward robust, tool-using enterprise AI systems.
|
| 130 |
+
|
| 131 |
+
## Key Takeaways
|
| 132 |
+
|
| 133 |
+
- Closed-loop simulation enables self-generated training data without relying only on fixed datasets.
|
| 134 |
+
- Partial observability and delayed penalties make long-horizon planning essential.
|
| 135 |
+
- Multi-objective rewards better reflect real enterprise optimization targets than single-score objectives.
|
| 136 |
+
- PPO provides a stable training mechanism for improving LLM tool-use policies over repeated interaction.
|
| 137 |
+
- Behavioral evidence shows transition from reactive actions to strategic decision-making.
|
Overview.png
ADDED
|
trajectory.png
ADDED
|
Git LFS Details
|