top of page

Prompting Techniques

Like any other engineering discipline, if you don't follow the prescribed techniques and methods, you can't expect to get good results. An electrical engineer's schematic design for an electronic device will fail if it's vague. It needs to be precise and follow specific engineering and design principles to ensure a predictable and reliable outcome. The more complex the device, the more specific and precise the design needs to be.

 

Prompt engineering is the same. I've created a cheat sheet of different prompting techniques using the example of 'explaining the Eiffel Tower' for all the techniques to help you understand the practical application for each. 

CLassroom.webp

Prompting Techniques

Naive Prompting

Summary:

Naive prompting involves straightforward, direct questions or commands. This method doesn't consider context or specific nuances, resulting in generic responses.

 

Example:

  • Prompt: "What is the Eiffel Tower?"

  • Response: "The Eiffel Tower is a famous landmark in Paris."

Contextual Prompting

Summary: Contextual prompting involves providing additional information to refine the response. It uses surrounding context to generate more accurate and relevant answers.

 

Example:

  • Prompt: "Considering its historical and cultural significance, what is the Eiffel Tower?"

  • Response: "The Eiffel Tower is an iconic landmark in Paris, built in 1889 for the Exposition Universelle (World's Fair). It is a symbol of French engineering and cultural heritage."

Instruction-Based Prompting

Summary: This technique provides specific instructions to guide the model on how to respond. It often includes directives on the style, format, or depth of the response.

 

Example:

  • Prompt: "Explain the history of the Eiffel Tower in three sentences."

  • Response: "The Eiffel Tower was constructed for the 1889 Exposition Universelle held to celebrate the 100th anniversary of the French Revolution. Designed by Gustave Eiffel, it was initially criticised by some of France's leading artists and intellectuals but has since become a global cultural icon of France. Standing at 324 meters tall, it was the tallest man-made structure in the world until 1930."

Role-Based Prompting

Summary: Role-based prompting assigns a specific role or persona to the model, instructing it to respond from that perspective. This helps tailor the output to particular needs or contexts.

 

Example:

  • Prompt: "As a history teacher, explain the significance of the Eiffel Tower."

  • Response: "As a history teacher, I would explain that the Eiffel Tower represents a remarkable achievement in engineering and architecture from the late 19th century. It symbolises the industrial era's innovation and has become a major tourist attraction, symbolising Paris and France worldwide."

Chain of Thought Prompting

Summary:

Chain of thought prompting encourages the model to think through the problem step-by-step, leading to a more logical and coherent response.

 

Example:

  • Prompt: "Explain step-by-step how the Eiffel Tower was constructed."

  • Response: "First, the foundation work began in January 1887, requiring deep excavations to support the massive structure. Next, prefabricated iron parts were produced in Eiffel's factory in Levallois-Perret and transported to the site. The iron pieces were then assembled using cranes and hydraulic lifts, with riveting teams joining the parts together. Finally, the tower was completed in March 1889, in time for the Exposition Universelle."

Few-Shot Prompting

Summary:

Few-shot prompting provides the model with a few examples of the desired output, helping it understand the pattern or format expected in the response.

 

Example:

  • Prompt: "Describe famous landmarks:

    1. Statue of Liberty: A symbol of freedom in New York City, gifted by France.

    2. Great Wall of China: An ancient series of walls and fortifications in northern China. Now describe the Eiffel Tower."

  • Response: "Eiffel Tower: An iconic iron lattice tower in Paris, built in 1889 for the World's Fair."

Zero-Shot Prompting

Summary:

Zero-shot prompting involves asking the model to perform a task it hasn’t been explicitly trained on, without providing examples. This relies on the model’s general understanding and capabilities.

 

Example:

  • Prompt: "Describe the Eiffel Tower in detail."

  • Response: "The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It was named after the engineer Gustave Eiffel, whose company designed and built the tower. Constructed from 1887 to 1889 as the entrance arch for the 1889 World's Fair, it is 324 meters tall and was the tallest man-made structure in the world until the completion of the Chrysler Building in New York in 1930."

Multi-Turn Prompting

Summary:

Multi-turn prompting uses a conversational approach, where the context is built over several turns. This method is useful for more complex interactions and maintaining context throughout the conversation.

 

Example:

  • Turn 1 Prompt: "What is the Eiffel Tower?"

  • Response: "The Eiffel Tower is a famous landmark in Paris, France."

 

  • Turn 2 Prompt: "Who designed the Eiffel Tower?"

  • Response: "The Eiffel Tower was designed by the French engineer Gustave Eiffel."

 

  • Turn 3 Prompt: "Why was the Eiffel Tower built?"

  • Response: "The Eiffel Tower was built as the entrance arch for the 1889 Exposition Universelle (World's Fair) held in Paris to celebrate the 100th anniversary of the French Revolution."

Advanced Structured Prompting

Summary:

This technique involves creating structured inputs with specific formats or templates to guide the model’s output. It’s often used for generating data in a consistent format or for complex task automation. It may produce this in code format for embedding into a specific tool.

 

Example:

  • Prompt: "Create a fact sheet about the Eiffel Tower including its location, height, construction dates, and purpose."

  • Response: 

Eiffel Tower Fact Sheet:

- Location: Champ de Mars, Paris, France
- Height: 324 meters (1,063 feet)
- Construction Dates: 1887-1889
- Purpose: Built as the entrance arch for the 1889 Exposition Universelle (World's Fair)
 

Interactive Prompting

Summary:

Interactive prompting involves using tools and interfaces to dynamically adjust prompts based on user inputs and model responses. It’s used for creating interactive applications or refining responses in real-time.

Example:

  • Prompt: "You are an interactive assistant. Ask the user for their interests and provide information about the Eiffel Tower accordingly."

  • Response: "Hi! Are you interested in the historical significance, architectural details, or tourist attractions of the Eiffel Tower?"

    • User Input: "I am interested in its architectural details."

    • Follow-Up Prompt: "The Eiffel Tower is made of wrought iron and was designed by Gustave Eiffel's engineering company. It stands at 324 meters tall and was the tallest man-made structure in the world at the time of its completion in 1889. Its lattice design was revolutionary for its time, showcasing the possibilities of iron as a construction material."

Combo Prompting Example

Now, let's combine a few of the techniques using the same example. This is where you can start to master LLMs and produce more reliable results, more consistently.

Prompt:

"You are a history teacher specialising in French landmarks. Explain the historical significance of the Eiffel Tower, how it was constructed, and its impact on French culture. Provide this explanation in three detailed steps."

  • Role-Based Prompting: Assigns the role of a history teacher specialising in French landmarks.

  • Contextual Prompting: Adds context about the Eiffel Tower's historical and cultural significance.

  • Instruction-Based Prompting: Provides specific instructions to explain in three detailed steps.

  • Chain of Thought Prompting: Encourages a step-by-step explanation.

 

Response:

"As a history teacher specialising in French landmarks, I'll explain the historical significance of the Eiffel Tower in three detailed steps:

  1. Historical Significance:

    • Technique: Contextual Prompting - The Eiffel Tower was constructed for the 1889 Exposition Universelle (World's Fair) held in Paris to celebrate the 100th anniversary of the French Revolution. It symbolised the industrial progress and engineering prowess of the late 19th century. Initially, the tower faced criticism from some of France's leading artists and intellectuals, but it gradually became a beloved symbol of modernity and innovation.

  1. Construction Process:

    • Technique: Chain of Thought Prompting - The construction of the Eiffel Tower began with the foundation work in January 1887, requiring deep excavations to support the massive structure. Prefabricated iron parts were produced in Gustave Eiffel's factory in Levallois-Perret and transported to the site. These parts were then assembled using cranes and hydraulic lifts. Riveting teams worked meticulously to join the iron pieces together. The tower was completed in March 1889, standing at 324 meters tall, and it remained the tallest man-made structure in the world until 1930.

  1. Impact on French Culture:

    • Technique: Instruction-Based Prompting - Over the years, the Eiffel Tower has become an iconic symbol of Paris and France. It attracts millions of tourists annually, contributing significantly to the country's economy. The tower is also a symbol of French artistic and architectural innovation, featured prominently in films, literature, and art. Its presence has inspired countless replicas and influenced architectural design worldwide. The Eiffel Tower remains a testament to France's rich cultural heritage and its enduring spirit of creativity and innovation."

bottom of page