AI Hints
Home›NLP Tutorial›Large Language Models
NLP · Lesson 26 of 106

Prompting for Real Work

Clear instructions, good results.

⏱ 2 min read▶ Video at 46:31🎓 Free
Watch this lesson in the NLP courseWatch on YouTube ↗Full NLP course

Imagine a brilliant new employee on their first day. They know a lot, but nothing about your shop. If you say, handle this complaint, you'll get something generic. If you give them a role, the rules, and an example, you'll get great work. Prompting is exactly that.

Prompting for Real Work
From the video: Prompting for Real Work
  • A brilliant new employee
  • Generic request, generic result
  • Role, rules, and an example

System instructions

We give the model a role, using a system instruction. Kind support agent, two short sentences, offer a replacement. The temperature is low, so that replies are consistent. Run it. It's a warm, specific reply that follows every rule. Scribe can now draft answers for staff. Notice that the system instruction stays the same for all customers. Only the message changes.

support_reply.pypython
from google import genai
from google.genai import types

client = genai.Client()

ticket = "My book arrived with a torn cover and I am really upset."

reply = client.models.generate_content(
    model="gemini-flash-latest",
    config=types.GenerateContentConfig(
        system_instruction="You are a kind support agent at Bright Books. "
                           "Reply in two short sentences. Offer a replacement.",
        temperature=0.3),
    contents=ticket)

print(reply.text)
Output
I am so sorry to hear that your book arrived damaged! I would be more than happy to send you a brand-new replacement right away.

Teaching by example

The most reliable trick is to show examples. This is called few shot prompting. We give three labelled messages, then a fourth to label. Run it. Delivery, with no explanation or extra words, because the examples showed it exactly what we wanted. This handles classification with no training data, and with no training at all. Examples often beat long explanations.

few_shot.pypython
from google import genai

client = genai.Client()

prompt = """Label each message as delivery, refund, or question.

Message: where is my parcel
Label: delivery

Message: i want my money back
Label: refund

Message: do you have this in hardback
Label: question

Message: the courier says it was left next door but nothing is there
Label:"""

print(client.models.generate_content(model="gemini-flash-latest",
                                     contents=prompt).text.strip())
Output
delivery

A prompt checklist

A strong prompt has a few parts. A role. Clear context. An exact task. The format that you want back. And examples if the task is tricky. Tell it what to do, more than what not to do. And test prompts like code, on a set of real examples, because a small change in wording can change results across thousands of messages.

Rolewho it is
Contextwhat it needs to know
Task and formatexactly what you want
Examplesshow, don't tell
Test itlike code

Summary

Role, context, task, format, and examples. Now Scribe writes good replies. But our software needs data, not paragraphs. Next, getting language models to reply in clean, structured form.

Key takeaways
  • System instructions set the role
  • Few-shot beats long instructions
  • Test prompts on real examples
Next up: Structured Output — from words to data