erllama_model_stub (erllama v0.10.0)

View Source

Deterministic test backend: no NIF, no GGUF, no hardware.

Load it with backend => erllama_model_stub to exercise your own code against the full erllama API (completion, streaming, sessions, cache tiers) in unit tests:

{ok, M} = erllama:load_model(#{backend => erllama_model_stub}),
{ok, #{reply := Reply}} = erllama:complete(M, <<"hello world">>, #{response_tokens => 4}).

Tokenisation hashes whitespace-delimited words (erlang:phash2/1), generation derives the next token from the context hash, so the same prompt always yields the same tokens; kv_pack/kv_unpack serialise the token list, so cache saves and restores work end to end. Chat templates, embeddings-as-vectors and adapters behave as on a model without those features ({error, not_supported} / {error, chat_not_supported}).

Load-config keys specific to this backend: step_delay_ms (hold each decode step that long, to make queueing observable) and thinking_capable (emit thinking events).

Summary

Functions

abort_handle(S)

applied_adapters/1

apply_adapters/2

apply_chat_template(S, Request)

clear_sampler/1

cleared/1

configure_sampler/2

decode_one(S, ContextTokens)

detokenize(S, Tokens)

embed(S, Tokens)

init(Config)

kv_pack(S, Tokens)

kv_pack(S, Tokens, SeqId)

kv_unpack(S, Bin)

kv_unpack(S, Bin, SeqId)

last_sampler_cfg/1

load_adapter/2

prefill(S, Tokens)

reset_context(S)

reset_sampler_new_cfgs()

reset_seq_rm_last_calls()

sampler_free(Sampler)

sampler_new(S, Cfg)

sampler_new_cfgs()

seq_rm(S, SeqId)

seq_rm_last(S, SeqId, N)

seq_rm_last_calls()

set_grammar/2

step/2

terminate(S)

thinking_signature(S, SeqId, Bytes)

tokenize(S, Text)

unload_adapter/2

wedge_next_step(Reason)