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
- HoldTheLine — Project home
- K-Systems Research — The math
- Papers — GF(4) routing, holographic capacity proofs
Metadata
Release files for k-familiar 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| k_familiar-0.2.0.tar.gz | 19.1 kB | Without provenance | Details for k_familiar-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| k_familiar-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for k_familiar-0.2.0-py3-none-any.whl |
Total release size: 34.7 kB
Release files / k_familiar-0.2.0.tar.gz
| Download URL | k_familiar-0.2.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fe5bb824c68c79155c9fcb2747b1b2e4c762cf55dece35f5498849534421f6f
|
|
BLAKE2b-256 checksum How to use checksums |
a0992bd739c08163e4310928ba486d94461e3ad1102a8802d6894d2e9fc87d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / k_familiar-0.2.0-py3-none-any.whl
| Download URL | k_familiar-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac417b6fe70b13c33c915a04c9ef97e792c5569fc5bab87f1feb02cd4d8e54a2
|
|
BLAKE2b-256 checksum How to use checksums |
d534cae7a747a244348016ac465ca07e6f324262ee9c2af845fa5cc4048e2e53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for k-familiar 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.