v0.1.0 · public alpha

Braiding signals into ranks.

A polymorphic, LLM-backed ranker for catalog-aware recommendations. Every backbone, store, reward, and loss is a registered concrete — swappable from one config, runnable from one CLI.

MIT licensed Python 3.11 · 3.12 Patterned on Netflix GenRec CPU / MPS-runnable
~/braid — zsh
live
categories
44
categories
polymorphic registry
concretes
147
concretes
real implementations
conformance
131 / 147
conformance
fail-fast, no stubs
tests passing
277
tests passing
+ 1 skipped
One registry · 44 categories
auth 3 backbone 4 bandit 3 batcher 4 cache · catalogstore 4 cflog 1 checkpoint 4 curriculum 5 datasink 2 datasource 1 drift 4 driftresponse 3 embedding 3 eval 7 indexer 4 log 2 loss 6 metadata 3 metrics · migrator · miner 5 optimizer 4 phase 5 quantizer 5 rankaggregator 3 ratelimit 3 regularizer 4 reqpre 3 resppost 3 reward 5 router 4 scheduler 4 secret · server 2 sessionizer 3 splitter 3 template 3 tokencounter 3 tokenizer 3 tracing · tracker 4 truncation 5 verbalizer 5
What's inside

A complete ranker, pluggable end-to-end.

braid ships four backbones, four catalog stores, three verbalizer families, five real rewards, six loss terms, seven evaluators, and four drift detectors — all reachable through one dispatch.

Polymorphic spine

One registry, every primitive.

Backbones, catalog stores, verbalizers, rewards, losses, evaluators, routers — every component is a registered concrete dispatched through `braid.registry.create(category, name, **cfg)`.

44 categories · 147 concretes
Braided loss

Weighted-sum ranking objectives.

`braidedloss` combines ranking-CE, L-max, diversity entropy, and reward-weighted terms into a single trainable scalar — without silent fallbacks.

Σ wᵢ · lossᵢ(scores, labels, …)
Catalog-aware

Matmul, int4 AWQ, FAISS, RQ-VAE.

Scoring is `h @ E.T` over embeddings. Swap in `matmulinmem`, `matmulint4awq`, `faissivfstore`, or RQ-VAE semantic IDs from one config field — same dispatch API.

≤1M items → matmul · ≥1M → FAISS
Multi-reward

Composite rewards, real math.

Long-term return, diversity bonus, novelty, content-type balance — and a `composite` that weighted-sums them at training time. All real implementations, not stubs.

Trainable · deterministic · inspectable
The polymorphic spine

Eight layers, one dispatch.

Every concrete in braid opts in to the same eight layers. Capabilities, traits, observability, and a fail-fast error model compose into a single uniform surface — the spine.

No silent fallbacks Typed errors Manifest-registered Pydantic config Polymorphic dispatch Entry-point extensible
  1. 1
    Registry layer

    create(category, name, **cfg)

  2. 2
    Traits layer

    streamable · cachable · persistable · observable · idempotent · distributable · teachable · asyncable

  3. 3
    Lifecycle layer

    setup · warmup · shutdown · health

  4. 4
    Capabilities layer

    gpu · async · fusedkernel · int4quantize · distributable · teachable

  5. 5
    Versioning layer

    configmigrator walks configs between versions

  6. 6
    Schema layer

    item · event · context · prompt · rankrequest/response (versioned)

  7. 7
    Observability layer

    obsgen → Prometheus rules + Grafana JSON + metric catalogue

  8. 8
    Context layer

    requestcontext flows through every layer

How it feels

One CLI. The registry, surfaced.

Every subcommand resolves a concrete. Inspect any component. Dryrun a config without executing. Generate observability assets with one command.

config → plan
dryrun
$ python -m braid dryrun \\
        --config configs/train/phase2.yaml


  "wouldinstantiate": [
     "category": "backbone",     "name": "minicpm5" ,
     "category": "catalogstore", "name": "matmulinmem" ,
     "category": "loss",         "name": "braidedloss" ,
     "category": "rewards",      "name": "composite" 
  ],
  "maxsteps": 8000,
  "resolves": true
concrete → capabilities
inspect
$ python -m braid inspect \\
        catalogstore matmulinmem

name            matmulinmem
category        catalogstore
version         1.0.0
module          braid.catalogstore.matmulinmem
capabilities    distributable, observable

methods:
  build
  metrics
  numshards
  observability
  score
  shardrank
  warmup
$ braid list $ braid inspect $ braid dryrun $ braid conformance $ braid data $ braid phase1 $ braid rewards $ braid train $ braid serve $ braid eval $ braid drift $ braid elbow $ braid obsgen
Inside the registry

Six categories. One dispatch API.

Every concrete is real. Every capability is declared. Inspect, swap, and compose them at runtime — or extend the registry from your own entry points.

backbone

4 concretes

Continued-pretraining and ranking heads for MiniCPM-5, Llama 3.2, Qwen 2.5, and Pythia-1B.

  • llama32distributable · gpu · teachable
  • minicpm5distributable · gpu · teachable
  • qwen25distributable · gpu · teachable
  • pythia1distributable · gpu · teachable

catalogstore

4 concretes

Matmul, int4 AWQ, FAISS IVF, and RQ-VAE semantic-id stores — all gated by `h @ E.T`.

  • matmulinmemdistributable
  • matmulint4awqint4quantize · distributable
  • faissivfstoredistributable · gpu
  • semanticidsdistributable

reward

5 concretes

Long-term return, diversity bonus, novelty, content-type balance — and a composite that weighted-sums them.

  • longtermreturnteachable
  • diversitybonus
  • noveltyreward
  • contenttypebalance
  • composite

loss

6 concretes

Ranking-CE, L-max, calibration, reward-weighted, diversity-entropy — and `braidedloss` to combine them.

  • rankingce
  • lmax
  • rewardweighted
  • diversityentropy
  • calibration
  • braidedlosscomposite

eval

7 concretes

Offline ranking, calibration, diversity, replay, interleaving, baseline — plus a composite with bootstrap CI.

  • offlineranking
  • calibration
  • diversity
  • replay
  • interleaving
  • baseline
  • composite

drift

4 concretes

PSI, Kolmogorov-Smirnov, Jensen-Shannon divergence, and Page-Hinkley — all detectable from the registry.

  • psi
  • ks
  • jsd
  • pagehinkleysequential
Who it's for

Built for teams who ship recommendations for real.

For research labs

Drop in a new backbone, reward, or loss without forking the training loop. The conformance harness reports pass / fail-fast across all 147 concretes.

  • Pydantic-typed configs
  • Hydra & OmegaConf wired
  • Polymorphic registry

For production rankers

A FastAPI app with `/rank`, `/metrics`, `/health`, `/ready`. Lifecycle hooks, typed errors, prefix KV-cache, drift-aware routers.

  • Prometheus + Grafana
  • Typed error model
  • Sticky-bucket & shadow A/B

For multi-reward teams

Composite rewards and braided losses let product, growth, and policy teams share one ranker without rule soup. Inspect every weight at runtime.

  • Real long-term return
  • Diversity & novelty
  • Weighted scalar composites
Get started

Ship a ranker this afternoon.

Bootstrap a working environment, inspect the registry, dryrun any config, then start ranking — without Kubernetes, without Kafka, without a separately-licensed inference engine.

bootstrap
$ git clone https://github.com/sachncs/braid
$ cd braid && make bootstrap
$ make list         # 44 categories × 147 concretes
$ make conformance  # 131 / 147 real-pass

# python -m braid serve   → :8080