← 开源
zakirullin

gpt-go

Tiny GPT implemented from scratch in pure Go. Optimized for understanding. Trained on Jules Verne books.

TutorialsLLM fundamentalsGo
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
643
Star
43
Fork
+0
本周
1
贡献者
创建于 2025-04-16 · 更新于 2026-10-06 · 今日第 15623 名
主要开发者

zakirullin/gpt-go 排名第 15,623,有 643 个星标。

同类别比较

zakirullin/gpt-go 排名第 15,623,此处有 8 个同类条目;predibase/llm_distillation_playbook 排名第 15,621。

同类别比较
名称排名指标
victor369basu/Real-time-stock-market-prediction15,592
语言:
JavaScript
星标数:
645
分叉数:
119
简介:
In this repository, I have developed the entire server-side principal architecture for real-time stock market prediction with Machine Learning. I have used Tensorflow.js for constructing ml model architecture, and Kafka for real-time data streaming and pipelining.
pieces-app/documentation15,604
语言:
TypeScript
星标数:
644
分叉数:
74
简介:
Official documentation for Pieces for Developers
HeroKillerEver/coursera-deep-learning15,610
语言:
Jupyter Notebook
星标数:
643
分叉数:
618
简介:
Solutions to all quiz and all the programming assignments!!!
predibase/llm_distillation_playbook15,621
语言:
Jupyter Notebook
星标数:
643
分叉数:
61
简介:
Best practices for distilling large language models.
DrHazemAli/enterprise-system-design15,625
星标数:
642
分叉数:
132
简介:
A source-grounded course and architectural reference for engineers designing systems that must survive real traffic, partial failure, security review, and changing requirements, spanning enterprise system design, distributed systems, AI systems, cybersecurity, reliability, cloud, HPC, edge, and mission-critical infrastructure.
WillKoehrsen/hyperparameter-optimization15,629
语言:
Jupyter Notebook
星标数:
642
分叉数:
313
简介:
Implementation of Bayesian Hyperparameter Optimization of Machine Learning Algorithms
ChileWang0228/Deep-Learning-With-Python15,640
语言:
Jupyter Notebook
星标数:
641
分叉数:
200
简介:
《Python深度学习》书籍代码
ChrisHayduk/minAlphaFold215,641
语言:
Python
星标数:
641
分叉数:
75
简介:
A minimal PyTorch re-implementation of AlphaFold2's model & training
关键参数与规格
关键参数与规格
参数值
语言Go
类别Tutorials
子类别LLM fundamentals
关键词Go
星标数643
分叉数43
贡献者1
创建日期2025-04-16
更新日期2026-10-06
1 天星标数0
7 天星标数0
排名15,623
上次排名15,435
排名变化-188
7 天星标排名15,088
上次 7 天星标排名15,091
7 天星标排名变化3
总星标排名15,915
上次总星标排名15,889
总星标排名变化-26
国家Cyprus
README 摘录

gpt-go Simple GPT implementation in pure Go. What kind of response you can expect from the model: Or this: How to run It takes about 40 minutes to train on MacBook Air M3. The trained weights will be saved to file. If you rerun the model, it will pick up the saved weights and continue training. The loss should decrease each time, indicating that the model is learning something useful. You can train on your own dataset by pointing

the variable to your text corpus. To run in chat-only mode once the training is done: How to understand You can use this repository as a companion to the Neural Networks: Zero to Hero course. Use to see how the model has evolved over time: , , , , , . go you will find explanations starting from basic neuron example: All the way to self-attention mechanism: Design choices No batches. I've given up the complexity of the batch dimension for the sake of

better understanding. It's far easier to build intuition with 2D matrices, rather than with 3D tensors. Besides, batches aren't inherent to the transformer architecture. For better gradient smoothing gradient accumulation was tried. The effect was negligible, so it was removed as well. The gave us ~30% performance boost, but it brought additional dependency. We're not striving for maximum efficiency here, rather for radical simplicity. Current matmul implementation is quite effective, and it's only 40 lines of plain readable code. Papers

