PyTorch Merge
This repository contains a script, py_merge.py, that can be used to merge two PyTorch model .bin files into a single model file. This can be useful when you need to combine the weights of two models that have the same architecture and are compatible. The script averages the parameter values of the models for keys that exist in both models.
Prerequisites
Before using this script, make sure you have the following Python packages installed:
- PyTorch
- Transformers
You can install them using pip:
pip install pytorch_merge
This will automatically install the dependencies (torch and transformers).
Usage
Open a terminal, and type:
pytorch_merge --help
To get the instructions on how to use it.
This tool requires 3 arguments:
--config config.json-- The configuration file for the model architecture you are working with.--bin model1.bin model2.bin model3.bin-- All the model’s weights .bin files you want to merge. You can merge weights files of one multiparts model, or weights from different models, in which case weights will be averaged. You can specify as many files as you want, they will be merged one after the others in a loop.--output merged_model.bin-- Where to save the output merged model.
For example:
pytorch_merge -c config.json -b model1.bin model2.bin -o merged_model.bin
You can now use the merged merged_model.bin file with your model architecture.
Note: Merging models may not always produce the desired results, especially if the models have different architectures or were trained on different data.
Use this script only when you are sure that the models are compatible.
License
This tool was made by Donalda Feith and is licensed under GNU General Public License v3 or later (GPLv3+).
Metadata
Release files for pytorch-merge 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytorch_merge-0.1.2.tar.gz | 17.9 kB | Without provenance | Details for pytorch_merge-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytorch_merge-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pytorch_merge-0.1.2-py3-none-any.whl |
Total release size: 35.4 kB
Release files / pytorch_merge-0.1.2.tar.gz
| Download URL | pytorch_merge-0.1.2.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6a862143ea489a78e569e3897a1f7e5ae0d8342b3425c10a6a47c2d75d6b660
|
|
BLAKE2b-256 checksum How to use checksums |
2881a81850b25fa3657cd8bf7004721c36fe72aaeb320f1eb14f947f3e54ae7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / pytorch_merge-0.1.2-py3-none-any.whl
| Download URL | pytorch_merge-0.1.2-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
806e511a6b04a532dc19e12f0e0c0a6d12d0a1a38f2be35ea88ac1f532689858
|
|
BLAKE2b-256 checksum How to use checksums |
913710448d8d684e514c03fd3f6c45191e3098830e758f2801c4a794b9e41048
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for pytorch-merge 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.