LangChain — Prompt Template

Tony
7 min readDec 28, 2023

What is a Prompt

A “prompt” is a carefully crafted input that is given to a language model to elicit a specific desired response. Prompts are essentially instructions or questions designed to guide the model’s output in a certain direction. They play a crucial role in interacting with models like GPT (Generative Pre-trained Transformer) and other AI language systems.

A basic prompt structure looks like:

  • Instructions: Informs the model about the general task at hand and how to approach it, such as how to utilize provided external information, process queries, and structure the output. This is typically a more constant section within a prompt template. A common use case involves telling the model “You are a useful XX assistant,” prompting it to take its role more seriously.
  • Context: It acts as an additional source of knowledge for the model. This information can be manually inserted into the prompt, retrieved through vector database searches, or brought in through other methods (like calling APIs, using calculators, etc.). A common application is to pass knowledge obtained from a vector database search to the model as context.

--

--

Tony
Tony

Responses (2)