srallabandi0225 commited on
Commit
f2f2e70
·
verified ·
1 Parent(s): 28a09f0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +278 -192
README.md CHANGED
@@ -1,202 +1,288 @@
1
  ---
2
- base_model: Qwen/Qwen2.5-0.5B-Instruct
3
- library_name: peft
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
-
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
 
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  ## Model Card Contact
198
 
199
- [More Information Needed]
200
- ### Framework versions
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)