No project description provided
Project description
LLM From Scratch
This project is a from-scratch implementation of a Large Language Model (LLM) in PyTorch. The primary goal is to build a decoder-only transformer model, train it on a custom dataset, and use it for text generation.
Features
- Data Loading: Custom data loader for text datasets.
- Tokenizer: Utilizes
tiktokenfor efficient tokenization. - Training: Implements a standard training loop with validation and checkpointing.
- Inference: Generate new text from a starting context.
- Utilities: Helper functions for saving/loading checkpoints and device selection.
Installation
It is recommended to use Poetry for managing dependencies.
-
Clone the repository:
git clone <repository-url> cd LLM
-
Install dependencies using Poetry:
poetry install
Usage
The primary entry point for training the model is main.py.
poetry run python main.py
You can modify main.py to experiment with different configurations and data. The playground.py file contains functions for simple inference and data inspection, which can be integrated into main.py for quick tests.
File Descriptions
| File | Description |
|---|---|
main.py |
The main entry point for training the model. |
config.py |
Contains the configuration class for the model architecture. |
data.py |
Handles data loading, tokenization, and creating DataLoader instances for training and validation. |
model.py |
Defines the LLM architecture. |
model_run.py |
Contains the main training loop and optimizer setup. |
model_run_utils.py |
Provides utility functions for the training loop, such as loss calculation and TensorBoard logging. |
inference.py |
Includes functions for generating text with a trained model. |
playground.py |
A collection of functions for experimenting with the model and data. |
utils.py |
Contains utility functions for saving/loading checkpoints and selecting the correct device for training. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vibhu_llm-0.1.9.tar.gz.
File metadata
- Download URL: vibhu_llm-0.1.9.tar.gz
- Upload date:
- Size: 5.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.8 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c951bfc6f930bec868496732df37d386f94eb456ba1af90e082b4878552d2a9
|
|
| MD5 |
d1651938886b52660c1ee2a55fb5999c
|
|
| BLAKE2b-256 |
3541edf69f565507147051ceb2066b15eccc2a27213cb21e9747d3fd7d92632e
|
File details
Details for the file vibhu_llm-0.1.9-py3-none-any.whl.
File metadata
- Download URL: vibhu_llm-0.1.9-py3-none-any.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.8 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54b81e4bf859a64fe8d77dfa547bdf5e885f4f203d071f5946681d79fc37f599
|
|
| MD5 |
a93f0ad30e34b577c0cc992c244f6d46
|
|
| BLAKE2b-256 |
0e3d8dbaff616ff81a6a0cba0f30f0e57d079767a49dfd62998facd470779d40
|