Cheap finetuning of Static Embedding models.
Minish Labs has done significant research work into building fast static embedding models from any embedding model. A static embedding model provides a fixed mapping of words (or tokens) to vectors. This approach is extremely low latency and demands minimal resources since it involves a per-token lookup, with a pooling operation (e.g. summation).
"The quick brown fox jumps over the lazy dog"
|
tokenize |
v
["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"]
|
Look up |
v
┌───────┬───────────────────────────────┐
│ the │ [ 0.02, -0.01, 0.03, 0.91 ] │
│ quick │ [ 0.11, 0.24, 0.68, 0.05 ] │
{ │ brown │ [ 0.82, 0.31, 0.04, 0.02 ] │
"brown": [ 0.82, 0.31, 0.04, 0.02], │ fox │ [ 0.27, 0.86, 0.19, 0.01 ] │
"green": [ 0.85, 0.02, 0.06, 0.03], │ jumps │ [ 0.03, 0.29, 0.87, 0.04 ] │
... per-token fixed vector │ over │ [ 0.01, 0.02, 0.41, 0.79 ] │
"fox": [ 0.27, 0.86, 0.19, 0.01], │ the │ [ 0.02, -0.01, 0.03, 0.91 ] │
"cat": [ 0.09, 0.91, 0.12, 0.02], │ lazy │ [ 0.06, 0.33, -0.52, 0.08 ] │
... │ dog │ [ 0.12, 0.89, 0.21, 0.03 ] │
} └───────┴───────────────────────────────┘
|
pool operator |
v
[ 0.16, 0.32, 0.22, 0.32 ]
Broadly, techniques for static models can be either distillation or training. Distillating a teacher model, T requires constructing the look up table by computing T(tok) for each token in the vocabulary. Training minimises the cosines distance between the static mode, and a frozen teacher model. This training attempts to embue a given static vector with context from across the input.
N-grams
Static models and transformer models (e.g. LLMs) are antonyms with respect to their opinion about contextual independence. LLMs attend to all other tokens in a sequence, whilst static models are entirely derived from the current token in a sequence. I think its interesting to consider models on a spectrum. The success of transformers was in part due to their ability to truly attend to a full sequence (i.e. no vanishing or exploding gradients). On the other end, N-grams model more inter-token interactions than a simple static model.
< ---- Transformers ---- RNNs/LSTMs/GRU ------------- n-gram static models ------- static models (1-gram)->
Its possible to extend static models to use n-grams to model more sequence context.
Efficient fine-tuning.
The above dichotomy of distillation or training leaves little room for efficient fine-tuning for a given use case. Distillation may help by extending the known vocabulary to novel words, but there is no more efficient method for inter-token interactions than standard training.