Skip to content
Anton GoncharovAI systems developer

Prompt Engineering for LLMs

John Berryman, Albert Ziegler

  • AI and agents
  • LLM
  • Prompt engineering

The authors are engineers who built GitHub Copilot. The book isn’t about “magic phrases” but about how to build an application around a model: how an LLM sees text, how to assemble context for it from user data, how conversational agents with tools and multi-step workflows work, and how to evaluate answer quality.

Key ideas

  1. The model continues a document: a prompt should look like a document whose natural continuation is the answer.
  2. Context is limited, so fragments are selected and ordered by importance rather than all thrown in.
  3. An LLM application is a loop: user request → prompt assembly → model response → turning the response into an action.
  4. Without evaluation on a set of examples, you can’t tell whether a prompt got better or worse.

How I apply it

In AI agents I assemble the prompt from a template, retrieved knowledge base fragments and the conversation history, and I check prompt changes on a set of test questions rather than by eye.

Where and how I applied it

  • Demo · Telegram and Max · knowledge base search

    AI support from a knowledge base

    The prompt is built from the knowledge base fragments that were found: only the most relevant go into the context, the answer cites them as [1], [2], and if the base doesn’t cover the question the bot honestly declines.

  • Demo · Web app · metrics · CI thresholds

    Bot quality evaluation

    Every change to the bot’s settings runs on 40 test questions: hit@1, hit@3 and the share of correct refusals show whether it got better or worse.

  • Demo · Web app · AI economics · vanilla JS

    AI bot cost calculator

    The calculation shows what the context is made of — instructions, knowledge base fragments, history, answer — and what each part costs in tokens.

More on the shelf

  • Reading

    Hands-On APIs for AI and Data Science

    Ryan Day

    A practical book on building an API for data and connecting AI to it. The running project is a FastAPI service with a database and documentation, then an SDK for it, using the API in analytics and, finally, LangChain agents that call the API themselves.

    AI and agentsPythonAPIApplied in 3 projects
  • Reading

    Server Applications in Python, Django, Flask and FastAPI

    R. S. Bukharev

    The path of server-side development in Python, from sockets and protocols to architecture and launch on a server. Django, Flask and FastAPI are covered through real projects: a CRM system, a Telegram bot with server-side logic, a REST API for a mobile app and a WebSocket chat. Separate chapters cover caching and scaling, Docker and Kubernetes, PostgreSQL, MySQL, SQLite and MongoDB, and security: password hashing, JWT and OAuth 2.0, protection against SQL injection, XSS and CSRF, TLS.

    ProgrammingPythonBackendApplied in 1 project