AbstractPhil commited on
Commit
2ebd035
·
verified ·
1 Parent(s): 2c1931d
amoe/sts/README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags: [amoe, adapter, sentence-similarity, captionbert, aleph]
4
+ base_model: AbstractPhil/captionbert-8192-v2
5
+ library_name: amoe-lora
6
+ ---
7
+
8
+ # captionbert-8192-v2 :: AMOE sentence-similarity anchor
9
+
10
+ An [amoe-lora](https://github.com/AbstractEyes/amoe-lora) aleph anchor trained on
11
+ the **frozen** `captionbert-8192-v2` trunk. The trunk never moves; only the
12
+ adapters train.
13
+
14
+ **This anchor is inert without its trunk.** It rewrites the residual stream of
15
+ specific blocks of this model and means nothing anywhere else, which is why it
16
+ ships here rather than as a standalone adapter repo.
17
+
18
+ ## Why it exists
19
+
20
+ The trunk is an unsupervised consensus distillation of five BERT-family teachers.
21
+ Measured at release: the consensus target uses **28.7 of 768** directions, the
22
+ trunk uses **102.9 in domain** but only **~33 on STS-B**, so the extra structure
23
+ it built on CC12M captions does not transfer. This anchor asks whether
24
+ supervision can add transferable directions the unsupervised consensus never had.
25
+ The gauge is the **effective-rank delta with anchors ON vs OFF**, not the
26
+ similarity score alone.
27
+
28
+ ## Toggle law
29
+
30
+ All anchors disabled == the base trunk, bit-exact in fp32 (asserted at train
31
+ time, not assumed). One artifact, both models:
32
+
33
+ ```python
34
+ import amoe, torch
35
+ # trunk: see the parent repo for CaptionEncoder
36
+ h = amoe.attach(trunk, "amoe/sts/captionbert-v2-sts-anchor.anchor.pt", binding=CaptionEncoderBinding(d=512))
37
+ emb_supervised = trunk(input_ids, attention_mask)
38
+ with h.only(): # or set enabled=False on the wrapped blocks
39
+ emb_unsupervised = trunk(input_ids, attention_mask)
40
+ base = h.detach() # bit-exact or raises
41
+ ```
42
+
43
+ The `.pt` anchor layout is `{block}.{param}` (the `blocks.{site}.{param}`
44
+ form in the amoe README is the *safetensors* layout — a different serializer).
45
+
46
+ ## Results
47
+
48
+ See `metrics.json` in this folder. Report STS-B / SICK-R spearman with anchors
49
+ ON and OFF, plus effective rank for each. SICK-R is never trained on and is the
50
+ honest transfer read.
51
+
52
+ ## Training
53
+
54
+ Frozen trunk, adapters only. MultipleNegativesRankingLoss on
55
+ `sentence-transformers/all-nli` triplets with in-batch + hard negatives.
56
+ Pure Adam wd=0 (`amoe.laws.make_optimizer`), fp32 / TF32 off
57
+ (`amoe.laws.pin_precision`). Config in `config.json`.
amoe/sts/captionbert-v2-sts-anchor.anchor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:886fcd0f593098a01209cb13a1ab6148d29df1c285d288a5123f3fed0701233e
3
+ size 6608605
amoe/sts/config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "run_name": "captionbert-v2-sts-anchor",
3
+ "trunk_repo": "AbstractPhil/captionbert-8192-v2",
4
+ "trunk_ckpt": "checkpoints/best_model.pt",
5
+ "tokenizer": "google-bert/bert-base-uncased",
6
+ "d_model": 512,
7
+ "n_heads": 8,
8
+ "n_layers": 12,
9
+ "d_ff": 2048,
10
+ "max_len": 8192,
11
+ "output_dim": 768,
12
+ "pooling": "mean",
13
+ "sites": "all",
14
+ "n_slots": 16,
15
+ "K": 64,
16
+ "D": 4,
17
+ "tau": 0.1,
18
+ "hidden": 178,
19
+ "gate_init": -3.0,
20
+ "data_repo": "sentence-transformers/all-nli",
21
+ "data_config": "triplet",
22
+ "n_train": 200000,
23
+ "max_tokens": 64,
24
+ "batch_size": 256,
25
+ "temperature": 0.05,
26
+ "use_hard_negatives": true,
27
+ "steps": 4000,
28
+ "lr": 0.001,
29
+ "warmup": 200,
30
+ "grad_clip": 1.0,
31
+ "seed": 0,
32
+ "log_every": 100,
33
+ "eval_every": 500,
34
+ "out_dir": "/content/amoe_sts",
35
+ "hf_repo": "AbstractPhil/captionbert-8192-v2",
36
+ "hf_path": "amoe/sts",
37
+ "hf_private": false,
38
+ "hf_push": true
39
+ }
amoe/sts/metrics.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "baseline": {
3
+ "STS-B": {
4
+ "spearman": 0.574721280584061,
5
+ "self_cos": 0.13962045311927795,
6
+ "erank": 36.611595622425114
7
+ },
8
+ "SICK-R": {
9
+ "spearman": 0.652602297708298,
10
+ "self_cos": 0.32337328791618347,
11
+ "erank": 39.12520123844512
12
+ }
13
+ },
14
+ "history": [
15
+ {
16
+ "step": 500,
17
+ "STS-B_OFF": 0.574721280584061,
18
+ "STS-B_ON": 0.7159579493702058,
19
+ "SICK-R_OFF": 0.652602297708298,
20
+ "SICK-R_ON": 0.7435196218188278
21
+ }
22
+ ],
23
+ "step": 500,
24
+ "config": {
25
+ "run_name": "captionbert-v2-sts-anchor",
26
+ "trunk_repo": "AbstractPhil/captionbert-8192-v2",
27
+ "trunk_ckpt": "checkpoints/best_model.pt",
28
+ "tokenizer": "google-bert/bert-base-uncased",
29
+ "d_model": 512,
30
+ "n_heads": 8,
31
+ "n_layers": 12,
32
+ "d_ff": 2048,
33
+ "max_len": 8192,
34
+ "output_dim": 768,
35
+ "pooling": "mean",
36
+ "sites": "all",
37
+ "n_slots": 16,
38
+ "K": 64,
39
+ "D": 4,
40
+ "tau": 0.1,
41
+ "hidden": 178,
42
+ "gate_init": -3.0,
43
+ "data_repo": "sentence-transformers/all-nli",
44
+ "data_config": "triplet",
45
+ "n_train": 200000,
46
+ "max_tokens": 64,
47
+ "batch_size": 256,
48
+ "temperature": 0.05,
49
+ "use_hard_negatives": true,
50
+ "steps": 4000,
51
+ "lr": 0.001,
52
+ "warmup": 200,
53
+ "grad_clip": 1.0,
54
+ "seed": 0,
55
+ "log_every": 100,
56
+ "eval_every": 500,
57
+ "out_dir": "/content/amoe_sts",
58
+ "hf_repo": "AbstractPhil/captionbert-8192-v2",
59
+ "hf_path": "amoe/sts",
60
+ "hf_private": false,
61
+ "hf_push": true
62
+ }
63
+ }