Contributing to minbpe

Thank you for your interest in contributing to minbpe. This project is intended to be a minimal and educational implementation of BPE, so contributions that align with this philosophy of simplicity and clarity are welcome.

Development Setup

To get started with development, you'll need to set up a local environment.

  1. Fork and Clone the Repository:

    First, fork the repository on GitHub. Then, clone your fork locally:

    git clone https://github.com/<username>/minbpe.git
    cd minbpe
  2. Install Dependencies:

    It's recommended to work within a Python virtual environment. Once your environment is activated, install the project's dependencies:

    pip install -r requirements.txt

Running the Code

There is no formal test suite in this project. The primary way to test changes is to run the train.py script, which trains the tokenizers on a sample text file.

python train.py

Feel free to modify this script or create new ones to test your changes and ensure that training, encoding, and decoding work as expected.

Submitting Changes

  1. Create a new branch for your feature or bug fix:

    git checkout -b my-awesome-feature
  2. Make your changes to the code.

  3. Commit your changes with a clear and descriptive message.

  4. Push your branch to your fork on GitHub:

    git push origin my-awesome-feature
  5. Open a Pull Request from your branch to the main branch of the original karpathy/minbpe repository.

Code Style

Please try to match the existing code style. The project values simplicity and readability above all else. Add comments where necessary to explain complex logic.

License

By contributing to this project, you agree that your contributions will be licensed under the MIT License. The full text of the license can be found in the LICENSE file.

MIT License

Copyright (c) 2024 Andrej

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.