You are designing a generative AI solution that uses Azure OpenAI Service. The solution must generate code snippets in Python and JavaScript. You need to ensure the model reliably outputs code in the correct language based on user input. Which approach should you use?
A system message sets persistent behavioural instructions applied to every turn, so it constrains the model to emit Python or JavaScript according to the user's request. This satisfies the reliability requirement better than per-prompt phrasing, which the model may inconsistently honour across requests.
Why this answer
System messages in Azure OpenAI Service allow you to set the context or behavior of the model, such as specifying the desired programming language for code generation. This approach is lightweight, requires no retraining, and reliably guides the model to output code in the correct language based on the user's request, leveraging the model's existing training on both Python and JavaScript.
Exam trap
The trap here is that candidates often confuse hyperparameters like temperature and top_p with content control mechanisms, mistakenly believing they can enforce output language, when in fact they only affect randomness and token selection probability.
How to eliminate wrong answers
Option A is wrong because setting top_p to a low value reduces the pool of tokens considered for sampling, which can make outputs more focused but does not control the language of the generated code; it is a nucleus sampling parameter, not a language selector. Option C is wrong because fine-tuning the model on a dataset of code in both languages is overkill for this requirement, as the base model already understands both languages; fine-tuning is typically used for specialized tasks or to adapt to a specific domain, not for simple language switching. Option D is wrong because setting temperature to 0 makes the model deterministic by always choosing the most likely token, but it does not enforce the output language; it can still produce code in the wrong language if the prompt is ambiguous, and it reduces creativity but does not guarantee language adherence.