Quality and testing – what we ran into

An AI search that answers wrongly with a convincing citation is worse than no search. Staff trust it because there is a source. Here are the mistakes we made ourselves, and the test we use today: does the cited chunk actually contain the answer?

Last checked:

ChecklistData quality and permissions – the real work
  • Old versions
  • Scanned PDFs without text
  • Permissions that don't follow
  • Data that should never go in

The mistake that taught us most

We built a lookup where a model with Google search had to find out who is behind a phone number. The answers were confident and came with sources. But some of the people did not exist, and the sources returned 404. Other answers pointed to real organisations whose page did not contain the number at all. The rule since then: check that the cited page actually contains the key – the number, the amount, the deadline – not just that the domain looks trustworthy.

In an internal RAG it is the same check, only easier, because you have the text yourself. The code on the recipe page returns the chunks the answer cites. A program can then check whether the key is in them.

A green test is not the same as correct

More than once we have seen tests pass while the result was wrong. In our own product JaKonto, reports from e-conomic showed a result of +2,555.50 while e-conomic itself showed −7,803.13. Every test was green because they ran against mocked data. Only a test against a real demo account found the bug. Elsewhere, 320 tests passed on SQLite while four tables were dead in production on MySQL. And in our Odoo we learned that “no errors” does not mean “delivered”: mail disappeared without a single error message, and we now check delivery by matching message ids.

The lesson for AI search is the same: test against real documents and the real model. We always test on the model that runs in production, with our own test data and a budget per run.

Three kinds of test question

Collect 30–50 real questions staff actually ask – from e-mail, Teams or the helpdesk. For each, write down the word or number the answer must contain. Mix these types:

The test set

TypeExampleCheck
Must answer“What is the notice period for a salaried employee?”the key (“3 months”) is in the answer AND in a cited chunk
Must say “don’t know”“How much is a cup of coffee on Mars?”no sources in the answer
Must not revealan employee without access asks about the management bonusno chunk from a closed document among the sources
Other languagethe same question in Danish or Ukrainiansame source; pick a key that is identical in both languages (a number, a name)
A question passes only if every check in its row holds

The last type is not decoration. When we tested a Danish search in a Ukrainian knowledge base, similarity was 0.048 – practically nothing. With eight generated questions per article at indexing time it rose to 0.84. Without a test question in the other language we would never have seen it.

The test as code

Test questions live in a JSONL file, one line per question. key is what must appear in both the answer and the source. null means the system must say “don’t know”. forbidden lists documents that must never appear as a source for that group.

{"question": "What is the notice period for a salaried employee?", "groups": ["all"], "key": "3 months"}
{"question": "How does the management bonus scheme work?", "groups": ["all"], "key": null}
{"question": "When is salary paid?", "groups": ["all"], "key": "last working day", "forbidden": ["documents/payroll.md"]}

The program uses ask() from the recipe and exits with an error code if even one question fails. That way it can run automatically after every change to documents, model or instructions.

# Run: python evaluate.py test_questions.jsonl
import json
import sys

from rag import ask

passed = 0
cases = [json.loads(line) for line in open(sys.argv[1], encoding="utf-8") if line.strip()]
for c in cases:
    r = ask(c["question"], c["groups"])
    key = c.get("key")                     # the word or number the answer MUST contain
    if key is None:                        # questions the system must NOT be able to answer
        ok, why = not r["sources"], "should have said 'don't know'"
    else:
        in_answer = key.lower() in r["answer"].lower()
        in_source = any(key.lower() in s["text"].lower() for s in r["sources"])
        forbidden = [s["source"] for s in r["sources"] if s["source"] in c.get("forbidden", [])]
        ok = in_answer and in_source and not forbidden
        why = (f"answer={'yes' if in_answer else 'NO'}, source={'yes' if in_source else 'NO'}"
               + (f", forbidden source: {forbidden}" if forbidden else ""))
    passed += ok
    print(("OK  " if ok else "FAIL"), c["question"], "" if ok else f"-> {why}")
