A short course on deeplearning.ai, taught by Andrew Ng and Isa Fulford.
Two types of LLMs (Large Language Models):
- Base LLM: Predicts next word, based on text training data (eg. internet)
- Eg: Once upon a time, there was a unicorn → that lived in a magical forest with all her unicorn friends
- Instruction Tuned LLM: Tries to follow instructions. Fine-tune on instruction and good attempts at following those instructions. It uses a technique call RLHF (Reinforcement Learning with Human Feedback).
- Differences: What is the capital of France?
- Base LLM: → What is France’s largest city, What is France’s population?… (what most asked together on the internet)
- Instruction Tuned LLM: → The capital of France is Paris.
In this course, we focus on Instruction Tuned LLM.
Sometimes, if LLM doesn’t work, it’s just because your instruction isn’t clear enough!
Two principles:
- Principle 1: Write clear and specific instructions
- Principle 2: Give the model time to “think”
- Tactic 1. Use delimiters to clearly indicate distinct parts of the input:
"""
,```
,---
,<>
,<tag></tag>
(xml tags)
- Tactic 2. Ask for a structured output: JSON, HTML
- Tactic 3. Ask the model to check whether conditions are satisfied → check assumptions required to do the task → how the model should handle the edge case to avoid unexpected errors or result.
- tactic 4 - “Few-shot” prompting. Give successful examples of completing tasks. Then ask model to perform the task.
It likes asking a person about a complex math. You cannot expect a good answer for it with a short time of thinking.
- Tactic 1 - Specify the steps to complete the task
Ask for output in a specified format,
- Tactic 2: Instruct the model to work out its own solution before rushing to a conclusion
Important remark: Below prompt was working in the video but at the time I learned this course, it was not working. It still gave the answer “Correct” for the solution of the student!!!
Hallucination: makes statements that sound plausible but are not true!
👉 Reducing hallucinations: ask the model
- First find relevant information
- Then answer the question based on the relevant information
You'll iteratively analyze and refine your prompts to generate marketing copy from a product fact sheet.
📙 Notebook.
Prompt guidelines:
- Be clear and specific
- Analyze why result doesn’t give desired output.
- Refine the idea and the prompt.
- Repeat.
Iterative process:
- Try something
- Analyze where the result does not give what you want
- Clarify instructions, give more time to think
- Refine prompts with a batch of examples
Original prompt,
Limit the number of words/sentences/characters,
Ask it to focus on the aspects that are relevant to the intended audience.
Ask it to extract information and organize it in a table.
You will summarize text with a focus on specific topics.
📙 Notebook.
You will infer sentiment and topics from product reviews and news articles.
📙 Notebook.
📙 Notebook.
ChatGPT is trained with sources in many languages. This gives the model the ability to do translation.
ChatGPT can translate between formats. The prompt should describe the input and output formats.
To signal to the LLM that you want it to proofread your text, you instruct the model to 'proofread' or 'proofread and correct'.
📙 Notebook.
You will generate customer service emails that are tailored to each customer's review. Please use LLM in a responsible way and a way that helps people!
Sentiment is detected before this task!
Sign the email as AI customer agent.
is adviced if your email isn’t generated from a real human.- For tasks that require reliability, predictability →
temperature = 0
- For tasks require variety / creeative →
temperature
higher!
📙 Notebook.
👇 Run this to have an UI of a chat.
After getting all informations from the client, we need one more prompt to sumerize the order,