
LANGCHAIN — The Prompt Landscape
Software is like entropy: It is difficult to grasp, weighs nothing, and obeys the Second Law of Thermodynamics; i.e., it always increases. — Norman Augustine.
Prompt engineering has become an essential technique to influence the behavior of large language models (LLMs) without making changes to the model weights. This article provides an overview of various categories of prompts and multiple interesting examples.
Reasoning
Chain-of-thought reasoning encourages the LLM to spread its “thinking” across multiple tokens. It has shown significant improvements in reasoning tasks and is relatively easy to implement. Here’s a simple statement as an example:
prompt = "Let's think step by step"Deepmind has used LLMs to optimize prompts and achieved exceptional performance. This demonstrates the potential for translation modules between human instruction and LLM-optimized prompts.
Writing
Prompts to enhance writing clarity and style have gained popularity. Here are a few examples:
prompt_1 = "Improve writing clarity"
prompt_2 = "Customize writing style"Diverse content generation prompts for onboarding emails, blog posts, tweet threads, and educational materials have also been widely adopted.
SQL
LLMs are being utilized as natural language interfaces for SQL databases. You can build prompts for querying SQL databases like this:
prompt = "Retrieve data from the customer table"Brainstorming
LLMs have proven to be valuable for brainstorming sessions. Business plan ideation prompts and specialized chatbots for design and research assistance are a few examples of this category.
Extraction
LLMs are being employed to extract text in specific formats, aided by function calling. Here’s an example of a prompt designed for knowledge graph triple extraction:
prompt = "Extract knowledge graph triples from the provided text"RAG
Retrieval augmented generation (RAG) leverages the reasoning capability of LLMs with the content of external data sources. For instance, a prompt for factual recall could look like this:
prompt = "Answer the question based on the provided context"Instruction-tuned LLMs
The landscape of open-source instruction-tuned LLMs has expanded significantly. Popular tasks like retrieval augmented generation can benefit from LLM-specific prompts. Here’s an example prompt for a specific LLM:
prompt = "Generate an article based on the given title"LLM Graders
LLMs can be used as graders to rank or grade responses relative to ground truth answers. Here’s an example of a prompt for an automated feedback system:
prompt = "Grade the response based on the given criteria"Synthetic Data Generation
Using LLMs to generate synthetic datasets has gained considerable attention. You can create prompts for generating question-answer pairs using LLMs:
prompt = "Generate question-answer pairs for the given topic"Prompt Optimization
The optimization of prompts for LLMs offers broad potential for translating human instruction into LLM-optimized prompts. Here’s an example prompt for a prompt maker:
prompt = "Optimize the provided prompt for better LLM response"Code Understanding and Generation
Code analysis and generation prompts have been widely used. GitHub Co-Pilot and Code Interpreter are popular examples of this. A prompt for GitHub code reviews could look like this:
prompt = "Review the provided GitHub code and suggest improvements"Summarization
Summarization of content is a powerful LLM use-case. Prompts for dense yet human-preferable summaries have been developed. An example prompt for summarizing a lengthy document could be:
prompt = "Summarize the provided document into 5 key points"In conclusion, prompt engineering has opened up a wide array of applications for LLMs. The LangChain Hub provides a platform for browsing community prompts and managing your own prompts, enabling individuals to experiment with various LLMs, many of which are freely accessible. If you want to explore any of these prompts, you can easily do so using the “Try It” button.
