davidhouseholter commited on
Commit
dddff86
·
verified ·
1 Parent(s): 23e04b5

Add GRT Whitepaper links, GNU Free-as-in-Freedom statement, and matterwave.ai citation

Browse files
Files changed (1) hide show
  1. README.md +173 -135
README.md CHANGED
@@ -1,135 +1,173 @@
1
- ---
2
- license: apache-2.0
3
- tags:
4
- - grt
5
- - geometric-rotation-transformer
6
- - sentence-transformers
7
- - feature-extraction
8
- - sentence-similarity
9
- - circular-pooling
10
- - rotational
11
- - qwen3
12
- datasets:
13
- - sentence-transformers/all-nli
14
- - sentence-transformers/stsb
15
- language:
16
- - en
17
- library_name: sentence-transformers
18
- pipeline_tag: sentence-similarity
19
- base_model: MatterWaveAI/grt-30m
20
- ---
21
-
22
- # GRT-30M-Embedding (Circular-Pooled Rotational Sentence Encoder)
23
-
24
- An **embedding-only Geometric Rotation Transformer (`GRTModel`)** contrastively fine-tuned from [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) for semantic textual similarity and dense retrieval using **planar-pair `circular` pooling** (`sentence-transformers`).
25
-
26
- Instead of dense linear projections (`nn.Linear`), GRT represents token embeddings in polar coordinates (`phase_angles` + `log_magnitude`) and transforms hidden states through cascades of content-modulated `2×2` Givens rotations on `SO(D)` interleaved with butterfly permutations. Because every hidden state is structured as `D / 2 = 128` planar `(x, y)` coordinate pairs, **`circular` pooling** decomposes each pair into its unit direction `(cos θ, sin θ)` and radius `r`, averages the unit directions and radii across non-padding tokens, and recombines them into a `256`-dimensional sentence embedding.
27
-
28
- ---
29
-
30
- ## Model Details
31
-
32
- | Property | Value |
33
- |---|---|
34
- | **Architecture** | `GRTModel` (`model_type: "grt"`, encoder/backbone without causal LM head) |
35
- | **Base model** | [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) |
36
- | **Pooling strategy** | `circular` (`Pooling(embedding_dimension=256, pooling_mode="circular")` + `Normalize`) |
37
- | **Output dimensionality** | `256` (`128` planar `(x, y)` pairs, L2-normalized) |
38
- | **Total stored parameters** | `29,305,497` (`29.31M`, `lm_head.output_scale` stripped) |
39
- | **Non-embedding backbone parameters** | `9,740,197` (`9.74M` across 12 rotational blocks) |
40
- | **`hidden_size` (`d_model`)** | `256` |
41
- | **`num_hidden_layers` (`n_blocks`)** | `12` |
42
- | **`num_attention_heads` (`n_heads`)** | `4` (`head_dim = 64`) |
43
- | **`intermediate_size` (`d_ff`)** | `1,024` |
44
- | **`n_qkv_rotations` / `n_mixer_rotations` / `ffn_n_rotations`** | `11` / `1` / `21` |
45
- | **Vocabulary** | `151,669` (Qwen 3 BPE) |
46
- | **Max sequence length** | `512` (supports up to `2,048` positions) |
47
-
48
- ---
49
-
50
- ## Two-Stage Contrastive Fine-Tuning Method (Intel Arc XPU)
51
-
52
- Starting from the pretrained [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) causal checkpoint (`lm_head.output_scale` stripped to form a headless `GRTModel` encoder), the `151,669` lexical `embedding.phase_angles` (`19.41M` parameters) were frozen to preserve the pretrained Qwen 3 polar token geometry while training the **`9,740,196` rotational backbone parameters + `151,669` token `log_magnitude` weights (`9,891,865` trainable parameters)** in `FP32` on an **Intel Arc 140T GPU (`xpu:0`, 32 GB)** using fused oneAPI DPC++ SYCL Givens and Clifford kernels (`~75s` total wall-clock time):
53
-
54
- | Stage | Dataset & Budget | Objective & Hyperparameters |
55
- |---|---|---|
56
- | **Parameter Freezing** | `embedding.phase_angles` frozen (`19.41M` params) | `9,891,865` trainable parameters (`12` rotational blocks + `embedding.log_magnitude`); max grad norm `1.0` |
57
- | **Stage 1: AllNLI Contrastive Alignment** | `sentence-transformers/all-nli` (`triplet` split) · `150 steps` (`4,800` triplets, `<1%` of corpus) | In-batch `MultipleNegativesRankingLoss` + explicit hard negatives (`τ = 0.05`), `batch_size = 32`, `max_length = 96`, `PairAdam(lr=1.5e-4, coupling_lr_mult=3.0, max_angular_step=0.05)` |
58
- | **Stage 2: STS-B Rank & Metric Calibration** | `sentence-transformers/stsb` (`train` split, `5,749` pairs) · `2 epochs` (`358 steps`) | `CoSENT` rank-consistency loss (`τ = 20.0`) + `2.0 × CosineMSE`, `batch_size = 32`, `max_length = 128`, `PairAdam(lr=8e-5, coupling_lr_mult=3.0, max_angular_step=0.05)` |
59
-
60
- ---
61
-
62
- ## Evaluation Results (STS-B)
63
-
64
- Evaluated on the **STS Benchmark (`sentence-transformers/stsb`)** validation and test splits using `circular` pooling and cosine similarity:
65
-
66
- | Split | Metric | `GRT-30M` (Pretrained Base) | `GRT-30M-Embedding` (`PairAdam`) | `AdamW` Ablation¹ | Delta (`PairAdam` vs. Base) |
67
- |---|---|---:|---:|---:|---:|
68
- | **STS-B Validation** | **Spearman (`×100`)** | `45.51` | **`71.79`** | `72.89` | **`+26.28`** |
69
- | **STS-B Test** | **Spearman (`×100`)** | `28.49` | **`62.42`** | `63.17` | **`+33.93`** |
70
- | **STS-B Test** | **Pearson (`×100`)** | `29.81` | **`63.30`** | `63.72` | **`+33.49`** |
71
-
72
- > ¹ *Optimizer comparison note:* The published checkpoint is trained with `PairAdam` (zero weight decay and `[-π, π]` wrapping on rotation angles, `max_angular_step = 0.05`, and rank-1 factored second moments with a `3×` learning-rate multiplier on `Cl(2,0)` coupling tensors) for consistency with `GRT-30M` pretraining. In a head-to-head run on the identical `508`-step schedule and random seed (`42`), standard `AdamW` (`1×` coupling LR, full diagonal second moments) reaches `72.89` Val / `63.17` Test Spearman (`+1.10` / `+0.75` points), indicating that while `PairAdam`'s factored moments and `3×` coupling LR multiplier stabilize large-batch (`524k` tok/step) pretraining from scratch, standard diagonal moments at `1×` coupling LR are slightly gentler during short, small-batch (`B = 32`) downstream fine-tuning.
73
-
74
- ---
75
-
76
- ## Usage
77
-
78
- ### 1. `sentence-transformers` (Recommended)
79
-
80
- ```python
81
- from sentence_transformers import SentenceTransformer
82
-
83
- model = SentenceTransformer("MatterWaveAI/grt-30m-embedding")
84
-
85
- sentences = [
86
- "Plants convert sunlight into chemical energy through photosynthesis.",
87
- "Chlorophyll absorbs light energy to synthesize glucose in plant leaves.",
88
- "The stock market experienced volatility during the afternoon session.",
89
- ]
90
-
91
- embeddings = model.encode(sentences)
92
- similarities = model.similarity(embeddings, embeddings)
93
- print(similarities)
94
- ```
95
-
96
- ### 2. Hugging Face `transformers` (`GRTModel` + Circular Pooling)
97
-
98
- ```python
99
- import torch
100
- import torch.nn.functional as F
101
- from transformers import AutoModel, AutoTokenizer
102
-
103
- model_id = "MatterWaveAI/grt-30m-embedding"
104
- tokenizer = AutoTokenizer.from_pretrained(model_id)
105
- model = AutoModel.from_pretrained(model_id).eval()
106
-
107
-
108
- def circular_pool(token_embeddings: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
109
- pairs = token_embeddings.float().unflatten(-1, (-1, 2))
110
- mask = attention_mask.float().unsqueeze(-1).unsqueeze(-1)
111
- radii = pairs.norm(dim=-1, keepdim=True)
112
- directions = pairs / torch.clamp(radii, min=1e-9)
113
- denom = torch.clamp(mask.sum(dim=1), min=1e-9)
114
- pooled = ((directions * mask).sum(dim=1) / denom) * ((radii * mask).sum(dim=1) / denom)
115
- return F.normalize(pooled.flatten(start_dim=1), p=2, dim=-1).to(token_embeddings.dtype)
116
-
117
-
118
- inputs = tokenizer(
119
- ["How does photosynthesis work?", "Plants convert sunlight into chemical energy."],
120
- padding=True,
121
- truncation=True,
122
- return_tensors="pt",
123
- )
124
- with torch.no_grad():
125
- outputs = model(**inputs)
126
- embeddings = circular_pool(outputs.last_hidden_state, inputs["attention_mask"])
127
-
128
- print("Cosine similarity:", float((embeddings[0] @ embeddings[1]).item()))
129
- ```
130
-
131
- ---
132
-
133
- ## License
134
-
135
- Apache 2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - grt
5
+ - geometric-rotation-transformer
6
+ - sentence-transformers
7
+ - feature-extraction
8
+ - sentence-similarity
9
+ - circular-pooling
10
+ - rotational
11
+ - qwen3
12
+ datasets:
13
+ - sentence-transformers/all-nli
14
+ - sentence-transformers/stsb
15
+ language:
16
+ - en
17
+ library_name: sentence-transformers
18
+ pipeline_tag: sentence-similarity
19
+ base_model: MatterWaveAI/grt-30m
20
+ ---
21
+
22
+ # GRT-30M-Embedding (Circular-Pooled Rotational Sentence Encoder)
23
+
24
+ An **embedding-only Geometric Rotation Transformer (`GRTModel`)** contrastively fine-tuned from [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) for semantic textual similarity and dense retrieval using **planar-pair `circular` pooling** (`sentence-transformers`).
25
+
26
+ Instead of dense linear projections (`nn.Linear`), GRT represents token embeddings in polar coordinates (`phase_angles` + `log_magnitude`) and transforms hidden states through cascades of content-modulated `2×2` Givens rotations on `SO(D)` interleaved with butterfly permutations. Because every hidden state is structured as `D / 2 = 128` planar `(x, y)` coordinate pairs, **`circular` pooling** decomposes each pair into its unit direction `(cos θ, sin θ)` and radius `r`, averages the unit directions and radii across non-padding tokens, and recombines them into a `256`-dimensional sentence embedding.
27
+
28
+ ---
29
+
30
+ ## Model Details
31
+
32
+ | Property | Value |
33
+ |---|---|
34
+ | **Architecture** | `GRTModel` (`model_type: "grt"`, encoder/backbone without causal LM head) |
35
+ | **Base model** | [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) |
36
+ | **Pooling strategy** | `circular` (`Pooling(embedding_dimension=256, pooling_mode="circular")` + `Normalize`) |
37
+ | **Output dimensionality** | `256` (`128` planar `(x, y)` pairs, L2-normalized) |
38
+ | **Total stored parameters** | `29,305,497` (`29.31M`, `lm_head.output_scale` stripped) |
39
+ | **Non-embedding backbone parameters** | `9,740,197` (`9.74M` across 12 rotational blocks) |
40
+ | **`hidden_size` (`d_model`)** | `256` |
41
+ | **`num_hidden_layers` (`n_blocks`)** | `12` |
42
+ | **`num_attention_heads` (`n_heads`)** | `4` (`head_dim = 64`) |
43
+ | **`intermediate_size` (`d_ff`)** | `1,024` |
44
+ | **`n_qkv_rotations` / `n_mixer_rotations` / `ffn_n_rotations`** | `11` / `1` / `21` |
45
+ | **Vocabulary** | `151,669` (Qwen 3 BPE) |
46
+ | **Max sequence length** | `512` (supports up to `2,048` positions) |
47
+
48
+ ---
49
+
50
+ ## Two-Stage Contrastive Fine-Tuning Method (Intel Arc XPU)
51
+
52
+ Starting from the pretrained [`MatterWaveAI/grt-30m`](https://huggingface.co/MatterWaveAI/grt-30m) causal checkpoint (`lm_head.output_scale` stripped to form a headless `GRTModel` encoder), the `151,669` lexical `embedding.phase_angles` (`19.41M` parameters) were frozen to preserve the pretrained Qwen 3 polar token geometry while training the **`9,740,196` rotational backbone parameters + `151,669` token `log_magnitude` weights (`9,891,865` trainable parameters)** in `FP32` on an **Intel Arc 140T GPU (`xpu:0`, 32 GB)** using fused oneAPI DPC++ SYCL Givens and Clifford kernels (`~75s` total wall-clock time):
53
+
54
+ | Stage | Dataset & Budget | Objective & Hyperparameters |
55
+ |---|---|---|
56
+ | **Parameter Freezing** | `embedding.phase_angles` frozen (`19.41M` params) | `9,891,865` trainable parameters (`12` rotational blocks + `embedding.log_magnitude`); max grad norm `1.0` |
57
+ | **Stage 1: AllNLI Contrastive Alignment** | `sentence-transformers/all-nli` (`triplet` split) · `150 steps` (`4,800` triplets, `<1%` of corpus) | In-batch `MultipleNegativesRankingLoss` + explicit hard negatives (`τ = 0.05`), `batch_size = 32`, `max_length = 96`, `PairAdam(lr=1.5e-4, coupling_lr_mult=3.0, max_angular_step=0.05)` |
58
+ | **Stage 2: STS-B Rank & Metric Calibration** | `sentence-transformers/stsb` (`train` split, `5,749` pairs) · `2 epochs` (`358 steps`) | `CoSENT` rank-consistency loss (`τ = 20.0`) + `2.0 × CosineMSE`, `batch_size = 32`, `max_length = 128`, `PairAdam(lr=8e-5, coupling_lr_mult=3.0, max_angular_step=0.05)` |
59
+
60
+ ---
61
+
62
+ ## Evaluation Results (STS-B)
63
+
64
+ Evaluated on the **STS Benchmark (`sentence-transformers/stsb`)** validation and test splits using `circular` pooling and cosine similarity:
65
+
66
+ | Split | Metric | `GRT-30M` (Pretrained Base) | `GRT-30M-Embedding` (`PairAdam`) | `AdamW` Ablation¹ | Delta (`PairAdam` vs. Base) |
67
+ |---|---|---:|---:|---:|---:|
68
+ | **STS-B Validation** | **Spearman (`×100`)** | `45.51` | **`71.79`** | `72.89` | **`+26.28`** |
69
+ | **STS-B Test** | **Spearman (`×100`)** | `28.49` | **`62.42`** | `63.17` | **`+33.93`** |
70
+ | **STS-B Test** | **Pearson (`×100`)** | `29.81` | **`63.30`** | `63.72` | **`+33.49`** |
71
+
72
+ > ¹ *Optimizer comparison note:* The published checkpoint is trained with `PairAdam` (zero weight decay and `[-π, π]` wrapping on rotation angles, `max_angular_step = 0.05`, and rank-1 factored second moments with a `3×` learning-rate multiplier on `Cl(2,0)` coupling tensors) for consistency with `GRT-30M` pretraining. In a head-to-head run on the identical `508`-step schedule and random seed (`42`), standard `AdamW` (`1×` coupling LR, full diagonal second moments) reaches `72.89` Val / `63.17` Test Spearman (`+1.10` / `+0.75` points), indicating that while `PairAdam`'s factored moments and `3×` coupling LR multiplier stabilize large-batch (`524k` tok/step) pretraining from scratch, standard diagonal moments at `1×` coupling LR are slightly gentler during short, small-batch (`B = 32`) downstream fine-tuning.
73
+
74
+ ---
75
+
76
+ ## Usage
77
+
78
+ ### 1. `sentence-transformers` (Recommended)
79
+
80
+ ```python
81
+ from sentence_transformers import SentenceTransformer
82
+
83
+ model = SentenceTransformer("MatterWaveAI/grt-30m-embedding")
84
+
85
+ sentences = [
86
+ "Plants convert sunlight into chemical energy through photosynthesis.",
87
+ "Chlorophyll absorbs light energy to synthesize glucose in plant leaves.",
88
+ "The stock market experienced volatility during the afternoon session.",
89
+ ]
90
+
91
+ embeddings = model.encode(sentences)
92
+ similarities = model.similarity(embeddings, embeddings)
93
+ print(similarities)
94
+ ```
95
+
96
+ ### 2. Hugging Face `transformers` (`GRTModel` + Circular Pooling)
97
+
98
+ ```python
99
+ import torch
100
+ import torch.nn.functional as F
101
+ from transformers import AutoModel, AutoTokenizer
102
+
103
+ model_id = "MatterWaveAI/grt-30m-embedding"
104
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
105
+ model = AutoModel.from_pretrained(model_id).eval()
106
+
107
+
108
+ def circular_pool(token_embeddings: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
109
+ pairs = token_embeddings.float().unflatten(-1, (-1, 2))
110
+ mask = attention_mask.float().unsqueeze(-1).unsqueeze(-1)
111
+ radii = pairs.norm(dim=-1, keepdim=True)
112
+ directions = pairs / torch.clamp(radii, min=1e-9)
113
+ denom = torch.clamp(mask.sum(dim=1), min=1e-9)
114
+ pooled = ((directions * mask).sum(dim=1) / denom) * ((radii * mask).sum(dim=1) / denom)
115
+ return F.normalize(pooled.flatten(start_dim=1), p=2, dim=-1).to(token_embeddings.dtype)
116
+
117
+
118
+ inputs = tokenizer(
119
+ ["How does photosynthesis work?", "Plants convert sunlight into chemical energy."],
120
+ padding=True,
121
+ truncation=True,
122
+ return_tensors="pt",
123
+ )
124
+ with torch.no_grad():
125
+ outputs = model(**inputs)
126
+ embeddings = circular_pool(outputs.last_hidden_state, inputs["attention_mask"])
127
+
128
+ print("Cosine similarity:", float((embeddings[0] @ embeddings[1]).item()))
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Whitepaper & Technical Reports (`matterwave.ai`)
134
+
135
+ - **Full Whitepaper**: [**The Geometric Rotation Transformer (GRT): A Purely Rotational Foundation Architecture (`GRT_Whitepaper.pdf`)**](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/GRT_Whitepaper.pdf)
136
+ - **Companion Technical Reports** ([`MatterWaveAI/grt-30m/tree/main/papers`](https://huggingface.co/MatterWaveAI/grt-30m/tree/main/papers)):
137
+ - [`rotational_embedding.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/rotational_embedding.pdf) — *RotationalEmbedding: Phase-Angle Token Representation on a Product of Circles*
138
+ - [`pearlnorm.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/pearlnorm.pdf) — *PearlNorm: Pair-Aware Root-Mean-Square Layer Normalization*
139
+ - [`rotationalmixer.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/rotationalmixer.pdf) — *RotationalMixer: Content-Dependent Butterfly-Shuffled Mixing Between Attention and FFN*
140
+ - [`radialgelu.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/radialgelu.pdf) — *RadialGELU: A Phase-Preserving Nonlinearity for Rotation-Based Neural Networks*
141
+ - [`pairadam.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/pairadam.pdf) — *PairAdam: Geometry-Aware Optimization for Rotation-Based Neural Networks*
142
+ - [`mor.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/mor.pdf) — *Mixture-of-Rotations: Soft Expert Routing for Rotation-Based Feed-Forward Networks*
143
+ - [`stokes_coupling.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/stokes_coupling.pdf) — *Stokes & Clifford Multivector Coupling for Rotational Attention*
144
+ - [`fermionic_grt.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/fermionic_grt.pdf) — *FermionicGRT: Real-Only Clifford-Algebra Transformers with Matchgate Simulation*
145
+ - [`prism_grt.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/prism_grt.pdf) — *PRISM: Probe-Reservoir Injection and State Modulation for Self-Editing Rotational Transformers*
146
+ - [`rotation_machine.pdf`](https://huggingface.co/MatterWaveAI/grt-30m/resolve/main/papers/rotation_machine.pdf) — *Rotation Machine: Language Modeling via Recursive Application of a Single Computational Rule*
147
+
148
+ ---
149
+
150
+ ## Free Software Statement ("Free as in Freedom") & License
151
+
152
+ > *"Free software is a matter of liberty, not price. To understand the concept, you should think of 'free' as in 'free speech,' not as in 'free beer.'"*
153
+ > — **Richard M. Stallman**, GNU Project / Free Software Foundation
154
+
155
+ All Geometric Rotation Transformer (**GRT**) model weights, polar tokenizers, training recipes, and custom hardware kernels (CUDA, ROCm/HIP, oneAPI SYCL XPU, Vulkan, and CPU AVX2) are released as **free software and free scientific works** under the **Apache-2.0 License** at [`https://matterwave.ai`](https://matterwave.ai) and [`https://huggingface.co/MatterWaveAI`](https://huggingface.co/MatterWaveAI). You have the four essential freedoms:
156
+ 1. **Freedom 0**: The freedom to run the models and software for any purpose.
157
+ 2. **Freedom 1**: The freedom to study how the rotational primitives, phase angles, and Clifford couplings work, and change them to make them do what you wish.
158
+ 3. **Freedom 2**: The freedom to redistribute exact copies to help others.
159
+ 4. **Freedom 3**: The freedom to distribute copies of your modified versions, upcycled experts, and fine-tuned checkpoints to the community.
160
+
161
+ ---
162
+
163
+ ## Citation
164
+
165
+ ```bibtex
166
+ @techreport{householter2026grt,
167
+ title = {The Geometric Rotation Transformer: A Purely Rotational Foundation Architecture},
168
+ author = {Householter, David and {The MatterWave AI Team}},
169
+ institution = {MatterWave AI},
170
+ year = {2026},
171
+ url = {https://matterwave.ai}
172
+ }
173
+ ```