Giter Club home page Giter Club logo

bin2ckpt's Introduction

bin2ckpt

alexng353's modifications

  • Added support for converting a PyTorch binary model to a TensorFlow checkpoint
  • Added support for converting CKPT to safetensors

Environment

python -m venv .

# linux
source bin/activate

# windows
.\Scripts\activate

## Install

pip install -r requirements.txt

Usage

Convert PyTorch binary model to TensorFlow checkpoint

python .\bin2ckpt.py --model_path="PATH TO MODEL REPO" --checkpoint_path="PATH TO OUTPUT FILE"

Convert TensorFlow checkpoint to safetensors

I was lazy so you have to edit the path in the script file lmao

python ckpt2safetensors.py

Original README

详细说明可以参见《将 PyTorch 版 bin 模型转换成 Tensorflow 版 ckpt》

Usage

bin_path = './pretrained_model/pytorch_model/'
bin_model = 'pytorch_model.bin'
ckpt_path = './pretrained_model/tensorflow_model/'
ckpt_model = 'bert_model.ckpt'

convert(bin_path, bin_model, ckpt_path, ckpt_model)
  • bin_path: pytorch model path
  • bin_model: pytorch model name
  • ckpt_path: path to save tf ckpt
  • ckpt_model: tf ckpt name

Notice: this script only supports to convert the BERT model. If you need to convert other models, please modify the function to_tf_var_name() and variable tensors_to_transpose.

Converted Models (ckpt)

  • SpanBERT

    • SpanBERT (base & cased): 12-layer, 768-hidden, 12-heads , 110M parameters
    • SpanBERT (large & cased): 24-layer, 1024-hidden, 16-heads, 340M parameters

    Download: GoogleDrive | BaiduDrive (Code: wtyr) | CTDrive

  • SimCSE

    • supervised SimCSE (base & uncased)
    • supervised SimCSE (large & uncased)

    Download: GoogleDrive | BaiduDrive (Code: gnq3) | CTDrive

bin2ckpt's People

Contributors

jsksxs360 avatar alexng353 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.