Skip to content
AI.info

Natural language processing

Robustness, Bias, Privacy, and Domain Shift

Stress-test NLP systems across changing language, uneven social groups, sensitive information, adversarial inputs, and evolving domains.

By the end you can

Example

A routing model that “worked yesterday”

A municipal help desk launches a multilingual classifier with strong held-out accuracy. Within three months, its most costly failures come from inputs that the original test set barely represented.

Each of the five pressures below has a measured, published instance in the sections that follow. Not one of them requires anybody to touch the model.

  • Language change: residents adopt abbreviations introduced by a new benefits program.
  • Channel shift: voice transcripts replace carefully typed web forms — and the transcription error rate is not the same for every resident.
  • Population shift: a community outreach campaign changes who uses the service.
  • Policy shift: two categories merge, while a formerly routine request now requires urgent handling.
  • Adversarial pressure: scammers imitate official wording to reach a protected queue, sometimes through documents the system itself retrieves.

Visual

Five ways the language environment can move

The remedy depends on what changed. So “drift” should not be used as one diagnosis.

Two of the five rows below have been measured, and the figures are worth carrying into the diagram. Surface variation is not free. Five commercial speech-recognition systems — Amazon, Apple, Google, IBM and Microsoft — were run over 19.8 hours of interview audio from 42 white and 73 black speakers across five US cities. Koenecke and colleagues reported the result in PNAS on 23 March 2020: “We found that all five ASR systems exhibited substantial racial disparities, with an average word error rate (WER) of 0.35 for black speakers compared with 0.19 for white speakers.” A 2024 study of nurse-patient speech in home healthcare, in JAMIA Open, reproduced the gap on AWS Transcribe: a median WER of 33% for white patients against 50% for black patients (P = 0.016). The help desk that swaps web forms for voice inherits that penalty on the day the channel changes. Its own accuracy report will still be about typed text.

The adversarial row has a published vocabulary too. NIST's adversarial machine learning taxonomy, published in March 2025 with the U.S. AI Safety Institute and the U.K. AI Security Institute, separates two kinds of prompt injection. Direct injection is made by the system's own user, through query access. Indirect injection is delivered through resource control by a third party — a retrieved document, an email, a web page. OWASP places the same split at LLM01 in its Top 10 for LLM Applications 2025. The consequence is the part teams miss, and §3.4 states it plainly: “In fact, in many cases, it is the primary user of the model who is harmed by the compromise of the integrity, availability, or privacy of the GenAI system through an indirect prompt injection attack.” The attacker need never touch your input box.

FigureHierarchy · 5 levels
  • Surface variation

    Typos, formatting, speech-recognition errors, paraphrases, dialect, and code-switching alter form while intent may remain stable.

    • Covariate or domain shift

      The distribution of documents, speakers, genres, or channels changes.

      • Prevalence shift

        The frequency of labels or intents changes while their meanings remain mostly stable.

        • Concept or policy shift

          The relationship between language and the desired decision changes.

          • Adversarial manipulation

            An actor crafts text to evade, confuse, extract, or redirect the system.

Comparison

Tests that answer different robustness questions

One aggregate robustness score hides whether meaning should stay stable or change.

The taxonomy below is not a house convention. Ribeiro and colleagues introduced CheckList at ACL 2020 with three test types: Minimum Functionality (MFT), Invariance (INV) and Directional Expectation (DIR). The middle two are the first two columns below, under the names their authors gave them.

The worked example is the argument. A commercial sentiment model, already shipped, failed 76.4% of templated negation cases generated from “I {NEGATION} {POS_VERB} the {THING}.” It failed 20.8% of NER invariance cases, where Chicago was swapped for Dallas, and 34.6% of directional cases. A model can hold an aggregate accuracy figure that satisfies a review board and still get three-quarters of a single grammatical construction wrong. The construction is a sliver of the held-out set and a large share of real complaints. The skill also transfers: “In another user study, NLP practitioners with CheckList created twice as many tests, and found almost three times as many bugs as users without it.”

