|
|
LLM System Prompts - Design Patterns and Best Practices
Author: Venkata Sudhakar
ShopMax India runs customer-facing chat features powered by LLMs - from product recommendation bots to support agents. The system prompt controls the model's persona, scope, and behaviour across every conversation. Well-designed system prompts reduce off-topic responses and ensure consistent brand voice across all interactions.
A system prompt is passed as the first message with role "system" in the messages array. Key design patterns include role assignment ("You are a ShopMax India support agent"), scope restriction, output format instructions, and escalation rules. Version-controlling prompts alongside code is essential as prompt changes can significantly alter model behaviour in production.
The below example shows how ShopMax India structures a system prompt for a product recommendation chatbot using the OpenAI API.
It gives the following output,
For a college student in Bangalore, I recommend the Lenovo IdeaPad Slim 3
at Rs 42,000 - good balance of performance and battery life for academics.
Alternatively, the HP Pavilion 15 at Rs 48,000 includes a dedicated GPU
for students who need more power.
Are you looking for something more budget-friendly, or would you like to
explore premium options like the Dell XPS 13?
Maintain separate system prompts for different use cases at ShopMax India (support, sales, returns) and A/B test them using conversation quality metrics. Avoid putting sensitive business logic in system prompts as they can be revealed by users with prompt injection techniques. Store prompts in a configuration file rather than hardcoding so non-engineers can update them without code deployments.
|
|