- Bored Of Your Data Job?
- Posts
- How To Use Large Language Models
How To Use Large Language Models
Good Morning Data Scientists,
I’ve worked with language models a lot at my 9-5 and my personal projects lately (where I built a chatbot over my journal entries).
Here’s 3 things I’ve Learnt about prompt engineering (i.e., how to write prompts to get language models to do what you want).
1. Give Examples
‘Don’t tell, show’ doesn’t just work in Data Science Interviews.
It’s essential for getting language models to give useful answers.
Let’s say you’re summarising documents, and you want the model to output where it got information from.
You could say something like
‘Please specify the page number and date you got the information from’.
That tells the language model what to do.
To show the language model what to do (and get better results) say something like
‘Please specify the page number and date you got the information from.
This is how you should structure your output: dd/mm/yyyy (Page Number): Sentence from the page number with the relevant information.
Here is an example: 01/01/1900 (Page Number 1): Albert is a Data Scientist who is also an excellent football player’
2. Repeat Yourself
In normal ‘day-to-day’ writing like emails, teams messages and PowerPoints, you want to be concise.
But I’ve found that repeating key information in a prompt (e.g. once at the start, and again at the end) ensures the language model doesn’t forget the information.
3. Smaller Prompts
If you’ve tried the two tips above and the language model still won’t give you what you want, trying splitting your prompt up into a sequence of smaller prompts.
For example, if you have one prompt which finds relevant data, summarises it and checks for errors, you could split this up into three prompts like this
First prompt to find relevant Data
Second Prompt to Summarise the Data
Third prompt to check for errors
This is a similar principle to functional programming, where you break your code down into lots of small functions (which have a specific task).
To summarise, you can get better results from language models by
Giving examples
Repeating yourself
Using smaller prompts
Happy Thursday and God Bless!
Albert
P.S.
Reply to this email if you found this useful and want to learn more about language models.