FigureComparison · 4 columns

Invariance tests

Change irrelevant form while preserving the intended meaning.

  • Typos and punctuation
  • Benign paraphrase
  • Name substitution
  • Expected result: stable output

Directional tests

Change meaning in a controlled way and require a corresponding output change.

  • Add or remove negation
  • Move time from past to present
  • Change severity language
  • Expected result: predictable movement

Slice tests

Measure naturally occurring groups, genres, languages, and channels separately.

  • Dialect or locale
  • Document length
  • Input source
  • Expected result: visible disparities

Adversarial tests

Probe malicious or boundary-seeking behavior.

  • Homoglyphs and hidden text
  • Prompt injection in retrieved content
  • Evasion paraphrases
  • Expected result: containment or escalation

Bias enters before, during, and after modeling

Historical text can encode unequal treatment, stereotypes, and gaps in who was documented. Annotation guidelines can reproduce institutional assumptions, while product thresholds can distribute errors unevenly even when the model is unchanged.

Removing a protected attribute does not remove correlated language, geography, occupation, or access patterns; fairness analysis therefore needs a workflow-aware account of where disparities arise.

The annotation pathway has been measured. A classifier trained on the DWMW17 corpus falsely flagged 46.3% of non-offensive African American English tweets as “offensive”, against 9.0% for white-aligned tweets. On FDCL18 the same comparison was 26.0% against 4.5%. Sap and colleagues reported that at ACL 2019, and their abstract names the mechanism: “models trained on these corpora acquire and propagate these biases, such that AAE tweets and tweets by self-identified African Americans are up to two times more likely to be labelled as offensive compared to others”. Davidson and colleagues found the same shape independently across five annotated Twitter datasets, with black-aligned tweets classified offensive at 0.173 against 0.065 for white-aligned tweets, a ratio of 2.65. The intervention that worked in the ACL 2019 study acted on nobody's architecture: priming annotators to consider dialect significantly reduced their offensiveness ratings. The defect was upstream of the loss function.

Another of those pathways sits inside the representation itself. The finding, reported by Bolukbasi and colleagues in 2016, was blunt: “even word embeddings trained on Google News articles exhibit female/male gender stereotypes to a disturbing extent”. The bias had a geometry: “gender bias is first shown to be captured by a direction in the word embedding”. That is what made it measurable. It is also what kept it invisible to anyone auditing the corpus for a protected column.

Bias is a property of the sociotechnical system, not a single column in a dataset.

Key idea

Text is unusually difficult to anonymize reliably

Free text can reveal identity through names, addresses, rare events, writing style, quoted correspondence, or combinations of facts. Simple redaction rules miss indirect identifiers and can remove medically or legally important context.

There is a written rule for the clinical case, and its shape is instructive. HIPAA's Safe Harbor method, at 45 CFR 164.514(b)(2), de-identifies a record only by stripping 18 enumerated categories of identifiers. The list runs from names and dates to IP addresses, voice prints and “any other unique identifying number, characteristic, or code”. Stripping them is not enough on its own. A second condition follows: “The covered entity does not have actual knowledge that the information could be used alone or in combination with other information to identify an individual who is a subject of the information.” That clause exists because the list alone was never expected to be sufficient.

The measured residual is real in both directions. A 2010 review by Meystre and colleagues, in BMC Medical Research Methodology, reports systems reaching 98% recall at 43% precision. One system scrubbed 11,273 of the 11,380 specified identifiers while committing 4,012 over-scrubbing errors. Leaving identifiers behind and destroying 4,012 pieces of clinical context are the same tuning decision seen from two ends.

Use data minimization, access controls, purpose limits, retention rules, encrypted storage, audit logs, and task-specific de-identification; evaluate residual risk rather than declaring a corpus anonymous by inspection.

