AdityaPS commited on
Commit
99e68d2
·
verified ·
1 Parent(s): e78f050

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +156 -120
README.md CHANGED
@@ -6,202 +6,238 @@ tags:
6
  - base_model:adapter:openai/gpt-oss-20b
7
  - lora
8
  - transformers
 
 
 
 
 
9
  ---
10
 
11
- # Model Card for Model ID
12
-
13
- <!-- Provide a quick summary of what the model is/does. -->
14
 
 
 
 
 
 
15
 
 
16
 
17
  ## Model Details
18
 
19
  ### Model Description
20
 
21
- <!-- Provide a longer summary of what this model is. -->
22
-
 
 
 
 
 
 
23
 
 
24
 
25
- - **Developed by:** [More Information Needed]
26
- - **Funded by [optional]:** [More Information Needed]
27
- - **Shared by [optional]:** [More Information Needed]
28
- - **Model type:** [More Information Needed]
29
- - **Language(s) (NLP):** [More Information Needed]
30
- - **License:** [More Information Needed]
31
- - **Finetuned from model [optional]:** [More Information Needed]
32
 
33
- ### Model Sources [optional]
34
-
35
- <!-- Provide the basic links for the model. -->
36
-
37
- - **Repository:** [More Information Needed]
38
- - **Paper [optional]:** [More Information Needed]
39
- - **Demo [optional]:** [More Information Needed]
40
 
41
  ## Uses
42
 
43
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
-
45
  ### Direct Use
46
 
47
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
-
49
- [More Information Needed]
50
-
51
- ### Downstream Use [optional]
52
 
53
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
 
55
- [More Information Needed]
 
56
 
57
  ### Out-of-Scope Use
58
 
59
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
-
61
- [More Information Needed]
62
-
63
- ## Bias, Risks, and Limitations
64
-
65
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
 
67
- [More Information Needed]
68
-
69
- ### Recommendations
70
-
71
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
-
73
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
 
75
  ## How to Get Started with the Model
76
 
77
- Use the code below to get started with the model.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- [More Information Needed]
80
 
81
  ## Training Details
82
 
83
  ### Training Data
84
 
85
- <!-- 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. -->
 
 
 
86
 
87
- [More Information Needed]
 
 
 
 
88
 
89
  ### Training Procedure
90
 
91
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
92
-
93
- #### Preprocessing [optional]
94
-
95
- [More Information Needed]
96
 
 
 
 
 
 
 
 
 
97
 
98
  #### Training Hyperparameters
99
 
100
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
-
102
- #### Speeds, Sizes, Times [optional]
103
-
104
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- [More Information Needed]
107
 
108
  ## Evaluation
109
 
110
- <!-- This section describes the evaluation protocols and provides the results. -->
111
-
112
- ### Testing Data, Factors & Metrics
113
 
114
- #### Testing Data
 
115
 
116
- <!-- This should link to a Dataset Card if possible. -->
117
 
118
- [More Information Needed]
119
-
120
- #### Factors
121
-
122
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
-
124
- [More Information Needed]
125
-
126
- #### Metrics
127
-
128
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
129
-
130
- [More Information Needed]
131
 
132
  ### Results
133
 
134
- [More Information Needed]
135
 
136
- #### Summary
137
 
 
138
 
 
 
 
 
 
139
 
140
- ## Model Examination [optional]
 
141
 
142
- <!-- Relevant interpretability work for the model goes here -->
143
-
144
- [More Information Needed]
145
 
146
  ## Environmental Impact
147
 
148
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
 
 
149
 
150
- 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).
 
 
 
 
151
 
152
- - **Hardware Type:** [More Information Needed]
153
- - **Hours used:** [More Information Needed]
154
- - **Cloud Provider:** [More Information Needed]
155
- - **Compute Region:** [More Information Needed]
156
- - **Carbon Emitted:** [More Information Needed]
157
 
158
- ## Technical Specifications [optional]
159
 
160
  ### Model Architecture and Objective
161
 
162
- [More Information Needed]
 
 
 
 
 
 
163
 
164
  ### Compute Infrastructure
165
 
166
- [More Information Needed]
167
-
168
- #### Hardware
169
-
170
- [More Information Needed]
171
-
172
- #### Software
173
 
174
- [More Information Needed]
175
-
176
- ## Citation [optional]
177
-
178
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
179
-
180
- **BibTeX:**
181
-
182
- [More Information Needed]
183
-
184
- **APA:**
185
-
186
- [More Information Needed]
187
-
188
- ## Glossary [optional]
189
-
190
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
191
 
192
- [More Information Needed]
193
 
194
- ## More Information [optional]
 
 
 
 
 
 
 
195
 
196
- [More Information Needed]
197
 
198
- ## Model Card Authors [optional]
199
 
200
- [More Information Needed]
201
 
202
  ## Model Card Contact
203
 
204
- [More Information Needed]
 
205
  ### Framework versions
206
 
207
  - PEFT 0.19.1
 
6
  - base_model:adapter:openai/gpt-oss-20b
