nraptisss commited on
Commit
4d20f09
·
verified ·
1 Parent(s): 2fdbc71

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +155 -0
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TMF921 Intent-to-Configuration Translation — Training Pipeline
2
+
3
+ > **The first open-source fine-tuning pipeline for translating natural language network intents into spec-compliant 5G/6G configurations across 6 telecom standards.**
4
+
5
+ ## What This Does
6
+
7
+ Fine-tunes an LLM (default: Qwen3-8B) via **4-bit QLoRA** on the [TMF921-intent-to-config-augmented](https://huggingface.co/datasets/nraptisss/TMF921-intent-to-config-augmented) dataset (41.8K samples) to translate natural language network intents into structured JSON configurations for:
8
+
9
+ | Target Standard | Description |
10
+ |---|---|
11
+ | **TMF921** | TM Forum Intent Management API v4 |
12
+ | **3GPP TS 28.312** | Intent-Driven Management (Rel-18) |
13
+ | **CAMARA** | GSMA Open Gateway NetworkSliceBooking |
14
+ | **ETSI ZSM** | Zero-touch Service Management intents |
15
+ | **O-RAN A1 Policy** | Non-RT RIC A1 policy objects |
16
+ | **3GPP O1 NRM** | O1 interface NR Network Resource Model |
17
+
18
+ Plus **TMF921 lifecycle operations** (activate, modify, suspend, resume, terminate, scale, monitor, report) and **adversarial rejection** (ambiguous, out-of-scope, contradictory intents).
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Clone & Install
23
+
24
+ ```bash
25
+ git clone https://huggingface.co/nraptisss/intent-translation-training
26
+ cd intent-translation-training
27
+ pip install -r requirements.txt
28
+ ```
29
+
30
+ ### 2. Train (defaults — RTX 6000 Ada 50GB)
31
+
32
+ ```bash
33
+ python train.py
34
+ ```
35
+
36
+ This will:
37
+ - Load Qwen3-8B in 4-bit NF4 quantization
38
+ - Apply QLoRA (r=32, alpha=64) to all linear layers
39
+ - Train for 3 epochs with cosine LR schedule
40
+ - Save checkpoints and best model to `./output/`
41
+
42
+ ### 3. Evaluate
43
+
44
+ ```bash
45
+ python evaluate.py --adapter_path ./output --num_samples 200
46
+ ```
47
+
48
+ ### 4. One-command pipeline
49
+
50
+ ```bash
51
+ chmod +x run.sh
52
+ ./run.sh
53
+ ```
54
+
55
+ ## Training Configuration
56
+
57
+ | Parameter | Default | Notes |
58
+ |---|---|---|
59
+ | Base model | `Qwen/Qwen3-8B` | Any HF causal LM works |
60
+ | Quantization | 4-bit NF4 + double quant | ~4.5 GB VRAM for weights |
61
+ | LoRA rank | 32 | target_modules="all-linear" |
62
+ | LoRA alpha | 64 | 2× rank |
63
+ | Batch size | 4 × 8 grad_accum = 32 effective | |
64
+ | Learning rate | 1e-4 | 10× base for LoRA |
65
+ | Epochs | 3 | ~3,700 steps total |
66
+ | Max length | 4096 tokens | Covers 99%+ of samples |
67
+ | Loss | assistant_only_loss=True | Train only on config outputs |
68
+ | Precision | bf16 | |
69
+ | Flash attention | Yes (flash_attention_2) | |
70
+ | Gradient checkpointing | Yes | Saves ~40% VRAM |
71
+
72
+ ### VRAM Estimate (RTX 6000 Ada 50GB)
73
+
74
+ | Component | VRAM |
75
+ |---|---|
76
+ | Model weights (4-bit) | ~4.5 GB |
77
+ | LoRA adapters | ~0.5 GB |
78
+ | Activations + gradients (checkpointed) | ~12 GB |
79
+ | Optimizer states (AdamW, LoRA params only) | ~1 GB |
80
+ | KV cache / batch | ~8 GB |
81
+ | **Total estimated** | **~26 GB** |
82
+
83
+ Leaves ~24 GB headroom. You can increase batch_size to 8 if desired.
84
+
85
+ ## Customization
86
+
87
+ ### Different base model
88
+ ```bash
89
+ python train.py --base_model Qwen/Qwen2.5-7B-Instruct
90
+ python train.py --base_model meta-llama/Llama-3.1-8B-Instruct
91
+ python train.py --base_model microsoft/phi-4
92
+ ```
93
+
94
+ ### Push to Hugging Face Hub
95
+ ```bash
96
+ export HF_TOKEN="hf_..."
97
+ python train.py --push_to_hub --hub_model_id your-username/model-name
98
+ ```
99
+
100
+ ### Adjust hyperparameters
101
+ ```bash
102
+ python train.py --lr 2e-4 --epochs 5 --lora_r 64 --lora_alpha 128 --batch_size 2 --grad_accum 16
103
+ ```
104
+
105
+ ### No flash attention (older GPUs)
106
+ ```bash
107
+ python train.py --no_flash_attn
108
+ ```
109
+
110
+ ## Evaluation Metrics
111
+
112
+ The evaluation script measures:
113
+
114
+ | Metric | Description |
115
+ |---|---|
116
+ | **JSON Validity Rate** | % of outputs that are valid JSON |
117
+ | **Structure Correctness** | % with correct root keys per standard |
118
+ | **KPI Field Accuracy** | % containing correct latency, throughput, reliability, UE values |
119
+ | **All KPIs Correct** | % where ALL 5 KPI fields match |
120
+ | **Adversarial Accuracy** | % of bad intents correctly rejected |
121
+
122
+ Results are broken down per target layer (TMF921, 3GPP, CAMARA, etc.).
123
+
124
+ ## File Structure
125
+
126
+ ```
127
+ ├── train.py # QLoRA fine-tuning script
128
+ ├── evaluate.py # Evaluation with per-layer metrics
129
+ ├── run.sh # One-command train+eval pipeline
130
+ ├── requirements.txt # Python dependencies
131
+ └── README.md # This file
132
+ ```
133
+
134
+ ## Dataset
135
+
136
+ [nraptisss/TMF921-intent-to-config-augmented](https://huggingface.co/datasets/nraptisss/TMF921-intent-to-config-augmented) — 41,815 samples:
137
+
138
+ - **39,153** standard intent→config pairs across 6 target layers
139
+ - **1,552** lifecycle operation samples (8 TMF921 operations)
140
+ - **141** adversarial samples (ambiguous, out-of-scope, contradictory)
141
+ - **18 sectors**, **147 use cases**, **55 regions**
142
+ - **6 slice types**: eMBB, URLLC, mMTC, V2X, MPS, HMTC
143
+
144
+ ## References
145
+
146
+ - [ORION: Intent-Aware Orchestration in Open RAN](https://arxiv.org/abs/2603.03667)
147
+ - [TelecomGPT](https://arxiv.org/abs/2407.09424)
148
+ - [ORANSight-2.0](https://arxiv.org/abs/2503.05200)
149
+ - [NEFMind](https://arxiv.org/abs/2508.09240)
150
+ - [TMF921 Intent Management API v5.0](https://www.tmforum.org/resources/specification/tmf921-intent-management-api-rest-specification-r21-0-0/)
151
+ - [3GPP TS 28.312 Rel-18](https://www.3gpp.org/dynareport/28312.htm)
152
+
153
+ ## License
154
+
155
+ Apache 2.0