How to guide LLM behavior with example conversations -- show, don't tell.
Few-shot priming is an LLM technique where you provide a few examples of the desired behavior before the actual task. Instead of only relying on system prompts, the model learns patterns from concrete examples of conversations.
System Prompt: "You are a casual Discord bot"
Few-Shot Examples:
User: "yo whats good"
Bot: "nm just chillin, u"
User: "bored af"
Bot: "lol same energy fr"
[Real message comes here]
User: "hey how are you"
Bot: [generates response in the same casual style]
The Luna-Protocol model is a fine-tuned Qwen2.5 1.5B trained on only 200k samples from the Discord-Dialogues dataset. This limited training data means:
Few-shot is handled server-side by Sapphire, not in the bot config. Edit Sapphire's few_shot_examples.yml file:
# few_shot_examples.yml
- user: "hello"
assistant: "hey, what's up?"
- user: "how are you"
assistant: "doing good tbh, just chilling"
Or set environment variables on Sapphire startup:
SAPPHIRE_FEW_SHOT_ENABLED=true \
SAPPHIRE_FEW_SHOT_EXAMPLES=./few_shot_examples.yml \
python server.py
SAPPHIRE_FEW_SHOT_ENABLED=false python server.py
Good: 3-5 high-quality examples
few_shot_examples:
- user: "yo"
assistant: "sup"
- user: "whats up"
assistant: "nm, hbu"
Bad: 20 mediocre examples (wastes tokens, dilutes pattern)
Casual bot:
few_shot_examples:
- user: "hey luna"
assistant: "yooo sup"
Professional bot:
few_shot_examples:
- user: "Hello, can you help?"
assistant: "Of course, I'm happy to assist."
Sarcastic bot:
few_shot_examples:
- user: "are you smart"
assistant: "yeah sure, whatever makes you sleep at night lol"
If you want brief responses, keep examples brief. If you want detailed responses, use longer examples.
Include different types of interactions: greetings, questions, statements, follow-ups, expressions.
Examples should sound natural, like real conversations:
Good: "yo whats good" → "nm just chillin, u"
Weird/Robotic: "I would like to inquire about your status" → "AFFIRMATIVE: I AM FUNCTIONING AT OPTIMAL CAPACITY"
Few-shot injection happens server-side in Sapphire (Python), not in the bot:
few_shot_examples.yml via load_few_shot_examples()/v1/respond request, format_few_shot_examples() converts them to message objectsinject_few_shot_into_conversation() inserts them after the system prompt, before conversation history[system_prompt] + [examples] + [conversation_history]Bots are thin SSE clients -- they send { username, text, session_id } to Sapphire and receive streamed tokens. No few-shot logic runs in the bot.
--cache-reuse), examples are cached after first requestIn Sapphire's src/sapphire/few_shot.py:
def inject_few_shot_into_conversation(
messages: list[dict],
few_shot_messages: list[dict],
) -> list[dict]:
system_idx = None
for i, m in enumerate(messages):
if m.get("role") == "system":
system_idx = i
break
if system_idx is not None:
result = messages[:system_idx + 1] + few_shot_messages + messages[system_idx + 1:]
else:
result = few_shot_messages + messages
return result
few_shot_examples.yml)- user: "yo whats good"
assistant: "nm just chillin, u"
- user: "bored af"
assistant: "lol same energy fr"
- user: "hey how are you"
assistant: "im doing pretty good tbh, just vibing"
- user: "whats up"
assistant: "yooo not much, what about you"
- user: "how was your day"
assistant: "it was alright, nothing crazy happened lol"
- user: "how do i do this"
assistant: "hmm usually you can just... try restarting first?"
- user: "thanks that worked"
assistant: "nice! glad i could help"
- user: "one more question"
assistant: "sure go ahead, what's up"
- user: "Hello, can you assist?"
assistant: "Of course, I'd be happy to help. What do you need?"
- user: "Thank you for your time"
assistant: "You're very welcome. Please don't hesitate to reach out again."
Check:
SAPPHIRE_FEW_SHOT_ENABLED=true env var on Sapphire startupuser and assistant keys in few_shot_examples.yml"N few-shot examples (enabled=True)"Solution:
Solution:
Solution:
few_shot_examples.ymlSAPPHIRE_FEW_SHOT_ENABLED=false env var to disable temporarily| Model Size | Impact |
|---|---|
| Small (1.5B) | ⭐⭐⭐⭐⭐ Significant improvement |
| Medium (7B) | ⭐⭐⭐⭐ Good improvement |
| Large (13B+) | ⭐⭐⭐ Modest improvement |
| Very Large (70B+) | ⭐⭐ Minimal improvement |