Prompt Engineering
Since everything the model knows about your task comes from the prompt, writing good prompts is a real skill. Two principles carry most of the weight.
Be specific, not vague
A vague prompt invites a vague (or wrong) answer. Compare:
# vague
"summarize this"
# specific
"Summarize this in 2 sentences for a non-technical reader. "
"Lead with the single most important number."State the format, the audience, the length, and what to focus on. The model is not a mind reader; it is a text predictor.
Show examples (few-shot prompting)
The most reliable trick is to show the model a few input/output pairs before your real question. This is called few-shot prompting, and it teaches the pattern far better than describing it:
Classify the sentiment.
Input: good
Output: positive
Input: awful
Output: negative
Input: great
Output:The model sees the shape of the task and continues it, filling in the final Output:. Leaving that last line open is the cue to answer.
Try it for real
In the Floati app, once an on-device model is loaded you can pass a string like this straight to it (for example await engine.chat(prompt) in the AI panel) and watch it complete the last line. We cannot run the live model inside this grader (it needs WebGPU and is non-deterministic), so here you will build the prompt string, which is the part you fully control.
Write few_shot_prompt(task, examples, query). It returns a string: the task line, then a blank line, then each (inp, out) example rendered as a Input: <inp> line followed by an Output: <out> line, then a final Input: <query> line and a trailing Output: for the model to complete. Join everything with newlines. Then set prompt = few_shot_prompt("Classify the sentiment.", examples, "great").
This lesson is locked
Lessons open one at a time. Finish the previous lesson to unlock this one.