Building with AI
AI is a new type of programming primitive. Large language models (LLMs) let us write software which can process unstructured information in a common sense way. Consider the task of writing a program to extract a list of people’s names from the following paragraph:Now the other princes of the Achaeans slept soundly the whole night through, but Agamemnon son of Atreus was troubled, so that he could get no rest. As when fair Hera’s lord flashes his lightning in token of great rain or hail or snow when the snow-flakes whiten the ground, or again as a sign that he will open the wide jaws of hungry war, even so did Agamemnon heave many a heavy sigh, for his soul trembled within him. When he looked upon the plain of Troy he marveled at the many watchfires burning in front of Ilion… - The Iliad, Scroll 10Extracting names is easy for humans, but is very difficult using only traditional programming. Writing a general program to extract names from any paragraph is harder still. However, with an LLM the task becomes almost trivial. We can simply provide the following input to an LLM:
List the names of people in the following paragraph, separated by commas: Now the other princes of the Achaeans slept soundly the whole night through, but Agamemnon son of Atreus was troubled, so that he could get no rest. As when fair Hera’s lord flashes his lightning in token of great rain or hail or snow when the snow-flakes whiten the ground, or again as a sign that he will open the wide jaws of hungry war, even so did Agamemnon heave many a heavy sigh, for his soul trembled within him. When he looked upon the plain of Troy he marveled at the many watchfires burning in front of Ilion… - The Iliad, Scroll 10The output would correctly be:
Agamemnon, Atreus, HeraIntegrating LLMs into software applications is as simple as calling an API. While the specifics of the API may vary between LLMs, most have converged on some common patterns:
- Calls to the API typically consist of parameters including a
modelidentifier, and a list ofmessages. - Each
messagehas aroleandcontent. - The
systemrole can be thought of as the instructions to the model. - The
userrole can be thought of as the data to process.
- OpenAI
- Anthropic