This repository contains samples to convert GPT text prompts to text prompts for Large Language Models (LLMs) on Amazon Bedrock.
A prompt to a Large Language Model (LLM) is an instruction provided to it to produce an output. There are many text prompting techniques.
This sample will walk you through examples of converting GPT text prompts to text prompts for LLMs available on Amazon Bedrock.
We will use the following process for prompt conversion,
- Step 1: Decompose the GPT text prompt into prompt elements using Anthropic Claude 3 or Anthropic Claude 3.5 Sonnet available on Amazon Bedrock. These constructs are,
- Context
- Input Data
- Output Indicator
- Instruction
- Step 2: Parse these constructs using a Python script and create the text prompts for the various LLMs available on Amazon Bedrock.
We will cover the following types of prompts,
- Zero-Shot Prompting
- Few-Shot Prompting
- Chain-of-Thought Prompting
- Self-Consistency
- Generated Knowledge Prompting
Note:
- These notebooks should only be run from within an Amazon SageMaker Notebook instance or within an Amazon SageMaker Studio Notebook
- These notebooks use text based models along with their versions that were available on Amazon Bedrock at the time of writing. Update these as required.
- At the time of this writing, Amazon Bedrock was only available in these supported AWS Regions. If you are running these notebooks from any other AWS Region, then you have to change the Amazon Bedrock client's region and/or endpoint URL parameters to one of those supported AWS Regions. Follow the guidance in the Organize imports section of the individual notebooks.
- On an Amazon SageMaker Notebook instance, these notebooks are recommended to be run with a minimum instance size of ml.t3.medium and with Amazon Linux 2, Jupyter Lab 3 as the platform identifier.
- On an Amazon SageMaker Studio Notebook, these notebooks are recommended to be run with a minimum instance size of ml.t3.medium and with Data Science 3.0 as the image.
- At the time of this writing, the most relevant latest version of the Kernel for running these notebooks were conda_python3 on an Amazon SageMaker Notebook instance or Python 3 on an Amazon SageMaker Studio Notebook.
This prompt conversion process has been provided to accelerate your migration from GPT to LLMs on Amazon Bedrock. You must review the converted prompts for accuracy, optimize and test them before using in your projects.
This repository contains
-
A Python script that contains helper functions.
-
A prompt templates folder that contains the prompts for Anthropic Claude 3 and 3.5 to perform Step 1 of the prompt conversion.
-
A source prompts folder containing example GPT prompts for the various prompt types mentioned above.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.