class
Embedding
extends
TinyLoraLayerEmbedding(base_layer: nn.Module, adapter_name: str, config: C)Implementing kernel
C++ engine symbols that back this Python API.An nn.Embedding with a TinyLoRA update: the table is looked up as .
The frozen SVD is that of the table, (num_embeddings, embedding_dim): has one row
per token and one column per feature, and the update of a token is the row of
it indexes, through and . The dropout acts on the looked-up rows.
Parameters
base_ layernn.EmbeddingThe layer to adapt; the other parameters are those of
TinyLoraLayer.adapter_ namestrName of the adapter created at once.
configTinyLoraConfigThe adapter's config.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> from lucid.peft import TinyLoraConfig
>>> from lucid.peft.tuners.tinylora import Embedding
>>> base = nn.Embedding(10, 4)
>>> layer = Embedding(base, "default", TinyLoraConfig(r=2, u=3, target_modules=["x"]))
>>> tuple(layer.tinylora_A["default"].shape), tuple(layer.tinylora_B["default"].shape)
((2, 4), (10, 2))
>>> ids = lucid.tensor([[1, 2, 3]])
>>> bool((layer(ids) == base(ids)).all().item()) # v starts at zero
True