filigrana
A writer-held statistical watermark for prose you wrote by hand.
filigrana lets you bias the equally-good choices in your own writing — toward vs
towards, however vs nevertheless, a number of vs several — according to a key only
you hold. Six months later, when a content farm has republished your essay as plain text,
you can run your key over their copy and get a p-value for whether your word choices are in
it.
Nothing is added to the text. There are no hidden characters, no metadata, no invisible codepoints. A reader sees an essay; someone with your key sees statistics.
$ pip install filigrana # Python 3.11+, macOS or Linux
$ filigrana key new # scrypt-encrypted keyring, 0600
$ filigrana audit essay.md # can this article even carry a mark?
$ filigrana embed essay.md # preview the diff, writes nothing
$ filigrana embed essay.md --anti-slop --out essay.marked.md --sidecar essay.sidecar.json
$ filigrana publish essay.marked.md --handle ada --published 2026-11-06 --domain example.com
$ filigrana detect scraped-copy.html # p-value plus caveats, never a verdict
From a checkout instead:
$ git clone https://github.com/moah0911/filigrana && cd filigrana && uv sync
$ uv run filigrana --version
A real run, on the 144-word article in examples/essay.md. Both output
files are checked in, so you can diff essay.md against essay.marked.md yourself — the
visible changes are a lot of→lots of, Perhaps→Maybe, Among→Amongst,
judgement→judgment, onward→onwards, at this point→at this stage,
recognise→recognize, although→though.
$ filigrana embed examples/essay.md --tier all --anti-slop
144 words, 23 eligible choices
8 edits (5.56% of words), 2 declined by you
21/23 slots now agree with the key
$ filigrana detect examples/essay.marked.md --tier all
143 words, 23 key-correlated choices (a:6, b:12, c:5)
agreement 21/23 slots on the key's side (chance would give 11.3)
statistics z = 4.04, p = 2.66e-05
strength 15.2 bits of evidence against chance
$ filigrana audit examples/essay.md --tier all # what this piece can support, up front
144 words, 23 choices (159.7 per 1000 words) {'b': 12, 'a': 6, 'c': 5}
best possible z at full strength: 4.88 (p = 5.38e-07)
verbatim copy z -> 4.88 p -> 5.38e-07
25% of slots edited away z -> 4.22 p -> 1.2e-05
half the text quoted z -> 3.45 p -> 0.000282
a quarter of slots left z -> 2.44 p -> 0.00737
Against a foreign key the same marked text scores 13/23, z = 0.70, p = 0.24 — chance. One
draw is not evidence of calibration; docs/CAPACITY.md has the null over
~28,000 foreign key/text pairs, where z sits at mean 0.006, sd 0.98, max 3.16 at article
length, with zero false reaches of p<1e-6 in 648k words of unmarked prose.
Read this first: the idea is not new
Three things you should know before you build anything on this README.
Someone has already shipped a version of this. vumichien/text-watermarking-toolkit
(MIT, Aug 2026) and its write-up in Towards Data Science
implement keyed word-choice watermarking for your own writing, with a model-free detector
and a calibrated null. It is the best introduction to the mechanism available, and it
measured the failure modes honestly — numbers we reproduce and extend in
docs/CAPACITY.md.
The mechanism is older than LLMs. Keyed synonym substitution is Topkara, Topkara &
Atallah, ACM MM&Sec 2006; syntactic equivalence classes go back to Atallah's NL Watermark
(IH 2001); context-aware lexical substitution is Yang et al., AAAI 2022. Model-free detection
by Bernoulli test is Yang et al., arXiv:2305.08883. filigrana claims no new algorithm.
What filigrana is actually for is the engineering those works do not do: an installable
library with a tested determinism contract, a key and identity model with rotation and
revocation (because a personal watermark identifies a person, which Anthropic's explicitly
does not), multiplicity-corrected p-values, an auditable equivalence table where every class
is provably substitutable in both directions, and published capacity numbers instead of
optimism.
What it is for, and what it is not
For: "someone republished my work and I want more than my word against theirs."
Not for:
- Proof of ownership. A watermark shows your version was copied. It cannot show you owned the underlying text. Genius planted a watermark in 301 songs, found it in Google's index, and still lost the case — because it licensed the lyrics. See docs/THREAT-MODEL.md.
- Surviving a rewrite. The mark lives in the words. Paraphrase it and it is gone — measured at 0% by prior art, and we expect the same. Translation, likewise.
- Any short text. A tweet has maybe one free choice. One coin flip is not evidence.
- Accusing people. The detector answers a narrow statistical question about one key and
one text. That is why
Decisionhas no truth value, and why there is no hosted verifier.
The two tiers, and why they are different problems
| Question | Cost in bits | Viable length | |
|---|---|---|---|
| tier 1 — attribution | you test your own key against a suspect copy | 0 — identity is the key's public fingerprint | ~1,000+ words |
| tier 2 — discovery | a stranger decodes who wrote this with no candidate | 45 (writer id 24 + date 13 + CRC 8) | book-length; see CAPACITY.md |
Most designs conflate these. For the scraper problem you already know who you are, so you
never need to decode anything — you just test your key. That is why tier 1 is the default and
why filigrana works at essay length where a full handle-plus-date payload does not.
How the watermark gets its "free choice"
Production LLM watermarks bias a model's logits during sampling. A human writer has no
logits. So filigrana manufactures the choice from a hand-audited table of equivalence
classes:
{"id": "b.although", "tier": "b", "members": ["although", "though"],
"not_after": ["even"], "avoid_clause_final": true}
A class is admissible only if every member can replace every other in every context. That
bar is much higher than "these are synonyms", and it is the whole project: help/aid is
excluded because foreign aid cannot become foreign help; although/though is kept but
guarded, because I liked it though has no although version. Automated synonym tables get
this wrong — the prior art measured 100% of marked passages becoming less fluent and 17.3%
gaining a grammatical error. filigrana therefore previews a diff and lets you veto any
edit, rather than rewriting your draft.
Each slot's demanded member is HMAC-SHA256(secret, scheme ‖ key_id ‖ class ‖ anchor ‖ payload bit) mod n_candidates, where the anchor is the handful of preceding words that
no class can reach — words the watermark itself will never rewrite, which is what makes
them safe to key off.
An earlier revision chained each demand off the previous slot decisions instead. It looks
elegant and it is wrong: one deleted sentence shifts the chain for the entire rest of the
document, and measurement showed a marked article scoring 30/53 slots — pure chance — after
30% sentence deletion. Anchoring bounds the damage to the neighbourhood of the edit, and the
same article keeps 40+/53. That regression is tests/test_statistics.py, not a footnote.
SynthID's own reference hash explicitly disclaims cryptographic security; ours needs it, because a leaked key here lets someone plant your mark on prose you never wrote.
Tiers of risk in the table itself
| tier | what | density | cost |
|---|---|---|---|
a |
orthographic — toward/towards, among/amongst |
low | invisible |
b |
low-salience lexical and connective — maybe/perhaps, often/frequently |
medium | slight register shift |
c |
locale (colour/color, -ise/-ize) and register (don't/do not) |
high | mixing forms in one article is a visible inconsistency |
Default is ab. Tier c is where the capacity is, and that is the real trade: a watermark
is intra-text inconsistency, because the mark has to vary. Anyone telling you a text
watermark is free has not looked at the output.
Ethics, in code rather than in prose
Decisionhas no truth value.bool(decision)raisesTypeError. There is nois_minefield and no--unsafe-verdictsescape hatch.- Multiplicity correction is automatic.
detect --key a --key b --key creports the Sidak-corrected p-value, because testing a registry of a million writers at p<1e-6 per test buys roughly one false accusation per scan. - Caveats are never empty, and short text says so itself: below 8 slots the statistic is noise and the output tells you not to quote it.
- Keys stay local.
filigrana detectperforms no network I/O. Any third-party "filigrana checker" is untrusted by design — it could both forge your mark and fingerprint your whole corpus. - Verification is delegable but scoped.
key.for_domain("example.com")gives a publisher enough to verify you on their site, not enough to derive your master key or scan the rest of your body of work.
What it costs, measured
Over 648,423 words of public-domain prose, 2,805 chunks and ~28,000 key/text pairs (full tables in docs/CAPACITY.md):
tier ab (safe) |
tier all (+ locale, contractions) |
|
|---|---|---|
| free choices per 1,000 words | 8.27 | 21.75 |
words to reach p<1e-6 |
2,733 | 1,039 |
| detected after 30% of sentences deleted | 1% | 64% |
| detected after a house-style normaliser | 13% | 77% |
| detected after full paraphrase or translation | ~0% | ~0% |
null z under a foreign key |
mean 0.006, sd 0.98, max 3.16 | mean 0.003, sd 0.99, max 3.16 |
false positives at p<1e-6 in 28,000 trials |
0 | 0 |
Three consequences worth stating plainly:
- Prior art's ρ ≈ 60 is achievable and costs prose. Their own numbers: 100% of passages less fluent, 17.3% with a new grammatical error. Our 8.27 is the price of a table where every class is provably substitutable both directions. Density is a measure of how much damage you accept, not a property of English.
- Tier 2 (decoding an identity out of unattributed text) needs ~41,000 words for 16 bits. Roughly half of all two-way slots carry no bit at all because the key demands the same word either way. Identity belongs in the key fingerprint, which is free, not in the payload.
- Serialization is free and rewriting is fatal. Reflow and case changes cost exactly
nothing (identical
z). A paraphrase costs everything, and nobody has found a way around that. Claim only verbatim-or-lightly-edited republication.
Layout
canon.py markup masking, offsets preserved, NFC (never NFKC)
keystream.py HMAC-SHA256 keyed choice over an anchor of unreachable words
ledger.py the ONE traversal both embed and detect share -- determinism lives here
providers.py equivalence-class scanning, guards, longest-match-first; also the
proposal seam (`CandidateProvider`) the model-gated path plugs into
embed.py diff proposal + veto + style guard + self-verification for drift
detect.py hits vs sum(1/n) over variable-size classes, multiplicity-corrected
decisions.py the output type is the safety mechanism: bool() raises
sidecar.py publish what was free, so verification needs no table, lexicon or model
codec.py tier-2 wire format and per-bit voting
keyring.py scrypt-encrypted keyring, fingerprints, domain subkeys, rotation
registry.py self-hosted id -> handle file; we run no service
manifest.py detached signed provenance (HMAC by default, Ed25519 via filigrana[sign])
gate.py the free-choice gate: keep a proposal only on a probability plateau
lm.py model-gated embedding under torch, optional: proposals filtered, never invented
lexical.py WordNet proposals, sense-blind by construction, refused without a gate
slop.py transparent proxy metrics for the AI-detector collision question
cli.py key | embed | detect | audit | publish | verify | registry | table
data/equivalence.json 135 hand-audited classes across three risk tiers
integrations/synthid.py writer-derived keys for the HF logits path
tools/ measure_free_choices, attack_eval, measure_lm_gate, detector_interference
bench/ the JSON those runs produced (density, attacks, lm_gate, interference)
Status
0.1.0, alpha, 206 tests, ruff + mypy + coverage-gated CI, full type annotations
(py.typed). Supported platforms are macOS and Linux; the keyring refuses to run on Windows
rather than writing a secret without POSIX 0600 semantics.
Shipped and measured: key generation with scrypt-encrypted atomic storage and scoped verifier
subkeys; tier-1 embedding with reviewed per-slot diffs; drift self-check; detection with
variable-arity statistics, multiplicity correction and mandatory caveats; a
serialization-invariance suite; the tier-2 payload codec; the registry format; detached
manifests (HMAC always; Ed25519 through the filigrana[sign] extra); the anti-slop style
guard; and the capacity report over 648k words.
The LM-assisted free-choice gate is in this tree and measured: gate.py adds the
plateau test, lm.py the torch-helper embedding path, lexical.py the WordNet proposer.
Measured at article length it keeps ~1 slot per 1,000 words at near-zero style cost
(≤ 0.0014 nats/token) — a precision instrument, not a capacity multiplier; the curated
tables remain what reach looks like. The numbers live in docs/CAPACITY.md
and bench/lm_gate.json.
Not shipped, in the order that matters:
- Inference beyond a first plateau pass: higher density without paying in prose quality is bounded by how rare the plateau condition is in real prose (measured; see CAPACITY).
- Ed25519 manifests as the default rather than the extra (
filigrana[sign]already installs the audited library; the default stays stdlib-HMAC until there is a reason). - A real detector-interference study on matched pairs through Originality/Pangram/
GPTZero. The proxy says the collision is mild;
--export-pairsand bench/interference.json are what the repository contributes to that study, not an answer. - A public-but-unforgeable in-band mark. Bounded by the impossibility results and by ~5,000 contiguous untouched tokens of cost. If someone claims to have shipped this, ask them what length it works at.
MIT. Not affiliated with Anthropic; the explainer this was read against is anthropic.com/news/claude-text-watermark.
Metadata
Release files for filigrana 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| filigrana-0.1.0.tar.gz | 111.1 kB | Without provenance | Details for filigrana-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| filigrana-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for filigrana-0.1.0-py3-none-any.whl |
Total release size: 181.7 kB
Release files / filigrana-0.1.0.tar.gz
| Download URL | filigrana-0.1.0.tar.gz |
|---|---|
| Size | 111.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9f1b54f5d136e29aa74d419cfcb4fabcb107dfadae7b418a550e6481a64c1c1
|
|
BLAKE2b-256 checksum How to use checksums |
5e932e0a0643ea44362c9ab6bfa0329552f7ee41bb26996f5d5a0251b845413b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / filigrana-0.1.0-py3-none-any.whl
| Download URL | filigrana-0.1.0-py3-none-any.whl |
|---|---|
| Size | 70.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65723643234258fb7023e593b8a25f3449821c75dd696fbba5151a5242341ea7
|
|
BLAKE2b-256 checksum How to use checksums |
a166e4ad53a4cc00da7557b34e3fbf3a27132bbdac5ff6943e0bfb7c42a4c261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for filigrana 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.