PEFT
qlora
sft
trl
qwen3
tmf921
intent-based-networking
network-slicing
rtx-6000-ada
ml-intern
nraptisss commited on
Commit
23140d4
·
verified ·
1 Parent(s): 77fad9d

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -310
README.md CHANGED
@@ -1,310 +0,0 @@
1
- ---
2
- license: apache-2.0
3
- tags:
4
- - qlora
5
- - sft
6
- - trl
7
- - peft
8
- - qwen3
9
- - tmf921
10
- - intent-based-networking
11
- - network-slicing
12
- - rtx-6000-ada
13
- - ml-intern
14
- base_model:
15
- - Qwen/Qwen3-8B
16
- datasets:
17
- - nraptisss/TMF921-intent-to-config-research-sota
18
- ---
19
-
20
- # TMF921 Intent-to-Config Training + Evaluation
21
-
22
- Training and evaluation repo for [`nraptisss/TMF921-intent-to-config-research-sota`](https://huggingface.co/datasets/nraptisss/TMF921-intent-to-config-research-sota) on a single **RTX 6000 Ada 48/50GB** server.
23
-
24
- The default recipe is **Qwen3-8B + QLoRA NF4 + TRL SFTTrainer + PEFT LoRA**.
25
-
26
- ## Why this recipe
27
-
28
- - Dataset rows were audited with `Qwen/Qwen3-8B` chat-template tokenization.
29
- - Source max length: **1,316 tokens**, p99: **1,300**, so `max_length=2048` is safe.
30
- - QLoRA NF4 + double quant follows the QLoRA recipe for fitting large models on one 48GB-class GPU.
31
- - LoRA uses `target_modules="all-linear"`, recommended for QLoRA-style training.
32
- - `assistant_only_loss=True` trains only the JSON/config response tokens.
33
- - Evaluation is split by in-distribution and OOD splits; do not report only a single merged score.
34
-
35
- ## Hardware target
36
-
37
- Recommended server:
38
-
39
- - GPU: NVIDIA RTX 6000 Ada, 48GB/50GB VRAM
40
- - RAM: 64GB+
41
- - Disk: 200GB+ free
42
- - CUDA-compatible PyTorch
43
-
44
- Default effective batch size:
45
-
46
- ```text
47
- per_device_train_batch_size = 2
48
- gradient_accumulation_steps = 8
49
- effective batch size = 16
50
- max_length = 2048
51
- ```
52
-
53
- If OOM occurs, preserve the effective batch size by changing:
54
-
55
- ```yaml
56
- per_device_train_batch_size: 1
57
- gradient_accumulation_steps: 16
58
- ```
59
-
60
- Do **not** reduce `max_length` unless you intentionally want a different training task.
61
-
62
- ## Quick start with nohup, unique run dirs, and resumable checkpoints
63
-
64
- ```bash
65
- git clone https://huggingface.co/nraptisss/tmf921-intent-training
66
- cd tmf921-intent-training
67
-
68
- python -m venv .venv
69
- source .venv/bin/activate
70
- python -m pip install -U pip
71
- bash scripts/install_rtx6000ada.sh
72
- python scripts/check_gpu.py
73
-
74
- export HF_TOKEN=hf_...
75
- export CUDA_VISIBLE_DEVICES=0
76
- export PYTHONPATH="$PWD/src"
77
- export TOKENIZERS_PARALLELISM=false
78
-
79
- # Optional Trackio dashboard
80
- # export TRACKIO_SPACE_ID=nraptisss/tmf921-trackio
81
-
82
- bash scripts/nohup_new_run.sh
83
- ```
84
-
85
- The helper creates a fresh run directory every time:
86
-
87
- ```text
88
- runs/qwen3-8b-qlora-YYYYMMDD-HHMMSS/
89
- configs/config.yaml
90
- logs/train.log
91
- outputs/adapter/checkpoint-*/
92
- eval/
93
- ```
94
-
95
- Monitor:
96
-
97
- ```bash
98
- RUN_DIR=runs/qwen3-8b-qlora-YYYYMMDD-HHMMSS
99
- bash scripts/status_run.sh "$RUN_DIR"
100
- tail -f "$RUN_DIR/logs/train.log"
101
- watch -n 2 nvidia-smi
102
- ```
103
-
104
- Resume after crash/reboot:
105
-
106
- ```bash
107
- cd tmf921-intent-training
108
- source .venv/bin/activate
109
- export HF_TOKEN=hf_...
110
- export CUDA_VISIBLE_DEVICES=0
111
- export PYTHONPATH="$PWD/src"
112
-
113
- bash scripts/nohup_resume.sh runs/qwen3-8b-qlora-YYYYMMDD-HHMMSS
114
- ```
115
-
116
- Evaluate after training:
117
-
118
- ```bash
119
- bash scripts/nohup_eval.sh runs/qwen3-8b-qlora-YYYYMMDD-HHMMSS
120
- ```
121
-
122
- Manual training command, if you do not want nohup:
123
-
124
- ```bash
125
- python scripts/train_qlora.py \
126
- --config configs/rtx6000ada_qwen3_8b_qlora.yaml
127
- ```
128
-
129
- ## Optional Trackio monitoring
130
-
131
- The training script uses the native Transformers/TRL Trackio integration when `project` is set in the config.
132
-
133
- Set a Trackio Space if desired:
134
-
135
- ```bash
136
- export TRACKIO_SPACE_ID=nraptisss/tmf921-trackio
137
- ```
138
-
139
- Or edit:
140
-
141
- ```yaml
142
- project: tmf921-intent-sft
143
- trackio_space_id: nraptisss/tmf921-trackio
144
- ```
145
-
146
- The trainer logs plain-text loss lines with:
147
-
148
- ```python
149
- disable_tqdm=True
150
- logging_strategy="steps"
151
- logging_first_step=True
152
- report_to="trackio"
153
- ```
154
-
155
- A callback emits Trackio alerts for NaN/Inf loss, high gradient norm, and high eval loss.
156
-
157
- ## Configs
158
-
159
- ### Recommended
160
-
161
- [`configs/rtx6000ada_qwen3_8b_qlora.yaml`](configs/rtx6000ada_qwen3_8b_qlora.yaml)
162
-
163
- Key settings:
164
-
165
- ```yaml
166
- model_name_or_path: Qwen/Qwen3-8B
167
- dataset_name: nraptisss/TMF921-intent-to-config-research-sota
168
- train_split: train_sota
169
- eval_split: validation
170
- max_length: 2048
171
- assistant_only_loss: true
172
- load_in_4bit: true
173
- lora_r: 64
174
- lora_alpha: 16
175
- lora_target_modules: all-linear
176
- learning_rate: 0.0002
177
- optim: paged_adamw_32bit
178
- bf16: true
179
- push_to_hub: true
180
- ```
181
-
182
- ### Experimental 14B
183
-
184
- [`configs/rtx6000ada_qwen3_14b_qlora_experimental.yaml`](configs/rtx6000ada_qwen3_14b_qlora_experimental.yaml)
185
-
186
- Use only after the 8B run, and expect tighter memory.
187
-
188
- ## Evaluation
189
-
190
- After training adapters:
191
-
192
- ```bash
193
- python scripts/evaluate_model.py \
194
- --model Qwen/Qwen3-8B \
195
- --adapter outputs/qwen3-8b-tmf921-qlora \
196
- --dataset nraptisss/TMF921-intent-to-config-research-sota \
197
- --output_dir outputs/qwen3-8b-tmf921-qlora/eval \
198
- --load_in_4bit
199
- ```
200
-
201
- Evaluated splits by default:
202
-
203
- - `test_in_distribution`
204
- - `test_template_ood`
205
- - `test_use_case_ood`
206
- - `test_sector_ood`
207
- - `test_adversarial`
208
-
209
- Metrics:
210
-
211
- - JSON parse rate
212
- - canonical JSON exact match
213
- - field precision / recall / F1
214
- - slice/SST diagnostic pass
215
- - KPI text-presence diagnostic pass
216
- - adversarial status pass
217
- - stratified metrics by `target_layer`, `slice_type`, and `lifecycle_operation`
218
-
219
- Outputs:
220
-
221
- ```text
222
- outputs/.../eval/all_metrics.json
223
- outputs/.../eval/<split>/metrics.json
224
- outputs/.../eval/<split>/predictions.json
225
- ```
226
-
227
- ## Merge adapter for deployment
228
-
229
- ```bash
230
- python scripts/merge_adapter.py \
231
- --base_model Qwen/Qwen3-8B \
232
- --adapter outputs/qwen3-8b-tmf921-qlora \
233
- --output_dir outputs/qwen3-8b-tmf921-merged
234
- ```
235
-
236
- Push merged model:
237
-
238
- ```bash
239
- python scripts/merge_adapter.py \
240
- --base_model Qwen/Qwen3-8B \
241
- --adapter nraptisss/Qwen3-8B-TMF921-Intent-QLoRA-ResearchSOTA \
242
- --output_dir outputs/merged \
243
- --push_to_hub \
244
- --hub_model_id nraptisss/Qwen3-8B-TMF921-Intent-Merged
245
- ```
246
-
247
- ## Scientific reporting protocol
248
-
249
- For research papers/reports, report at least:
250
-
251
- 1. validation loss,
252
- 2. `test_in_distribution` metrics,
253
- 3. `test_template_ood` metrics,
254
- 4. `test_use_case_ood` metrics,
255
- 5. `test_sector_ood` metrics,
256
- 6. `test_adversarial` metrics,
257
- 7. per-target-layer field F1,
258
- 8. JSON parse rate,
259
- 9. exact-match rate,
260
- 10. rare-class metrics for lifecycle operations and adversarial categories.
261
-
262
- Do **not** claim production standards compliance from JSON validity alone. Official TMF921/3GPP/ETSI/CAMARA/O-RAN validators are still needed for schema-level certification.
263
-
264
- ## Files
265
-
266
- ```text
267
- configs/
268
- rtx6000ada_qwen3_8b_qlora.yaml
269
- rtx6000ada_qwen3_14b_qlora_experimental.yaml
270
- scripts/
271
- train_qlora.py
272
- evaluate_model.py
273
- merge_adapter.py
274
- run_rtx6000ada.sh
275
- nohup_new_run.sh
276
- nohup_resume.sh
277
- nohup_eval.sh
278
- status_run.sh
279
- src/tmf921_train/
280
- utils.py
281
- requirements.txt
282
- ```
283
-
284
- ## References
285
-
286
- - QLoRA: https://huggingface.co/papers/2305.14314
287
- - LoRA: https://huggingface.co/papers/2106.09685
288
- - TRL SFTTrainer docs: https://huggingface.co/docs/trl/sft_trainer
289
- - TRL PEFT integration: https://huggingface.co/docs/trl/peft_integration
290
- - Source dataset: https://huggingface.co/datasets/nraptisss/TMF921-intent-to-config-research-sota
291
-
292
- <!-- ml-intern-provenance -->
293
- ## Generated by ML Intern
294
-
295
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
296
-
297
- - Try ML Intern: https://smolagents-ml-intern.hf.space
298
- - Source code: https://github.com/huggingface/ml-intern
299
-
300
- ## Usage
301
-
302
- ```python
303
- from transformers import AutoModelForCausalLM, AutoTokenizer
304
-
305
- model_id = 'nraptisss/tmf921-intent-training'
306
- tokenizer = AutoTokenizer.from_pretrained(model_id)
307
- model = AutoModelForCausalLM.from_pretrained(model_id)
308
- ```
309
-
310
- For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.