Community Session - PromptEngineering-Fine-Tuning
Community Session - PromptEngineering-Fine-Tuning
Fine-Tuning
Community Session
Outline
Introductory Talk
● Prompt Engineering and Best-Practices
● Fine-Tuning the Input-Output Schema of an LLM
● Instruction-Tuning
© 2023 FourthBrain
Meet Shoggoth
https://en.wikipedia.org/wiki/Shoggoth
A few LLM Renditions
https://twitter.com/anthrupad
© 2023 FourthBrain
Consider Latent Space
https://twitter.com/i/status/1577061390720069632
© 2023 FourthBrain
Prompt Engineering & Best-Practices
Prompt Engineering
● “Prompt engineering is a relatively new discipline for developing and optimizing
prompts to efficiently use language models (LMs) for a wide variety of applications
and research topics.”
https://www.promptingguide.ai/
● Definitions
○ Zero-shot = zero examples provided
○ Few-shot = providing a few examples to serve to condition the model
© 2023 FourthBrain
Zero-Shot Prompting
● Classify the text into neutral, negative or positive.
Text: I think this community session is OK.
Sentiment:
● Instruction
Input
Completion indicator
© 2023 FourthBrain
Few-Shot Prompting
● A "whatpu" is a small, furry animal native to Tanzania.
An example of a sentence that uses the word whatpu is:
We were traveling in Africa and we saw these very cute whatpus.
To do a "farduddle" means to jump up and down really fast.
An example of a sentence that uses the word farduddle is:
● Example
Instruction
Input
Completion indicator
© 2023 FourthBrain
Self-Refinement
● A way to move from Standard Prompting to Chain-of-Thought Prompting
© 2023 FourthBrain
Prompt Improvement: An example
Prompt:
© 2023 FourthBrain
Using Search to Improve Prompts
© 2023 FourthBrain
Iteration 1
A 3D visualization of latent space that looks like a 32-bit isometric video game
© 2023 FourthBrain
Iteration 2
A colorful and abstract 3D visualization of latent space with duotone effect
© 2023 FourthBrain
Iteration 3
A 3D visualization of latent space in the style of Salvador Dali
© 2023 FourthBrain
#1 Rule in Prompting
Write clear, specific, (even itemized) Instructions
Key Elements of Prompt Engineering
1. Instruction: Write clear and specific instructions
2. Context: Role/Voice/Character/Persona
3. *Self-Refinement*
4. Input: Few-shot/CoT prompting
5. Output: Format
© 2023 FourthBrain
Prompt Engineering =
© 2023 FourthBrain
Fine-Tuning
Unsupervised Pre-Training → Completion
● 🟢 Predicting the next word
● 🔴 Following instructions
© 2023 FourthBrain
Beyond Unsupervised Fine-Tuning
So what are we left with?
1. Supervised Fine-Tuning
Both of these tools “unlock” capabilities that the pretrained model already
has, but are hard for users to access via prompting alone.
https://huyenchip.com/2023/05/02/rlhf.html
© 2023 FourthBrain
Prompting versus Fine-Tuning I-O Schema
Prompting: for each
sample, explicitly tell your
model how it should
respond.
● 🔴 Following instructions
© 2023 FourthBrain
Instruction Tuning IS Fine-Tuning
● “InstructGPT is better than GPT-3 at following instructions”
● “We’ve trained language models that are much better at following user
intentions than GPT-3 while also making them more truthful and less toxic,
using techniques developed through our alignment research.”
○ https://openai.com/research/instruction-following
© 2023 FourthBrain
© 2023 FourthBrain
Rule of Thumb:
Always pick up Instruct-Tuned Models off the Shelf
When should you use prompt
© 2023 FourthBrain
This week’s build - SQL from Natural Language
● Model: OpenLLaMA
○ LoRA: Low-Rank Adaptation of Large Language Models
● Dataset: wikisql
○ A large crowd-sourced dataset for developing natural language interfaces for relational databases.
○ WikiSQL is a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across
24241 tables from Wikipedia.
© 2023 FourthBrain
Let’s Check it Out!
Thank You!