Lesson 13: Building an LLM Application Step by Step
You have now met the pieces: prompts, embeddings, retrieval, tools and agents. This lesson puts them together into a plan for building a real application — a study helper, a support chatbot, a document question-answerer — step by step, in an order that avoids the most common mistakes. The plan is deliberately boring: it starts with the user, not the model, and it adds complexity only when the simple version has proved itself.
Step one is to define the job precisely. Who is the user, what do they want to achieve, and what does a good answer look like? A study helper for history students has a different job from a support chatbot for a shop, and the difference decides everything else: what documents to use, what the model may and may not say, and how success will be measured. Write the job down in one paragraph, with an example of a good answer and an example of a bad one. If you cannot write that paragraph, you are not ready to build.
Start simple, then add retrieval
Step two is to build the simplest version that could work: a well-written prompt, with the role, the format and the constraints from Lessons 9 and 10, and nothing else. Test it on twenty real questions from real users, and read every answer yourself. You will learn more from twenty honest tests than from any amount of theory about which model to choose. Only when the simple version's failures are clear should you add the next layer — usually retrieval, from Lesson 11, so the model answers from your documents rather than from memory.
Step three is to add the plumbing around the model: a way to take in the user's question, retrieve the relevant passages, build the prompt, call the model, and show the answer together with its sources. Step four is to add safety: the guardrails from Lesson 15, such as refusing questions outside the application's job, and never inventing facts the documents do not contain. Step five is to measure: build a small set of test questions with known good answers, run the application against them regularly, and record the results. That test set is your early-warning system — it tells you the moment a change makes things worse.
Learning from real users
Once an application is live, its users become its best testers — if you listen to them properly. The simplest form of listening is the feedback button: a thumbs up or down on each answer, with an optional note. More valuable still is reading a sample of real conversations every week, looking for the questions the application answered badly and the ones it was never designed to handle. Those failures are the specification for the next version: they tell you which documents are missing, which prompts are unclear, and which guardrails are too strict or too loose. But there is a privacy cost to reading real conversations, and it must be handled openly: users should know their conversations may be reviewed, personal details should be removed before review, and the review should be done by as few people as necessary. Done well, this loop — users, feedback, fixes — is how a mediocre application becomes a good one over months, without any change to the underlying model.
The order matters. Teams that start with the fanciest model, the most tools and the most complex agent usually end up with a system nobody can debug, and no way to tell whether it is getting better or worse. Teams that start simple, test honestly and add one layer at a time end up with something that works — and something they understand. In the next lesson you will learn how to judge whether your application is actually good, which is the hardest part of all.
Key Terms
- Application
- A complete product built around a language model, such as a study helper or a support chatbot, with prompts, retrieval and guardrails.
- Requirements
- A written definition of the job: who the user is, what they want, and what a good answer looks like.
- Test set
- A small set of questions with known good answers, run regularly to check whether the application is getting better or worse.
- Prototype
- The simplest version of an application that could work, built first to learn from real tests before adding complexity.
- Plumbing
- The surrounding code of an application: taking in questions, retrieving passages, building prompts, calling the model and showing answers with sources.
- Iteration
- Improving an application one small change at a time, testing after each change.
Discussion Questions
- Why should you write down the job, with examples of good and bad answers, before building anything?
- A team builds the fanciest agent first and cannot tell whether it is getting better or worse. What did they skip, and how would you fix it?
- Why test the simplest version on twenty real questions before adding retrieval or tools?
Practice Questions
- What is step one in building an LLM application?
- Why build the simplest version first?
- What is a test set for an LLM application?
- What is the 'plumbing' around a model?
- Why is adding complexity one layer at a time better than building everything at once?
Show answers
- Define the job precisely: who the user is, what they want, and what a good answer looks like. Write it down with an example of a good answer and a bad one.
- So you learn from real tests what actually fails before adding complexity. Twenty honest tests of a simple prompt teach more than theory about which model to choose.
- A small set of questions with known good answers, run regularly to check the application. It is the early-warning system that tells you when a change makes things worse.
- The code that takes in questions, retrieves passages, builds prompts, calls the model and shows answers with sources. The model is only one part of a working application.
- Because a complex system nobody can debug cannot be improved or trusted. Starting simple and testing honestly ends with something that works and is understood.