Get startedGet started for free

Guiding unstructured responses

1. Guiding unstructured responses

In this video, we'll explore how to guide Llama's responses to be more aligned with specific tasks.

2. Controlling model output

Even after setting the appropriate parameters and roles, we may find that the responses generated by Llama need further refinement. There are a few techniques we can use to achieve this:

3. Controlling model output

refining prompts to provide clearer instructions,

4. Controlling model output

leveraging zero-shot and few-shot prompting, and

5. Controlling model output

using stop words to limit unnecessary text.

6. Refining prompts

Let's say we're using Llama to summarize industry trends for a quarterly report. We would ask: 'Summarize key trends in the aviation industry from the last year, focusing on fuel efficiency innovations' or 'Tell me about the aviation industry'? The first prompt is specific, and will be more effective in generating the response we're looking for.

7. Components of effective prompting

To create effective prompts, we should: be

8. Components of effective prompting

precise, avoid

9. Components of effective prompting

ambiguity and vague prompts, use

10. Components of effective prompting

keywords,

11. Components of effective prompting

action words, and, if possible,

12. Components of effective prompting

provide examples.

13. Zero-shot prompting

When we can't provide an example, we use zero-shot prompting, meaning we give the model a single instruction. It works well for simple tasks, like generating a summary. For example, if we need a high-level report, we might use: 'Summarize recent mergers in the airline industry.'

14. Refining zero-shot prompts

However, even with general questions, models can sometimes struggle to distinguish between the task, expected output, and any additional context if the prompt is long and unstructured. To improve clarity, we can use clear labels to separate these elements, helping the model understand what's needed. For example, adding 'Instruction', 'Question', and 'Answer' labels ensures the model recognizes what it should do, the specific query being asked, and is prompted to respond.

15. Few-shot prompting

For even more structured responses, we use few-shot prompting by providing examples. This helps the model recognize the expected format and generate consistent outputs. For instance, if we want Llama to generate structured aircraft fuel efficiency comparisons, we can show a pattern that includes

16. Few-shot prompting

the aircraft model,

17. Few-shot prompting

passenger capacity,

18. Few-shot prompting

and fuel consumption.

19. Few-shot prompting

Then, we ask the model to continue the entries using the same format.

20. Using stop words

Sometimes, Llama generates long responses when only concise insights are needed. By using stop words, we can end the response at a specific point. For example, if we're working on a question-answering application for flight tracking, we may want to stop responses before they continue into the next question. To prevent the model from generating output beyond the first answer, we set the 'stop' argument to 'Q:', ensuring the assistant only answers one question at a time without continuing into unrelated queries.

21. Let's practice!

Let's practice generating efficient prompts by combining these techniques.