AdityaPS commited on
Commit
30ae827
·
verified ·
1 Parent(s): 8a486ac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +128 -74
README.md CHANGED
@@ -1,6 +1,5 @@
1
  ---
2
- license: other
3
- license_name: todo-confirm
4
  language:
5
  - en
6
  library_name: peft
@@ -25,62 +24,72 @@ model-index:
25
  metrics:
26
  - type: bertscore
27
  name: BERTScore F1 (roberta-large)
28
- value: 0.902252
29
  - type: f1
30
  name: Token F1
31
- value: 0.404100
32
  - type: exact_match
33
  name: Exact match
34
- value: 0.004734
35
  ---
36
 
37
  # SpaceLLM Single-Turn QA
38
 
39
- A LoRA adapter for [`openai/gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b), fine-tuned to answer single-turn questions about space-agency material. This repository contains **adapter weights only**; the base model must be loaded separately.
40
 
41
- - **Developed by:** TODO_AUTHORS
42
- - **Paper:** TODO_PAPER_LINK
43
- - **Model type:** LoRA adapter (PEFT)
44
  - **Language:** English
45
- - **Base model:** `openai/gpt-oss-20b` (21B total / 3.6B active parameters), revision `6cee5e81ee83917806bbde320786a8fb61efebee`
46
- - **Companion model:** SpaceLLM Multi-Turn QA (separate adapter, separate repository)
47
 
48
  > **Please note**
49
- > - This adapter does **not** use retrieval (no RAG, index, or retrieved passages). Nothing is looked up at inference time.
50
- > - It adapts attention projections only (`q_proj`, `k_proj`, `v_proj`, `o_proj`), not `lm_head`.
51
- > - Training references were generated by a teacher model and were **not fact-checked**. Scores measure similarity to those references, not verified factual accuracy.
52
- > - This is a different artifact from the older `AdityaPS/SpaceLLM_v1` (lm_head-only, rank 32, alpha 128, different data and evaluation).
 
 
53
 
54
  ## Uses
55
 
56
- **Intended:** research on domain-adapted QA over space-agency-style text, and as a baseline against the multi-turn adapter.
 
 
 
 
 
 
 
57
 
58
- **Out of scope:** safety-critical or engineering decisions, mission planning, or any setting where an incorrect answer could cause harm. Multi-turn dialogue is not evaluated for this adapter.
 
 
59
 
60
  ## How to get started
61
 
62
- The example loads the pinned base model and this adapter, applies the Harmony chat template, forces the assistant **final** channel, and prints only the final answer. Do not print a full `skip_special_tokens=True` decode, since it can expose analysis-channel text.
63
 
64
  ```python
65
  import torch
66
  from transformers import AutoModelForCausalLM, AutoTokenizer, Mxfp4Config
67
  from peft import PeftModel
68
 
69
- BASE = "openai/gpt-oss-20b"
70
  BASE_REVISION = "6cee5e81ee83917806bbde320786a8fb61efebee"
71
- ADAPTER = "TODO_REPO_ID"
72
 
73
- tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
74
- base = AutoModelForCausalLM.from_pretrained(
75
- BASE,
76
  revision=BASE_REVISION,
77
  torch_dtype=torch.bfloat16,
78
  quantization_config=Mxfp4Config(dequantize=True),
79
  device_map="auto",
80
  )
81
- model = PeftModel.from_pretrained(base, ADAPTER).eval()
82
 
83
- question = "What was the primary goal of the Mars Science Laboratory mission?"
84
  prompt = tokenizer.apply_chat_template(
85
  [{"role": "user", "content": question}],
86
  tokenize=False,
@@ -89,90 +98,135 @@ prompt = tokenizer.apply_chat_template(
89
  prompt += "<|channel|>final<|message|>" # force the final channel
90
 
91
  inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
92
- with torch.no_grad():
93
- out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
94
 
95
- text = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
96
- for stop in ("<|return|>", "<|end|>"):
97
- text = text.split(stop)[0]
98
- print(text.strip())
 
 
 
 
 
 
 
 
 
 
99
  ```
100
 
 
 
 
 
101
  ## Training details
102
 
103
  ### Training data
104
 
105
- Built offline in five steps:
106
 
107
  1. Space-agency text was scraped and stored as JSON.
108
- 2. The text was cleaned and split into chunks.
109
- 3. Each chunk was passed directly to a teacher model (Mistral `mistral:7b`).
110
- 4. The teacher generated single-turn question-answer pairs.
111
- 5. This adapter was trained on those pairs. (The multi-turn adapter uses three-level dialogue chains and is trained separately.)
112
 
113
- | Split | Records |
114
- |---|---|
115
  | Train | 14,395 |
116
  | Validation | 1,695 |
117
- | Test | 845 |
118
-
119
- TODO_VERIFY: confirm the counts against the JSONL files and state whether any records were filtered or skipped. Add source-record and chunk counts, agency distribution, splitting unit, duplicate handling, and provenance from `metadata.csv` and `manifest.json`.
120
 
121
- Teacher prompts ask for answers supported by the supplied chunk, but the pipeline does not verify that answers are entailed by their sources. Some answers may be unsupported or wrong. Source-text use is subject to the original publishers' terms (TODO_CONFIRM).
122
 
123
  ### Training hyperparameters
124
 
125
  | Setting | Value |
126
  |---|---|
127
- | Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj` |
128
- | LoRA rank / alpha / dropout | 16 / 32 / 0.05 |
129
- | Epochs | 3 |
130
- | Learning rate | 5e-6 |
131
- | Batch size / gradient accumulation | 1 / 16 (effective 16) |
132
- | Max sequence length | 2048 |
133
- | Loss | Final assistant-answer tokens only |
134
- | Compute dtype | BF16 (FP16 off) |
135
- | Base weights | MXFP4 dequantization requested |
136
-
137
- The `fp16` string in some output directory names is historical and does not reflect the actual training regime.
138
 
139
  ## Evaluation
140
 
141
- **Test set:** 845 single-turn records. SHA-256 of the test file: `337a80d2375a053ab7d8e9e1c5ee2ec7b975f74bfe16db13bf0d1c5a60aa91f6`.
 
 
 
 
142
 
143
- **Protocol:** same base revision and prompts for base and adapter; `final_channel` response mode with answer-only extraction; `max_new_tokens=512`; BERTScore with `roberta-large`; missing answers score zero and all valid records stay in the denominator (there were none missing).
 
 
144
 
145
  ### Results
146
 
147
- | Metric | Base | + Adapter |
148
- |---|---|---|
149
- | BERTScore F1 | 0.823306 | **0.902252** |
150
- | Token F1 | 0.140682 | **0.404100** |
151
- | Exact match | 1 / 845 | 4 / 845 |
152
- | Outputs hitting the 512-token cap | 384 | 28 |
153
 
154
- The BERTScore F1 change is an **absolute gain of 0.078946**, not a percentage improvement. It is not evidence of verified factuality or domain understanding. References are teacher-generated, and independent factuality review is pending. Part of the gain likely reflects the adapter matching the style and length of the reference answers. Single-turn and multi-turn results are reported separately and are not merged.
155
 
156
- **Reproducibility:** TODO_LINK to `evaluation_config.json`, `comparison.json`, `summary.txt`, and sample-level predictions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  ## Bias, risks, and limitations
159
 
160
- - Answers may be fluent but incorrect. There is no retrieval and no source citation.
 
 
 
 
 
 
 
 
161
  - Knowledge is fixed at training time and may be outdated.
162
- - Overlap metrics reward similarity to teacher references; low exact-match rates are expected for free-form answers.
163
  - English only.
164
- - Limitations and terms of the base model `openai/gpt-oss-20b` also apply.
165
 
166
- ## Files
167
 
168
- `adapter_model.safetensors`, `adapter_config.json`, tokenizer files, `chat_template.jinja`, `README.md`. Checksums match the archived adapter: TODO_ADD_SHA256.
169
 
170
- ## License
 
171
 
172
- TODO_CONFIRM. It must be consistent with the base model's licence, the teacher model's terms for generated outputs, and the source-text terms. Once confirmed, replace `license: other` and `license_name` in the metadata with the correct identifier.
 
 
173
 
174
- ## Citation
 
 
 
 
175
 
176
- ```bibtex
177
- TODO_BIBTEX
178
- ```
 
1
  ---
2
+ license: apache-2.0
 
3
  language:
4
  - en
5
  library_name: peft
 
24
  metrics:
25
  - type: bertscore
26
  name: BERTScore F1 (roberta-large)
27
+ value: 0.897506
28
  - type: f1
29
  name: Token F1
30
+ value: 0.371768
31
  - type: exact_match
32
  name: Exact match
33
+ value: 0.002367
34
  ---
35
 
36
  # SpaceLLM Single-Turn QA
37
 
38
+ A LoRA adapter for [`openai/gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b), fine-tuned for single-turn question answering over space-agency-derived text. This repository contains **adapter weights only**; the base model must be loaded separately.
39
 
40
+ - **Developed by:** Aditya Pratap Singh et al.
41
+ - **Model type:** PEFT LoRA adapter (`CAUSAL_LM`)
 
42
  - **Language:** English
43
+ - **Base model:** `openai/gpt-oss-20b`, revision `6cee5e81ee83917806bbde320786a8fb61efebee`
44
+ - **Companion model:** SpaceLLM Multi-Turn QA — a separate adapter trained on a different data format and evaluated on a different test set. **The two adapters' scores are not a head-to-head comparison.**
45
 
46
  > **Please note**
47
+ > - This adapter uses **no retrieval**. There is no RAG pipeline, no index, and nothing looked up at inference time.
48
+ > - LoRA targets attention projections only — `q_proj`, `k_proj`, `v_proj`, `o_proj` — **not** `lm_head`.
49
+ > - Training and evaluation references were generated by a teacher model and have **not been independently fact-checked**. Reported scores measure similarity to those references, not verified factual accuracy.
50
+ > - This is a distinct artifact from the older [`AdityaPS/SpaceLLM_v1`](https://huggingface.co/AdityaPS/SpaceLLM_v1) checkpoint, which used a different configuration (`lm_head`-only, rank 32) and different data/evaluation. If `SpaceLLM_v1` remains public, treat it as a separate, earlier experiment — its card and weights should not be conflated with this one.
51
+
52
+ ---
53
 
54
  ## Uses
55
 
56
+ **Intended:**
57
+ - Research on parameter-efficient domain adaptation for space-agency-style QA.
58
+ - Serving as a single-turn baseline in comparative dialogue/QA evaluations.
59
+
60
+ **Out of scope:**
61
+ - Mission-critical operations, spacecraft control, orbital mechanics execution, or any safety-critical or autonomous decision system.
62
+ - Any use where an unverified or incorrect answer could cause harm.
63
+ - Multi-turn dialogue (use the companion multi-turn adapter, evaluated separately, for that).
64
 
65
+ Expert verification is recommended before relying on any specific technical claim this model produces.
66
+
67
+ ---
68
 
69
  ## How to get started
70
 
71
+ The example loads the pinned base revision and this adapter, applies the Harmony chat template, forces the assistant **final** channel, and extracts only that channel's text — the same approach used in evaluation. Relying on `skip_special_tokens=True` alone is avoided because it can mix analysis-channel and final-channel text.
72
 
73
  ```python
74
  import torch
75
  from transformers import AutoModelForCausalLM, AutoTokenizer, Mxfp4Config
76
  from peft import PeftModel
77
 
78
+ BASE_MODEL = "openai/gpt-oss-20b"
79
  BASE_REVISION = "6cee5e81ee83917806bbde320786a8fb61efebee"
80
+ ADAPTER_REPO = "AdityaPS/SpaceLLM-SingleTurn"
81
 
82
+ tokenizer = AutoTokenizer.from_pretrained(ADAPTER_REPO)
83
+ base_model = AutoModelForCausalLM.from_pretrained(
84
+ BASE_MODEL,
85
  revision=BASE_REVISION,
86
  torch_dtype=torch.bfloat16,
87
  quantization_config=Mxfp4Config(dequantize=True),
88
  device_map="auto",
89
  )
90
+ model = PeftModel.from_pretrained(base_model, ADAPTER_REPO).eval()
91
 
92
+ question = "What was the primary objective of the Mars Science Laboratory mission?"
93
  prompt = tokenizer.apply_chat_template(
94
  [{"role": "user", "content": question}],
95
  tokenize=False,
 
98
  prompt += "<|channel|>final<|message|>" # force the final channel
99
 
100
  inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
 
 
101
 
102
+ with torch.no_grad():
103
+ outputs = model.generate(
104
+ **inputs,
105
+ max_new_tokens=512, # inference-example setting; evaluation used 2048 (see below)
106
+ do_sample=False,
107
+ repetition_penalty=1.05,
108
+ no_repeat_ngram_size=6,
109
+ )
110
+
111
+ generation = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
112
+ for stop_token in ("<|return|>", "<|end|>"):
113
+ generation = generation.split(stop_token)[0]
114
+
115
+ print("Answer:", generation.strip())
116
  ```
117
 
118
+ *Note: this example uses `max_new_tokens=512` for a quick, practical demo. This differs from the 2,048-token limit used during evaluation (see [Evaluation](#evaluation)) — treat this as an inference-example setting, not the evaluated protocol.*
119
+
120
+ ---
121
+
122
  ## Training details
123
 
124
  ### Training data
125
 
126
+ Data was built offline, with no retrieval stage used anywhere in training or inference:
127
 
128
  1. Space-agency text was scraped and stored as JSON.
129
+ 2. Text was normalized and split into chunks.
130
+ 3. Each chunk was passed directly to an Ollama `mistral:7b` teacher model.
131
+ 4. The teacher was prompted to generate **five standalone single-turn question–answer pairs per chunk**, with answers requested to be grounded in the supplied chunk.
132
+ 5. The generation pipeline did **not** independently verify that answers were entailed by their source chunk — some answers may be unsupported or incorrect.
133
 
134
+ | Split | Usable examples |
135
+ |---|---:|
136
  | Train | 14,395 |
137
  | Validation | 1,695 |
138
+ | Test (evaluated) | 845 |
 
 
139
 
140
+ **These are the only counts supported for this artifact.** A previously circulated figure of "3,428 documents / 16,831 training samples" does not match this adapter's training/evaluation split counts or file hashes and should not be cited for this repository.
141
 
142
  ### Training hyperparameters
143
 
144
  | Setting | Value |
145
  |---|---|
146
+ | LoRA target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj` |
147
+ | LoRA rank ($r$) / alpha ($\alpha$) | 16 / 32 |
148
+ | LoRA dropout | 0.05 |
149
+ | Task type | `CAUSAL_LM` |
150
+ | Max sequence length | 2,048 tokens |
151
+ | Base weights | MXFP4, dequantized at load time |
152
+ | Compute precision | BF16 |
153
+
154
+ The base model is the published MXFP4 `gpt-oss-20b` checkpoint, loaded with MXFP4 dequantization and run in BF16 compute — this is a loading/compute configuration, not a separately distributed "BF16 version" of the model.
155
+
156
+ ---
157
 
158
  ## Evaluation
159
 
160
+ **Test set:** 845 single-turn records.
161
+ **Test file SHA-256:** `337a80d2375a053ab7d8e9e1c5ee2ec7b975f74bfe16db13bf0d1c5a60aa91f6`
162
+ **Adapter config SHA-256:** `ef641c55f5f961a86be20f364b39b80f7777053959caff1523b2348f00432748`
163
+
164
+ **Protocol:** Base and adapter used identical tokenized prompts. All 845 records produced a final answer; none were skipped. Generation was deterministic (`do_sample=False`) with `max_seq_len=2048`, `max_new_tokens=2048`, `repetition_penalty=1.05`, and `no_repeat_ngram_size=6`, applied to both base and adapter. Only text from the Harmony `final` channel was scored; analysis-channel text was excluded.
165
 
166
+ **Metrics:** BERTScore computed with `roberta-large`; token F1 computed on lowercased whitespace tokens; exact match computed after stripping surrounding whitespace. A missing answer would score zero on all metrics while remaining in the denominator — no answers were missing for this test set.
167
+
168
+ References were produced by the same teacher-based generation process used for training data and have not received independent factuality verification.
169
 
170
  ### Results
171
 
172
+ | Model | BERTScore P | BERTScore R | BERTScore F1 | Token F1 | Exact match | Hit 2,048-token cap |
173
+ |---|---:|---:|---:|---:|---:|---:|
174
+ | Base (`gpt-oss-20b`) | 0.781081 | 0.869184 | 0.822320 | 0.122433 | 0 / 845 | 3 / 845 |
175
+ | + SpaceLLM Single-Turn Adapter | 0.905112 | 0.890707 | 0.897506 | 0.371768 | 2 / 845 | 1 / 845 |
176
+
177
+ **BERTScore F1 change: an absolute gain of 0.075186.** This is not a "6% improvement," and it is not evidence of improved factual accuracy or domain understanding — it reflects greater semantic/stylistic similarity to teacher-generated references under this specific protocol.
178
 
179
+ ### Reading the weaker metrics honestly
180
 
181
+ - **Exact match is very low (2/845, ≈0.24%) for both models**, which is expected for free-form generative QA — a correct answer rarely matches a reference string verbatim in wording, order, or length. This metric is reported for completeness, not as a proxy for correctness rate.
182
+ - **Token F1 (0.372) is modest in absolute terms**, even though it nearly tripled over the base model's 0.122. Token overlap penalizes any answer that is phrased differently from the reference, including answers that may be factually equivalent. Treat the *relative* change as a signal of closer stylistic alignment, not the *absolute* value as an accuracy score.
183
+ - **BERTScore is the most informative similarity signal here, but it has the same ceiling as its references**: since references are teacher-generated and unverified, a higher BERTScore partly reflects the adapter reproducing the teacher's phrasing habits — including any errors or unsupported claims the teacher made — rather than confirmed improvement in factual correctness.
184
+
185
+ ---
186
+
187
+ ## Generation stability
188
+
189
+ An earlier unguarded diagnostic run at the same 2,048-token maximum, without repetition controls, produced outputs that fell into **exact phrase loops**. The final evaluation protocol added `repetition_penalty=1.05` and 6-token n-gram blocking (`no_repeat_ngram_size=6`) to **both** base and adapter generations to address this.
190
+
191
+ | Model | Unguarded diagnostic (cap events) | Guarded final run (cap events) | Reduction |
192
+ |---|---:|---:|---:|
193
+ | Base | 35 | 3 | 91.4% |
194
+ | Adapter | 28 | 1 | 96.4% |
195
+
196
+ This is reported as an **engineering diagnostic, not a controlled ablation**: prompt hashes changed across rebuilt evaluation images between the unguarded and guarded runs, so the reduction cannot be attributed to the decoding settings alone. Additionally, the guarded settings removed the conspicuous exact-repetition loops but did **not** eliminate semantic degeneration generally — a small number of guarded outputs still reached the token cap while producing drifting numerical lists or otherwise unrelated text.
197
+
198
+ ---
199
 
200
  ## Bias, risks, and limitations
201
 
202
+ - **The supported conclusion is narrow:** these results show improved similarity to synthetic, teacher-generated references under this specific evaluation protocol. They do not establish improved factual accuracy, reasoning ability, or general domain understanding.
203
+ - **Exact match (2/845) and token F1 (0.372) are low in absolute terms.** This is a known property of free-form generative QA evaluated against a single reference string, not necessarily a sign the model is "wrong" most of the time — but it also means these numbers cannot be read as an accuracy rate.
204
+ - **No independent factuality check exists.** References were generated by the same `mistral:7b` teacher process used for training data; higher similarity scores may partly reflect the adapter learning to imitate the teacher's style, length, and any of its errors, rather than confirmed improvements in correctness.
205
+ - **The exact training/evaluation data snapshot has not yet been recovered and published**; the dataset manifest, source-agency distribution, and dedup/filtering details are pending.
206
+ - **This adapter has not been validated for operational, mission-critical, or safety-critical use of any kind**, including spacecraft control, mission planning, or autonomous decision-making.
207
+ - There is no retrieval and no source citation — answers cannot be traced back to a specific source document by the model itself.
208
+ - `no_repeat_ngram_size=6` can suppress legitimate repeated technical phrases (e.g., a mission name or unit repeated for clarity), which may slightly affect fluency on some answers.
209
+ - Generation stability numbers above are diagnostic, not a controlled ablation (see [Generation stability](#generation-stability)).
210
+ - Single-turn and multi-turn adapters were trained on different formats and evaluated on different test files; **do not compare their scores directly**.
211
  - Knowledge is fixed at training time and may be outdated.
 
212
  - English only.
213
+ - General limitations and terms of the base model `openai/gpt-oss-20b` also apply.
214
 
215
+ ---
216
 
217
+ ## Reproducibility artifacts
218
 
219
+ - **Test set SHA-256:** `337a80d2375a053ab7d8e9e1c5ee2ec7b975f74bfe16db13bf0d1c5a60aa91f6`
220
+ - **Adapter config SHA-256:** `ef641c55f5f961a86be20f364b39b80f7777053959caff1523b2348f00432748`
221
 
222
+ ---
223
+
224
+ ## Files
225
 
226
+ `adapter_model.safetensors`, `adapter_config.json`, tokenizer files, `chat_template.jinja`, `README.md`.
227
+
228
+ ---
229
+
230
+ ## License
231
 
232
+ Apache-2.0, matching the base model (`openai/gpt-oss-20b`). Note: this covers the adapter weights and code; it does not by itself establish licensing terms for the scraped source text or the teacher-generated training data used to produce this adapter.