Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,288 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
-
###
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
[
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
##
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
- **
|
| 148 |
-
|
| 149 |
-
-
|
| 150 |
-
|
| 151 |
-
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
##
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
- PEFT 0.14.0
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- infrastructure-as-code
|
| 9 |
+
- terraform
|
| 10 |
+
- kubernetes
|
| 11 |
+
- docker
|
| 12 |
+
- devops
|
| 13 |
+
- iac
|
| 14 |
+
- dapo
|
| 15 |
+
- reinforcement-learning
|
| 16 |
+
- fine-tuned
|
| 17 |
+
base_model: srallabandi0225/inframind-0.5b-grpo
|
| 18 |
+
datasets:
|
| 19 |
+
- custom
|
| 20 |
+
model-index:
|
| 21 |
+
- name: inframind-dapo
|
| 22 |
+
results:
|
| 23 |
+
- task:
|
| 24 |
+
type: text-generation
|
| 25 |
+
name: IaC Generation
|
| 26 |
+
dataset:
|
| 27 |
+
name: InfraMind-Bench
|
| 28 |
+
type: custom
|
| 29 |
+
metrics:
|
| 30 |
+
- type: accuracy
|
| 31 |
+
value: 96.4
|
| 32 |
+
name: DAPO Accuracy
|
| 33 |
---
|
| 34 |
|
| 35 |
+
# InfraMind-DAPO: Infrastructure-as-Code Model with Direct Advantage Policy Optimization
|
| 36 |
|
| 37 |
+
**InfraMind-DAPO** is a 0.5B parameter language model fine-tuned for Infrastructure-as-Code (IaC) generation using **DAPO (Direct Advantage Policy Optimization)** - an advanced reinforcement learning technique that builds upon GRPO.
|
| 38 |
+
|
| 39 |
+
## Model Description
|
| 40 |
+
|
| 41 |
+
| Attribute | Value |
|
| 42 |
+
|-----------|-------|
|
| 43 |
+
| **Base Model** | [inframind-0.5b-grpo](https://huggingface.co/srallabandi0225/inframind-0.5b-grpo) |
|
| 44 |
+
| **Original Base** | Qwen/Qwen2.5-0.5B-Instruct |
|
| 45 |
+
| **Parameters** | 500M |
|
| 46 |
+
| **Training Method** | DAPO (Direct Advantage Policy Optimization) |
|
| 47 |
+
| **Domain** | Infrastructure-as-Code |
|
| 48 |
+
| **License** | MIT |
|
| 49 |
+
|
| 50 |
+
### Training Pipeline
|
| 51 |
+
|
| 52 |
+
```
|
| 53 |
+
Qwen2.5-0.5B-Instruct → GRPO Training → inframind-grpo → DAPO Training → inframind-dapo
|
| 54 |
+
(Stage 1) (Stage 2 - This Model)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
This model is the **second stage** of InfraMind training, starting from the GRPO-trained checkpoint and applying DAPO innovations for enhanced learning.
|
| 58 |
+
|
| 59 |
+
## What is DAPO?
|
| 60 |
+
|
| 61 |
+
**Direct Advantage Policy Optimization (DAPO)** is an advanced RL algorithm that improves upon GRPO with four key innovations:
|
| 62 |
+
|
| 63 |
+
| Innovation | Description | Benefit |
|
| 64 |
+
|------------|-------------|---------|
|
| 65 |
+
| **Clip-Higher** | Asymmetric clipping (ε_low=0.2, ε_high=0.28) | Allows high-advantage tokens to be reinforced more strongly |
|
| 66 |
+
| **Dynamic Sampling** | Skip batches with uniform rewards | Prevents entropy collapse, maintains exploration |
|
| 67 |
+
| **Token-Level Loss** | Per-token policy gradient | Finer-grained credit assignment |
|
| 68 |
+
| **Overlong Punishment** | Soft length penalty | Prevents verbose, repetitive outputs |
|
| 69 |
+
|
| 70 |
+
### Why DAPO After GRPO?
|
| 71 |
+
|
| 72 |
+
| Stage | Method | Purpose |
|
| 73 |
+
|-------|--------|---------|
|
| 74 |
+
| Stage 1 | GRPO | Establish IaC generation capability from base model |
|
| 75 |
+
| Stage 2 | DAPO | Refine with advanced techniques for quality improvement |
|
| 76 |
+
|
| 77 |
+
## Evaluation Results
|
| 78 |
+
|
| 79 |
+
| Model | Training Method | Accuracy | Pass Threshold |
|
| 80 |
+
|-------|-----------------|----------|----------------|
|
| 81 |
+
| **inframind-grpo** | GRPO | **97.3%** | 0.6 |
|
| 82 |
+
| **inframind-dapo** | DAPO | **96.4%** | 0.6 |
|
| 83 |
+
| Base (Qwen2.5-0.5B) | None | ~30% | 0.6 |
|
| 84 |
+
|
| 85 |
+
Evaluated on **InfraMind-Bench** (110 held-out test samples) across:
|
| 86 |
+
- Terraform (AWS, GCP, Azure)
|
| 87 |
+
- Kubernetes (Deployments, Services, Ingress)
|
| 88 |
+
- Docker (Dockerfile, docker-compose)
|
| 89 |
+
- CI/CD (GitHub Actions, GitLab CI)
|
| 90 |
+
|
| 91 |
+
## Quick Start
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 95 |
+
|
| 96 |
+
# Load DAPO model
|
| 97 |
+
model = AutoModelForCausalLM.from_pretrained("srallabandi0225/inframind-0.5b-dapo")
|
| 98 |
+
tokenizer = AutoTokenizer.from_pretrained("srallabandi0225/inframind-0.5b-dapo")
|
| 99 |
+
|
| 100 |
+
# Generate Terraform
|
| 101 |
+
prompt = """### Instruction:
|
| 102 |
+
Create Terraform for AWS EC2 instance
|
| 103 |
+
### Input:
|
| 104 |
+
t3.micro instance type
|
| 105 |
+
### Response:
|
| 106 |
+
"""
|
| 107 |
+
|
| 108 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 109 |
+
outputs = model.generate(
|
| 110 |
+
**inputs,
|
| 111 |
+
max_new_tokens=512,
|
| 112 |
+
temperature=0.7,
|
| 113 |
+
do_sample=True,
|
| 114 |
+
pad_token_id=tokenizer.pad_token_id
|
| 115 |
+
)
|
| 116 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### Example Output
|
| 120 |
+
|
| 121 |
+
```hcl
|
| 122 |
+
resource "aws_instance" "web" {
|
| 123 |
+
ami = "ami-0c55b159cbfafe1f0"
|
| 124 |
+
instance_type = "t3.micro"
|
| 125 |
+
|
| 126 |
+
tags = {
|
| 127 |
+
Name = "web-server"
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
## Supported IaC Categories
|
| 133 |
+
|
| 134 |
+
| Category | Examples | Coverage |
|
| 135 |
+
|----------|----------|----------|
|
| 136 |
+
| **Terraform** | EC2, S3, VPC, RDS, EKS, Lambda, IAM | AWS, GCP, Azure |
|
| 137 |
+
| **Kubernetes** | Deployment, Service, Ingress, ConfigMap, RBAC | All K8s resources |
|
| 138 |
+
| **Docker** | Dockerfile, docker-compose | Multi-stage builds |
|
| 139 |
+
| **CI/CD** | GitHub Actions, GitLab CI, Jenkins | Workflows, pipelines |
|
| 140 |
+
| **Ansible** | Playbooks, roles | Server configuration |
|
| 141 |
+
| **Helm** | Charts, values.yaml | K8s package management |
|
| 142 |
|
| 143 |
## Training Details
|
| 144 |
|
| 145 |
+
### DAPO Configuration
|
| 146 |
+
|
| 147 |
+
```yaml
|
| 148 |
+
Training:
|
| 149 |
+
epochs: 2
|
| 150 |
+
batch_size: 16 (effective)
|
| 151 |
+
learning_rate: 5e-6
|
| 152 |
+
beta (KL): 0.0 # Pure DAPO - no KL penalty
|
| 153 |
+
generations_per_prompt: 8
|
| 154 |
+
|
| 155 |
+
DAPO Innovations:
|
| 156 |
+
clip_higher:
|
| 157 |
+
epsilon_low: 0.2
|
| 158 |
+
epsilon_high: 0.28
|
| 159 |
+
dynamic_sampling: true
|
| 160 |
+
token_level_loss: true
|
| 161 |
+
overlong_punishment:
|
| 162 |
+
enabled: true
|
| 163 |
+
soft_penalty: true
|
| 164 |
+
|
| 165 |
+
LoRA:
|
| 166 |
+
r: 16
|
| 167 |
+
alpha: 32
|
| 168 |
+
target_modules: [q_proj, k_proj, v_proj, o_proj]
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
### Reward Function
|
| 172 |
+
|
| 173 |
+
Domain-specific reward for IaC quality:
|
| 174 |
+
|
| 175 |
+
```
|
| 176 |
+
Reward = α × Syntax + β × Correctness + γ × Format
|
| 177 |
+
|
| 178 |
+
Where:
|
| 179 |
+
- Syntax (α=0.4): Valid resource declarations
|
| 180 |
+
- Correctness (β=0.3): Correct resource types
|
| 181 |
+
- Format (γ=0.3): Proper structure
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
## GRPO vs DAPO Comparison
|
| 185 |
+
|
| 186 |
+
| Aspect | GRPO | DAPO |
|
| 187 |
+
|--------|------|------|
|
| 188 |
+
| KL Penalty | β=0.04 | β=0.0 (none) |
|
| 189 |
+
| Clipping | Symmetric | Asymmetric (Clip-Higher) |
|
| 190 |
+
| Loss Granularity | Sequence-level | Token-level |
|
| 191 |
+
| Sampling | All batches | Dynamic (skip uniform) |
|
| 192 |
+
| Length Control | None | Overlong punishment |
|
| 193 |
+
|
| 194 |
+
## Hardware Requirements
|
| 195 |
+
|
| 196 |
+
| Deployment | Memory | GPU |
|
| 197 |
+
|------------|--------|-----|
|
| 198 |
+
| Training | 16GB+ | A100/A10G |
|
| 199 |
+
| Inference | 2GB | Optional |
|
| 200 |
+
| Edge (Raspberry Pi 5) | 4GB | None |
|
| 201 |
+
|
| 202 |
+
The 0.5B model is small enough to run on edge devices, making it suitable for:
|
| 203 |
+
- Air-gapped environments
|
| 204 |
+
- Local development
|
| 205 |
+
- CI/CD pipelines
|
| 206 |
+
- IoT/Edge infrastructure
|
| 207 |
+
|
| 208 |
+
## Limitations
|
| 209 |
+
|
| 210 |
+
- **IaC-specific**: Optimized for infrastructure tasks, not general conversation
|
| 211 |
+
- **English only**: Training data is in English
|
| 212 |
+
- **No execution**: Generates code, does not execute or validate against real infrastructure
|
| 213 |
+
- **Version-sensitive**: Generated code may use older API versions
|
| 214 |
+
- **Security**: Always review generated code for security best practices
|
| 215 |
+
|
| 216 |
+
### Out-of-Scope Uses
|
| 217 |
+
|
| 218 |
+
- Legal or medical advice
|
| 219 |
+
- General-purpose chatbot
|
| 220 |
+
- Executing infrastructure changes without human review
|
| 221 |
+
- Production deployment without validation
|
| 222 |
+
|
| 223 |
+
## Intended Use
|
| 224 |
+
|
| 225 |
+
### Primary Use Cases
|
| 226 |
+
- Generating Terraform configurations
|
| 227 |
+
- Creating Kubernetes manifests
|
| 228 |
+
- Writing Dockerfiles and docker-compose
|
| 229 |
+
- Building CI/CD pipelines
|
| 230 |
+
- Infrastructure automation scripting
|
| 231 |
+
|
| 232 |
+
### Users
|
| 233 |
+
- DevOps engineers
|
| 234 |
+
- Platform engineers
|
| 235 |
+
- SREs
|
| 236 |
+
- Cloud architects
|
| 237 |
+
- Infrastructure developers
|
| 238 |
+
|
| 239 |
+
## Training Data
|
| 240 |
+
|
| 241 |
+
**InfraMind-Bench**: 2000+ IaC tasks in Alpaca format
|
| 242 |
+
|
| 243 |
+
| Category | Tasks |
|
| 244 |
+
|----------|-------|
|
| 245 |
+
| Terraform | 500+ |
|
| 246 |
+
| Kubernetes | 400+ |
|
| 247 |
+
| Docker | 300+ |
|
| 248 |
+
| CI/CD | 300+ |
|
| 249 |
+
| Ansible | 200+ |
|
| 250 |
+
| Helm | 150+ |
|
| 251 |
+
| Monitoring | 150+ |
|
| 252 |
+
|
| 253 |
+
## Ethical Considerations
|
| 254 |
+
|
| 255 |
+
- Model may generate insecure configurations if not prompted for security
|
| 256 |
+
- Generated infrastructure code should always be reviewed before deployment
|
| 257 |
+
- Model does not have access to real infrastructure or credentials
|
| 258 |
+
- Users are responsible for validating generated code against their security policies
|
| 259 |
+
|
| 260 |
+
## Citation
|
| 261 |
+
|
| 262 |
+
```bibtex
|
| 263 |
+
@misc{rallabandi2024inframind,
|
| 264 |
+
title={InfraMind: Fine-tuning Small Language Models for Infrastructure-as-Code Generation with Reinforcement Learning},
|
| 265 |
+
author={Rallabandi, Sai Kiran},
|
| 266 |
+
year={2024},
|
| 267 |
+
publisher={HuggingFace},
|
| 268 |
+
url={https://huggingface.co/srallabandi0225/inframind-0.5b-dapo}
|
| 269 |
+
}
|
| 270 |
+
```
|
| 271 |
+
|
| 272 |
+
## Links
|
| 273 |
+
|
| 274 |
+
- **GitHub**: [github.com/saikiranrallabandi/inframind](https://github.com/saikiranrallabandi/inframind)
|
| 275 |
+
- **GRPO Model**: [srallabandi0225/inframind-0.5b-grpo](https://huggingface.co/srallabandi0225/inframind-0.5b-grpo)
|
| 276 |
+
- **DAPO Model**: [srallabandi0225/inframind-0.5b-dapo](https://huggingface.co/srallabandi0225/inframind-0.5b-dapo)
|
| 277 |
+
|
| 278 |
+
## Acknowledgments
|
| 279 |
+
|
| 280 |
+
- [Qwen Team](https://github.com/QwenLM/Qwen) for the base model
|
| 281 |
+
- [DeepSeek](https://github.com/deepseek-ai) for GRPO
|
| 282 |
+
- [NVIDIA NeMo](https://docs.nvidia.com/nemo) for DAPO reference
|
| 283 |
+
- [TRL](https://github.com/huggingface/trl) for training infrastructure
|
| 284 |
|
| 285 |
## Model Card Contact
|
| 286 |
|
| 287 |
+
**Author**: Sai Kiran Rallabandi
|
| 288 |
+
**GitHub**: [@saikiranrallabandi](https://github.com/saikiranrallabandi)
|
|
|
|
|
|