LexicalWatermarker<T>
Models & Types · AiDotNet.Safety.Watermarking
Keyed synonym-substitution text watermark: at every word from a synonym group, the key and the preceding word choose which synonym the text uses.
Inheritance: ModelBase<T, Vector<T>, Vector<T>> → SafetyModuleBase<T> → TextSafetyModuleBase<T> → TextWatermarkerBase<T> → KeyedSubstitutionWatermarker<T> → LexicalWatermarker<T>
For Beginners
This watermarker swaps words with their synonyms in a pattern that only your key can recognise. The meaning stays the same, but text marked with your key always agrees with the key’s choice, while other text agrees only about half the time.
How It Works
This is the synonym-substitution family of natural-language watermarks (Topkara, Topkara and Atallah 2006) with a
keyed, context-dependent choice and a z-test detector; see KeyedSubstitutionWatermarker for the
embedding and the statistic. It works on finished text, so it can mark the output of any model.
The default groups are words that can replace each other in nearly every context and start with the same kind of sound, so a preceding “a” or “an” stays correct (for example “rarely” and “seldom”, “toward” and “towards”, “additional” and “extra”). Pass your own groups to cover the vocabulary of your domain. Ordinary prose contains only a few sites per hundred words, so this watermark needs long text: with two-member groups, 36 distinct sites reach full confidence.
Constructors
| Constructor | Summary |
|---|---|
LexicalWatermarker(double watermarkStrength) |
Preserves the original constructor signature using the default configuration. |
LexicalWatermarker(double watermarkStrength, string key, IReadOnlyList<IReadOnlyList<string>> synonymGroups) |
Initializes a new lexical watermarker. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<IReadOnlyList<string>> DefaultSynonymGroups { get; } |
The default synonym groups. |
string ModuleName { get; } |