7
  - lora
8
  - transformers
9
+ - space
10
+ - question-answering
11
+ license: apache-2.0
12
+ metrics:
13
+ - bertscore
14
  ---
15
 
16
+ # SpaceLLM v1 — LoRA Adapter for Space Domain QA
 
 
17
 
18
+ SpaceLLM v1 is a parameter-efficient LoRA adapter fine-tuned on top of
19
+ [openai/gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) for space-domain
20
+ question answering. Only the `lm_head` is trained; the full transformer backbone
21
+ remains frozen, keeping the adapter extremely lightweight while steering the model's
22
+ output distribution toward space mission knowledge.
23
 
24
+ ---
25
 
26
  ## Model Details
27
 
28
  ### Model Description
29
 
30
+ - **Developed by:** AdityaPS
31
+ - **Model type:** LoRA adapter (PEFT) over a causal language model
32
+ - **Base model:** [openai/gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) (22B params, BF16/MXFP4)
33
+ - **Language(s):** English
34
+ - **License:** Apache 2.0 (inherited from base model)
35
+ - **Fine-tuned from:** openai/gpt-oss-20b
36
+ - **PEFT version:** 0.19.1
37
+ - **Fine-tuning strategy:** LoRA on `lm_head` only — backbone fully frozen (BF16, NOT QLoRA)
38
 
39
+ ### Model Sources
40
 