Retention is the control that most often has a court attached to it. On 31 May 2023 the FTC and DOJ charged Amazon with keeping children's Alexa voice recordings indefinitely and failing to delete transcripts of what children said even after parents asked. Samuel Levine, Director of the FTC's Bureau of Consumer Protection, said in the press release of that day: “Amazon's history of misleading parents, keeping children's recordings indefinitely, and flouting parents' deletion requests violated COPPA and sacrificed privacy for profits.” The stipulated order, entered on 19 July 2023, imposed a $25 million civil penalty and required deletion of inactive child profiles. Note which artefact carried the exposure. The transcript — the text your NLP pipeline created and copied onward — outlived the audio it came from and the deletion request aimed at it.

The extreme case was demonstrated at USENIX Security in 2021. Carlini and colleagues queried GPT-2 until it returned its own training data. They “extract hundreds of verbatim text sequences from the model’s training data”. Those include “(public) personally identifiable information (names, phone numbers, and email addresses), IRC conversations, code, and 128-bit UUIDs”. The attack works “even though each of the above sequences are included in just one document in the training data”. The finding that ages worst is the last: “larger models are more vulnerable than smaller models”. In total the team identified “604 unique memorized training examples”.

De-identification reduces exposure; it does not create a universal guarantee of anonymity.

Analogy

A bridge tested under ordinary traffic and exceptional loads

Engineers test a bridge with daily vehicles, strong winds, unusual weight distributions, and deliberate overload scenarios. Passing one calm-day measurement would not establish safety.

Steel changes visibly under load. Social meaning and policy can change without any visible surface change. A sentiment model that fails 76.4% of one negation template shows nothing on its aggregate gauge. A transcription pipeline that costs one group a 0.35 word error rate against another group's 0.19 looks, on the single averaged number, like one bridge carrying one kind of traffic. Representative tests and targeted stress tests still serve different purposes.

Robustness requires both realistic operating evidence and deliberately difficult challenges.

Steps

Run an NLP risk review before release

The review should connect a failure mechanism to a test, control, owner, and response.

For a high-risk deployment in the EU, steps 3 and 5 are not left to the team's own judgement. Article 15 of the EU Artificial Intelligence Act makes robustness a legal requirement, and Article 15(5) names the attack classes by their technical names: “The technical solutions to address AI specific vulnerabilities shall include, where appropriate, measures to prevent, detect, respond to, resolve and control for attacks trying to manipulate the training data set (data poisoning), or pre-trained components used in training (model poisoning), inputs designed to cause the AI model to make a mistake (adversarial examples or model evasion), confidentiality attacks or model flaws.” The Regulation was published in the Official Journal on 12 July 2024. It came into force on 1 August 2024 and applies from 2 August 2026.

Two neighbouring paragraphs bind the rest of this lesson to the same text. Article 15(3) requires declared accuracy levels in the instructions of use. Article 15(4) requires that feedback loops from continued learning be addressed. A statutory list is a floor for step 3, not a substitute for the domain experts and incident history it asks you to add.

FigureProcess · 5 steps
  1. 1. Map people and consequences

    Identify who produces text, who is described, who receives decisions, and who bears errors.

  2. 2. Inventory sensitive evidence

    Record personal data, confidential content, inferred attributes, and retention requirements.

  3. 3. Enumerate plausible shifts and attacks

    Use domain experts, red teams, and incident history rather than generic checklists alone.

  4. 4. Build measurable challenge suites

    Create invariance, directional, slice, privacy, and adversarial tests with expected behavior.

  5. 5. Define containment and escalation

    Specify abstention, manual review, rate limits, quarantine, rollback, and notification.

A challenge suite should live after launch

A one-time audit cannot anticipate new slang, policy changes, attacks, or data sources; keep high-value tests in regression suites and refresh them from production incidents without leaking protected evaluation sets into routine tuning.

