Grounding Gemini and making the model stay focused on the grounding docs

I’m working on an app in which I’ve grounded Gemini 1.5 Pro in a Vertex AI Search app and data store. The user chats with the model, the intended use case being that they ask questions related to the subject matter covered in the grounding documents.

I need the model to consistently and reliably decline to answer the following prompts:

  1. Questions for which the answer cannot be found in the grounding documents
  2. Questions that are entirely unrelated to the grounding documents

I’ve also observed that the model sometimes provides a citation and sometimes doesn’t, even in response to the exact same prompt. I’d like the model to always provide a citation whenever one is available.

My question is, are there particular settings (system instructions, temperature, top-P, something else?) that will make the model consistently behave in the ways I’ve described above? (Or, given my needs, perhaps a different tool/approach is more appropriate?)

Thanks for your help.

Hello lambdalove,

There are two different grounding tools for Gemini model responses to Google Search and for Gemini to a Vertex AI Search data store. For further exploration with regards to consideration, citation, and parameters here are the detailed documentations that includes code sample, see the following:

For different tool/approach you may also consider these models:

I hope the above information is helpful.