NegationGuard

class NegationGuard(markers: Set<String> = Vocabulary.NEGATION_MARKERS, stopwords: Set<String> = Vocabulary.STOPWORDS) : MatchGuard

Rejects matches where one prompt is negated and the other is not.

Negation is close to invisible to an embedding model: "is this column nullable" and "is this column not nullable" are one short function word apart, and that word carries the entire answer.

The test is presence, not count, so two differently-phrased negatives ("no such file" and "file not found") still match each other. Contractions are caught by an n't substring test, which survives any tokenizer that splits on apostrophes.

Constructors

Link copied to clipboard
constructor(markers: Set<String> = Vocabulary.NEGATION_MARKERS, stopwords: Set<String> = Vocabulary.STOPWORDS)

Properties

Link copied to clipboard
open override val name: String

Short stable identifier, surfaced in dev.kmemo.CacheLookup.Miss.detail.

Functions

Link copied to clipboard
open override fun evaluate(query: String, candidate: String): GuardVerdict

Judges serving the response cached for candidate in answer to query.