# Plugin list

`laplacekit-transformers` First-party · Library integration Install

Laplace-LoRA on Hugging Face causal language models and sequence classifiers.

[Guide](../quickstart/llm.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/transformers) · [Yang et al., 2024](https://arxiv.org/abs/2308.13111)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[transformers]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[transformers]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[transformers]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[transformers]"
```

Then:

``` python
import laplacekit as lk

post = lk.transformers.laplace_lora(model, train_loader)
```

`laplacekit-diffusers` First-party · Library integration Install

Last-layer Laplace on `diffusers` denoisers with DDPM-family schedulers.

[Guide](../quickstart/diffusion.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/diffusers) · [Kou et al., 2024](https://arxiv.org/abs/2310.11142)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[diffusers]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[diffusers]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[diffusers]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[diffusers]"
```

Then:

``` python
import laplacekit as lk

post = lk.diffusers.laplace(unet, scheduler, train_loader, n_data=60_000)
```

`laplacekit-subnet` First-party · Subset Install

Subnetwork Laplace over random, largest-magnitude or largest-variance weights.

[Guide](../quickstart/subnetwork.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/subnet) · [Daxberger et al., 2021](https://arxiv.org/abs/2010.14689)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[subnet]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[subnet]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[subnet]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[subnet]"
```

Then:

``` python
import laplacekit as lk

subnet = lk.subnet.largest_magnitude(1000)
post = lk.laplace(model, train_loader, likelihood=lk.Categorical(), subset=subnet)
```

`laplacekit-heteroscedastic` First-party · Likelihood Install

Heteroscedastic regression with a Gaussian likelihood in natural parameters.

[Guide](../quickstart/heteroscedastic.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/heteroscedastic) · [Immer et al., 2023](https://openreview.net/forum?id=A6EquH0enk)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[heteroscedastic]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[heteroscedastic]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[heteroscedastic]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[heteroscedastic]"
```

Then:

``` python
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` First-party · Likelihood Install

Reward models fit on preference pairs with Bradley–Terry.

[Guide](../quickstart/reward.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/reward) · [Yang et al., 2024](https://arxiv.org/abs/2402.13210)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[reward]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[reward]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[reward]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[reward]"
```

Then:

``` python
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` First-party · Function-space approximation Install

Function-space Laplace at scale: ELLA (Nyström), VaLLA (variational inducing points) and FSP-Laplace (GP priors).

[Guide](../quickstart/gp.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/gp) · [Deng et al., 2022](https://arxiv.org/abs/2210.12642)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[gp]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[gp]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[gp]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[gp]"
```

Then:

``` python
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` First-party · Tuning objective Install

Marginal-likelihood training, which fits the network, its prior precision and its noise together.

[Guide](../quickstart/marglik.llms.md) · [Source](https://github.com/laplacekit/laplacekit/tree/main/plugins/marglik) · [Immer et al., 2021](https://arxiv.org/abs/2104.04975)

## uv

In a uv project. This also adds it to `pyproject.toml`.

``` bash
uv add "laplacekit[marglik]"
```

## pip

In the virtual environment that has laplace**kit**.

``` bash
pip install "laplacekit[marglik]"
```

## conda

In the conda environment that has laplace**kit**, through pip.

``` bash
conda activate myenv
pip install "laplacekit[marglik]"
```

## Jupyter

In a notebook cell. Restart the kernel afterwards.

``` bash
%pip install "laplacekit[marglik]"
```

Then:

``` python
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
```
