Skip to main content

k-familiar

A fast, zero-training intent router that thinks in six table lookups.

~16,000 classifications/second. Zero training. numpy-only. Accurate on covered vocabulary — and it asks when it isn't sure instead of guessing.

from k_familiar import Familiar

f = Familiar()
result = f.classify("analyze the flaw in this argument")

print(result["suit"])        # "spades" (mind/analysis domain)
print(result["confidence"])  # 1.0  (all content-words agree)
print(result["k_addr"])      # "+4S"
print(result["latency_us"])  # ~60

What It Does

Classifies text into four cognitive domains using GF(4) finite field algebra. It votes over a fixed keyword→suit table, so it is accurate on covered vocabulary and returns low/zero confidence (or ASKs) on words it doesn't know — it won't invent a class:

Domain Suit What it catches
Hearts H Emotion, relationships, connection, care
Spades S Analysis, logic, conflict, truth-seeking
Diamonds D Material, building, engineering, physical
Clubs C Action, energy, will, commands, creation

Each classification also returns:

  • Confidence (0.0–1.0) — the fraction of content-words that agree on the winner (1.0 = unanimous, 0.5 = a two-way split). An interpretable vote share, not a calibrated probability.
  • Rank (1-13, intensity/complexity)
  • Polarity (light/dark, positive/negative valence)
  • K-address (e.g., "+7H" = high-intensity positive emotional content)

Why It's Different

Feature k-familiar Typical classifier
Model size 313 bytes 100MB+
Training required None Hours/days
Parameters 0 Millions
Speed ~60us/query ~50ms/query
Dependencies numpy only torch, transformers, ...
Safety By construction By filtering
Offline Always Usually not

How It Works

Six operations over GF(4) lookup tables:

Operation Symbol What it does
BIND a x b Associate two ideas (GF(4) multiply)
BUNDLE a + b Hold multiple ideas at once (GF(4) add)
RETRIEVE s x key^-1 Pull one idea back out (multiply by inverse)
FOLD C(v) Compress 3:1 through codon lookup table
CHECK k <= sqrt(d) Am I sure? Test holographic capacity
ASK ? I'm not sure. Escalate to human/LLM

The entire computation is table lookups. No matrix multiplies. No floating point in the critical path. Fits in L1 cache.

Install

pip install k-familiar

Quick Start

Classify text

from k_familiar import Familiar

f = Familiar()

# Classify text — accurate when the words are covered
print(f.classify("analyze the flaw in this argument"))
# {'suit': 'spades', 'confidence': 1.0, 'k_addr': '+4S', ...}

print(f.classify("I feel grateful and connected to my team"))
# {'suit': 'hearts', 'confidence': 1.0, 'k_addr': '+4H', ...}

print(f.classify("take action now and execute the plan"))
# {'suit': 'clubs', 'confidence': 1.0, 'k_addr': '+4C', ...}

print(f.classify("the server needs more memory"))
# {'suit': 'diamonds', 'confidence': 1.0, 'k_addr': '+3D', ...}

Route to templates

f = Familiar()

# Set responses for each domain
f.set_template("H", response="Take a breath. You're not alone in this.")
f.set_template("S", response="Let's break this down step by step.")
f.set_template("D", response="Check the specs, then build a prototype.")
f.set_template("C", response="Start now. Iterate later.")

# Route automatically
result = f.route("I can't figure out this algorithm")
print(result["response"])  # "Let's break this down step by step."
print(result["source"])    # "template"

Working memory

f = Familiar()

# Remember things (holographic superposition)
f.remember("morning", "had coffee with Sarah, felt good")
f.remember("task", "need to finish the API by Thursday")

print(f.status())
# {'bundle_items': 2, 'capacity': {'phase': 'green', ...}, ...}

# Capacity is bounded: ~10 items for d=64
# The Familiar KNOWS when it's full and will refuse + ASK

Use the raw opcodes

from k_familiar import bind, bundle, retrieve, fold, check
import numpy as np

# Create vectors
key = np.random.randint(0, 4, 64).astype(np.uint8)
val = np.random.randint(0, 4, 64).astype(np.uint8)

# Bind, bundle, retrieve
bound = bind(key, val)
memory = bundle(bound, np.zeros(64, dtype=np.uint8))
recovered = retrieve(memory, key)

# Compress
folded = fold(recovered)  # 64 -> 21 elements (3:1 via genetic code table)

# Check capacity
status = check(bundle_items=3, d=64)
print(status)  # {'items': 3, 'capacity': 10.67, 'ok': True, 'phase': 'green'}

Use Cases

Pre-LLM router — Classify intent locally before making expensive API calls. Route 80% of queries to templates, send only the hard 20% to GPT/Claude.

Safety layer — The Familiar can't produce harmful outputs because the codon tables don't have paths to harm. Not filtered. Absent. Use as a first-pass safety check.

Agent classifier — In multi-agent systems (CrewAI, AutoGen, LangGraph), use k-familiar to route tasks to the right agent by domain.

Offline AI — Works on airplanes, in the field, on Raspberry Pi. No internet, no API keys, no latency.

Education — Teach information theory, finite fields, and holographic memory with a working implementation.

The Math

The GF(4) field has four elements {0, 1, 2, 3} with addition and multiplication tables:

ADD:  0 1 2 3    MUL:  0 1 2 3
    0 0 1 2 3        0 0 0 0 0
    1 1 0 3 2        1 0 1 2 3
    2 2 3 0 1        2 0 2 3 1
    3 3 2 1 0        3 0 3 1 2

These 32 bytes (two 4x4 tables) are the entire "model." Everything else is derived.

The capacity bound: a bundle of k items in d dimensions can be reliably retrieved when k <= (q/(q-1)) * sqrt(d). For GF(4), d=64: capacity ~ 10.67 items.

The fold operation uses the biological genetic code (64 codons -> 21 amino acids) as a compression table. This is not a metaphor. It's the same math.

License

MIT. Use it for anything.

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k_familiar-0.2.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k_familiar-0.2.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file k_familiar-0.2.0.tar.gz.

File metadata

  • Download URL: k_familiar-0.2.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for k_familiar-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4fe5bb824c68c79155c9fcb2747b1b2e4c762cf55dece35f5498849534421f6f
MD5 1b25d5de16efd32d0c23942c4e667c1d
BLAKE2b-256 a0992bd739c08163e4310928ba486d94461e3ad1102a8802d6894d2e9fc87d99

See more details on using hashes here.

File details

Details for the file k_familiar-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: k_familiar-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for k_familiar-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac417b6fe70b13c33c915a04c9ef97e792c5569fc5bab87f1feb02cd4d8e54a2
MD5 5b51bdcedf1b2ee0cfd823365d7f4fc1
BLAKE2b-256 d534cae7a747a244348016ac465ca07e6f324262ee9c2af845fa5cc4048e2e53

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page