# Reference

## With BoTorch

A BoTorch `Model`, for BoTorch’s acquisition functions and optimizers.

|  |  |
|----|----|
| [LaplaceBoTorchSurrogate](../reference/LaplaceBoTorchSurrogate.llms.md#laplacekit_bayesopt.LaplaceBoTorchSurrogate) | A Laplace-approximated neural network as a BoTorch model. |

## Training

What trains the network and fits the Laplace approximation, for both surrogates.

|  |  |
|----|----|
| [PosthocMarglik](../reference/PosthocMarglik.llms.md#laplacekit_bayesopt.PosthocMarglik) | Train on the mean squared error, then tune the prior on the marginal likelihood. |
| [OnlineMarglik](../reference/OnlineMarglik.llms.md#laplacekit_bayesopt.OnlineMarglik) | Train with marginal-likelihood steps on the prior (Immer et al. 2021). |
| [FSPLaplace](../reference/FSPLaplace.llms.md#laplacekit_bayesopt.FSPLaplace) | Train under a GP prior over functions, then fit FSP-Laplace (Cinquin et al. 2024). |
| [Trainer](../reference/Trainer.llms.md#laplacekit_bayesopt.Trainer) | Trains a network on the data and returns its Laplace posterior. |

## Without BoTorch

A surrogate for inputs that aren’t tensors, and acquisition functions over a set of candidates.

|  |  |
|----|----|
| [LaplaceDiscreteSurrogate](../reference/LaplaceDiscreteSurrogate.llms.md#laplacekit_bayesopt.LaplaceDiscreteSurrogate) | A Laplace-approximated network, trained on the data, as a surrogate. |
| [Prediction](../reference/Prediction.llms.md#laplacekit_bayesopt.Prediction) | The posterior over the outcomes at some inputs, in the outcomes’ own units. |
| [discrete_acqf.expected_improvement](../reference/discrete_acqf.expected_improvement.llms.md#laplacekit_bayesopt.discrete_acqf.expected_improvement) | How much each candidate is expected to improve on `best`. |
| [discrete_acqf.upper_confidence_bound](../reference/discrete_acqf.upper_confidence_bound.llms.md#laplacekit_bayesopt.discrete_acqf.upper_confidence_bound) | An optimistic guess: the mean plus `beta` standard deviations. |
| [discrete_acqf.thompson_sampling](../reference/discrete_acqf.thompson_sampling.llms.md#laplacekit_bayesopt.discrete_acqf.thompson_sampling) | The values of one function drawn from the posterior. |
| [discrete_acqf.thompson_batch](../reference/discrete_acqf.thompson_batch.llms.md#laplacekit_bayesopt.discrete_acqf.thompson_batch) | The indices of `q` different candidates to evaluate together. |

## Language models

`laplacekit_bayesopt.llm`, with `pip install "laplacekit-bayesopt[llm]"`.

|  |  |
|----|----|
| [llm.LoRARegressor](../reference/llm.LoRARegressor.llms.md#laplacekit_bayesopt.llm.LoRARegressor) | A pretrained language model with LoRA adapters and an MLP head, on texts. |
| [llm.TextEncoder](../reference/llm.TextEncoder.llms.md#laplacekit_bayesopt.llm.TextEncoder) | A pretrained language model that turns each text into one vector. |
| [llm.LoRAFinetune](../reference/llm.LoRAFinetune.llms.md#laplacekit_bayesopt.llm.LoRAFinetune) | Fine-tune the adapters and the head, then the head alone, then fit the Laplace approximation. |
