The Model Runtime

Crime Engine runs its characters on a local language model. There is no server and no network connection during play: the weights ship in the distribution, load into the player's own machine, and a conversation costs nothing but that machine's time. This page describes the runtime as it stands in A Detective Story, which is the engine's current reference implementation.

The figures below were measured in the demo product. The engine reads the same environment variables, which keep the ADS_ prefix of the game they came from.

1. Two completion models and one embedding model

Role Model File
Basic dialogue Llama 3.2 3B Instruct, Q4_K_M Models/Basic.gguf
Advanced dialogue Google Gemma 4 E2B Instruct, Unsloth Q8_0 Models/Model.gguf
Retrieval embedding Qwen3 Embedding 0.6B, Q8_0 Models/Embedding.gguf

Both dialogue models ship together and only the selected one is loaded. The embedding model is shared: it indexes authored knowledge and searches it, so it is loaded whichever dialogue model is chosen. See Knowledge and retrieval.

Advanced is the default. Basic asks less of the machine and, on the development machine, usually returns a turn sooner — but that is one machine's observation, not a guarantee. Advanced is the larger file and the better writer; a quality improvement does not imply lower latency.

The player chooses in Settings, and the choice is saved to the per-machine settings file and takes effect on the next launch, leaving the current conversation and save data intact. Both front-ends read the same preference, and both construct the same chat service, so the two see identical character prompts, retrieval and item authorisation.

2. What it costs

Basic Advanced
Parameters 3B E2B (Gemma 4's effective-2B mixture)
Quantisation Q4_K_M Q8_0
On disk smaller 5,048,350,848 bytes
GPU layers by default 999, i.e. all of them 16, tuned for a 4 GB GPU

The Advanced figure is a measured file: SHA-256 0A8488B149E1F700712C35D5BF0A3795F9DCC2563B4944D5EF2FB89375F9483E, embedded architecture gemma4, name Gemma-4-E2B-It, licence apache-2.0. The licence and attribution travel with the release.

The conversation context is 4,096 tokens. That is the number every other decision on this page is pressed against: it is why retrieval returns selected passages rather than a character's whole memory, why remembered dialogue is chunked one question-and-answer pair at a time, and why a long interview eventually rebuilds its opening briefing from recalled history instead of carrying every turn forward. Context and compute-buffer allocation sit inside the CPU fallback boundary, so a machine that cannot fit them on its GPU still plays.

Host-operation offload is disabled deliberately. With the Advanced file and partial GPU offload, the LLamaSharp 0.27.0 native backend aborts with GGML_SCHED_MAX_SPLIT_INPUTS at the default setting; keeping host operations on the CPU is what permits sixteen transformer layers to run on the GPU at all.

3. Prompt formats

Gemma 4 uses <|turn>system, <|turn>user and <|turn>model, separated by <turn|> and real newlines — which differs from earlier Gemma models. HostedTextChatModel selects its tested format from the GGUF's own metadata rather than being told, and Llama 3 remains supported so that developers can compare the two. The older HostedLlama3_2Model API stays available for other engine clients.

Thinking is disabled. A stream filter suppresses unexpected thought channels across token boundaries, and a conversation that has acquired one is rebuilt from visible memory on the next turn. Player text cannot insert native role delimiter tokens. This protects the prompt's structure; it is not a behavioural guarantee, and the application still decides whether any action a character attempts is legal.

4. Tool use

Characters act through an application-defined structured-output protocol, not a model's native function-call tokens:

<tool_call>{"name":"give_item","arguments":{"offer_id":"..."}}</tool_call>

The parser accepts complete calls only. Before anything changes in inventory or evidence, the engine checks the actual character, the actual location, the verified gifts and the already-claimed offers. Spoken payments and alleged tool results create nothing. See Evidence and items for the authorisation rules in full.

5. Configuration

Setting Meaning
ADS_MODELS folder holding Basic.gguf, Model.gguf and Embedding.gguf; defaults to Models beside the service assembly
ADS_COMPLETION_MODEL full path to a different completion GGUF for comparisons; embedding selection is unchanged
ADS_MODEL developer override, Basic or Advanced, without touching the player's saved preference
ADS_GPU auto by default; off forces CPU, force disables fallback for diagnosis
ADS_GPU_LAYERS completion layer count; 0 puts completion on the CPU
ADS_MODEL_SEED sampling seed for repeatable probes; ordinary play uses random seeds
ADS_MODEL_TRACE 1 prints native loading and placement diagnostics
ADS_SETTINGS_FILE isolates developer or test preferences from the player's

An explicit ADS_COMPLETION_MODEL takes precedence over ADS_MODEL, and should be cleared when what you are testing is the player-facing setting rather than a particular file.

6. Recovering from an empty reply

A reply with neither meaningful speech nor a tool call gets one fresh-context retry inside the same player turn. The question allowance, the gift receipt and action execution are not repeated. Ordinary refusals and action-only replies are not retried. If the second generation is also empty the player sees an explicit error rather than silent dialogue, and the offline trace records the attempt count.

This is a recovery, not a fix: it adds latency, and it is not evidence that the underlying model follows instructions reliably.

7. Measuring it honestly

Small local models are the engine's hard constraint, and the temptation to quote a flattering number about them is the documentation hazard this section most has to resist.

  • A single sample is not a reliability estimate. Compare models with the same questions and the same seeds, record every failure, and keep content contradictions separate from inference failures.
  • Timing needs alternating runs on a quiet machine, reported as medians and ranges rather than a best case. Response latency includes retrieval and output length, not just generation.
  • Retrieval is not a truth verifier. A small model can misread good context or invent a detail from it. Read the raw transcripts and the retained passages before changing a relevance threshold.
  • Transport success is not correctness. A probe reporting that the model returned usable text has graded nothing about whether the text was true or well written.

One recorded example of how easily this goes wrong: a French-language result cited as evidence of fluency was a single question to one character about Cassiopeia and the Summer Triangle. Gemma stayed in French where Llama mixed in English, and Gemma still missed the requested two-sentence limit. That is an observation about one question.

See also