Understanding Grounding Under the Hood

Ok, now I understand.

Your question was more about “how do I validate the response given to my prompt by a 3rd party service (chatbot, APIs etc)?”

The answer stays the same: by surrounding your call to the service/bot/app with your 2 “grounding” workflows:

  1. You build your prompt to contain the “trustful sources” and the query [1]
  2. 3rd party produces an answer (from your point of view this is a black box which may or not contain its own “grounding” / “validation” logic, so best take is NEVER TRUST IT BLINDLY)
  3. you check if the answer is valid/uses the provided sources and how the sources where used.

Originally, I was talking more about how to build the grounding in that “black box” that you expose as a (3rd party) service to someone.

[1] - in your example the prompt you send would be something like this:

Related information you may use:

…The capital of France is Paris… (source_id: 1, source_url: https://www.coe.int/en/web/interculturalcities/paris )
…Paris is the capital of France… (source_id: 2, source_url: https://en.wikipedia.org/wiki/Paris)
—
User message:

What is the capital of France?
—
Answer format template:

{$answer text} [{id: {$answer_source_id}, url: {$answer_source_url}}]
—
Answer: