hands-on lab

Formatting Large Language Model Inputs With LangChain Prompt Templates

Beginner
Up to 45m
2
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

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:

Environment before

Environment after

About the author

Avatar
Jun Fritz, opens in a new tab
Cloud Labs Developer
Students
40,940
Labs
111
Courses
1
Learning paths
6

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics

Lab steps

Introducing LangChain Prompt Classes
Compiling Prompt Templates With LangChain and LangChain Hub