Synoema

Prompt Templates

Task-specific micro-references for small-model (4B–32B) Synoema generation

The full LLM reference (/llm) is ~1 800 tokens — that's fine for a 32K-context model and a one-shot generation, but it's a lot of attention budget when you only need to generate a list comprehension. The compact reference (synoema-compact.md, ~900 tokens) is a middle ground; the templates below are the lower end. Pick the smallest one that covers your task category, prepend it to your prompt, generate.

The seven templates

TemplateTokensBest for
arithmetic.md~540Recursion, math, conditionals (fac n = ..., fib n = ..., prime sieves)
lists.md~730List ops, higher-order functions, comprehensions (map, filter, foldl, [x | x <- xs, x > 0])
adt-patterns.md~620ADTs, pattern matching, Result/Maybe (type Shape = Circle Float | Rect Float Float)
records-maps.md~610Records, Maps, key-value data ({x = 1, y = 2}, map_lookup)
string-io.md~600String processing, IO, readline, file_read/file_write, print
semantic-guide.md~600Contracts (requires/ensure), tail recursion, anti-patterns
concurrent.md~260scope/spawn/chan, worker pools, pmap, race/gather

Source: synoema/docs/llm/templates/. Each template is a self-contained chunk you paste before your task description.

Usage

# 1. Pick the template matching your task
TEMPLATE=$(cat docs/llm/templates/lists.md)

# 2. Prepend to your prompt
PROMPT="${TEMPLATE}

Write a function that removes duplicates from a list."

# 3. Generate with GBNF-constrained decoding (recommended)
./main -m model.gguf --grammar-file synoema.gbnf -p "$PROMPT"

The GBNF grammar (lang/tools/constrained/synoema.gbnf) guarantees every sampled token is syntactically valid Synoema. The template guides the model toward semantically appropriate constructs for the task category. Together they shrink the search space dramatically.

Gotcha injection (optional)

Tasks that span multiple categories — say a list of records that need string formatting — can pull only the gotchas relevant to the features detected in the task, instead of switching to the full reference. The mapping lives in gotcha-map.json:

import json

features = ["lists", "strings"]              # detect from task text
gotchas = json.load(open("gotcha-map.json"))
ids = set()
for f in features:
    ids.update(gotchas.get(f, []))

# inject the corresponding gotcha entries (numbered list) into prompt

This keeps prompts narrow without losing the corner-case warnings the model needs.

When to skip the templates

  • Task genuinely spans 3+ categories — use synoema-compact.md (~900 tokens) instead. It carries all gotchas in a unified format.
  • Long-context model (32K+) — the full LLM reference (~1 800 tokens) is fine and gives the model more context for ambiguous prompts.
  • One-off prototyping with a strong model — you may not need any reference. Synoema's GBNF constraint already enforces syntactic correctness; large frontier models often have enough Synoema in pre-training.

Cross-references