Ebbinghaus Curve is a simple demonstration project that shows how Hermann Ebbinghaus’s forgetting theory can be implemented for spaced word repetition.
The project includes:
- a minimal PostgreSQL model
- SQL queries for calculating repetition priority
- Python examples (e.g., plotting forgetting curves)
git clone https://github.com/ivakorn/Ebbinghaus_curve.git
cd Ebbinghaus_curveInstall dependencies:
pip install -r requirements.txtThe project provides a docker-compose.yml file to run PostgreSQL.
Start it with:
docker-compose up -dAfter PostgreSQL is up, create the tables and populate them with test data using the script:
python update_db.pyThis will create the words table and insert example English words with review dates and correct/incorrect answer statistics.
-
Fetch words from the database:
python get_words.py
-
Plot forgetting curves:
python draw_graphs.py
- The theory: the project uses Ebbinghaus’s forgetting curve formula:
where S is the strength coefficient (based on answer statistics).
- SQL implementation: Priority for each word is calculated directly in the query:
SELECT
text,
100 * (1.84 + GREATEST(correct_count * 0.8 - wrong_count * 0.5, 0))
/ (
1.84 + GREATEST(correct_count * 0.8 - wrong_count * 0.5, 0)
+ POWER(LOG(GREATEST(EXTRACT(EPOCH FROM (NOW() - last_review)) / 60, 1)), 1.25)
) AS priority
FROM words
ORDER BY priority ASC
LIMIT 5;This allows filtering and sorting words that need review directly at the database level, without extra client-side processing.
- Python implementation: Equivalent formula in Python:
memory_decay_factor = (math.log10(max(minutes_since, 1))) ** 1.25
retention = 100 * (1.84 + strength) / (1.84 + strength + memory_decay_factor)This model fits any application where learning depends on repetition and retention, such as:
- language learning
- exam preparation
- memorizing texts or formulas
If you’d like to dive deeper into the math behind Ebbinghaus’s formula, check out my detailed article on TProger: “The Ebbinghaus Forgetting Curve in User Applications."
And if you want to see the theory in action, try my Telegram bot @Duck - Your translater. It helps you learn English words and uses these algorithms to schedule reviews.