Sample foundation model prompts for common tasks
Sample foundation model prompts for common tasks Try these samples to learn how different prompts can guide foundation models to do common tasks. How to use this topic Explore the sample prompts in this topic: * Copy and paste the prompt text and input parameter values into the Prompt Lab in IBM watsonx.ai * See what text is generated. * See how different models generate different output. * Change the prompt text and parameters to see how results vary. There is no one right way to prompt foundation models. But patterns have been found, in academia and industry, that work fairly reliably. Use the samples in this topic to build your skills and your intuition about prompt engineering through experimentation. This video provides a visual method to learn the concepts and tasks in this documentation. Video chapters [ 0:11 ] Introduction to prompts and Prompt Lab [ 0:33 ] Key concept: Everything is text completion [ 1:34 ] Useful prompt pattern: Few-shot prompt [ 1:58 ] Stopping criteria: Max tokens, stop sequences [ 3:32 ] Key concept: Fine-tuning [ 4:32 ] Useful prompt pattern: Zero-shot prompt [ 5:32 ] Key concept: Be flexible, try different prompts [ 6:14 ] Next steps: Experiment with sample prompts Samples overview You can find samples that prompt foundation models to generate output that supports the following tasks: * [Classification](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=enclassification) * [Extraction](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=enextraction) * [Generation](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=engeneration) * [Question answering (QA)](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=enqa) * [Summarization](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensummarization) * [Code generation and conversion](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=encode) * [Dialogue](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=endialogue) The following table shows the foundation models that are used in task-specific samples. A checkmark indicates that the model is used in a sample for the associated task. Table 1. Models used in samples for certain tasks Model Classification Extraction Generation QA Summarization Coding Dialogue flan-t5-xxl-11b ✓ ✓ flan-ul2-20b ✓ ✓ ✓ gpt-neox-20b ✓ ✓ ✓ granite-13b-chat-v1 ✓ granite-13b-instruct-v1 ✓ ✓ granite-13b-instruct-v2 ✓ ✓ ✓ llama-2 chat ✓ mpt-7b-instruct2 ✓ ✓ mt0-xxl-13b ✓ ✓ starcoder-15.5b ✓ The following table summarizes the available sample prompts. Table 2. List of sample prompts Scenario Prompt editor Prompt format Model Decoding Notes [Sample 1a: Classify a message](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample1a) Freeform Zero-shot * mt0-xxl-13b <br>* flan-t5-xxl-11b <br>* flan-ul2-20b Greedy * Uses the class names as stop sequences to stop the model after it prints the class name [Sample 1b: Classify a message](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample1b) Freeform Few-shot * gpt-neox-20b <br>* mpt-7b-instruct Greedy * Uses the class names as stop sequences [Sample 1c: Classify a message](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample1c) Structured Few-shot * gpt-neox-20b <br>* mpt-7b-instruct Greedy * Uses the class names as stop sequences [Sample 2a: Extract details from a complaint](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample2a) Freeform Zero-shot * flan-ul2-20b <br>* granite-13b-instruct-v2 Greedy [Sample 3a: Generate a numbered list on a particular theme](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample3a) Freeform Few-shot * gpt-neox-20b Sampling * Generates formatted output <br>* Uses two newline characters as a stop sequence to stop the model after one list [Sample 3b: Generate a numbered list on a particular theme](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample3b) Structured Few-shot * gpt-neox-20b Sampling * Generates formatted output. <br>* Uses two newline characters as a stop sequence [Sample 3c: Generate a numbered list on a particular theme](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample3c) Freeform Zero-shot * granite-13b-instruct-v1 <br>* granite-13b-instruct-v2 Greedy * Generates formatted output [Sample 4a: Answer a question based on an article](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample4a) Freeform Zero-shot * mt0-xxl-13b <br>* flan-t5-xxl-11b <br>* flan-ul2-20b Greedy * Uses a period "." as a stop sequence to cause the model to return only a single sentence [Sample 4b: Answer a question based on an article](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample4b) Structured Zero-shot * mt0-xxl-13b <br>* flan-t5-xxl-11b <br>* flan-ul2-20b Greedy * Uses a period "." as a stop sequence <br>* Generates results for multiple inputs at once [Sample 4c: Answer a question based on a document](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample4c) Freeform Zero-shot * granite-13b-instruct-v2 Greedy [Sample 4d: Answer general knowledge questions](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample4d) Freeform Zero-shot * granite-13b-instruct-v1 Greedy [Sample 5a: Summarize a meeting transcript](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample5a) Freeform Zero-shot * flan-t5-xxl-11b <br>* flan-ul2-20b <br>* mpt-7b-instruct2 Greedy [Sample 5b: Summarize a meeting transcript](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample5b) Freeform Few-shot * gpt-neox-20b Greedy [Sample 5c: Summarize a meeting transcript](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample5c) Structured Few-shot * gpt-neox-20b Greedy * Generates formatted output <br>* Uses two newline characters as a stop sequence to stop the model after one list [Sample 6a: Generate programmatic code from instructions](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample6a) Freeform Few-shot * starcoder-15.5b Greedy * Generates programmatic code as output <br>* Uses <end of code> as a stop sequence [Sample 6b: Convert code from one programming language to another](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample6b) Freeform Few-shot * starcoder-15.5b Greedy * Generates programmatic code as output <br>* Uses <end of code> as a stop sequence [Sample 7a: Converse in a dialogue](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample7a) Freeform Custom structure * granite-13b-chat-v1 Greedy * Generates dialogue output like a chatbot <br>* Uses a special token that is named END_KEY as a stop sequence [Sample 7b: Converse in a dialogue](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-prompt-samples.html?context=cdpaas&locale=ensample7b) Freeform Custom structure * llama-2 chat Greedy * Generates dialogue output like a chatbot <br>* Uses a model-specific prompt format Classification Classification is useful for predicting data in distinct categories. Classifications can be binary, with two classes of data, or multi-class.