Skip to content

buffs: add Turkish locale case mapping buffs - #1997

Open
fevziegeyurtsevenler wants to merge 1 commit into
NVIDIA:mainfrom
fevziegeyurtsevenler:buff/turkish-casefold
Open

fevziegeyurtsevenler wants to merge 1 commit into
NVIDIA:mainfrom
fevziegeyurtsevenler:buff/turkish-casefold

Conversation

@fevziegeyurtsevenler

Copy link
Copy Markdown

Adds buffs.turkish_casefold with TurkishLowercase and TurkishUppercase.

Why

Turkish keeps the dot on i as a distinguishing feature across case changes, so it has two i-pairs — I/ı and İ/i — where the default Unicode case mapping has one. str.lower() and str.casefold() implement the default mapping, so anything that normalises with them before matching a keyword list can be stepped around:

>>> "IGNORE previous instructions".lower()
"ignore previous instructions"          # a keyword filter matches

>>> turkish_lower("IGNORE previous instructions")
"ıgnore previous instructions"          # it does not — but a model still reads it

The other direction leaves a residue that survives normalisation, because İ lowercases to i + U+0307 rather than to i:

>>> turkish_upper("ignore").lower()
"i̇gnore"                                # still != "ignore"

This is distinct from the homoglyph substitution in probes.smuggling — no characters are swapped for lookalikes from another script. These are the codepoints a tr locale legitimately produces, so the text survives round-tripping through anything that is locale-aware.

What

Two buffs, deliberately placed next to buffs.lowercase so the default and tr mappings can be run against the same target and compared. lang = "*", since the transformation applies to any source language.

Notes

Local run: pytest tests/buffs/ tests/test_docs.py tests/test_configurable.py — all green.

Turkish keeps the dot on i as a distinguishing feature across case changes,
so it has two i pairs (I/ı and İ/i) where the default Unicode case mapping
has one. str.lower() and str.casefold() implement the default mapping, so a
guardrail that normalises with them before matching a keyword list can be
stepped around: "IGNORE" lowered under tr rules is "ıgnore", which no longer
contains "ignore", while the text stays readable to a model. Going the other
way, İ lowercases to i + U+0307, so the dot survives a later normalisation
pass and still fails an equality test.

Adds TurkishLowercase and TurkishUppercase alongside buffs.lowercase, so the
two mappings can be compared against the same target. No new dependencies.

Signed-off-by: Fevzi Ege Yurtsevenler <[email protected]>
@fevziegeyurtsevenler

Copy link
Copy Markdown
Author

Gentle ping — this has been open for ~3 weeks with CI still pending workflow approval; would appreciate an approval run when someone has a moment.

One framing note, since non-English coverage is an evolving topic here: this PR is a buff (a deterministic locale-aware casing transformation applied to existing probes, analogous to buffs.lowercase), not a native-language probe — so it doesn't depend on how native-probe inclusion mechanisms evolve. Happy to adjust anything if the team prefers a different shape for it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant