Configure an Ollama backend
ollama_backend.RdBundles connection and sampling settings into one object, passed down whole so parameters cannot drift between call sites. Drift can create context size differences between calls, defeating the prefix cache and forcing Ollama to reload the model.
Scoring reads log probabilities, which need an Ollama server at version
0.12.11 or later. measure() checks for them before a run and stops when
none come back.
Usage
ollama_backend(
model = NULL,
...,
keep_alive = "24h",
timeout = 600,
top_logprobs = 20L,
host = NULL,
modalities = c("text", "image"),
validate = TRUE
)Arguments
- model
A string giving the model name as Ollama knows it, e.g.
"gemma3:27b". The full tag is required. Shorthand is refused. Omit it entirely to list what the server has installed.- ...
Not used, and refused if anything reaches it. Every argument after it is name-only, so a misspelling lands here rather than being matched by position.
- keep_alive
A string setting how long Ollama holds the model after a call. The default,
"24h", is long because a corpus run over one model should not pay a reload between documents. A loop over several models on one machine wants a short value instead, since each one called stays resident for the whole window and the cost arrives as memory pressure rather than as an error.- timeout
A number giving the request timeout in seconds for generation calls. A cold prefill on a very long document can run minutes. Discovery and validation use their own shorter timeout. Default is 600.
- top_logprobs
An integer giving the number of alternatives to return at each position. Ollama caps this at 20. Lower it only if every label reliably appears in the top-k. Default is 20.
- host
A string giving the server URL. Defaults to
OLLAMA_HOSTor localhost. A host given with no scheme and no port takes port 11434, the way Ollama's own client readsOLLAMA_HOST.- modalities
A character vector of what the server accepts, which is
text,imageor both. A fact about the server rather than the model.measure()refuses a column naming something absent here, locally and before any call, because Ollama returns HTTP 200 for a field it does not recognize. Audio and video are not among them.prepare_audio()turns a recording into a transcript, andprepare_video()turns a video into frames plus a transcript when it has sound, which reach the model astextandimage. Default isc("text", "image").- validate
A logical value indicating whether to contact the server and confirm
modelis installed.FALSEconstructs blind with no network call, which is what examples, documentation builds, and constructor tests use. Default isTRUE.
Value
An object of class fathom_backend, a list of eight settings. It
holds no connection, so it is cheap to build and safe to keep.
modelis the tag calls are sent to. Recorded on the results as themodelattribute, so a corpus says which model produced it.hostis the server address, normalized to include a scheme.modalitiesholds what this server accepts.measure()refuses a column naming something absent here, before any call, because Ollama answers HTTP 200 to a field it does not recognize and an undeclared column would otherwise be discarded in silence.top_logprobssays how many alternatives are requested at the answer position. Ollama caps this at 20. A label whose token falls outside the returned set is scored as absent, soprobis a lower bound andprob_otherabsorbs the difference.thinkis alwaysFALSE, and not an argument. Reasoning is disabled on every call, because scoring reads generated position 1 and a model that reasons first puts something else there.keep_alivesays how long the server holds the model in memory between calls. Long enough that a corpus run does not pay reload cost.timeoutis the number of seconds before a single call is abandoned. A call that times out returns a failed row rather than ending the run.validatedsays whether the constructor confirmed the model is installed.FALSEwhen built withvalidate = FALSE, which skips the check rather than failing it.
Called with no model name it prints what is installed and stops, which doubles as a way to confirm the server is running.
Omitting model
The call contacts the server, prints the models installed there, and errors.
It does not return NULL or a partial object, so instrument() and
measure() never receive a backend with no model attached.
Temperature and seed
Neither is exposed. Temperature is fixed at 0, where the returned probabilities are the model's unmodified posterior. Scoring reads the distribution at generated position 1 and discards the token that would have been drawn from it, so temperature rescales the logits being measured without changing what is read.
At temperature 0 there is no sampling, and identical calls return byte-identical token sequences. A seed has nothing to control.
See also
measure(), which takes the backend, and instrument(), which can
probe labels against it.