41
+ - **Repository:** [AdityaPS/SpaceLLM_v1](https://huggingface.co/AdityaPS/SpaceLLM_v1)
42
+ - **Paper:** [Quantifying the Carbon Emissions of Machine Learning (Lacoste et al., 2019)](https://arxiv.org/abs/1910.09700)
 
 
 
 
 
43
 
44
+ ---
 
 
 
 
 
 
45
 
46
  ## Uses
47
 
 
 
48
  ### Direct Use
49
 
50
+ Load alongside `openai/gpt-oss-20b` for space-domain conversational question answering.
51
+ The model expects inputs formatted using the **harmony response format** (gpt-oss-20b's
52
+ required chat template) — passing raw text without the template will degrade output quality.
 
 
53
 
54
+ ### Downstream Use
55
 
56
+ Can be plugged into RAG pipelines, mission-planning assistants, or educational tools
57
+ focused on space science, satellite operations, and related domains.
58
 
59
  ### Out-of-Scope Use
60
 
61
+ - General-purpose chat without space-domain context
62
+ - Tasks requiring multi-modal input (images, structured data)
63
+ - Deployment without the base model (`openai/gpt-oss-20b` must be loaded alongside the adapter)
 
 
 
 
64
 
65
+ ---
 
 
 
 
 
 
66
 
67
  ## How to Get Started with the Model
68
 
69
+ ```python
70
+ from transformers import AutoModelForCausalLM, AutoTokenizer, Mxfp4Config
71
+ from peft import PeftModel
72
+
73
+ # Load base model (requires ~44 GB VRAM in BF16, or use MXFP4 for lower memory)
74
+ base_model = AutoModelForCausalLM.from_pretrained(
75
+ "openai/gpt-oss-20b",
76
+ quantization_config=Mxfp4Config(dequantize=True), # dequantizes to BF16
77
+ device_map="auto",
78
+ trust_remote_code=True,
79
+ )
80
+
81
+ # Load LoRA adapter on top
82
+ model = PeftModel.from_pretrained(base_model, "AdityaPS/SpaceLLM_v1")
83
+ tokenizer = AutoTokenizer.from_pretrained("AdityaPS/SpaceLLM_v1")
84
+
85
+ # Inference — must use harmony chat template
86
+ messages = [
87
+ {"role": "system", "content": "You are a space domain expert assistant."},
88
+ {"role": "user", "content": "What is the purpose of a Sun-synchronous orbit?"},
89
+ ]
90
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
91
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
92
+
93
+ output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
94
+ print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
95
+ ```
96
+
97
+ > **Note:** `openai/gpt-oss-20b` uses the **harmony response format**. Always use
98
+ > `tokenizer.apply_chat_template()` — do not pass raw text directly.
99
 
100
+ ---
101
 
102
  ## Training Details
103
 
104
  ### Training Data
105
 
106
+ Fine-tuned on an internal space-domain QA dataset (`DatasetA_core_QA_v2`) consisting
107
+ of multi-turn conversational records with `system`, `user`, and `assistant` turns.
108
+ Records are tagged with metadata fields including `organization`, `difficulty`,
109
+ `aspect`, and `chain_id` for multi-hop reasoning chains.
110
 
111
+ | Split | Records |
112
+ |------------|---------|
113
+ | Train | ~4,800 |
114
+ | Validation | — |
115
+ | Test | 5,291 |
116
 
117
  ### Training Procedure
118
 
119
+ #### Key Design Choices
 
 
 
 
120
 
121
+ - **LoRA applied to `lm_head` only** — the full MoE transformer backbone is frozen.
122
+ - **Critical fix:** `lm_head.weight` is physically untied from `embed_tokens.weight`
123
+ via `detach().clone()` *before* `get_peft_model()` is called. Without this,
124
+ autograd sees `lm_head` and `embed_tokens` as the same tensor, cutting gradients
125
+ to `lora_A`.
126
+ - **Device-aware CE loss** injected to handle MoE multi-GPU sharding where `lm_head`
127
+ may land on a different device from the labels.
128
+ - Model loaded in MXFP4 and dequantized to BF16 before LoRA application.
129
 
130
  #### Training Hyperparameters
131
 
132
+ | Hyperparameter | Value |
133
+ |--------------------------|--------------------------|
134
+ | Training regime | BF16 mixed precision |
135
+ | LoRA rank (r) | 32 |
136
+ | LoRA alpha | 128 |
137
+ | LoRA dropout | 0.1 |
138
+ | Target modules | `lm_head` |
139
+ | Learning rate | 2e-4 |
140
+ | LR scheduler | cosine with restarts |
141
+ | Optimizer | adamw_torch_fused |
142
+ | Batch size | 1 |
143
+ | Gradient accumulation | 32 (effective batch = 32)|
144
+ | Max grad norm | 0.3 |
145
+ | Weight decay | 0.01 |
146
+ | Warmup steps | 200 |
147
+ | Max sequence length | 2,048 |
148
+ | Epochs | 5 |
149
+ | Early stopping patience | 8 eval steps |
150
+ | Vocab size (padded) | 200,064 |
151
+ | Hardware | Multi-GPU (cuda:1, cuda:2)|
152
 
153
+ ---
154
 
155
  ## Evaluation
156
 
157
+ ### Testing Data
 
 
158
 
159
+ Evaluation was run on the held-out test split of `DatasetA_core_QA_v2`
160
+ (5,291 records, covering diverse space organizations and difficulty levels).
161
 
162
+ ### Metrics
163
 
164
+ - **Loss** — mean cross-entropy loss on the assistant response tokens
165
+ - **Exact Match (EM)** — generated answer matches reference exactly (case-insensitive)
166
+ - **Token F1** — word-overlap F1 between generated and reference answers
167
+ - **BERTScore** — semantic similarity using `roberta-large`
 
 
 
 
 
 
 
 
 
168
 
169
  ### Results
170
 
 
171
 
 
172
 
173
+ #### BERTScore (`roberta-large`)
174
 
175
+ | Metric | Score |
176
+ |-----------|--------|
177
+ | Precision | 0.8736 |
178
+ | Recall | 0.8857 |
179
+ | **F1** | **0.8795** |
180
 
181
+ The BERTScore F1 of **0.8795** indicates strong semantic alignment between the
182
+ model's generated answers and the reference answers across the full test set.
183
 
184
+ ---
 
 
185
 
186
  ## Environmental Impact
187
 
188
+ Carbon emissions estimated using the
189
+ [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute)
190
+ (Lacoste et al., 2019).
191
 
192
+ - **Hardware type:** NVIDIA multi-GPU (cuda:1, cuda:2)
193
+ - **Hours used:** ~6.6 hours (396.58 min inference; training time not reported)
194
+ - **Cloud provider:** Not applicable (on-premise)
195
+ - **Compute region:** Not reported
196
+ - **Carbon emitted:** Not measured
197
 
198
+ ---
 
 
 
 
199
 
200
+ ## Technical Specifications
201
 
202
  ### Model Architecture and Objective
203
 
204
+ - **Architecture:** Mixture-of-Experts (MoE) causal language model (gpt-oss-20b)
205
+ with a LoRA adapter injected at the `lm_head` projection layer
206
+ - **Active parameters during inference:** 3.6B (out of 21B total)
207
+ - **LoRA parameters:** ~4 × vocab_size (two low-rank matrices of rank 32,
208
+ applied to a single linear layer)
209
+ - **Objective:** Next-token prediction with cross-entropy loss, masked so that
210
+ only assistant response tokens contribute to the loss
211
 
212
  ### Compute Infrastructure
213
 
214
+ - **Training hardware:** 2× NVIDIA GPUs (indices 1 and 2), dispatched via
215
+ `accelerate.dispatch_model`
216
+ - **Framework:** PyTorch + HuggingFace Transformers + PEFT 0.19.1 + Accelerate
 
 
 
 
217
 
218
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
+ ## Citation
221
 
222
+ ```bibtex
223
+ @article{lacoste2019quantifying,
224
+ title={Quantifying the Carbon Emissions of Machine Learning},
225
+ author={Lacoste, Alexandre and Luccioni, Alexandra and Schmidt, Victor and Dandres, Thomas},
226
+ journal={arXiv preprint arXiv:1910.09700},
227
+ year={2019}
228
+ }
229
+ ```
230
 
231
+ ---
232
 
233
+ ## Model Card Authors
234
 
235
+ AdityaPS
236
 
237
  ## Model Card Contact
238
 
239
+ [Open an issue or discussion on the HuggingFace repository]
240
+
241
  ### Framework versions
242
 
243
  - PEFT 0.19.1