Note 01 — Prompt Engineering for Developer

Topic: Intro of LLMs (Large Languages Models)

Mars Wang
3 min readFeb 9, 2024
Photo by Mojahid Mottakin on Unsplash

Prologue

In these stories, I organize some points and tidy up my notes from the videos. The learning source of this series of notes comes from DLAI lectured by Andrew Ng & Isa Fulford. I strongly recommend you to watch this series of videos to better understand the concept and hands-on practices.

If you have already known how to use ChatGPT, why don’t you give it a try to download transcripts from the learning website and generate a AI-generated summary.😎

What are Large Language Models (LLMs) ?

Very large deep learning models that are pre-trained on vast amounts of data.

Two Types of LLMs

In the development of LLMs, there have been broadly 2 types of LLM:

  1. Base LLMs Predicts next words, based on text training data
  2. Instruction Tuned LLMs → Tries to follow instructions

Base LLM

  • Source of training data: Internet (publicly available)
  • Purpose: To predict the most likely word to follow.
  • Example:
Good Response: 
- Prompt: Once upon a time, there was a unicorn
- Response by model: that lived in a magical forest with all her unicorn friends
[✓] Final Result: Once upon a time, there was a unicorn that lived in a magical forest with all her unicorn friends

Bad Response:
- Prompt: What is the capital of France?
- Response by model:
1. What is France's largest city?
2. What is France’s population?
3. What is the currency of France?
...
[𝗑] Final Reuslt: What is the capital of France? What is France's largest city?

✏️ Bad Response Analysis:
The prompt ”What is the capital of France?” seems a simple question. However, due to the source of training data, this prompt may find the same sentence in an article might called “50 questions you may ask about France (without answers).”

Instruction Tuned LLM (Recommend to use for your apps)

  • Source of training data:
    Step 1. start off with a Base LLM (trained on text data)
    Step 2. fine-tune LLM with inputs and outputs that are instructions
    Step 3. further refined using RLHF (Reinforcement Learning with Human Feedback), which regards human feedback as a reward/punishment.
  • Purpose: Through instruction-tuned methods, LLM may response correctly and properly, which are less likely to output problematic text.
  • Example:
- Prompt: What is capital of France?
- Response: The capital of France is Paris.
[✓] Final Result: What is capital of France? The capital of France is Paris.

Summary

  1. Instruction-Tuned LLM is like an encyclopedia, which knows everything and different ways to figure out your problems. However, you have to ask the questions clear enough and specifically so that the encyclopedia could search its knowledge out and answer it.
  2. When an LLM doesn’t work, it’s sometimes because the instructions weren’t clear enough.
  • Example:
    - Prompt: Write something about Lebron James (a well-known NBA Player).
    ✏️ Why the prompt isn’t clear enough?
    → It’s because the prompt didn’t actually say about which specific stuffs or things of Lebron you want to write about. Is his story of becoming a NBA player? or Where does he live right now?

--

--