WordOrderGuard

class WordOrderGuard(stopwords: Set<String> = Vocabulary.STOPWORDS, sentenceOpeners: Set<String> = Vocabulary.SENTENCE_OPENERS, nonEntityCapitals: Set<String> = Vocabulary.NON_ENTITY_CAPITALS, minAnchors: Int = DEFAULT_MIN_ANCHORS) : MatchGuard

Rejects matches whose prompts name the same things in a different order.

The near miss every other guard in the chain is structurally unable to see. Flights from New York to Miami and Flights from Miami to New York have the same words, the same numbers, the same entities, the same units and the same length. Every set-based guard compares two identical sets and abstains correctly, and SubstitutionGuard, the one guard that reads order, requires the order to be the same and differ in one position, so a swap is invisible to it too. What changed is not a token, it is which token is the subject.

The one condition that keeps it from eating paraphrases

English paraphrases reorder constantly. Active becomes passive, a clause moves to the front, a modifier trails instead of leading, and none of that changes the answer. A guard that rejected on reordering would reject most of the paraphrases it was shown.

So it does not read reordering. It reads two anchors that swapped past each other. An anchor is a token that names something specific: a capitalized entity or a number. Reordering a sentence moves phrases around; reversing a relation moves two named things past each other, and only the second is evidence. Flights from New York to Miami has anchors New York before Miami; the other prompt has them the other way round, and that is what fires.

Both prompts must also carry the same multiset of content words. A pair that differs in what it says is somebody else's job, and this guard has nothing to add to it.

Not in any default preset

It is opt-in, and docs/MEASUREMENTS.md carries the reason with the numbers. It was built to answer a pre-registered target on an adversarial corpus, and it is reported there whether it met it or not.

Parameters

minAnchors

anchors both prompts must carry before an order difference is read as evidence. Two is the minimum that can express a relation at all; higher makes the guard quieter still.

Constructors

Link copied to clipboard
constructor(stopwords: Set<String> = Vocabulary.STOPWORDS, sentenceOpeners: Set<String> = Vocabulary.SENTENCE_OPENERS, nonEntityCapitals: Set<String> = Vocabulary.NON_ENTITY_CAPITALS, minAnchors: Int = DEFAULT_MIN_ANCHORS)

Types

Link copied to clipboard
object Companion

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.