A transformer reads text as tokens, and a token needs unpacking. Before the model sees any text, a fixed program cuts the text into pieces drawn from a vocabulary of a few tens of thousands of pieces. A common word is one piece and a rare word is several, so unbelievable might become un, believ and able. Each piece has a number, its id, and the model only ever sees the list of ids.
The first thing the model does with each id is look up a row of numbers for it in a table, with one row per token in the vocabulary. That row is the token's embedding, the table is the embedding table, and it is the dullest part of a transformer. The length of each row is the model width, and every layer above works on lists of that length. In a small sentence encoder, a model that turns a whole sentence into one list of numbers, the table is also most of the parameters, where a parameter is one learned number and the count of them is the usual measure of a model's size.
A 30,522-token vocabulary at width 256 is 7.8M numbers before a single attention layer. In the one-layer encoder below that table is 7.8M of the 8.9M total. Those numbers are the wrong shape for a device budget. The attention layers, where each token reads the other tokens in the sentence, and the feed-forward layers, where each token is transformed on its own, are where the sentence gets understood. They are crowded out by a lookup that gives every token its own independent 256 numbers, including the tokens seen a handful of times in training.
Rare tokens end up with under-trained vectors. Distinct vectors end up encoding overlapping roles. And the count grows as , vocabulary size times width, whether or not that freedom is used. I wanted to know whether a compact sentence encoder actually needs an independent vector per token, or whether the rows of that table could be generated by one shared function of the token id.
| name | what it is |
|---|---|
| SNLI and MNLI | Two datasets of sentence pairs labelled by whether the second sentence follows from the first. NLI stands for natural language inference, and these are what the encoders train on. |
| STS-B | The Semantic Textual Similarity Benchmark, sentence pairs that people scored from 0 to 5 for how similar they are. This is what the encoders are tested on. |
| BERT | Google's 2019 encoder model that most small sentence encoders descend from. |
| WordPiece | The program BERT uses to cut text into tokens. Its vocabulary has 30,522 word pieces, each with an id. |
| BERT-Tiny, BERT-Mini, TinyBERT, MobileBERT-Tiny | Shrunk versions of BERT at 4M to 15M parameters. I quote them only as context for scale. |
| ALBERT | A BERT variant that, among other changes, shrinks the table by writing it as the product of two smaller matrices. It is one of the methods I did not compare against. |
PETE does the second. It maps the id to a single number between minus one and one, expands that number with fixed sines and cosines, and refines the result with a small shared network. Encoders are trained on NLI, the task of saying whether one sentence follows from another, and tested on STS-B, which asks how similar two sentences are. In that setting PETE keeps most of the lookup table's score with a model up to eight times smaller, and a 58K-parameter version still lines up with human similarity judgments to a useful degree. The claim is narrow and I will say how narrow.
The row generator
From here on there is some notation, but it all describes one picture. A standard embedding layer learns a free matrix , one independent row per token, so its parameter count is . Geometrically the table is points scattered freely in a space with dimensions, with nothing tying one to another. PETE replaces the rows with a rule,
where is a fixed rule that turns a token id into a list of numbers, and is a learned function shared by every token. The composite takes a single number to a vector, so the set of all its possible outputs is a curve in . The rows of the table are samples along that one curve.
That is the geometric content of the method. Instead of placing points I place one curve and read it at positions. The learned part is a two-layer MLP of hidden width . An MLP is the plainest kind of neural network. It multiplies its input by a matrix of weights, passes each result through a fixed curve such as one that sets negative values to zero, and multiplies by a second matrix, and the hidden width is the number of results in the middle. So the embedding stage has learned parameters and none of them depend on . Make the vocabulary ten times larger and the embedding stage does not grow, it is only read at more positions.
This is not a low-rank factorisation , where the table is written as the product of two thin matrices. The rank of a table is the number of independent directions its rows span, and a low-rank table puts all rows inside a flat sheet with directions through the origin. A curve is a different constraint. It has one direction at any point, but it can wind through the whole space, so the matrix of its samples need not have low rank at all.
What the two share is the motivation, replacing an unconstrained dense matrix with a structured one that has far fewer free numbers. PETE is a low-capacity row generator, not a rank cut.
The coordinate
The curve needs a parameter, and the only thing a token brings to the embedding layer is its id, its position in the vocabulary list. So the coordinate is the id, scaled into a fixed interval,
which puts token 0 at , token at and the rest evenly between. The interval is the same whatever the vocabulary size.
Two things make that less silly than it sounds. Subword tokenisers like BPE and WordPiece, the programs that cut text into tokens, assign ids roughly in descending order of frequency. So the frequent tokens crowd one end of the interval and the rare ones the other, and there is weak statistical structure along the index even though the ordering is imperfect, corpus-dependent and noisy.
And the point is not that neighbouring ids mean similar things. They mostly do not. The id is a fixed coordinate system over the vocabulary and that is all it is. PETE does not assume that id proximity means similar meaning, does not claim the vocabulary has a hidden structure along a single line, and leaves the disentangling of what the index muddles to the layers above the embedding.
Fourier features
A single number is a poor input for a small network, which would have to carve into tens of thousands of distinguishable pieces on its own. So the coordinate is first turned into numbers by a fixed set of sines and cosines. A basis is a set of building-block functions that other functions are written as combinations of, and sines and cosines at whole-number frequencies are the Fourier basis,
Pairs of coordinates share an integer frequency. Coordinates 0 and 1 are the sine and cosine at frequency 1, which complete one cycle as runs from to . Coordinates 2 and 3 are at frequency 2, and so on up to frequency .
Each sine and cosine pair traces a circle as moves, and the pair at frequency goes round times across the vocabulary. is the point on all those circles at once at the moment . So is itself a curve, a fixed one, smooth and bounded in every coordinate, winding through .
Two ids far apart on the index are far apart on the curve, and two adjacent ids are close. The high-frequency coordinates separate ids that the low-frequency ones cannot. Because every coordinate takes the same value at and , the curve is closed, and the first and last ids receive the same features.
These sines and cosines are a standard basis for functions on an interval. Any reasonably smooth function of the index can be written as a combination of them. The low frequencies carry the slow trends, such as whatever frequency ordering the tokeniser left in the ids, and the high frequencies carry the fine variation.
Three things make this the right lift. It costs no parameters, it is fixed before training, and it covers both slowly and rapidly varying functions of the index at once.
The residual MLP
The fixed curve on its own is not an embedding. Its shape was chosen with no knowledge of language, and the index is only weakly tied to token statistics, so the curve has to be bent into a shape the encoder can use. A shared MLP does the bending, and it is attached as a residual, which means its output is added to its input rather than replacing it,
Read this as a displacement field. Every point on the fixed curve is moved by a vector the MLP computes from where that point is. Because the MLP is continuous the moved points still lie on a continuous curve.
The residual matters for two reasons. When the MLP's output is small, which is how it starts, the embedding is already the Fourier curve, a spread-out set of distinct vectors rather than noise, so training begins from structure. And the MLP only has to learn the correction to that structure rather than the structure itself.
The embedding table becomes a low-capacity deformation of a fixed basis, and every token shares the parameters of the deformation. That sharing is a strong structural prior, a built-in assumption about what the table should look like. It is better understood as a constraint that keeps the encoder from overfitting than as a claim that token meaning lies along a single line.
It also has a cost I will come back to. The curve is smooth, so neighbouring ids get nearly the same embedding. That is enforced smoothness over an index that does not in general respect meaning.
The comparison
The question is whether a sentence encoder with its table replaced still produces useful sentence vectors, so the test is sentence-level and nothing else changes. Encoders train on SNLI and MNLI with a contrastive loss in the style of InfoNCE. A contrastive loss teaches the model to pull matching pairs together and push everything else apart.
Each training pair is a premise and a hypothesis labelled entailment, which means the hypothesis follows from the premise, and that pair is a positive. Every other sentence in the batch is a negative. The sentence embedding is the one list of numbers the encoder produces for a whole sentence. Sentence embeddings and are compared by cosine similarity, the cosine of the angle between the two vectors, which is 1 when they point the same way and 0 when they are at right angles. The similarity is scaled by a learned temperature that sets how sharp the comparison is. The loss pushes the positive pair's similarity above the similarity to every in-batch negative.
Evaluation is zero-shot, meaning the model never trains on STS-B. I take the model's cosine similarity for each pair of sentences and measure how well it agrees with the human scores on the STS-B validation set. Spearman correlation measures whether the model ranks the pairs in the same order as people do, and Pearson correlation measures whether the two sets of scores move together in a straight line.
The lookup baseline and PETE share everything else. Same number of layers, same number of attention heads, where a head is one of several copies of attention run side by side, same width and same feed-forward ratio, the size of the feed-forward layer relative to the width. Both use the same GeGLU activation inside the feed-forward layers, a gated version of the fixed curve, rotary position embeddings, which tell the model where in the sentence each token sits, RMSNorm, which rescales each vector to a standard size, and the BERT WordPiece tokenizer with .
Both train with the same AdamW optimiser, the procedure that updates the weights from the loss, at a learning rate of , which is the size of each update step. Both use 1,000 warmup steps, during which the learning rate ramps up from zero, a batch of 128 pairs per step, 122,700 steps and mixed precision, which stores some numbers at lower precision to run faster. Neither uses dropout, the practice of switching off random units during training, so that nothing regularises one and not the other. In the table, L is the number of layers, H the number of heads and d the width.
| model | L / H | d | params | Spearman | Pearson |
|---|---|---|---|---|---|
| PETE | 1 / 4 | 256 | 1.1M | 74.93 | 74.54 |
| lookup | 1 / 4 | 256 | 8.9M | 77.01 | 76.80 |
| PETE | 1 / 8 | 512 | 4.7M | 75.21 | 74.65 |
| lookup | 1 / 8 | 512 | 20.1M | 77.50 | 76.78 |
| PETE | 2 / 4 | 256 | 2.2M | 76.38 | 76.02 |
| lookup | 2 / 4 | 256 | 9.9M | 77.34 | 76.89 |
Read the parameter column against the score column. At one layer and width 256 the lookup model is 8.9M parameters and PETE is 1.1M, about eight times smaller, for 2.1 Spearman points. At width 512 it is 20.1M against 4.7M for 2.3 points. At two layers and width 256 it is 9.9M against 2.2M for about one point.
The gap closes with depth, which is what you would expect if the layers above are doing the refining that the table used to do. The reduction is smaller at the larger configurations because the encoder layers grow with width and depth while the table does not. So the table's share of the total shrinks and there is less for PETE to remove.
Pushing further down, with smaller feed-forward layers and reduced intermediate widths while keeping the same embedding mechanism, a 58K-parameter PETE encoder reaches 69.25 average correlation after fine-tuning on STS-B, meaning further training on STS-B's own training split. 396K reaches 78.0, 1.5M reaches 79.7, and 3.6M reaches 81.8.
BERT-Tiny at about 4M and BERT-Mini at about 11M sit at 73.95 in the same table. TinyBERT and MobileBERT-Tiny at 14 to 15M reach 80.4 and 80.1 Spearman. But the training objectives, data, distillation and optimisation all differ across those rows. Distillation means training a small model to copy a large one, and some of those models had that help. So that table is context for the scale of the models and not a head-to-head. The controlled comparison in this paper is the one above.
What it does not say
The result means that in a compact sentence encoder the embedding layer tolerates a far stronger built-in assumption than it usually gets. Independent token vectors are not necessary for useful sentence-level representations at this scale, and a curve with a shared deformation recovers most of what they gave. It does not mean the table is unnecessary in general.
- There is no comparison at matched parameter counts against the other ways of shrinking a table. Those are low-rank tables, hashed tables where several tokens share rows by a fixed rule, product-quantised tables where each row is stored as a few codes from small shared lists, and ALBERT-style factorised tables. So this is evidence that generating rows from a function is promising, and not a ranking of compression methods.
- There is no test with randomly permuted token ids, so I cannot yet separate the tokenizer's frequency ordering from the Fourier basis from the MLP.
- There is no multilingual, byte-level or character-level tokenisation, and no languages where words change form heavily, such as Finnish or Turkish.
- Tasks that need to know which exact word was there, like finding the names of people and places in text, tagging each word with its role, and generating text, are probably a bad fit for enforced smoothness over ids.
- Fourier features were chosen for being simple and parameter-free, not shown to be the best fixed basis.
What stands is that the embedding layer in a small sentence encoder can take a far stronger built-in assumption than it usually gets, and that generating rows from a function is a reasonable design point next to explicit low-rank compression rather than a replacement for it.
References
- Lan et al., ALBERT: a lite BERT for self-supervised learning of language representations, 2020.
- Svenstrup, Hansen and Winther, Hash embeddings for efficient word representations, 2017.
- Xu, Xu and Mandic, TensorGPT: efficient compression of large language models based on tensor-train decomposition, 2024.
- Shen et al., Q-BERT: Hessian based ultra low precision quantization of BERT, 2019.
- Bowman et al., A large annotated corpus for learning natural language inference, EMNLP, 2015.
- Williams, Nangia and Bowman, A broad-coverage challenge corpus for sentence understanding through inference, NAACL, 2018.
- Cer et al., SemEval-2017 task 1: semantic textual similarity, 2017.
- Devlin et al., BERT: pre-training of deep bidirectional transformers for language understanding, NAACL, 2019.
- Su et al., RoFormer: enhanced transformer with rotary position embedding, 2023.