Formatting Large Language Model Inputs With LangChain Prompt Templates
Description
Prompt templates are a critical component of the LangChain framework. They are used to format the input to large language models (LLM) by replacing placeholders with actual values. The nature of these templates can vary depending on the use case, but they will typically include a prompt string, a list of input parameters, and formatting logic to generate the final prompt string. To assist developers with managing these templates, LangChain also provides version-control and sharing capabilities through the LangChain Hub.
In this lab, you will learn how to create custom prompts using LangChain templates and placeholders. You will also explore pre-built templates from the LangChain Hub.
Learning objectives
Upon completion of this beginner-level lab, you will be able to:
- Format LangChain prompt templates using the PromptTemplate and ChatPromptTemplate classes
- Leverage the Messages class to provide additional context to large language models
- Pull and format pre-built templates from the LangChain Hub
Intended audience
- Candidates for the AWS Certified Machine Learning Specialty certification
- Cloud Architects
- Software Engineers
Prerequisites
Familiarity with the following will be beneficial but is not required:
- Python
- LangChain
- Amazon Bedrock
The following content can be used to fulfill the prerequisites: