sergiogmn commited on
Commit
b16b943
·
verified ·
1 Parent(s): 0633684

Add Cyber LoRA adapter (epoch 2, r=16, alpha=32) with splice metadata

Browse files
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: thinkingmachines/Inkling-2-Mini
4
+ base_model_relation: adapter
5
+ library_name: peft
6
+ tags:
7
+ - lora
8
+ - peft
9
+ - inkling2
10
+ - inkling-2-mini
11
+ - cybersecurity
12
+ ---
13
+
14
+ # Inkling-2-Mini-Cyber-LoRA
15
+
16
+ The PEFT LoRA adapter behind [sergiogmn/Inkling-2-Mini-Cyber-GGUF](https://huggingface.co/sergiogmn/Inkling-2-Mini-Cyber-GGUF). It touches only `self_attn.o_proj` on layers 4–23 of [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini). Use it to merge the Cyber edit into the full-precision base, for example before a QLoRA fine-tune of your own.
17
+
18
+ The same files are in the `adapter/` folder of the GGUF repo. This repo adds the splice metadata.
19
+
20
+ ## Provenance
21
+
22
+ | | |
23
+ |---|---|
24
+ | Base model | `thinkingmachines/Inkling-2-Mini` @ `c9d028302cd0f035fdf8e7e91f089a4ce94d2195` |
25
+ | Base weights SHA-256 | `65e60f51aa1284d4fb022584908c315270334d991828bb774af60584523539d1` (unchanged since the first upload) |
26
+ | `adapter_model.safetensors` SHA-256 | `537fa0d986d132544fbe3444d5a97b7f93ae29d60204872b1d73669b0122bce7` |
27
+ | Checkpoint | epoch 2 of 2, 140 steps (`train_manifest.json`) |
28
+ | LoRA | `r=16`, `lora_alpha=32`, no rsLoRA, no DoRA, 40 F32 tensors, 1,720,320 params |
29
+ | Targets | `model.language_model.layers.{4..23}.self_attn.o_proj.linear` |
30
+
31
+ Tensor keys follow the transformers `inkling2_loop` module names:
32
+
33
+ ```
34
+ base_model.model.model.language_model.layers.{4..23}.self_attn.o_proj.linear.lora_A.weight [16, 3072]
35
+ base_model.model.model.language_model.layers.{4..23}.self_attn.o_proj.linear.lora_B.weight [2304, 16]
36
+ ```
37
+
38
+ In the raw checkpoint these modules are `model.llm.layers.N.attn.wo_ud.weight` (BF16, `[2304, 3072]`). In GGUF they are `blk.N.attn_output.weight`.
39
+
40
+ ## Scale: the GGUF is not a plain PEFT merge
41
+
42
+ The GGUF was spliced with `apply_lora_gguf.py --scale 1.55`, which computes
43
+
44
+ ```
45
+ W' = W + 1.55 * (lora_alpha / r) * (B @ A) = W + 3.1 * (B @ A)
46
+ ```
47
+
48
+ Standard PEFT scaling is `lora_alpha / r = 2.0`. A plain `merge_and_unload()` therefore gives the weaker scale-1.0 model from the sweep in the GGUF card (79/104 AdvBench compliance instead of 99/104). To match the released GGUF, set the scale to 1.55 before merging:
49
+
50
+ ```python
51
+ import torch
52
+ from transformers import AutoModelForMultimodalLM
53
+ from peft import PeftModel
54
+ from peft.tuners.lora import LoraLayer
55
+
56
+ base = AutoModelForMultimodalLM.from_pretrained(
57
+ "thinkingmachines/Inkling-2-Mini",
58
+ revision="c9d028302cd0f035fdf8e7e91f089a4ce94d2195",
59
+ dtype=torch.bfloat16,
60
+ )
61
+ model = PeftModel.from_pretrained(base, "sergiogmn/Inkling-2-Mini-Cyber-LoRA")
62
+ for m in model.modules():
63
+ if isinstance(m, LoraLayer):
64
+ m.set_scale("default", 1.55) # scaling = 1.55 * 32/16 = 3.1
65
+ merged = model.merge_and_unload()
66
+ merged.save_pretrained("Inkling-2-Mini-Cyber-merged")
67
+ ```
68
+
69
+ Loading needs a transformers release with `inkling2_loop` support. The adapter was trained with transformers 5.24 and PEFT 0.22.
70
+
71
+ ## Verification
72
+
73
+ - Injecting the adapter into the base model with PEFT 0.22 (transformers 5.24) gives 40 LoRA parameters, all with weights, 0 unexpected keys and matching shapes.
74
+ - Splice check: dequantizing stock `ggml-org/Inkling-2-Mini-GGUF` IQ4_NL `blk.{4,10,23}.attn_output.weight`, applying this adapter at scale 1.55 and re-quantizing to Q8_0 gives tensors byte-identical to `Inkling-2-Mini-Cyber-IQ4_NL.gguf` (GGUF repo revision `7e46c354`). Scales 1.0 and 1.65, and the epoch-1 checkpoint, do not match.
75
+
76
+ `splice_metadata.json` has the same facts in machine-readable form.
77
+
78
+ ## License
79
+
80
+ Apache-2.0, same as the base model. The model has reduced refusals on offensive-security prompts. See the GGUF card for its intended use and benchmarks.
adapter_config.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "astra_config": null,
6
+ "auto_mapping": {
7
+ "base_model_class": "Inkling2LoopForConditionalGeneration",
8
+ "parent_library": "transformers.models.inkling2_loop.modeling_inkling2_loop"
9
+ },
10
+ "base_model_name_or_path": "thinkingmachines/Inkling-2-Mini",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "kasa_config": null,
20
+ "layer_replication": null,
21
+ "layers_pattern": null,
22
+ "layers_to_transform": null,
23
+ "loftq_config": {},
24
+ "lora_alpha": 32,
25
+ "lora_bias": false,
26
+ "lora_dropout": 0.05,
27
+ "lora_ga_config": null,
28
+ "megatron_config": null,
29
+ "megatron_core": "megatron.core",
30
+ "modules_to_save": null,
31
+ "monteclora_config": null,
32
+ "peft_type": "LORA",
33
+ "peft_version": "0.22.0",
34
+ "qalora_group_size": 16,
35
+ "r": 16,
36
+ "rank_pattern": {},
37
+ "revision": null,
38
+ "target_modules": [
39
+ "model.language_model.layers.14.self_attn.o_proj.linear",
40
+ "model.language_model.layers.20.self_attn.o_proj.linear",
41
+ "model.language_model.layers.15.self_attn.o_proj.linear",
42
+ "model.language_model.layers.8.self_attn.o_proj.linear",
43
+ "model.language_model.layers.11.self_attn.o_proj.linear",
44
+ "model.language_model.layers.9.self_attn.o_proj.linear",
45
+ "model.language_model.layers.6.self_attn.o_proj.linear",
46
+ "model.language_model.layers.13.self_attn.o_proj.linear",
47
+ "model.language_model.layers.23.self_attn.o_proj.linear",
48
+ "model.language_model.layers.17.self_attn.o_proj.linear",
49
+ "model.language_model.layers.10.self_attn.o_proj.linear",
50
+ "model.language_model.layers.22.self_attn.o_proj.linear",
51
+ "model.language_model.layers.18.self_attn.o_proj.linear",
52
+ "model.language_model.layers.12.self_attn.o_proj.linear",
53
+ "model.language_model.layers.21.self_attn.o_proj.linear",
54
+ "model.language_model.layers.4.self_attn.o_proj.linear",
55
+ "model.language_model.layers.19.self_attn.o_proj.linear",
56
+ "model.language_model.layers.5.self_attn.o_proj.linear",
57
+ "model.language_model.layers.7.self_attn.o_proj.linear",
58
+ "model.language_model.layers.16.self_attn.o_proj.linear"
59
+ ],
60
+ "target_parameters": null,
61
+ "task_type": null,
62
+ "trainable_token_indices": null,
63
+ "use_bdlora": null,
64
+ "use_dora": false,
65
+ "use_qalora": false,
66
+ "use_rslora": false,
67
+ "velora_config": null
68
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:537fa0d986d132544fbe3444d5a97b7f93ae29d60204872b1d73669b0122bce7
3
+ size 6887496
splice_metadata.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "thinkingmachines/Inkling-2-Mini",
3
+ "base_model_revision": "c9d028302cd0f035fdf8e7e91f089a4ce94d2195",
4
+ "base_model_weights_sha256": "65e60f51aa1284d4fb022584908c315270334d991828bb774af60584523539d1",
5
+ "base_model_weights_note": "model-00001-of-00001.safetensors is byte-identical in every revision from 1fb4134 (first upload) to c9d0283; the self_attn.o_proj (checkpoint name attn.wo_ud) weights are BF16 [2304, 3072]",
6
+ "adapter_file": "adapter_model.safetensors",
7
+ "adapter_sha256": "537fa0d986d132544fbe3444d5a97b7f93ae29d60204872b1d73669b0122bce7",
8
+ "adapter_dtype": "F32",
9
+ "adapter_tensors": 40,
10
+ "adapter_params": 1720320,
11
+ "checkpoint": "epoch 2 of 2 (140 optimizer steps)",
12
+ "peft_type": "LORA",
13
+ "r": 16,
14
+ "lora_alpha": 32,
15
+ "use_rslora": false,
16
+ "use_dora": false,
17
+ "peft_scaling": 2.0,
18
+ "layers": "4-23",
19
+ "peft_target_modules": "model.language_model.layers.{4..23}.self_attn.o_proj.linear",
20
+ "checkpoint_tensor_names": "model.llm.layers.{4..23}.attn.wo_ud.weight",
21
+ "gguf_tensor_names": "blk.{4..23}.attn_output.weight",
22
+ "gguf_splice": {
23
+ "tool": "tools/ik2_ablate/apply_lora_gguf.py (GodGMN/tintero)",
24
+ "command": "apply_lora_gguf.py <stock.gguf> <adapter_dir> <out> --scale 1.55 --full",
25
+ "scale_flag": 1.55,
26
+ "formula": "W' = W + scale * (lora_alpha / r) * (B @ A)",
27
+ "effective_multiplier_on_BA": 3.1,
28
+ "is_standard_peft_scaling": false,
29
+ "note": "The GGUF uses 1.55x the standard PEFT scaling (alpha/r = 2.0), so the total multiplier on B@A is 3.1. A plain PEFT merge_and_unload applies 2.0 and reproduces the scale-1.0 row of the sweep, not the released model.",
30
+ "requantized_as": "Q8_0 in all three released GGUFs",
31
+ "verification": "Dequantized stock ggml-org IQ4_NL blk.{4,10,23}.attn_output.weight, applied this adapter at scale 1.55, re-quantized to Q8_0: byte-identical to sergiogmn/Inkling-2-Mini-Cyber-GGUF@7e46c354 Inkling-2-Mini-Cyber-IQ4_NL.gguf. Scales 1.0/1.65 and the epoch-1 adapter do not match."
32
+ },
33
+ "released_gguf_repo": "sergiogmn/Inkling-2-Mini-Cyber-GGUF",
34
+ "released_gguf_revision": "7e46c354db5cc7feaa70b7a5d61e9e873e893968"
35
+ }
train_manifest.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "thinkingmachines/Inkling-2-Mini",
3
+ "data_file": "teacher_sft.jsonl",
4
+ "n_samples": 555,
5
+ "layers": "4-23",
6
+ "targets": "wo_ud",
7
+ "exact_targets": [
8
+ "model.language_model.layers.10.self_attn.o_proj.linear",
9
+ "model.language_model.layers.11.self_attn.o_proj.linear",
10
+ "model.language_model.layers.12.self_attn.o_proj.linear",
11
+ "model.language_model.layers.13.self_attn.o_proj.linear",
12
+ "model.language_model.layers.14.self_attn.o_proj.linear",
13
+ "model.language_model.layers.15.self_attn.o_proj.linear",
14
+ "model.language_model.layers.16.self_attn.o_proj.linear",
15
+ "model.language_model.layers.17.self_attn.o_proj.linear",
16
+ "model.language_model.layers.18.self_attn.o_proj.linear",
17
+ "model.language_model.layers.19.self_attn.o_proj.linear",
18
+ "model.language_model.layers.20.self_attn.o_proj.linear",
19
+ "model.language_model.layers.21.self_attn.o_proj.linear",
20
+ "model.language_model.layers.22.self_attn.o_proj.linear",
21
+ "model.language_model.layers.23.self_attn.o_proj.linear",
22
+ "model.language_model.layers.4.self_attn.o_proj.linear",
23
+ "model.language_model.layers.5.self_attn.o_proj.linear",
24
+ "model.language_model.layers.6.self_attn.o_proj.linear",
25
+ "model.language_model.layers.7.self_attn.o_proj.linear",
26
+ "model.language_model.layers.8.self_attn.o_proj.linear",
27
+ "model.language_model.layers.9.self_attn.o_proj.linear"
28
+ ],
29
+ "rank": 16,
30
+ "alpha": 32,
31
+ "lr": 0.00015,
32
+ "epochs": 2.0,
33
+ "total_steps": 140,
34
+ "elapsed_s": 2967.4
35
+ }