A Mental Model For Prompting Large Language Models

Nov 14, 2024
6 minute read

People are often disappointed when they use a Large Language Model (LLM) like ChatGPT or Claude for the first time. They've heard about this magical tool that helps people write code, edit blog posts, or suggest delicious recipes, but then Google Gemini tells them to add glue to their pizza, and the magic vanishes.

There are countless guides out there on how to improve your prompts or get better answers. But tips and tricks only go so far. Instead, I’d like to share an analogy that might help you come up with better prompts using your own judgment. There is no magic in computers, even when using a computer feels magical.

Using An LLM

LLMs are trained by scouring data from across the internet 1, and "learning” that information. 2 Imagine a world map where all this knowledge is stored in different places: financial advice in America, programming knowledge scattered across Asia, writing skills in Ireland, and so on.

  • You open ChatGPT and ask for help with your portfolio.
  • ChatGPT doesn’t know whether you mean a writing portfolio or a financial portfolio.
  • Instead of asking for clarification, it assumes you mean financial advice. It tries to remember that by muttering to itself that this is a financial question, so from now on we're going to look for all of our information in “America”.
  • Next, you hand it a writing assignment about the stock market, hoping it will improve the quality of your writing.
  • But instead of focusing on writing quality, ChatGPT invents some information about stocks.
  • ChatGPT has just hallucinated.

Why LLMs Make Mistakes

To simplify, LLMs don’t actually know anything. Instead they take best guesses word by word 3 to try and predict the best next word, until it completes an answer to your question. A hallucination is a model's best guess gone awry, when the model doesn't have a high quality answer or has misinterpreted some context. Instead of pausing to think — because models can't think — the model will instead continue on with its answer. To humans this reads as incorrect information, bullshitting, or even lying. But the model doesn't really know good from bad, it just makes a statistically reasonable guess. 4

This is why people sometimes think LLMs are useless — and it’s hard to blame them! But I’d like to show you how to make them work better for you, so you can get more value out of them.

Polite People Are Prompt

Rule #1 of successful prompting is to be as specific as possible. The more hints you give the model about what you want to know and where to look, the better its answers will be. In our earlier example, the model struggled because it couldn’t tell if you meant a financial or a writing portfolio, so it looked in the wrong place. The frustrating part? The model had the information you needed but it didn’t know where to find it.

Let’s extend our map analogy a bit to show why hints are useful. Imagine you’re solving a programming problem. As we discussed, programming knowledge is scattered across Asia. The model knows most JavaScript expertise resides in Japan, while Swift knowledge is mostly in Korea — though there are exceptions.

When we tell the model we’re looking to solve a JavaScript programming problem, we’re helping it focus on information in Japan, not South Korea. This avoids the earlier mistake of the model searching for writing advice in America, which is good because America ranks 36th in the world for literacy. We can narrow it down further by specifying we want to use d3.js, guiding the model to look in Tokyo — specifically, Shibuya, where d3.js information “lives.”

Using An LLM (Better)

Let’s say I have another programming problem I want to solve. I give ChatGPT a code snippet that draws a simple multi-colored square on the screen. Then I tell ChatGPT:

I want to make this darker

  • First of all, what is this? The model has no idea.
  • What color do you want to make darker?
  • What does “darker” even mean? Do you want the multi-colored box to be one solid color, like black? Because that's as dark as anything can be.
  • Follow-up questions: How much darker? Do you have a specific percentage in mind? Which method should it use — adjust hue, saturation, RGB, luminance, etc?

If a human would have follow-up questions for you, a model probably will too. You can answer those questions in advance or even instruct the LLM to ask you questions if anything is too ambiguous or needs clarification.


Now that we’ve anticipated some potential issues, we can compose a clearer prompt to describe the problem we’re trying to solve.

I have a JavaScript code snippet that draws a simple multi-colored square on the screen. The colors are currently red, blue, green, and orange. I want a new color palette that’s slightly darker, but still vibrant so the colors pop.

  • Please rewrite the code without using third-party dependencies or frameworks.

  • Generate 10 color palette options that I can try in my project.

  • Once I review them, I’ll let you know which one I like best, and I’d like 10 more options based on that.

If anything is unclear or if you have any follow up questions that may help resolve ambiguities, please ask them before writing any code.

See how much clearer this prompt is? It’s more likely to get a good answer because we were very specific about the problem we’re trying to solve. Even as I wrote it, I realized there were multiple ways to approach this problem and details I hadn’t initially considered. The process is a bit like teaching someone who’s never seen the problem before — talking it through helps clarify what needs to be done, both for them and for you.


Writing good prompts is like any skill — the more you do it the better you'll get. While this analogy is just a starting point, I hope it demonstrates why good prompting is important and how it can help you make the most of this new, almost magical technology. With this technique we’ve brought a little more determinism into a non-deterministic system, and when you’re ready to go deeper, this paper covers advanced prompting techniques and strategies to truly level up your use of LLMs.


  1. For the purposes of this explanation, let's not get hung up on the fact that this is a legal and ethical gray area.
  2. For the purposes of this explanation, let's not get hung up on the fact that LLMs are statistical models, and aren't learning anything.
  3. This in itself is an oversimplification. LLMs actually use tokens, which are a way to chunk letters together, and usually amount to 3-4 characters per token.
  4. There are a lot of techniques to minimize hallucinations, and to provide better information. This is partially why AI has advanced so much, so quickly, as we've done a great job of preventing LLMs from going off the rails.

Joe Fabisevich is an indie developer creating software at Red Panda Club Inc. while writing about design, development, and building a company here at build.ms. Before all that he was working as an iOS developer on societal health issues @Twitter.

Like my writing? You can keep up with it in your favorite RSS reader, or get posts emailed in newsletter form. I promise to never spam you or send you anything other than my posts, it's just a way for you to read my writing wherever's most comfortable for you.

If you'd like to know more, wanna talk, or need some advice, feel free to sign up for office hours at no charge, I'm very friendly. 🙂