Google Flu Trends is the documented case of a text-driven system decaying while nobody touched the model. GFT ran high in 100 of the 108 weeks from 21 August 2011 to 1 September 2013. It overshot the 2011-2012 season by more than 50%, and by February 2013 it was predicting more than double the CDC's proportion of doctor visits for influenza-like illness. Lazer and colleagues reported that in Science on 14 March 2014. Part of the cause was Google's own product: suggested search terms arrived in June 2011 and symptom-based diagnoses in February 2012, changing the search behaviour the model was reading. The authors call that “blue team” dynamics, and distinguish it from the other direction of pressure: “Red team dynamics occur when research subjects (in this case Web searchers) attempt to manipulate the data-generating process to meet their own goals, such as economic or political gain.” Olson and colleagues had already reported independently, in PLOS Computational Biology, that GFT missed the first wave of the 2009 A/H1N1 pandemic and greatly overestimated the 2012-13 A/H3N2 epidemic. One hundred consecutive-season weeks of error is what an unmonitored deployment looks like from the inside. Nothing crashed.

Monitor input characteristics, output rates, confidence, abstention, user corrections, privacy incidents, and delayed task outcomes by meaningful slices; a statistical alert should send somebody to investigate, not make an automatic claim of harm or model failure.

Release testing becomes operational assurance only when failures feed durable tests and response procedures.

Position

Neither of these risks can be read off the training data

The standard governance move for a language system is to review the corpus: list the sources, check the licences, look for protected attributes, sample some rows, sign the page. That review answers a real question, and it is not either of the two this lesson asks. Both findings here were made on the trained model, and the reason is not that somebody read the corpus carelessly.

The first was made on the vectors. Word embeddings trained on Google News articles exhibit female/male gender stereotypes to a disturbing extent, Bolukbasi and colleagues reported at NIPS 2016, and the shape of the result matters as much as the result: the bias is captured by a direction in the embedding. A direction is not a column. There is no field to inspect and no value to redact. The geometry that made the bias measurable is the same geometry that kept it invisible to anyone auditing the corpus for a protected column. It is legible in the fitted vectors, not in a ledger of sources and fields.

The harder version of the point was made by querying a model until it leaked. Carlini and colleagues ran that attack on GPT-2 at USENIX Security in 2021, and it returned hundreds of verbatim sequences from the training data — among them public personally identifiable information in the form of names, phone numbers and email addresses, along with IRC conversations, code and 128-bit UUIDs, and 604 unique memorized training examples in total. Here the material is in the corpus, which is exactly what makes the result awkward. The attack works even though each of those sequences is included in just one document in the training data. How often a document occurs says nothing about whether the model will hand it back. That is why this lesson tells you to evaluate residual risk rather than declare a corpus anonymous by inspection. And 604 is what one team confirmed, on one public model, by one method — a count of what was found, not of what is there.

So this is an argument about where an audit points. A data review answers a question about inputs. Both of these are questions about a fitted artefact: what geometry the representation acquired, and what the weights returned word for word under attack. Both were answered by interrogating the model, each with a method built to look for one specific thing. A release process that inspects the dataset and then pronounces the model clean has not run either test.

The extraction worked on sequences that appeared in exactly one training document. How often a document occurs says nothing about whether the model kept it.

Draft a risk register for a language feature

Choose a concrete system, such as complaint routing, clinical extraction, or moderation. List at least eight risks across representation, privacy, security, bias, shift, and workflow. Use the cases in this lesson as templates rather than as reading: an ASR channel with a 0.35 against 0.19 word error rate gap, an annotation pipeline flagging 46.3% against 9.0%, a retention rule that a stipulated order priced at $25 million, an indirect injection arriving in a retrieved document, and a hundred high weeks out of 108 that nobody noticed.

For each risk, write one observable indicator, one preventive control, one detection test, one fallback, and one accountable owner. Name the detection test by type — Minimum Functionality, Invariance or Directional Expectation, slice or adversarial — so that the register says what a passing result would mean. Mark any risk that cannot be measured with the data currently collected.

A risk register is useful only when every entry can change a design, test, or operating decision.

Key takeaways