
Llama prompts work best when the request matches the selected checkpoint's training and message format. Pick the exact generation first, then give it a clear task, the context it should use, and a concrete response shape.
Choose the right checkpoint
Use an Instruct checkpoint for assistant-style dialogue. A base checkpoint is trained to continue text and may continue your prompt instead of following it as a chat request. Code Llama also has base, Python-specialized and Instruct variants; use the Instruct version for natural-language coding requests. See the Llama 3.1 model card and Code Llama repository for their variant descriptions.
Let the tokenizer apply the chat template
When calling a chat API, pass structured system, user and assistant messages and let the runtime apply the template bundled with the checkpoint. This avoids mismatches in special tokens and whitespace. If an inference engine asks for a raw Llama 3 style prompt, its turn structure looks like this:
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{{system_prompt}}<|eot_id|><|start_header_id|>user<|end_header_id|>
<|eot_id|><|start_header_id|>assistant<|end_header_id|>
