Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/flyingfathead/gpt2-tensorflow-to-pytorch-converter

Convert TensorFlow-based GPT-2 models to Pytorch in a breeze
https://github.com/flyingfathead/gpt2-tensorflow-to-pytorch-converter

conversion converter gpt-2 gpt2 llm model openai python python3 pytorch pytorch-model pytorch-models tensorflow tensorflow-model tensorflow-models tensorflow2 tf2

Last synced: about 2 hours ago
JSON representation

Convert TensorFlow-based GPT-2 models to Pytorch in a breeze

Awesome Lists containing this project

README

        

# gpt2-tensorflow-to-pytorch-converter

This repository contains a quick-to-use script to convert GPT-2 models from TensorFlow to PyTorch model format.

## Usage

1. Collect all your TensorFlow model files into a singular directory, i.e. these files:

```
model-.meta
vocab.bpe
model-.data-00000-of-00001
model-.index
checkpoint
counter
encoder.json
hparams.json
```

2. Clone the repo, install prerequisites with i.e. `pip install -r requirements.txt` if needed.

3. Run the script:
```bash
python convert_model.py /path/to/your/model/files
```
4. The converted PyTorch model will be saved in the `./converted_model` directory.

## Notes

Have fun, I probably won't be updating this one much.

## License

This project is licensed under the MIT License.

## Contribute

All code improvements are welcome. This should at least work on all TF1.x-based GPT-2 architecture models.

## About
- Flying from the mind of [FlyingFathead](https://github.com/FlyingFathead/)
- Digital ghost code by ChaosWhisperer