Michalina Graczyk

Testing AI robustness: How to protect an LLM from an unpredictable user, or tester?

5 min read
🇬🇧
LLMQARobustnessEvalsTesting

This post is translated from Polish. Read the original

In the previous part we talked about Guardrails and Safety, that is, how to stop the model from doing illegal or dangerous things.

Now we come back down to earth. In real life, the QA team’s problem is rarely hackers. The main problem is… ordinary users.

The ones who type in a hurry on their phone. The ones who paste a three-page email instead of a short question. Or the ones who lose spaces and Polish diacritics. Your model must handle all of this. We call it Robustness.

Safety versus Robustness

Many people confuse these two concepts. Let’s sort it out right away.

Safety makes sure the model does not do bad things (for example, does not help build a bomb). We call this working in hostile (adversarial) conditions.

Robustness makes sure the model still does its legitimate tasks well, even if the input conditions are dirty (noisy). It is testing resistance to chaos, carelessness and strange user behavior.

Your LLM cannot break just because someone wrote “wehre” instead of “where”.

A real-life example: a parcel tracking assistant

Imagine you are testing an AI assistant for a big courier company (heh heh.) The bot’s job is to give the status of a parcel based on the tracking number.

In our ideal tests, in a sterile development environment, the test prompt looks like this: “Please give me the status of the shipment with number 123456789.”

The model returns an answer with no problem: “Parcel 123456789 is at the delivery branch. Expected delivery time: 14:00.” Everything is green. But in production, such an assistant hits a wall. “Dirty” data from users is a fast track to lower quality and model hallucinations. What situations do we need to test?

1. Text distortions (Perturbations and Typos)

A user walks down the street in the rain, holds an umbrella in one hand and types with their thumb. They type: “wehre my prcel 123456789 quick”.

Will your model understand the intent, ignore the typos and extract the correct number? Distortions include spelling mistakes, missing Polish diacritics, random capital letters and words stuck together. Robustness means that the model’s Accuracy does not drop drastically with such distortions.

2. Information noise (Noise injection)

The customer has no time to retype the number. They copy the whole email from the shop that starts with “Hello, thank you for shopping in our store…”, then there is a list of products, a footer, a GDPR consent, and somewhere at the bottom a note: “your shipping code is: 123456789”. Below it the customer adds: “when do i finaly get it??”.

Flooded with unnecessary text, models can lose focus. They focus on the GDPR text instead of the task. Adding noise to tests is a basic tactic to verify robustness.

3. Input format change (Formatting)

Instead of a number, the user pastes a whole unstructured chunk of an Excel table without columns. Messy text with spaces instead of tabs. Or they forget to use structured tags. Models often expect a specific input (for example JSON), and a backend parser failure cuts off the closing character of the structure. Will the model throw up its hands and return a technical system error, or will it try to interpret the intent?

How to test Robustness?

You do not look for these cases manually before every push to production. You use a concept known as Data Augmentation.

You take the Golden Set you built earlier. It holds your beautiful reference prompts. Then you run them through a simple script before the test.

This script (often another, smaller local AI model, or just a Python function) deliberately:

  • “breaks” the text with typos (for example, swaps 5% of characters),
  • adds blocks of random text at the beginning or at the end,
  • removes punctuation.

Then you send these “dirty” prompts to the model under test. Next, you use your Evals categories to check whether, despite the weak prompt, the model still delivers correct answers. You evaluate the difference in quality between a clean request and a “dirty” one.

And here comes the key point: when you test dozens or hundreds of spelling and formatting variants this way, you will not manage (and you should not even try) to evaluate all of it by hand. This is the perfect moment to bring in automation in the form of LLM-as-a-Judge. Another language model will easily evaluate the differences in Fidelity, Accuracy or Tone between both variants in a fraction of a second, and scale your robustness tests.

QA checklist for this post

  • Have you defined how “dirty” the input data the application can handle is (what is the threshold for spelling and syntax errors)?
  • Does your test pipeline automatically add information noise to clean prompts (Noise Injection)?
  • Do you check the behavior with unexpected changes in letter case, page layout format, missing punctuation?
  • Do you verify the robustness of context memory in a long conversation (when in the fifth message someone mentions the parcel from message number one)?
  • Do you manage to verify the change in effectiveness (Accuracy) for an ideal prompt vs one “taken from the street”?

Summary

Robustness is not a luxury add-on. Users rarely care about correct punctuation in a chat with AI. When you test Robustness, you prove that the system will work in production as well as it works in perfectly staged demo meetings.

It is one of those things that separate a cool tech demo from a solid product for customers. Take care of it!

In the next article of the series we will cover LLM-as-a-Judge, that is, how to hire one model to test another in practice (and what can go wrong). Talk soon!

Stay up to date with LLM and QA! 🚀

Practical notes on testing, QA processes and modern quality strategy. No fluff - for testers and leaders who want to get quality right. The newsletter is in Polish.

When you join, you agree to receive news from me. You can unsubscribe at any time.