Business context
AI-assisted search of regulatory documentation needs to produce answers that are both correct and supported by the right source material. A fluent response or a plausible-looking citation is insufficient when the content may inform important decisions. The work built a framework for testing answers, citation sources and hostile inputs, providing evidence for deciding whether a system could be trusted and released for public production use.
Implementation
Build from Copilot Studio trials to an Azure evaluation service
I began with trials in Copilot Studio, using regulatory documentation to explore AI-assisted search and the relationship between generated answers and their cited sources. I then moved the search integration into Azure Foundry and deployed a RAG Evaluation App Service and a Foundry Project to support the evaluation work.
The retrieval layer used Azure AI Search (Foundry IQ). Azure AI Search underpins Foundry IQ, providing the search foundation for retrieving relevant material. The evaluation application brought questions, responses and citation evidence together so they could be assessed through repeatable tests.
This separated the user-facing answer from the evidence used to judge it. A result could be inspected for the expected facts, its source attribution and its response to unsafe instructions, then retested as the retrieval or prompting changed.
Retrieval engineering
Understand how chunking and embeddings shape the answer
Retrieval-augmented generation (RAG) depends on supplying the model with relevant evidence. Chunking determines which parts of a regulatory document travel together, so a fragment can lose an exception, definition or qualification if its boundary is poorly chosen. Retaining source identity and context matters as much as retrieving similar language.
Embeddings represent content for similarity-based retrieval, while ranking and the amount of retrieved context influence what reaches the model. This work demonstrated how Jedwards Tech can assess those interactions, inspect retrieved passages and identify whether an answer needs better source context, retrieval tuning or changes to response generation.
Evaluation framework
Turn expected facts and citation evidence into repeatable tests
I built an evaluation framework to assess the correctness of answers and their attached citation sources. Questions needed explicit expectations: the facts an answer should contain, the sources that should support them and the behaviour required when the available evidence could not justify an answer.
Deterministic assertions provided repeatable pass or fail decisions over the captured response and citation evidence. The generated wording could vary between runs; the test logic still needed a stable definition of what counted as acceptable.
Normalising phrases and using pattern matching required care. Differences in case, spacing or equivalent wording should not create unnecessary failures, but a broad match can incorrectly accept an answer that reverses the meaning or omits a material qualification. False positives in an evaluator can make an unreliable system appear ready for use.
Metrics and diagnosis
Measure the right part of the evidence chain
RAG evaluation needs several complementary measures:
- Retrieval relevance: whether useful passages were found.
- Answer correctness: whether the required facts are right.
- Groundedness: whether the response is supported by the supplied context.
- Citation assessment: whether the attached source supports the associated claim.
These measures need to be interpreted against the regulatory question and its expected evidence. A single overall score can conceal the difference between missing source material, an unsupported answer and an evaluator that has matched the wrong phrase.
The evaluation work demonstrated the checks Jedwards Tech can build into a customer solution: investigating false positives, tracing results to their evidence and using test failures to guide improvements. The quality of the evaluator is itself an engineering responsibility.
Adversarial testing
Detect malicious instructions and prompt injection
The framework also addressed malicious instructions and prompt-injection attacks. Regulatory documents and retrieved passages are source material; embedded instructions must not acquire authority over the application or its evaluation rules.
Adversarial cases tested how the system handled attempts to redirect its behaviour and whether the resulting answer and citations remained within the intended task. Detection needed the same care as correctness testing: overbroad patterns can flag harmless text, while narrow ones can miss a differently worded attack.
Outcomes
Demonstrate a practical foundation for customer solutions
The result was a working technical foundation for repeatable evaluation of AI-assisted regulatory search using real Azure resources. It connected retrieval, generated answers, citation evidence and adversarial checks in a process that could be rerun as the implementation changed.
The work highlighted the scope of considerations needed to design a production service: RAG evaluation, chunking, embeddings, meaningful metrics and the quality of the evaluator itself. It demonstrated how Jedwards Tech can implement these practices for customers building new systems, connecting acceptance criteria and source evidence with a governed route to public production use.
Discuss your project
Building trustworthy AI-assisted search?
Contact me to discuss retrieval, citation governance and repeatable evaluations that test the answers your users will rely on.
Discuss an AI engineering engagement