Skip to content

On-premise users: click in-app to access the full platform documentation for your version of DataRobot.

Prompting reference

The following sections provide basic and more advanced few shot prompting guidance.

Effective prompting strategies

This section uses the following example to identify elements of prompt engineering:

You are a world-renowned poet in the early 1800s. Write a poem in the style of Edgar Allan Poe. It must be 10 sentences long and use “set up, rhyme” format.

Consider the elements through the following images.

Persona

Persona provides a role or voice to ensure that answers resemble a specific counterpart throughout (e.g., profession, known person).

Context and sensitivity

Context is information or nuance that can steer the model toward a given setting (e.g., temporal, subject matter). Specificity provides additional details as part of the context that can lead to better results (e.g., tone and style).

Instruction

Instruction is a specific task you want the model to perform (e.g., write, translate, summarize).

Rules

Rules provide specifications to limit or otherwise restrain the response (e.g., word limit, topics to avoid).

Output format

The output format is the type and/or format of the output. Optionally, you can provide examples (e.g., question/answer, headline) to further refine the desired response.

Example response

Few-shot prompting

Few-shot prompting is a technique for generating or classifying text based on a limited number of examples or prompts—"in-context learning." The examples, or "shots," condition a model to follow patterns in the provided context; it can then generate coherent and contextually relevant text even if it has never seen similar examples during training. This is in contrast to traditional machine learning, where models typically require a large amount of labeled training data. Few-shot prompting makes the model a good candidate for tasks like text generation, text summarization, translation, question-answering, and sentiment analysis without requiring fine-tuning on a specific dataset.

A simple example of few-shot prompting is used in categorizing customer feedback as positive or negative. By showing the model three examples of positive and negative feedback, when the model sees unclassified feedback it can assign a rating based on the first three examples. Few-shot prompting is when you show the model 2 or more examples; zero-shot and one-shot prompting are similar techniques.

The following shows the use of few-shot prompting in DataRobot. In the system prompt field, provide a prompt and some examples for learning:

Given text in a customer support ticket text, determine the name of the product it refers to, as well as the issue type. The issue type can be "hardware" or "software". Format the response as JSON with two keys, "product" and "issue type".

---------------
Examples:

Input: I'm encountering a bug in TPS Report Generator Enterprise Edition. Whenever I click "Generate", the application crashes. Are there any updates or fixes available?
Output: {"product": "TPS Report Generator Enterprise Edition", "issue_type": "software"}

Input: The screen is flickering on my Acme Phone 5+, and I'm unable to use it. What should I do? I want to install a few games and performed a factory reset, hoping it would resolve the problem, but it didn't help.
Output: {"product": "Acme Phone 5+", "issue_type": "hardware"}
---------------

After providing the LLM with that context, try some example prompts:

Prompt: I've noticed a peculiar error message popping up on my PrintPro 9000 screen. It says "PC LOAD LETTER". What does it mean?

Prompt: I cannot install firmware v12.1 on my Print Pro 9002. It says "Incompatible product version".

See the MIT Prompt Engineering Guide for more detailed information.


Updated May 14, 2024