You don't need to read them to understand the code :) Attention Is All You Need Deep Residual Learning DeepMind WaveNet Batch Normalization Deep NN + huge data = breakthrough performance OpenAI GPT-3 paper Analyzing the Structure of Attention Credits Many thanks to Andrej Karpathy for his brilliant Neural Networks: Zero to Hero course. Thanks to @itsubaki for his elegant autograd package.

常见问题

记录了多少星标和分叉?

zakirullin/gpt-go 有 643 个星标和 43 个分叉。

仓库排名是多少?

zakirullin/gpt-go 排名第 15,623。

记录的语言和类别是什么?

zakirullin/gpt-go 有 643 个星标,语言为 Go,类别为 Tutorials。

哪个仓库排名最接近?

zakirullin/gpt-go 与 predibase/llm_distillation_playbook 比较,后者排名第 15,621,有 643 个星标。

README

gpt-go

Simple GPT implementation in pure Go. Trained on favourite Jules Verne books.

What kind of response you can expect from the model:

Mysterious Island.
Well.
My days must follow

Or this:

Captain Nemo, in two hundred thousand feet weary in
the existence of the world.

How to run

$ go run .

It takes about 40 minutes to train on MacBook Air M3. The trained weights will be saved to model-1.234M file. If you rerun the model, it will pick up the saved weights and continue training. The loss should decrease each time, indicating that the model is learning something useful.

You can train on your own dataset by pointing the data.dataset variable to your text corpus.

To run in chat-only mode once the training is done:

$ go run . -chat

How to understand

You can use this repository as a companion to the Neural Networks: Zero to Hero course. Use git checkout to see how the model has evolved over time: naive, bigram, multihead, block, residual, full.

In main_test.go you will find explanations starting from basic neuron example:

// Our neuron has 2 inputs and 1 output (number of columns in weight matrix).
// Its goal is to predict next number in the sequence.
input := V{1, 2} // {x1, x2}
weight := M{
    {2}, // how much x1 contributes to the output
    {3}, // how much x2 contributes to the output
}

All the way to self-attention mechanism:

// To calculate the sum of all previous tokens, we can multiply by this triangular matrix:
tril := M{
    {1, 0, 0, 0}, // first token attends only at itself ("cat"), it can't look into the future
    {1, 1, 0, 0}, // second token attends at itself and the previous token ( "cat" + ", ")
    {1, 1, 1, 0}, // third token attends at itself and the two previous tokens ("cat" + ", " + "dog")
    {1, 1, 1, 1}, // fourth token attends at itself and all the previous tokens ("cat" + ", " + "dog" + " and")
}.Var()
// So, at this point each embedding is enriched with the information from all the previous tokens.
// That's the crux of self-attention.
enrichedEmbeds := MatMul(tril, inputEmbeds)

Design choices

No batches.
I've given up the complexity of the batch dimension for the sake of better understanding. It's far easier to build intuition with 2D matrices, rather than with 3D tensors. Besides, batches aren't inherent to the transformer architecture. For better gradient smoothing gradient accumulation was tried. The effect was negligible, so it was removed as well.

Removed gonum.
The gonum.matmul gave us ~30% performance boost, but it brought additional dependency. We're not striving for maximum efficiency here, rather for radical simplicity. Current matmul implementation is quite effective, and it's only 40 lines of plain readable code.

Papers

You don't need to read them to understand the code :)

Attention Is All You Need
Deep Residual Learning
DeepMind WaveNet
Batch Normalization
Deep NN + huge data = breakthrough performance
OpenAI GPT-3 paper
Analyzing the Structure of Attention

Credits

Many thanks to Andrej Karpathy for his brilliant Neural Networks: Zero to Hero course.

Thanks to @itsubaki for his elegant autograd package.

排名相邻
同类项目