Plugin list
laplacekit-transformers
Laplace-LoRA on Hugging Face causal language models and sequence classifiers.
Guide · Source · Yang et al., 2024
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[transformers]"In the virtual environment that has laplacekit.
pip install "laplacekit[transformers]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[transformers]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[transformers]"Then:
import laplacekit as lk
post = lk.transformers.laplace_lora(model, train_loader)laplacekit-diffusers
Last-layer Laplace on diffusers denoisers with DDPM-family schedulers.
Guide · Source · Kou et al., 2024
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[diffusers]"In the virtual environment that has laplacekit.
pip install "laplacekit[diffusers]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[diffusers]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[diffusers]"Then:
import laplacekit as lk
post = lk.diffusers.laplace(unet, scheduler, train_loader, n_data=60_000)laplacekit-subnet
Subnetwork Laplace over random, largest-magnitude or largest-variance weights.
Guide · Source · Daxberger et al., 2021
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[subnet]"In the virtual environment that has laplacekit.
pip install "laplacekit[subnet]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[subnet]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[subnet]"Then:
import laplacekit as lk
subnet = lk.subnet.largest_magnitude(1000)
post = lk.laplace(model, train_loader, likelihood=lk.Categorical(), subset=subnet)laplacekit-heteroscedastic
Heteroscedastic regression with a Gaussian likelihood in natural parameters.
Guide · Source · Immer et al., 2023
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[heteroscedastic]"In the virtual environment that has laplacekit.
pip install "laplacekit[heteroscedastic]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[heteroscedastic]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[heteroscedastic]"Then:
import laplacekit as lk
from torch import nn
model = nn.Sequential(body, nn.Linear(32, 2), lk.heteroscedastic.NaturalHead())
post = lk.laplace(model, train_loader, likelihood=lk.heteroscedastic.NaturalGaussian())laplacekit-reward
Reward models fit on preference pairs with Bradley–Terry.
Guide · Source · Yang et al., 2024
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[reward]"In the virtual environment that has laplacekit.
pip install "laplacekit[reward]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[reward]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[reward]"Then:
import laplacekit as lk
model = lk.reward.pairwise(net)
data = lk.data.from_loader(pair_loader, prepare=lk.reward.prepare_pairs)
post = lk.laplace(model, data, likelihood=lk.reward.bradley_terry())laplacekit-gp
Function-space Laplace at scale: ELLA (Nyström), VaLLA (variational inducing points) and FSP-Laplace (GP priors).
Guide · Source · Deng et al., 2022
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[gp]"In the virtual environment that has laplacekit.
pip install "laplacekit[gp]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[gp]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[gp]"Then:
import laplacekit as lk
import torch
ella = lk.gp.ELLA(lk.gp.from_data(100), rank=15)
gp = lk.function_space.laplace(model, train_loader, lk.Categorical(), method=ella)
vgp = lk.function_space.laplace(model, train_loader, lk.Categorical(), method=lk.gp.VaLLA(lk.gp.from_data(50)))
vgp = lk.gp.fit_variational(vgp, train_loader, steps=1000, lr=1e-2, learn_prior=False)
# model: a MAP trained with lk.gp.rkhs_norm
prior = lk.gp.FunctionPrior(lk.gp.RBF(torch.tensor(0.3)))
fsp = lk.gp.fsp_laplace(model, train_loader, likelihood=lk.Gaussian(), prior=prior, context=lk.gp.grid(-2.0, 2.0, 100), rank=100)laplacekit-marglik
Marginal-likelihood training, which fits the network, its prior precision and its noise together.
Guide · Source · Immer et al., 2021
In a uv project. This also adds it to pyproject.toml.
uv add "laplacekit[marglik]"In the virtual environment that has laplacekit.
pip install "laplacekit[marglik]"In the conda environment that has laplacekit, through pip.
conda activate myenv
pip install "laplacekit[marglik]"In a notebook cell. Restart the kernel afterwards.
%pip install "laplacekit[marglik]"Then:
import laplacekit as lk
import torch
opt = torch.optim.Adam(model.parameters(), lr=1e-3)
trained = lk.marglik.train(
model, train_loader, n_data=60_000, likelihood=lk.Categorical(), optimizer=opt, epochs=100
)
post = trained.post