Grounding gives a generative model relevant external information as context for its response. For example, a technical support assistant can use service documentation to answer questions about a product. The information can be specific to the use case and absent from the model’s training data. section 3.4.1 section 7.2
For a small amount of information, include the context in a system message alongside instructions for using it. For larger datasets, use embeddings and semantic search to retrieve the most relevant information. Retrieval-augmented generation (RAG) is a common grounding approach. section 3.4.1 section 7.2
Listing 3.22 Grounding system message example
{"role": "system", "content": Assistant is an intelligent chatbot designed to help users answer technical questions about Azure OpenAI service. Only answer questions using the context below. Don’t make up the answer. If you are unsure of an answer, say 'I don't know'.
Context:
- Azure OpenAI Service provides REST API access to OpenAI's powerful language models including the GPT-3, Codex and Embeddings model series.
- Azure OpenAI Service gives customers advanced language AI with OpenAI GPT-3, Codex, and DALL-E models with the security and enterprise promise of Azure.
..."
},
{"role": "user", "content": "What is Azure OpenAI Service?"}
This system message supplies Azure OpenAI Service facts and instructs the assistant to answer only from that context or say it does not know. section 3.4.1
Grounding can make answers more relevant and reduce hallucinations, but it does not guarantee correctness. A larger context window is not automatically a substitute for selecting relevant data: long contexts can increase complexity, while finite context windows and token costs constrain what an application can send. section 7.2 section 8.1.1 section 3.5
Grounding code suggestions
GitHub Copilot uses the edited file and other open tabs and files alongside the prompt as context for suggestions. An existing solution can therefore provide context that an otherwise empty solution does not. section 5.1.2







