Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Achieve the llama3 inference step-by-step, grasp the core concepts, master the process derivation, implement the code.
| Date | Stars |
|---|---|
| 2026-07-24 | 632 |
| 2026-07-25 | 632 |
| 2026-07-28 | 632 |
| 2026-07-30 | 632 |
| 2026-08-06 | 632 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
<p align="center">
<img src="images/logo.png" width="600px"/>
</p>
<h1 align="center">Deepdive-llama3-from-scratch</h1>
<p align="center">
<a href="https://github.com/therealoliver/Deepdive-llama3-from-scratch/blob/main/LICENSE"><img src="https://img.shields.io/github/license/therealoliver/Deepdive-llama3-from-scratch" alt="License"></a>
<a href="https://github.com/therealoliver/Deepdive-llama3-from-scratch/stargazers"><img src="https://img.shields.io/github/stars/therealoliver/Deepdive-llama3-from-scratch" alt="GitHub stars"></a>
<a href="#from_me"><img src="https://img.shields.io/badge/☕%20Buy%20me%20a%20coffee-ff69b4" alt="Buy me a coffee"></a>
</p>
<h3 align="center">
<p>
<b>[ View in English | <a href="https://github.com/therealoliver/Deepdive-llama3-from-scratch/blob/main/README_zh.md">中文版文档点这里</a> ]</b>
</p>
</h3>
---
This project is an enhanced version based on [naklecha/llama3-from-scratch](https://github.com/naklecha/llama3-from-scratch). It has been comprehensively improved and optimized on the basis of the original project, aiming to help everyone more easily understand and master the implementation principle and the detailed reasoning process of the Llama3 model. Thanks to the contributions of the original author :)
<br><br>
<h3>
The following are the core improvements of this project:
</h3>
1. **Structural Optimization**
The presentation sequence of the content has been rearranged, and the directory structure has been adjusted to make the learning process clearer and more reasonable, facilitating everyone to understand the code step by step.
2. **Code Annotations**
A large number of detailed code annotations have been added to teach you how to understand the function of each piece of code. Even beginners can get started easily.
3. **Dimension Tracking**
The changes in the matrix dimensions in each step of the calculation are fully annotated, making it easier for you to understand the entire process.
4. **Principle Explanation**
Abundant principle-related explanations and a large number of detailed derivations have been added. It not only tells you "what to do" but also deeply explains "why to do it", helping you fundamentally master the design concept of the model.
5. **KV-Cache Insights**
An additional derivation chapter on KV-Cache has been added, covering detailed core concepts, principle derivations, and the application process in the attention mechanism, allowing you to understand every detail and philosophy of KV-Cache from its roots.
6. **Bilingual Documents**
Code files in both Chinese and English are provided. The native Chinese translation avoids the problem of inaccurate expressions caused by machine translation.
<br><br>
---
<h2 align="center">Table of Contents</h2>
- [Loading the model](#loading-the-model)
- [Loading the tokenizer](#loading-the-tokenizer)
- [Reading model files and configuration files](#reading-model-files-and-configuration-files)
- [Inferring model details using the configuration file](#inferring-model-details-using-the-configuration-file)
- [Convert the input text into embeddings](#convert-the-input-text-into-embeddings)
- [Convert the text into a sequence of token ids](#convert-the-text-into-a-sequence-of-token-ids)
- [Convert the sequence of token ids into embeddings](#convert-the-sequence-of-token-ids-into-embeddings)
- [Build the first Transformer block](#build-the-first-transformer-block)
- [Normalization](#normalization)
- [Using RMS normalization for embeddings](#using-rms-normalization-for-embeddings)
- [Implementing the single-head attention mechanism from scratch](#implementing-the-single-head-attention-mechanism-from-scratch)
- [Obtain the QKV vectors corresponding to the input tokens](#obtain-the-qkv-vectors-corresponding-to-the-input-tokens)
- [Obtain the query vector](#obtain-the-query-vector)
- [Unfold the query weight matrix](#unfold-Excerpt of 102,967 characters
Read on GitHub8
Carlos Aguayo · @appian
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:63b79163162d6c8a, topic:transformer, topic:gpt, topic:llama