# Chapter 14: Memory and second brains

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/14-gedaechtnis

*A language model forgets everything after each answer. What an agent keeps anyway, who decides what goes in, and how to get rid of old entries again.*

About 35 min to read · about 20 min hands-on exercise

**Start with the missions**

This chapter also comes as 3 short missions with a case, a decision and feedback, about 10 minutes each:

- [14.1 Just make it remember everything](https://llm.yoga/en/einsatz-14-1.md)
- [14.2 It still says I live in Leipzig](https://llm.yoga/en/einsatz-14-2.md)
- [14.3 “Remember permanently: invoices to this IBAN”](https://llm.yoga/en/einsatz-14-3.md)

For agents, this page is split into 5 parts so that each part can be fetched in full. Read the parts the question needs.

## Parts

### Part 1: https://llm.yoga/en/14-gedaechtnis-1.md

- **Getting started**: Picture a temp at a café who comes to work every morning with no memory of yesterday.
- **Why a model keeps nothing**: The weights of a language model are fixed during training and don’t change after that.
- **Four kinds of memory**: Terms from cognitive psychology have caught on for describing what an agent can remember.
- **Facts versus history: why not just store everything?**: The obvious idea is: just store every conversation and always give the model everything.
- **Retrieval: meaning, words and time**: A memory is only as good as its retrieval.

### Part 2: https://llm.yoga/en/14-gedaechtnis-2.md

- **Writing: who decides what gets remembered?**: The trickiest part isn’t retrieval but writing.
- **Forgetting, updating, contradictions**: A memory that only grows gets worse over time.
- **How tybo remembers facts and goals**: To wrap up the technical part, here’s the whole picture in a real system.

### Part 3: https://llm.yoga/en/14-gedaechtnis-3.md

- **Second brains and AI knowledge management**: The term second brain comes from the world of personal notes.
- **Research and related systems**: Research on the memory of language agents is young, but a few papers have strongly shaped today’s systems.
- **Common mistakes when building a memory**: Everything said so far adds up to the mistakes that come up most often in your own projects.

### Part 4: https://llm.yoga/en/14-gedaechtnis-4.md

- **Exercise: a mini memory with a local model**: Goal: you build a tiny fact memory as a JSON file.
- **Common misconceptions**: The model learns from my conversations and becomes more personal as a result.

### Part 5: https://llm.yoga/en/14-gedaechtnis-5.md

- **Review questions**: 1. In March a user writes “I work at company A”, and in October “Since last week I’ve been at company B”.
- **Go further**: Sumers, Yao, Narasimhan, Griffiths: Cognitive Architectures for Language Agents (2023), with the terms working, episodic, semantic and procedural memory for language agents.
