Strona główna / Artykuły / A Tiny Salience Gate: How a Squared Score Keeps Latency Near 119 ms

Artykuł opublikowany po angielsku.

A Tiny Salience Gate: How a Squared Score Keeps Latency Near 119 ms

Break down a pre-model gate that scores messages with pi times psi squared, why squaring favors strong signals, and how a 0.2 ms local classifier keeps responses fast.

1029 słów

A gate that decides what an assistant should remember can be tiny. The H-Governor is a pre-model scoring layer that answers in about 119 ms to first byte, and the reason it's quick comes down to one formula, a small classifier and a few lines of Python. Here's the math, the code and what's actually being measured, so you can check it yourself instead of taking a latency number on faith.

One formula

The whole score is this:

H = πψ²

Read it as pi times psi squared, with three parts:

  • H is the overall "energy" score, the final result. It runs from 0 up to about 3.14.
  • pi is the usual constant, roughly 3.14159.
  • psi is a coherence score between 0 and 1, describing how well-formed the input text is and how its sentences are structured.

There's no neural network and no transformer in that. It's a plain closed-form calculation, closer in spirit to a physics equation than to a black-box model.

Why psi gets squared

Squaring is nonlinear, and that's the point. Before it's multiplied by pi, the normalized coherence value is squared, so weak signals shrink and strong ones stand out. A psi of 0.2 contributes only 0.04, while a psi of 1.0 contributes 1.0, which is 25 times more weight.

The practical effect is that routine remarks stay quiet and important facts dominate. A general chat model asked about the same idea described it the same way: squaring psi suppresses weak signals and gives much more weight to strong ones, which makes the formula a reasonable salience governor. That's a sanity check, not a proof, but it matches the arithmetic.

What NumPy does here, and what it doesn't

NumPy is Python's standard numerical library for vectors, matrices, statistics and general math. In this system it handles the number-crunching half: you hand it an already-estimated psi and it produces a consistent H score. That score then informs what happens to a message, such as whether it should touch memory, conversational continuity or model routing.

What NumPy cannot do is work out psi. The hard part is reading a real human message well enough to estimate which signals matter, and that job belongs to the psi-inference layer. Some sample inputs show the range:

  • A note about moving to Los Angeles last week is probably durable personal information.
  • Musing about quitting a job is likely an important decision or an unresolved goal.
  • Missing a parent carries emotional weight without asking anyone to store a fact.
  • A request to be reminded about marathon training is a commitment that will matter in later conversations.

The governor doesn't need to understand everything the way a frontier language model does. Its job is narrower: spot the signals that should change memory, continuity, routing or response behavior.

Classification quality is where this succeeds or fails. If psi is estimated badly, the formula is still mathematically correct and still operationally useless. You'd see things like:

  • A trivial message scored too high and stored when it should have been ignored.
  • A real commitment scored too low and forgotten.
  • An emotional remark mistaken for a lasting fact.
  • A short but important message outweighed by a long, repetitive one.

The formula is deterministic, so its usefulness depends entirely on the inputs. Roughly, memory quality is the quality of psi plus the behavior of the governor.

That's also why this layer sits before generation. It's a lightweight, inspectable decision step that sets a coherent state before the language model produces its probabilistic answer. The LLM then receives context shaped by an explicit policy, instead of having to decide from scratch what matters. The arithmetic is cheap. The judgment baked into psi is the real design problem.

The five-category classifier

So how is psi produced? In this implementation it's a five-category classifier that runs locally in about 0.2 ms, with no API call and no LLM round trip, just regular expressions and arithmetic:

def infer_tem_inputs(user_input):
    # 1. Durable personal info (name, location, goals)
    # 2. Important decisions (job change, trade entry)
    # 3. Emotional significance (loss, breakthrough, frustration)
    # 4. Commitments / unresolved objectives (psi-seeds)
    # 5. Future-relevant context (next steps, deadlines)

    # Returns: emotion, clarity, focus scores (0-1)
    # These combine into ψ

Every category adds to a final psi between 0 and 1, and H = pi times psi squared is then evaluated in microseconds.

That ordering explains the speed. Psi is computed before any expensive inference, so the costly layer only ever sees messages that already passed the salience filter.

The request path

Here is the actual governor pass from the app's request handler:

start_ns = time.perf_counter_ns()
emo, clarity, focus = infer_tem_inputs(request.input)
psi_report = tem_engine.evaluate(ThoughtSignal(clarity, focus, emo))
g_core = GongjuCore(psi=psi_report.coherence)
h_energy = g_core.holistic_energy()  # H = πψ²
latency_us = (time.perf_counter_ns() - start_ns) / 1_000
latency_buffer.append(latency_us)

It times itself in nanoseconds, infers the emotion, clarity and focus scores, evaluates them into a coherence value, and derives H. You can run it, confirm the 0.2 ms figure and check the formula. Numbers you can reproduce are worth more than vendor claims.

What to take from it

The formula is simple, the math is provable and the scaling is nonlinear. The intelligence lives in psi: knowing which messages matter, which facts are durable, which decisions are commitments and which context will be relevant later.

That's why the governor runs before the model, why it costs far less than a full inference, and why 119 ms to first byte is reachable without hurting memory quality. It's not a benchmark trick. It's what you get when you push the decision down into the cheap layer.