erllama_nif (erllama v0.1.0)
View SourceSingle NIF entry module for erllama.
v0.2 surface (post step 2b):
crc32c/1 CRC32C of an iodata, dirty CPU. fsync_dir/1 dir fsync (dirty IO). load_model/2 path + opts -> {ok, ModelRef} | {error, _}. free_model/1 eager release; resource also freed on GC. new_context/2 model + opts -> {ok, CtxRef} | {error, _}. free_context/1 eager release; resource also freed on GC. tokenize/3 model + text + opts -> [token_id()]. kv_pack/3 ctx + tokens + n_tokens -> binary(). (Tokens/NTokens are informational; the in- memory llama API saves whatever is currently in the context's seq_id=0 KV cache. The model layer prefills exactly the desired prefix before calling.) kv_unpack/3 ctx + binary + seq_id -> ok | {error, _}.
Summary
Types
Functions
-spec adapter_free(adapter_ref()) -> ok | {error, atom()}.
-spec adapter_load(model_ref(), iodata()) -> {ok, adapter_ref()} | {error, atom()}.
-spec clear_sampler(context_ref()) -> ok.
-spec configure_sampler(context_ref(), map()) -> ok | {error, atom()}.
-spec crc32c(iodata()) -> non_neg_integer().
-spec decode_one(context_ref()) -> {ok, token_id()} | {eog, token_id()} | {error, term()}.
-spec embed(context_ref(), [token_id()]) -> {ok, [float()]} | {error, atom()}.
-spec free_context(context_ref()) -> ok.
-spec free_model(model_ref()) -> ok.
-spec kv_pack(context_ref(), [token_id()], non_neg_integer()) -> binary() | {error, atom()}.
-spec kv_pack(context_ref(), [token_id()], non_neg_integer(), non_neg_integer()) -> binary() | {error, atom()}.
-spec kv_seq_rm(context_ref(), integer(), integer(), integer()) -> ok | {error, atom()}.
-spec kv_unpack(context_ref(), binary(), non_neg_integer()) -> ok | {error, atom()}.
-spec new_context(model_ref(), map()) -> {ok, context_ref()} | {error, atom()}.
-spec prefill(context_ref(), [token_id()]) -> ok | {error, term()}.
-spec sampler_free(sampler_ref()) -> ok | {error, atom()}.
-spec sampler_new(context_ref(), map()) -> {ok, sampler_ref()} | {error, atom()}.
-spec set_adapters(context_ref(), [{adapter_ref(), float()}]) -> ok | {error, atom()}.
-spec set_grammar(context_ref(), binary()) -> ok | {error, atom()}.