print(f"\n{passed}/{len(cases)} passed")
sys.exit(0 if passed == len(cases) else 1)

Run the test again every time you change model. Models disappear: a free Gemini model suddenly answered 404 “no longer available to new users”, and the alias hung for over two minutes. We now keep a chain of models in configuration, so the system moves to the next one on errors. A new model is a new system until the test says otherwise.

Data quality and permissions – the real work

Most bad answers are not the model’s fault but the documents’:

  • Old versions. If the staff handbooks from 2022 and 2025 are both in the folder, search finds both. Clean up, or store a validity date and filter on it.
  • Scanned PDFs without text. extract_text() returns empty text. They need OCR first – that belongs on ai-dokumenter.best-choice.dk.
  • Permissions that don’t follow. Copy files out of SharePoint into a new search and they lose their permissions. Store the group with the document and fetch it from the source at every indexing.
  • Data that should never go in. When we imported a salon booking site’s customer list into Odoo, we left out free-text notes and birthdays. The same thinking applies before documents go into an AI search.

And keep AI in the adviser’s role. In our own product jajob, AI gives scores with citations but never rejects anyone on its own.

GDPR: when documents are sent to an AI

Your documents almost always contain personal data: names in customer cases, payslips in the HR folder, CVs in recruitment. If a model vendor processes them for you, the vendor is a data processor. GDPR Art. 28 then requires a written agreement – electronic is fine – under which the vendor acts only on your documented instructions, including on transfers outside the EU. It must secure the processing under Art. 32, use sub-processors only with written authorisation, and delete or return the data when the work ends. Datatilsynet’s (the Danish Data Protection Agency’s) standard agreement is optional, and the European Commission’s standard clauses are equivalent.

Where is the data processed? Microsoft describes Copilot as an EU Data Boundary service for EU customers, but models from Anthropic, which Microsoft uses as a sub-processor, are currently excluded from that boundary. Pinecone’s free tier is US-only. With your own server in Germany or Finland, the vectors stay in the EU.

Deletion. GDPR has no fixed deletion periods. You set them yourself and need routines for deleting continuously. Delete a document and its chunks and embeddings must go too – in the recipe that happens automatically. But removing an invoice from the AI search is not the same as deleting it: under the Danish Bookkeeping Act (bogføringsloven) accounting records must be kept for 5 years from the end of the financial year.

Only what is needed. Keep special categories such as health data, and free-text notes, out of the index unless the search really needs them. Our inbound route into Odoo accepts only whitelisted fields, so end customers’ data never lands in the CRM.

Records and AI literacy. The exemption from the record of processing for businesses under 250 employees is narrow; add the AI search to your record. Since 27 July 2026, Art. 4 of the AI Act requires you to support your staff’s AI literacy – not to guarantee a particular level. We don’t write your data processing agreement or privacy policy; the templates are at Datatilsynet, and the rules for AI systems are on ai-forordning.best-choice.dk.

Sources

Last reviewed: 2026-12-03

Questions about quality and testing

How many test questions do we need?

Start with 30–50 real questions and add one each time someone reports a bad answer. A bad answer that becomes a test question cannot come back unnoticed.

Can we let an AI grade the answers?

For a first sort, yes. But the most important check – is the key in the source – is a simple text search, which cannot fail the way a model can.

May we send documents with personal data to OpenAI or Microsoft?

Yes, when you have a data processing agreement, know where the data is processed and send only what is needed. Keep special categories such as health data out unless they are necessary.

How often should the test run?

After every change of model, instructions or indexing, and ideally once a week. It costs a few kroner to run.

What do we do with failing questions?

Look at the source first: did the search find the right chunk? If not, it is the search or the document. If it did but answered wrongly, it is the instructions or the model.

Fixed price, no commitment

Get a fixed price for AI on your own data

Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.

  • A fixed price before we start
  • An answer by e-mail, no calls
  • Your details are used only to answer you

Fields marked with * are required.

What is it about?