Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/noise-prototypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ export class NoisePrototypeBank {
}
this.builtinCount = this.vectors.length;
this._initialized = true;

// Degeneracy check: if all prototype vectors are nearly identical, the
// embedding model does not produce discriminative outputs (e.g. a
// deterministic mock that ignores text). In that case the noise bank
// would flag every input as noise, so we disable ourselves.
if (this.vectors.length >= 2) {
const sim = cosine(this.vectors[0], this.vectors[1]);
if (sim > 0.98) {
this.debugLog(
`noise-prototype-bank: degenerate embeddings detected (pairwise cosine=${sim.toFixed(4)}), disabling noise filter`,
);
this._initialized = false;
this.vectors = [];
return;
}
}

this.debugLog(
`noise-prototype-bank: initialized with ${this.builtinCount} built-in prototypes`,
);
Expand Down
Loading