Skip to content

aws-samples/convert-gpt-text-prompts-to-amazon-bedrock-llm-prompts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Convert GPT text prompts to text prompts for LLMs on Amazon Bedrock

This repository contains samples to convert GPT text prompts to text prompts for Large Language Models (LLMs) on Amazon Bedrock.

Overview

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,

  1. Zero-Shot Prompting
  2. Few-Shot Prompting
  3. Chain-of-Thought Prompting
  4. Self-Consistency
  5. 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.

Disclaimer

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.

Repository structure

This repository contains

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

How to convert GPT text prompts to text prompts for Large Language Models (LLMs) on Amazon Bedrock.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published