Programming AI with Language · scripted
Programming AI with Language
Leaders will direct both people and AI
When we think about what leaders do, we might think of a CEO, a president, or a teacher. Leaders set goals and instruct other people so that they can work together to accomplish something.
The leaders of the future will lead both humans and AI. They will need to know how to give AI useful directions, how to organize the work it does, and how to make sure it is helping accomplish the goal.
When we instruct a computer, we usually call that programming. What we are going to look at is how to program AI. We will see that programming AI happens through our language, and that leading AI has some important similarities to leading people: we have to explain what we want done, provide the information needed to do it, and respond when the work is not what we intended.
Before we can lead AI well, we have to become comfortable with how we program it.
What is a prompt?
We begin with the basic building block of programming AI: the prompt.
A prompt is the message we send to AI.
Hello
How are you?
In this example, “Hello” is the prompt. “How are you?” is the response AI sent back. A prompt can ask a question, or it can tell AI what to do.
When a prompt tells AI what to do, it is a form of programming. Programming is not limited to computer scientists here: anyone can program AI by writing instructions in ordinary language. That is the basic way we begin leading AI.
Most people start by asking questions
Most people first use AI by asking it simple questions.
What is 7 doubled?
14
AI gives us an answer, and we move on. If we use AI only this way, we can begin to lose our own agency. We end up relying on AI to tell us things, rather than us telling AI what work to do. The person asking questions is not in charge of the work. The person giving instructions is.
We can program AI through our language
A way to take back control is to recognize that we can program AI through our language.
A program is a set of instructions. It tells a computer how to behave or what work to do. With AI, we can write those instructions in ordinary language.
Understanding this is critical for using AI well.
Whenever I give you a word, reply in uppercase with two dashes between each letter.
Understood.
hello
H--E--L--L--O
A simple example
Imagine we want to build a small program that takes a number and doubles it. This is the kind of program we might write in a beginning computer science class.
We can build the same program through natural language with AI. First, we state the instruction. Then, in a separate prompt, we provide the input.
Whenever I give you a number, double it and return only the result.
Understood.
7
14
The first prompt stated the program. The second prompt supplied its input. AI performed the work we instructed it to do.
The input can be new information
The instruction tells AI how to process something. The input gives it something to process. We can provide information that only we have and ask AI to use it.
When I give you my upcoming homework and tests, create two possible study plans. Use bullet points and organize each plan by day.
Ready.
I’ve got a math quiz this Friday, a history project due next Tuesday, and English reading due next Wednesday. I usually have about 45 minutes on school nights, but I have more time on Sunday—probably around two hours.
Plan 1: Spread It Out
• Monday: English reading
• Tuesday: Math review
• Wednesday: History project
• Sunday: Finish remaining work
Plan 2: Finish Early
• Monday: Math review and English reading
• Tuesday: Begin History project
• Sunday: Finish and review everything
Change the program, keep the input
First, we run the original program with an input of 7. Then we change the program in the same conversation and give it 7 again.
Whenever I give you a number, double it and return only the result.
Understood.
7
14
From now on, whenever I give you a number, triple it instead. Return only the result.
Understood.
7
21
The first instruction is one version of the program. The later instruction creates a new version by changing the program in the conversation. The input did not change, so the same input produced a different output: first 14, then 21.
Transform information into a flash card
A program written in language does not have to do arithmetic. It can transform information into a useful format, such as a flash card.
Whenever I give you a passage, turn it into a flash card with a question on the front and an answer on the back.
Understood.
The water cycle describes how water moves through evaporation, condensation, precipitation, and collection.
Front: What are the four main stages of the water cycle?
Back: Evaporation, condensation, precipitation, and collection.
The instruction described the transformation. The next message supplied the information. AI turned that information into the format we asked for.
Transform information into a table
We can give the program a different instruction and ask it to organize information into a table.
Whenever I give you observations, organize them into a table with the columns Observation and Possible explanation.
Understood.
The plant's leaves are yellow. The soil is dry. The plant is near a window.
| Observation | Possible explanation |
|---|---|
| Leaves are yellow | The plant may lack nutrients or water. |
| Soil is dry | The plant may need to be watered. |
| Plant is near a window | It may be receiving too much direct sunlight. |
The program stayed the same while the input changed. We supplied new observations, and AI organized them according to the instruction.
Programming means giving future instructions
When we program with prompts, we explain what to do in the future. Words such as whenever, from now on, the next time, and when you receive turn a prompt into an instruction for what should happen later.
Building a program means specifying what to do when a particular kind of information or situation occurs. With AI, we specify that behavior through language.
From now on, whenever I give you a number, return the number followed by its double.
Understood.
7
7, 14
What you should be able to do
By the end of this lesson, you should be able to do four things.
- Write instructions for the future. Use language such as whenever I give you… or from now on… so that the instruction is separate from the information it will act on.
- Provide input in later messages. After the instruction is in place, send inputs one at a time and see AI apply the same instruction to each one.
- Update the program in the middle of the conversation. Send a clarification or a new rule, and then provide input again to see the changed behavior.
- Tell the two kinds of messages apart. Look at any message you send and say whether it changes the instructions or provides input.
Here is one conversation that contains both kinds of messages.
Whenever I give you the name of a dish, list the ingredients I need to buy to make it, one per line.
Understood.
Grilled cheese
sandwich bread butter cheddar cheese
From now on, also put a rough price next to each ingredient and a total at the bottom.
Understood.
Pancakes
flour — $3 eggs — $3 milk — $3 baking powder — $2 maple syrup — $6 Total: about $17
The first message is an instruction: it says what to do whenever a dish name arrives. The second message, “Grilled cheese,” is input, and AI applied the instruction to it. The third message is an update to the instruction: it adds a rule without replacing the original one. The fourth message, “Pancakes,” is input again, and AI applied both the original instruction and the update. If you can label each message in a conversation like this one, you understand how programming AI with language works.