Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .github/workflows/pre-commit.ymlAdded+39
- .gitignoreAdded+160
- .pre-commit-config.yamlAdded+20
- LICENSEAdded+165
- README.mdAdded+217
- config1.ymlAdded+16
- config2.yamlAdded+10
- docs/evolve.mdAdded+176
- docs/moe.mdAdded+124
- examples/gradient-slerp.ymlAdded+20
- examples/linear.ymlAdded+12
- examples/mega.ymlAdded+37
- examples/orcamini-platy-44layer.ymlAdded+9
- examples/ties.ymlAdded+22
- mergekit/__init__.pyAdded
- mergekit/_data/__init__.pyAdded
- mergekit/_data/architectures/__init__.pyAdded
- mergekit/_data/architectures/baichuan.jsonAdded+47
- mergekit/_data/architectures/bert-masked-lm.jsonAdded+118
- mergekit/_data/architectures/bert-sequence-classification.jsonAdded+118
- mergekit/_data/architectures/bert.jsonAdded+175
- mergekit/_data/architectures/chatglm.jsonAdded+50
- mergekit/_data/architectures/cohere.jsonAdded+53
- mergekit/_data/architectures/distilbert-masked-lm.jsonAdded+104
- mergekit/_data/architectures/distilbert-sequence-classification.jsonAdded+94
- mergekit/_data/architectures/distilbert-token-classification.jsonAdded+88
- mergekit/_data/architectures/distilbert.jsonAdded+81
- mergekit/_data/architectures/falcon.jsonAdded+53
- mergekit/_data/architectures/gemma.jsonAdded+85
- mergekit/_data/architectures/gemma2.jsonAdded+62
- mergekit/_data/architectures/gpt-neox.jsonAdded+74
- mergekit/_data/architectures/gpt2-sequence-classification.jsonAdded+66
- mergekit/_data/architectures/gpt2.jsonAdded+64
- mergekit/_data/architectures/gptbigcode.jsonAdded+70
- mergekit/_data/architectures/jais.jsonAdded+70
- mergekit/_data/architectures/llama.jsonAdded+91
- mergekit/_data/architectures/mamba.jsonAdded+57
- mergekit/_data/architectures/mistral.jsonAdded+90
- mergekit/_data/architectures/phi-1.jsonAdded+66
- mergekit/_data/architectures/phi2-old.jsonAdded+62
- mergekit/_data/architectures/phi2.jsonAdded+74
- mergekit/_data/architectures/phi3.jsonAdded+50
- mergekit/_data/architectures/qwen.jsonAdded+50
- mergekit/_data/architectures/qwen2.jsonAdded+65
- mergekit/_data/architectures/roberta-masked-lm.jsonAdded+104
- mergekit/_data/architectures/roberta-sequence-classification.jsonAdded+95
- mergekit/_data/architectures/roberta-token-classification.jsonAdded+89
- mergekit/_data/architectures/roberta.jsonAdded+89
- mergekit/_data/architectures/stablelm.jsonAdded+98
- mergekit/_data/architectures/stablelm2.jsonAdded+74
123456789101112131415161718192021222324252627282930313233343536373839name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- uses: pre-commit/action@v3.0.0
pytest:
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
name: PyTest
needs: [pre-commit]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python_version: ["3.9", "3.10", "3.11"]
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: "pip"
- name: Install dependencies
run: pip3 install -U -e .[test]
- name: Run tests
run: pytest .123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/1234567891011121314151617181920repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-added-large-files
- id: check-yaml
args: ["--allow-multiple-documents"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217# mergekit
`mergekit` is a toolkit for merging pre-trained language models. `mergekit` uses an out-of-core approach to perform unreasonably elaborate merges in resource-constrained situations. Merges can be run entirely on CPU or accelerated with as little as 8 GB of VRAM. Many merging algorithms are supported, with more coming as they catch my attention.
Features:
- Supports Llama, Mistral, GPT-NeoX, StableLM, and more
- Many [merge methods](#merge-methods)
- GPU or CPU execution
- Lazy loading of tensors for low memory use
- Interpolated gradients for parameter values (inspired by Gryphe's [BlockMerge_Gradient](https://github.com/Gryphe/BlockMerge_Gradient) script)
- Piecewise assembly of language models from layers ("Frankenmerging")
- [Mixture of Experts merging](#mixture-of-experts-merging)
🔊 Call to Evolve - to solve evolutionary merge methods as a community - please see <https://github.com/arcee-ai/mergekit/issues/207>.
🌐 GUI Launch Alert 🤗 - We are excited to announce the launch of a graphical user interface for mergekit in Hugging Face Spaces! This GUI simplifies the merging process, making it more accessible to a broader audience. Check it out and contribute at [Hugging Face Spaces - mergekit-community](https://huggingface.co/mergekit-community).
## Installation
```sh
git clone https://github.com/arcee-ai/mergekit.git
cd mergekit
pip install -e . # install the package and make scripts available
```
If the above fails with the error of:
```
ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode:
(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)
```
You may need to upgrade pip to > 21.3 with the command `python3 -m pip install --upgrade pip`
## Usage
The script `mergekit-yaml` is the main entry point for `mergekit`. It takes a YAML configuration file and an output path, like so:
```sh
mergekit-yaml path/to/your/config.yml ./output-model-directory [--cuda] [--lazy-unpickle] [--allow-crimes] [... other options]
```
This will run the merge and write your merged model to `./output-model-directory`.
For more information on the arguments accepted by `mergekit-yaml` run the command `mergekit-yaml --help`.
### Uploading to Huggingface
When you have a merged model you're happy with, you may want to share it on the Hugging Face Hub. `mergekit` generates a `README.md` for your merge with some basic information for a model card. You can edit it to include more details about your merge, like giving it a good name or explaining what it's good at; rewrite it entirely; or use the generated `README.md` as-is. It is also possible to edit your `README.md` online once it has been uploaded to the Hub.
Once you're happy with your model card and merged model, you can upload it to the Hugging Face Hub using the [huggingface_hub](https://huggingface.co/docs/huggingface_hub/index) Python library.
```
# log in to huggingface with an access token (must have write permission)
huggingface-cli login
# upload your model
huggingface-cli upload your_hf_username/my-cool-model ./output-model-directory .
```
The [documentation](https://huggingface.co/docs/huggingface_hub/guides/cli#huggingface-cli-upload) for `huggingface_hub` goes into more detail about other options for uploading.
## Merge Configuration
Merge configurations are YAML documents specifying the operations to perform in order to produce your merged model.
Below are the primary elements of a configuration file:
- `merge_method`: Specifies the method to use for merging models. See [Merge Methods](#merge-methods) for a list.
- `slices`: Defines slices of layers from different models to be used. This field is mutually exclusive with `models`.
- `models`: Defines entire models to be used for merging. This field is mutually exclusive with `slices`.
- `base_model`: Specifies the base model used in some merging methods.
- `parameters`: Holds various parameters such as weights and densities, which can also be specified at different levels of the configuration.
- `dtype`: Specifies the data type used for the merging operation.
- `tokenizer_source`: Determines how to construct a tokenizer for the merged model.
### Parameter Specification
Parameters are flexible and can be set with varying precedence. They can be specified conditionally using tensor name filters, which allows finer control such as differentiating between attention heads and fully connected layers.
Parameters can be specified as:
- **Scalars**: Single floating-point values.
- **Gradients**: List of floating-point values, specifying an interpolated gradient.
The parameters can be set at different levels, with decreasing precedence as follows:
1. `slices.*.sources.parameters` - applying to a specific input slice
2. `slices.*.parameters` - applying to a specific output slice
3. `models.*.parameters` or `input_model_parameters` - applying to any tensors coming from specific input models
4. `parameters` - catchall
### Tokenizer Source
The `tokenizer_source` field of a configuration file determines what tokenizer is used by the merged model. This also effects how embeddings and language model heads are merged.
This functionality is still experimental and may break. Please file an issue if you encounter any issues with it.
Valid values:
- `base`: use the tokenizer from the base model
- `union`: construct a tokenizer with all tokens from all models
- `model:<model_path>`: use the tokenizer from a specific model
If set, mergekit will find a mapping between each model's vocabulary and the output tokenizer. This allows models with different vocabularies or added tokens to be meaningfully merged.
`tokenizer_source` is compatible with all merge methods, but when used `lm_head`/`embed_tokens` will be merged linearly. For two-model merges, the `embed_slerp` parameter can be set to `true` to use SLERP instead.
If the `tokenizer_source` field is not set, mergekit will fall back to its legacy default behavior. The tokenizer for the base model (or first model in the merge, if no base model is specified) will be copied to the output directory. The parameter matrices for `lm_head`/`embed_tokens` will be truncated to the smallest size present in the merge. In _most_ cases this corresponds to using the tokenizer for the base model.
### Examples
Several examples of merge configurations are available in [`examples/`](examples/).
## Merge Methods
A quick overview of the currently supported merge methods:
| Method | `merge_method` value | Multi-Model | Uses base model |
| ------------------------------------------------------------------------------------------------ | -------------------- | ----------- | --------------- |
| Linear ([Model Soups](https://arxiv.org/abs/2203.05482)) | `linear` | ✅ | ❌ |
| SLERP | `slerp` | ❌ | ✅ |
| [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `task_arithmetic` | ✅ | ✅ |
| [TIES](https://arxiv.org/abs/2306.01708) | `ties` | ✅ | ✅ |
| [DARE](https://arxiv.org/abs/2311.03099) [TIES](https://arxiv.org/abs/2306.01708) | `dare_ties` | ✅ | ✅ |
| [DARE](https://arxiv.org/abs/2311.03099) [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `dare_linear` | ✅ | ✅ |
| Passthrough | `passthrough` | ❌ | ❌ |
| [Model Breadcrumbs](https://arxiv.org/abs/2312.06795) | `breadcrumbs` | ✅ | ✅ |
| [Model Breadcrumbs](https://arxiv.org/abs/2312.06795) + [TIES](https://arxiv.org/abs/2306.01708) | `breadcrumbs_ties` | ✅ | ✅ |
| [Model Stock](https://arxiv.org/abs/2403.19522) | `model_stock` | ✅ | ✅ |
### Linear
The classic merge method - a simple weighted average.
Parameters:
- `weight` - relative (or absolute if `normalize=False`) weighting of a given tensor
- `normalize` - if true, the weights of all models contributing to a tensor will be normalized. Default behavior.
### SLERP
Spherically interpolate the parameters of two models. One must be set as `base_model`.
Parameters:
- `t` - interpolation factor. At `t=0` will return `base_model`, at `t=1` will return the other one.
### [Task Arithmetic](https://arxiv.org/abs/2212.04089)
Computes "task vectors" for each model by subtracting a base model. Merges the task vectors linearly and adds back the base. Works great for models that were fine tuned from a common ancestor. Also a super useful mental framework for several of the more involved merge methods.
Parameters: same as [Linear](#linear)
### [TIES](https://arxiv.org/abs/2306.01708)
Builds on the task arithmetic framework. Resolves interference between models by sparsifying the task vectors and applying a sign consensus algorithm. Allows you to merge a larger number of models and retain more of their strengths.
Parameters: same as [Linear](#linear), plus:
- `density` - fraction of weights in differences from the base model to retain
### [DARE](https://arxiv.org/abs/2311.03099)
In the same vein as TIES, sparsifies task vectors to reduce interference. Differs in that DARE uses random pruning with a novel rescaling to better match performance of the original models. DARE can be used either with the sign consensus algorithm of TIES (`dare_ties`) or without (`dare_linear`).
Parameters: same as [TIES](#ties) for `dare_ties`, or [Linear](#linear) for `dare_linear`
### Passthrough
`passthrough` is a no-op that simply passes input tensors through unmodified. It is meant to be used for layer-stacking type merges where you have only one input model. Useful for frankenmerging.
### [Model Breadcrumbs](https://arxiv.org/abs/2312.06795)
An extension of task arithmetic that discards both small and and extremely large differences from the base model. As with DARE, the Model Breadcrumbs algorithm can be used with (`breadcrumbs_ties`) or without (`breadcrumbs`) the sign consensus algorithm of TIES.
Parameters: same as [Linear](#linear), plus:
- `density` - fraction of weights in differences from the base model to retain
- `gamma` - fraction of largest magnitude differences to remove
Note that `gamma` corresponds with the parameter `β` described in the paper, while `density` is the final density of the sparsified tensors (related to `γ` and `β` by `density = 1 - γ - β`). For good default values, try `density: 0.9` and `gamma: 0.01`.
### [Model Stock](https://arxiv.org/abs/2403.19522)
Uses some neat geometric properties of fine tuned models to compute good weights for linear interpolation. Requires at least three models, including a base model.
Parameters:
- `filter_wise`: if true, weight calculation will be per-row rather than per-tensor. Not recommended.
## LoRA extraction
Mergekit allows extracting PEFT-compatible low-rank approximations of finetuned models.
### Usage
```sh
mergekit-extract-lora finetuned_model_id_or_path base_model_id_or_path output_path [--no-lazy-unpickle] --rank=desired_rank
```
## Mixture of Experts merging
The `mergekit-moe` script supports merging multiple dense models into a mixture of experts, either for direct use or for further training. For more details see the [`mergekit-moe` documentation](docs/moe.md).
## Citation
We now have a [paper](https://arxiv.org/abs/2403.13257) you can cite for the MergeKit library:
```bibtex
@article{goddard2024arcee,
title={Arcee's MergeKit: A Toolkit for Merging Large Language Models},
author={Goddard, Charles and Siriwardhana, Shamane and Ehghaghi, Malikeh and Meyers, Luke and Karpukhin, Vlad and Benedict, Brian and McQuade, Mark and Solawetz, Jacob},
journal={arXiv preprint arXiv:2403.13257},
year={2024}
}
```12345678910111213141516slices:
- sources:
- model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
layer_range: [0, 32]
- model: NousResearch/Hermes-2-Theta-Llama-3-8B
layer_range: [0, 32]
merge_method: slerp
base_model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
parameters:
t:
- filter: self_attn
value: [0, 0.5, 0.3, 0.7, 1]
- filter: mlp
value: [1, 0.5, 0.7, 0.3, 0]
- value: 0.5
dtype: bfloat1612345678910models:
- model: NousResearch/Hermes-2-Theta-Llama-3-8B
parameters:
weight: 0.6
- model: MaziyarPanahi/Llama-3-8B-Instruct-v0.8
parameters:
weight: 0.4
merge_method: task_arithmetic
base_model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
dtype: bfloat16123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176# mergekit-evolve
`mergekit-evolve` is a script that uses an evolutionary algorithm (CMA-ES) to optimize the parameters of a merge against model metrics. This is inspired by SakanaAI's [Evolutionary Optimization of Model Merging Recipes](https://arxiv.org/abs/2403.13187), in particular their parameter-space approach. `mergekit-evolve` uses EleutherAI's [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to define and evaluate the scoring function. The script is set up to be run either single-node or on a Ray cluster and has a few different strategies for scheduling operations depending on your particular configuration of compute.
## Installation
Install `mergekit` with the `evolve` (and optionally `vllm`) features:
```sh
git clone https://github.com/arcee-ai/mergekit.git
cd mergekit
pip install -e .[evolve,vllm]
```
If you had a perfectly good pytorch environment going and installing an older version of vLLM downgraded it and broke flash attention, run the following commands to fix it:
```sh
pip uninstall flash-attn
pip cache purge
pip install flash-attn
```
## Configuration
`mergekit-evolve` takes in a YAML configuration file that defines how the merge is parameterized and what metrics to optimize. The general syntax is as follows:
```yml
genome:
models:
- model_1
- model_2
...
- model_n
merge_method: dare_ties
base_model: base_model_if_needed
tokenizer_source: null # optional
layer_granularity: 8
# optional:
normalize: false
allow_negative_weights: false
smooth: false
filters: ...
tasks:
- name: lm_eval_task_name
weight: 1.0 # optional
metric: "acc,none" # defaults to acc,none
- name: ... # as many as you want
```
### Genome Definition
The `genome` section of the configuration file defines the parameter space that `mergekit-evolve` will be optimizing in.
#### `models`
This should be a list of all of the models you want available to be merged. Depending on the merge method not all are guaranteed to be used in the final merge.
#### `merge_method`
Merge method to be used. Currently supported values are `linear`, `dare_ties`, `task_arithmetic`, `ties`, and `slerp`.
#### `base_model`
The base model for the merge, if applicable.
#### `layer_granularity`
A set of parameters will be introduced for each consecutive slice of `layer_granularity` layers. So for example, a 32-layer model like `mistralai/Mistral-7B-v0.1` with `layer_granularity: 8` will be divided into 4 groups of 8 layers with different merge parameters for each. The value specified here must be a divisor of the number of layers in your input models. Large values of `layer_granularity` will reduce the search space greatly, meaning you will get faster convergence at the cost of a potentially less good global solution.
When not set, one set of parameters will be used for all layers.
#### `normalize`
Sets the `normalize` flag when merging. For methods like `linear`, `ties`, and `dare_ties` this constrains the search space to a set of definitely valid models. Similarly to `layer_granularity`, this can greatly speed up convergence at the cost of ruling out oddball solutions that might score better than more standard merges.
#### `allow_negative_weights`
Pretty self explanatory. When this flag is not set, the absolute value of weight parameters is used. Sensible search space reduction for `linear` and `slerp`. For task arithmetic based methods you probably want `allow_negative_weights: true`.
#### `smooth`
If set to `true`, then parameter values will be interpolated across layers instead of assigning a single, fixed value to each block.
#### `filters`
Accepts a list of filters, as in `mergekit-yaml`, by which to separate the parameters. So, for example, setting filters as below for a Llama-based merge:
```yaml
filters:
- self_attn
- mlp
```
Will divide up the merge parameters into three groups - self attention parameters, MLP parameters, and a third for everything else. Separating the parameters out like this can be very beneficial when merging models trained on different prompt formats. It also makes your parameter space three times as big though!
### Task Definition
To evaluate the produced merges you need to specify a list of tasks supported by the EleutherAI LM evaluation harness. This can be either [built in tasks](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks) (don't be naughty) or tasks you define yourself (see the [New Task Guide](https://github.com/EleutherAI/lm-evaluation-harness/blob/main/docs/new_task_guide.md) for how). If your task does not use `acc` as the metric then you must specify the correct metric name. Each task can also optionally have a weight associated.
`mergekit-evolve` aims to maximize the score of the merge, so if you are using any tasks or metrics where a lower score is better (like perplexity) be sure to assign a negative weight to that task.
## Running `mergekit-evolve`
```sh
mergekit-evolve [OPTIONS] --storage-path PATH GENOME_CONFIG_PATH
```
`mergekit-evolve` needs a storage path specified, where it will save the input models, merges to evaluate, and the config for the current best merge evaluated. If you are not using in-memory merging this can require a _lot_ of space - expect at least one fp16 model per GPU.
Some important options:
### Scheduling Strategy (`--strategy`)
There are three different strategies implemented for scheduling merging and evaluation jobs.
#### `pool`
Assigns an actor to each GPU in your cluster and guarantees merges and evaluations are performed on the same node. This is a safe default suitable for any configuration, local or distributed.
#### `buffered`
Maintains a buffer of tasks scheduled to ensure that there is always a model mergign or ready to evaluate for each gpu. Allows for concurrent merging and evaluation of models on the same GPU if enough VRAM is available. Only suitable for a single-node setup or when `--storage-path` points to a fast shared filesystem.
#### `serial`
Uses Ray placement groups to ensure merges and their evaluations happen on the same node, but otherwise just lets Ray take the wheel. Maybe give a try if you're having trouble with the other two, otherwise probably don't use it.
### Evaluation LLM Backend
By default `mergekit-evolve` will use the `hf` backend for `lm-eval`. To use vLLM instead, pass the `--vllm` flag.
### On-Disk vs. In-Memory
By default `mergekit-evolve` will perform merges, write the result to disk, then start up an instance of lm-eval pointing at that path. This is a safe default and will generally always work but also causes a lot of GPU downtime and eats disk space. When using the `pool` scheduling strategy, you have the option to instead keep a model resident in memory and directly update its parameters instead of merging to disk. This is much faster and uses no additional disk space. However, it does involve mucking around in the internals of vLLM and the LM evaluation harness. So it might break at any moment! Choose wisely. Use `--in-memory` to enable this mode.
### Task search path
If you're using custom task definitions (and you should be) then you can append to the search path using the `--task-search-path` option. This should point to the directory your custom task YAML is in (or a parent of that directory). Multiple paths can be included by repeating the option.
### Batch size
Override the batch size used during merge evaluation. If using vLLM `auto` is recommended (default).
### CMA-ES options
#### `--max-fevals`
Maximum number of merges to evaluate. Note that the `cma` package is very loosey-goosey with this number and will happily go over by 50% depending on the size of each generation. Set to 100 by default.
#### `--sigma0`
Initial value of sigma for CMA-ES. No need to play with this unless you really know what you're doing.
### WandB logging
`mergekit-evolve` supports logging metrics to Weights & Biases. Enable this functionality with the `--wandb` flag. Project and entity names can be overridden with the `--wandb-project` and `--wandb-entity` options.
### Example
```sh
mergekit-evolve --strategy pool --wandb --wandb-project mergekit-evolve --wandb-entity arcee-ai --storage-path /path/to/mergekit-evolve/ ./config.yml
```
## Output
`mergekit-evolve` will write the merge configuration for the best merge found so far to the storage path with the filename `best_config.yaml`. If you're using WandB it will also log the config as an artifact. The script will keep running until a KeyboardInterrupt is received or `--max-fevals` is generously exceeded.
## Caveats
`mergekit-evolve` is a work in progress and has probably not been tested on your specific configuration. Keep an eye on the output before leaving it running, and if you run in to any issues don't hesitate to file an issue!
## Acknowledgements
Thanks to SakanaAI for the inspiration and the EleutherAI team for the LM evaluation harness.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124# mergekit-moe
`mergekit-moe` is a script for combining Mistral or Llama models of the same size into Mixtral Mixture of Experts models. The script will combine the self-attention and layer normalization parameters from a "base" model with the MLP parameters from a set of "expert" models.
If using the `hidden` or `cheap_embed` gate mode, the output model will be usable without any further training. If you are initializing a model to do further training on, such as for sparse upcycling, then use the `random` gate mode to get a model ready for training.
## Configuration
`mergekit-moe` uses its own YML configuration syntax, which looks like so:
```yml
base_model: path/to/self_attn_donor
gate_mode: hidden # one of "hidden", "cheap_embed", or "random"
dtype: bfloat16 # output dtype (float32, float16, or bfloat16)
## (optional)
# experts_per_token: 2
experts:
- source_model: expert_model_1
positive_prompts:
- "This is a prompt that is demonstrative of what expert_model_1 excels at"
## (optional)
# negative_prompts:
# - "This is a prompt expert_model_1 should not be used for"
- source_model: expert_model_2
# ... and so on
```
The script takes two arguments, an input config and an output path: `mergekit-moe ./config.yml ./my-clowncar-moe-12x180B`
Currently the script can output models that use the Mixtral, Deepseek MoE, or Qwen MoE architectures. Some output architectures support a shared expert which will be activated for all tokens, which can be configured like this:
```yml
base_model: path/to/self_attn_donor
gate_mode: hidden # one of "hidden", "cheap_embed", or "random"
dtype: bfloat16 # output dtype (float32, float16, or bfloat16)
experts:
...
shared_experts:
- source_model: model_name
positive_prompts: # required by Qwen MoE for "hidden" gate mode, otherwise not allowed
- "blah blah"
# (optional, but recommended:)
residual_scale: 0.1 # downweight output from shared expert to prevent overcooking the model
```
Currently only up to one shared expert is supported.
An appropriate architecture will be inferred based on the input models and presence or absence of shared experts in your configuration. Alternatively, you can explicitly specify an output architecture by setting the `architecture:` field in your config. For example:
```yml
base_model: path/to/self_attn_donor
architecture: qwen
# ... and so on
```
### Gate Modes
There are three methods for populating the MoE gates implemented.
#### "hidden"
Uses the hidden state representations of the positive/negative prompts for MoE gate parameters. Best quality and most effective option; the default. Requires evaluating each prompt using the base model so you might not be able to use this on constrained hardware (depending on the model). You can use `--load-in-8bit` or `--load-in-4bit` to reduce VRAM usage.
#### "cheap_embed"
Uses only the raw token embedding of the prompts, using the same gate parameters for every layer. Distinctly less effective than "hidden". Can be run on much, much lower end hardware.
#### "random"
Randomly initializes the MoE gates. Good for if you are going to fine tune the model afterwards, or maybe if you want something a little unhinged? I won't judge.
## Example Configurations
Sparse upcycling of smol_llama into a 8x220M MoE:
```yml
base_model: BEE-spoke-data/smol_llama-220M-GQA
gate_mode: random
dtype: bfloat16
experts:
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
- source_model: BEE-spoke-data/smol_llama-220M-GQA
# and then train the sucker!
```
Shove some Mistral models in a clown car:
```yml
base_model: NousResearch/Hermes-2-Pro-Mistral-7B
gate_mode: hidden
dtype: bfloat16
experts:
- source_model: NousResearch/Hermes-2-Pro-Mistral-7B
positive_prompts:
- "<|im_start|>user\nHello, who are you?<|im_end|>"
- "<|im_start|>user\nI need help with"
- source_model: BioMistral/BioMistral-7B-DARE
positive_prompts:
- "As a doctor of medicine,"
- source_model: PocketDoc/Dans-AdventurousWinds-7b
positive_prompts:
- "[Genres: Science Fiction]\n[Tags: humor, old school, sci fi]"
- "> get ye flask"
- "[Mode: Interactive Storyteller]"
- source_model: VAGOsolutions/SauerkrautLM-7b-HerO
positive_prompts:
- "<|im_start|>user\nWie geht es dir?<|im_end|>"
- "Das ist ein Satz auf Deutsch."
```
## FAQ
### What does the "Your model has duplicated tensors but the --clone-tensors flag is not set" warning mean?
Answer from [Charles O. Goddard (cg123)](https://github.com/cg123)
(also see [this GitHub issue](https://github.com/arcee-ai/mergekit/issues/279#issuecomment-2081818104)):
> This is completely benign. This happens when a single tensor from a model is used in multiple places, like when doing sparse upcycling with the moe script or doing passthrough merges that repeat layers. Having `--clone-tensors` set can use slightly more memory, but having it unset will slow down saving and introduce small memory usage spikes in cases where this warning occurs. It's honestly a small enough difference that the warning could be removed entirely.1234567891011121314151617181920slices:
- sources:
- model: psmathur/orca_mini_v3_13b
layer_range: [0, 40]
- model: garage-bAInd/Platypus2-13B
layer_range: [0, 40]
# or, the equivalent models: syntax:
# models:
# - model: psmathur/orca_mini_v3_13b
# - model: garage-bAInd/Platypus2-13B
merge_method: slerp
base_model: psmathur/orca_mini_v3_13b
parameters:
t:
- filter: self_attn
value: [0, 0.5, 0.3, 0.7, 1]
- filter: mlp
value: [1, 0.5, 0.7, 0.3, 0]
- value: 0.5 # fallback for rest of tensors
dtype: float16123456789101112models:
- model: psmathur/orca_mini_v3_13b
parameters:
weight: 1.0
- model: WizardLM/WizardLM-13B-V1.2
parameters:
weight: 0.3
- model: garage-bAInd/Platypus2-13B
parameters:
weight: 0.5
merge_method: linear
dtype: float1612345678910111213141516171819202122232425262728293031323334353637slices:
- sources:
- model: psmathur/orca_mini_v3_13b
layer_range: [0, 40]
- model: garage-bAInd/Platypus2-13B
layer_range: [0, 40]
merge_method: slerp
base_model: psmathur/orca_mini_v3_13b
parameters:
t:
- filter: self_attn
value: [0, 0.5, 0.3, 0.7, 1]
- filter: mlp
value: [1, 0.5, 0.7, 0.3, 0]
- value: 0.5 # fallback for rest of tensors
dtype: float16
name: gradient-slerp
---
models:
- model: gradient-slerp
parameters:
density: [1, 0.7, 0.1] # density gradient
weight: 1.0
- model: WizardLM/WizardMath-13B-V1.0
parameters:
density: 0.33
weight:
- filter: mlp
value: 0.5
- value: 0
merge_method: ties
base_model: TheBloke/Llama-2-13B-fp16
parameters:
normalize: true
int8_mask: true
dtype: float16
name: gradient-slerp-ties123456789slices:
- sources:
- model: psmathur/orca_mini_v3_13b
layer_range: [0, 24]
- sources:
- model: garage-bAInd/Platypus2-13B
layer_range: [20, 40]
merge_method: passthrough
dtype: float1612345678910111213141516171819202122models:
- model: psmathur/orca_mini_v3_13b
parameters:
density: [1, 0.7, 0.1] # density gradient
weight: 1.0
- model: garage-bAInd/Platypus2-13B
parameters:
density: 0.5
weight: [0, 0.3, 0.7, 1] # weight gradient
- model: WizardLM/WizardMath-13B-V1.0
parameters:
density: 0.33
weight:
- filter: mlp
value: 0.5
- value: 0
merge_method: ties
base_model: TheBloke/Llama-2-13B-fp16
parameters:
normalize: true
int8_mask: true
dtype: float161234567891011121314151617181920212223242526272829303132333435363738394041424344454647{
"model_type": "baichuan",
"architectures": [
"BaichuanForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "model.norm.weight"
},
{
"name": "lm_head.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.W_pack.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118{
"model_type": "bert",
"architectures": [
"BertForMaskedLM"
],
"pre_weights": [
{
"name": "bert.embeddings.position_embeddings.weight"
},
{
"name": "bert.embeddings.token_type_embeddings.weight"
},
{
"name": "bert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "bert.embeddings.LayerNorm.bias",
"aliases": [
"bert.embeddings.LayerNorm.beta"
]
},
{
"name": "bert.embeddings.LayerNorm.weight",
"aliases": [
"bert.embeddings.LayerNorm.gamma"
]
},
{
"name": "bert.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "bert.pooler.dense.weight"
},
{
"name": "bert.pooler.dense.bias"
},
{
"name": "cls.predictions.bias"
},
{
"name": "cls.predictions.decoder.weight",
"aliases": [
"bert.embeddings.word_embeddings.weight"
],
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "bert.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
]
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
]
},
{
"name": "bert.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
]
},
{
"name": "bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
]
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118{
"model_type": "bert",
"architectures": [
"BertForSequenceClassification",
"BertForMultipleChoice",
"BertForTokenClassification"
],
"pre_weights": [
{
"name": "bert.embeddings.position_embeddings.weight"
},
{
"name": "bert.embeddings.token_type_embeddings.weight"
},
{
"name": "bert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "bert.embeddings.LayerNorm.bias",
"aliases": [
"bert.embeddings.LayerNorm.beta"
]
},
{
"name": "bert.embeddings.LayerNorm.weight",
"aliases": [
"bert.embeddings.LayerNorm.gamma"
]
},
{
"name": "bert.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "bert.pooler.dense.weight",
"optional": true
},
{
"name": "bert.pooler.dense.bias",
"optional": true
},
{
"name": "classifier.bias"
},
{
"name": "classifier.weight"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "bert.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
]
},
{
"name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
]
},
{
"name": "bert.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "bert.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
]
},
{
"name": "bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
]
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175{
"model_type": "bert",
"architectures": [
"BertModel"
],
"pre_weights": [
{
"name": "embeddings.position_embeddings.weight",
"aliases": [
"bert.embeddings.position_embeddings.weight"
]
},
{
"name": "embeddings.token_type_embeddings.weight",
"aliases": [
"bert.embeddings.token_type_embeddings.weight"
]
},
{
"name": "embeddings.word_embeddings.weight",
"is_embed": true,
"aliases": [
"bert.embeddings.word_embeddings.weight"
]
},
{
"name": "embeddings.LayerNorm.bias",
"aliases": [
"embeddings.LayerNorm.beta",
"bert.embeddings.LayerNorm.bias",
"bert.embeddings.LayerNorm.beta"
]
},
{
"name": "embeddings.LayerNorm.weight",
"aliases": [
"embeddings.LayerNorm.gamma",
"bert.embeddings.LayerNorm.weight",
"bert.embeddings.LayerNorm.gamma",
"bert.embeddings.LayerNorm.weight"
]
},
{
"name": "embeddings.position_ids",
"optional": true,
"force_dtype": "int64",
"aliases": [
"bert.embeddings.position_ids"
]
}
],
"post_weights": [
{
"name": "pooler.dense.weight",
"aliases": [
"bert.pooler.dense.weight"
]
},
{
"name": "pooler.dense.bias",
"aliases": [
"bert.pooler.dense.bias"
]
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "encoder.layer.${layer_index}.attention.self.query.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.query.weight"
]
},
{
"name": "encoder.layer.${layer_index}.attention.self.query.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.query.bias"
]
},
{
"name": "encoder.layer.${layer_index}.attention.self.key.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.key.weight"
]
},
{
"name": "encoder.layer.${layer_index}.attention.self.key.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.key.bias"
]
},
{
"name": "encoder.layer.${layer_index}.attention.self.value.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.value.weight"
]
},
{
"name": "encoder.layer.${layer_index}.attention.self.value.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.self.value.bias"
]
},
{
"name": "encoder.layer.${layer_index}.attention.output.dense.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.dense.weight"
]
},
{
"name": "encoder.layer.${layer_index}.attention.output.dense.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.attention.output.dense.bias"
]
},
{
"name": "encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
"aliases": [
"encoder.layer.${layer_index}.attention.output.LayerNorm.beta",
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
]
},
{
"name": "encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
"aliases": [
"encoder.layer.${layer_index}.attention.output.LayerNorm.gamma",
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
"bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
]
},
{
"name": "encoder.layer.${layer_index}.intermediate.dense.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.intermediate.dense.weight"
]
},
{
"name": "encoder.layer.${layer_index}.intermediate.dense.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.intermediate.dense.bias"
]
},
{
"name": "encoder.layer.${layer_index}.output.dense.weight",
"aliases": [
"bert.encoder.layer.${layer_index}.output.dense.weight"
]
},
{
"name": "encoder.layer.${layer_index}.output.dense.bias",
"aliases": [
"bert.encoder.layer.${layer_index}.output.dense.bias"
]
},
{
"name": "encoder.layer.${layer_index}.output.LayerNorm.bias",
"aliases": [
"encoder.layer.${layer_index}.output.LayerNorm.beta",
"bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
"bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
]
},
{
"name": "encoder.layer.${layer_index}.output.LayerNorm.weight",
"aliases": [
"encoder.layer.${layer_index}.output.LayerNorm.gamma",
"bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
"bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
]
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{
"model_type": "chatglm",
"architectures": [
"ChatGLMModel"
],
"pre_weights": [
{
"name": "transformer.embedding.word_embeddings.weight",
"is_embed": true
},
{
"name": "transformer.rotary_pos_emb.inv_freq"
}
],
"post_weights": [
{
"name": "transformer.encoder.final_layernorm.weight"
},
{
"name": "transformer.output_layer.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "transformer.encoder.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "transformer.encoder.layers.${layer_index}.mlp.dense_4h_to_h.weight"
},
{
"name": "transformer.encoder.layers.${layer_index}.mlp.dense_h_to_4h.weight"
},
{
"name": "transformer.encoder.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "transformer.encoder.layers.${layer_index}.self_attention.dense.weight"
},
{
"name": "transformer.encoder.layers.${layer_index}.self_attention.query_key_value.bias"
},
{
"name": "transformer.encoder.layers.${layer_index}.self_attention.query_key_value.weight"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253{
"model_type": "cohere",
"architectures": [
"CohereForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "model.norm.weight"
},
{
"name": "lm_head.weight",
"is_embed": true,
"aliases": [
"model.embed_tokens.weight"
]
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104{
"model_type": "distilbert",
"architectures": [
"DistilBertForMaskedLM"
],
"pre_weights": [
{
"name": "distilbert.embeddings.position_embeddings.weight"
},
{
"name": "distilbert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "distilbert.embeddings.LayerNorm.bias",
"aliases": [
"distilbert.embeddings.LayerNorm.beta"
]
},
{
"name": "distilbert.embeddings.LayerNorm.weight",
"aliases": [
"distilbert.embeddings.LayerNorm.gamma"
]
}
],
"post_weights": [
{
"name": "vocab_transform.weight"
},
{
"name": "vocab_transform.bias"
},
{
"name": "vocab_layer_norm.bias"
},
{
"name": "vocab_layer_norm.weight"
},
{
"name": "vocab_projector.weight",
"is_embed": true,
"aliases": [
"distilbert.embeddings.word_embeddings.weight"
]
},
{
"name": "vocab_projector.bias"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394{
"model_type": "distilbert",
"architectures": [
"DistilBertForSequenceClassification"
],
"pre_weights": [
{
"name": "distilbert.embeddings.position_embeddings.weight"
},
{
"name": "distilbert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "distilbert.embeddings.LayerNorm.bias",
"aliases": [
"distilbert.embeddings.LayerNorm.beta"
]
},
{
"name": "distilbert.embeddings.LayerNorm.weight",
"aliases": [
"distilbert.embeddings.LayerNorm.gamma"
]
}
],
"post_weights": [
{
"name": "classifier.bias"
},
{
"name": "classifier.weight"
},
{
"name": "pre_classifier.bias"
},
{
"name": "pre_classifier.weight"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788{
"model_type": "distilbert",
"architectures": [
"DistilBertForTokenClassification"
],
"pre_weights": [
{
"name": "distilbert.embeddings.position_embeddings.weight"
},
{
"name": "distilbert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "distilbert.embeddings.LayerNorm.bias",
"aliases": [
"distilbert.embeddings.LayerNorm.beta"
]
},
{
"name": "distilbert.embeddings.LayerNorm.weight",
"aliases": [
"distilbert.embeddings.LayerNorm.gamma"
]
}
],
"post_weights": [
{
"name": "classifier.bias"
},
{
"name": "classifier.weight"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081{
"model_type": "distilbert",
"architectures": [
"DistilBertModel"
],
"pre_weights": [
{
"name": "distilbert.embeddings.position_embeddings.weight"
},
{
"name": "distilbert.embeddings.word_embeddings.weight",
"is_embed": true
},
{
"name": "distilbert.embeddings.LayerNorm.bias",
"aliases": [
"distilbert.embeddings.LayerNorm.beta"
]
},
{
"name": "distilbert.embeddings.LayerNorm.weight",
"aliases": [
"distilbert.embeddings.LayerNorm.gamma"
]
}
],
"post_weights": [],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
},
{
"name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
},
{
"name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253{
"model_type": "falcon",
"architectures": [
"FalconForCausalLM"
],
"pre_weights": [
{
"name": "transformer.word_embeddings.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "transformer.ln_f.weight"
},
{
"name": "transformer.ln_f.bias"
},
{
"name": "lm_head.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.ln_attn.bias"
},
{
"name": "transformer.h.${layer_index}.ln_attn.weight"
},
{
"name": "transformer.h.${layer_index}.ln_mlp.bias"
},
{
"name": "transformer.h.${layer_index}.ln_mlp.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.dense_4h_to_h.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.dense_h_to_4h.weight"
},
{
"name": "transformer.h.${layer_index}.self_attention.dense.weight"
},
{
"name": "transformer.h.${layer_index}.self_attention.query_key_value.weight"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485{
"model_type": "gemma",
"architectures": [
"GemmaForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true,
"output_space": "h_0"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight",
"input_space": "h_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_v_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight",
"input_space": "attn_v_${layer_index}",
"output_space": "post_attn_${layer_index}"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight",
"input_space": "h_a_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight",
"input_space": "up_${layer_index}",
"output_space": "post_mlp_${layer_index}"
}
],
"procedural_spaces": [
{
"name": "h_a_${layer_index}",
"type": "residual",
"inputs": [
"h_${layer_index}",
"post_attn_${layer_index}"
]
},
{
"name": "h_${layer_index+1}",
"type": "residual",
"inputs": [
"h_a_${layer_index}",
"post_mlp_${layer_index}"
]
}
]
},
"post_weights": [
{
"name": "model.norm.weight",
"input_space": "h_${num_layers}"
}
]
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162{
"model_type": "gemma2",
"architectures": [
"Gemma2ForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.pre_feedforward_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight"
},
{
"name": "model.layers.${layer_index}.post_feedforward_layernorm.weight"
}
]
},
"post_weights": [
{
"name": "model.norm.weight"
},
{
"name": "lm_head.weight",
"is_embed": true,
"aliases": [
"model.embed_tokens.weight"
]
}
]
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374{
"model_type": "gpt_neox",
"architectures": [
"GPTNeoXForCausalLM"
],
"pre_weights": [
{
"name": "gpt_neox.embed_in.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "gpt_neox.final_layer_norm.bias"
},
{
"name": "gpt_neox.final_layer_norm.weight"
},
{
"name": "embed_out.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "gpt_neox.layers.${layer_index}.attention.dense.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.dense.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.query_key_value.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.query_key_value.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.input_layernorm.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.mlp.dense_4h_to_h.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.mlp.dense_4h_to_h.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.mlp.dense_h_to_4h.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.mlp.dense_h_to_4h.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "gpt_neox.layers.${layer_index}.post_attention_layernorm.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.bias"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.masked_bias"
},
{
"name": "gpt_neox.layers.${layer_index}.attention.rotary_emb.inv_freq"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566{
"model_type": "gpt2",
"architectures": [
"GPT2ForSequenceClassification"
],
"pre_weights": [
{
"name": "transformer.wte.weight"
},
{
"name": "transformer.wpe.weight"
}
],
"post_weights": [
{
"name": "transformer.ln_f.weight"
},
{
"name": "transformer.ln_f.bias"
},
{
"name": "score.weight"
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.attn.c_attn.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_attn.bias"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.bias"
},
{
"name": "transformer.h.${layer_index}.ln_1.weight"
},
{
"name": "transformer.h.${layer_index}.ln_1.bias"
},
{
"name": "transformer.h.${layer_index}.ln_2.weight"
},
{
"name": "transformer.h.${layer_index}.ln_2.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.bias"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364{
"model_type": "gpt2",
"architectures": [
"GPT2LMHeadModel"
],
"pre_weights": [
{
"name": "wte.weight",
"is_embed": true
},
{
"name": "wpe.weight"
}
],
"post_weights": [
{
"name": "ln_f.weight"
},
{
"name": "ln_f.bias"
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "h.${layer_index}.attn.c_attn.weight"
},
{
"name": "h.${layer_index}.attn.c_attn.bias"
},
{
"name": "h.${layer_index}.attn.c_proj.weight"
},
{
"name": "h.${layer_index}.attn.c_proj.bias"
},
{
"name": "h.${layer_index}.ln_1.weight"
},
{
"name": "h.${layer_index}.ln_1.bias"
},
{
"name": "h.${layer_index}.ln_2.weight"
},
{
"name": "h.${layer_index}.ln_2.bias"
},
{
"name": "h.${layer_index}.mlp.c_proj.weight"
},
{
"name": "h.${layer_index}.mlp.c_proj.bias"
},
{
"name": "h.${layer_index}.mlp.c_fc.weight"
},
{
"name": "h.${layer_index}.mlp.c_fc.bias"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970{
"model_type": "gpt_bigcode",
"architectures": [
"GPTBigCodeForCausalLM"
],
"pre_weights": [
{
"name": "transformer.wte.weight",
"is_embed": true
},
{
"name": "transformer.wpe.weight"
}
],
"post_weights": [
{
"name": "transformer.ln_f.weight"
},
{
"name": "transformer.ln_f.bias"
},
{
"name": "lm_head.weight",
"aliases": [
"transformer.wte.weight"
]
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.attn.c_attn.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_attn.bias"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.bias"
},
{
"name": "transformer.h.${layer_index}.ln_1.weight"
},
{
"name": "transformer.h.${layer_index}.ln_1.bias"
},
{
"name": "transformer.h.${layer_index}.ln_2.weight"
},
{
"name": "transformer.h.${layer_index}.ln_2.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.bias"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970{
"model_type": "jais",
"architectures": [
"JAISLMHeadModel"
],
"pre_weights": [
{
"name": "transformer.wte.weight",
"is_embed": true
},
{
"name": "transformer.relative_pe.slopes"
}
],
"post_weights": [
{
"name": "transformer.ln_f.weight"
},
{
"name": "transformer.ln_f.bias"
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.attn.c_attn.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_attn.bias"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.bias"
},
{
"name": "transformer.h.${layer_index}.ln_1.weight"
},
{
"name": "transformer.h.${layer_index}.ln_1.bias"
},
{
"name": "transformer.h.${layer_index}.ln_2.weight"
},
{
"name": "transformer.h.${layer_index}.ln_2.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc2.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_fc2.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.bias"
}
]
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091{
"model_type": "llama",
"architectures": [
"LlamaForCausalLM",
"LLaMaForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true,
"output_space": "h_0"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight",
"input_space": "h_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_v_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight",
"input_space": "attn_v_${layer_index}",
"output_space": "post_attn_${layer_index}"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight",
"input_space": "h_a_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight",
"input_space": "up_${layer_index}",
"output_space": "post_mlp_${layer_index}"
}
],
"procedural_spaces": [
{
"name": "h_a_${layer_index}",
"type": "residual",
"inputs": [
"h_${layer_index}",
"post_attn_${layer_index}"
]
},
{
"name": "h_${layer_index+1}",
"type": "residual",
"inputs": [
"h_a_${layer_index}",
"post_mlp_${layer_index}"
]
}
]
},
"post_weights": [
{
"name": "model.norm.weight",
"input_space": "h_${num_layers}"
},
{
"name": "lm_head.weight",
"input_space": "h_${num_layers}",
"is_embed": true
}
]
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657{
"model_type": "mamba",
"architectures": [
"MambaForCausalLM"
],
"pre_weights": [
{
"name": "backbone.embeddings.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "backbone.norm_f.weight"
},
{
"name": "lm_head.weight",
"is_embed": true,
"aliases": ["backbone.embeddings.weight"]
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "backbone.layers.${layer_index}.mixer.A_log"
},
{
"name": "backbone.layers.${layer_index}.mixer.conv1d.bias"
},
{
"name": "backbone.layers.${layer_index}.mixer.conv1d.weight"
},
{
"name": "backbone.layers.${layer_index}.mixer.D"
},
{
"name": "backbone.layers.${layer_index}.mixer.dt_proj.bias"
},
{
"name": "backbone.layers.${layer_index}.mixer.dt_proj.weight"
},
{
"name": "backbone.layers.${layer_index}.mixer.in_proj.weight"
},
{
"name": "backbone.layers.${layer_index}.mixer.out_proj.weight"
},
{
"name": "backbone.layers.${layer_index}.mixer.x_proj.weight"
},
{
"name": "backbone.layers.${layer_index}.norm.weight"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990{
"model_type": "mistral",
"architectures": [
"MistralForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true,
"output_space": "h_0"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight",
"input_space": "h_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_v_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight",
"input_space": "attn_v_${layer_index}",
"output_space": "post_attn_${layer_index}"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight",
"input_space": "h_a_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight",
"input_space": "up_${layer_index}",
"output_space": "post_mlp_${layer_index}"
}
],
"procedural_spaces": [
{
"name": "h_a_${layer_index}",
"type": "residual",
"inputs": [
"h_${layer_index}",
"post_attn_${layer_index}"
]
},
{
"name": "h_${layer_index+1}",
"type": "residual",
"inputs": [
"h_a_${layer_index}",
"post_mlp_${layer_index}"
]
}
]
},
"post_weights": [
{
"name": "model.norm.weight",
"input_space": "h_${num_layers}"
},
{
"name": "lm_head.weight",
"input_space": "h_${num_layers}",
"is_embed": true
}
]
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566{
"model_type": "mixformer-sequential",
"architectures": [
"MixFormerSequentialForCausalLM"
],
"pre_weights": [
{
"name": "layers.0.wte.weight",
"is_embed": true
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "layers.${layer_index}.ln.bias"
},
{
"name": "layers.${layer_index}.ln.weight"
},
{
"name": "layers.${layer_index}.mixer.Wqkv.bias"
},
{
"name": "layers.${layer_index}.mixer.Wqkv.weight"
},
{
"name": "layers.${layer_index}.mixer.out_proj.bias"
},
{
"name": "layers.${layer_index}.mixer.out_proj.weight"
},
{
"name": "layers.${layer_index}.mixer.rotary_emb.inv_freq"
},
{
"name": "layers.${layer_index}.mlp.fc1.bias"
},
{
"name": "layers.${layer_index}.mlp.fc1.weight"
},
{
"name": "layers.${layer_index}.mlp.fc2.bias"
},
{
"name": "layers.${layer_index}.mlp.fc2.weight"
}
]
},
"post_weights": [
{
"name": "layers.${num_layers}.linear.bias",
"is_embed": true
},
{
"name": "layers.${num_layers}.linear.weight",
"is_embed": true
},
{
"name": "layers.${num_layers}.ln.bias"
},
{
"name": "layers.${num_layers}.ln.weight"
}
]
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162{
"model_type": "phi-msft",
"architectures": [
"PhiForCausalLM"
],
"pre_weights": [
{
"name": "transformer.embd.wte.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "lm_head.linear.bias"
},
{
"name": "lm_head.linear.weight",
"is_embed": true
},
{
"name": "lm_head.ln.bias"
},
{
"name": "lm_head.ln.weight"
}
],
"num_layers_config_key": "n_layer",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.ln.bias"
},
{
"name": "transformer.h.${layer_index}.ln.weight"
},
{
"name": "transformer.h.${layer_index}.mixer.out_proj.bias"
},
{
"name": "transformer.h.${layer_index}.mixer.out_proj.weight"
},
{
"name": "transformer.h.${layer_index}.mixer.Wqkv.bias"
},
{
"name": "transformer.h.${layer_index}.mixer.Wqkv.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.fc1.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.fc1.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.fc2.bias"
},
{
"name": "transformer.h.${layer_index}.mlp.fc2.weight"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374{
"model_type": "phi",
"architectures": [
"PhiForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "lm_head.bias"
},
{
"name": "lm_head.weight",
"is_embed": true
},
{
"name": "model.final_layernorm.bias"
},
{
"name": "model.final_layernorm.weight"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.bias"
},
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.dense.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.dense.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.fc1.bias"
},
{
"name": "model.layers.${layer_index}.mlp.fc1.weight"
},
{
"name": "model.layers.${layer_index}.mlp.fc2.bias"
},
{
"name": "model.layers.${layer_index}.mlp.fc2.weight"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{
"model_type": "phi",
"architectures": [
"Phi3ForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "lm_head.weight",
"is_embed": true
},
{
"name": "model.norm.weight"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight",
"is_embed": false
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight",
"is_embed": false
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight",
"is_embed": false
},
{
"name": "model.layers.${layer_index}.self_attn.qkv_proj.weight",
"is_embed": false
},
{
"name": "model.layers.${layer_index}.mlp.gate_up_proj.weight",
"is_embed": false
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight",
"is_embed": false
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{
"model_type": "qwen",
"architectures": [
"QWenLMHeadModel"
],
"pre_weights": [
{
"name": "transformer.wte.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "transformer.ln_f.weight"
},
{
"name": "lm_head.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "transformer.h.${layer_index}.attn.c_attn.bias"
},
{
"name": "transformer.h.${layer_index}.attn.c_attn.weight"
},
{
"name": "transformer.h.${layer_index}.attn.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.ln_1.weight"
},
{
"name": "transformer.h.${layer_index}.ln_2.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.c_proj.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.w1.weight"
},
{
"name": "transformer.h.${layer_index}.mlp.w2.weight"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465{
"model_type": "qwen2",
"architectures": [
"Qwen2ForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "model.norm.weight"
},
{
"name": "lm_head.weight",
"is_embed": true,
"aliases": [
"model.embed_tokens.weight"
]
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight"
}
]
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104{
"model_type": "roberta",
"architectures": [
"RobertaForMaskedLM"
],
"pre_weights": [
{
"name": "roberta.embeddings.position_embeddings.weight"
},
{
"name": "roberta.embeddings.word_embeddings.weight"
},
{
"name": "roberta.embeddings.token_type_embeddings.weight"
},
{
"name": "roberta.embeddings.LayerNorm.weight"
},
{
"name": "roberta.embeddings.LayerNorm.bias"
},
{
"name": "roberta.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "lm_head.bias"
},
{
"name": "lm_head.dense.weight"
},
{
"name": "lm_head.dense.bias"
},
{
"name": "lm_head.layer_norm.weight"
},
{
"name": "lm_head.layer_norm.bias"
},
{
"name": "lm_head.decoder.weight",
"aliases": [
"roberta.embeddings.word_embeddings.weight"
]
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495{
"model_type": "roberta",
"architectures": [
"RobertaForSequenceClassification"
],
"pre_weights": [
{
"name": "roberta.embeddings.position_embeddings.weight"
},
{
"name": "roberta.embeddings.word_embeddings.weight"
},
{
"name": "roberta.embeddings.token_type_embeddings.weight"
},
{
"name": "roberta.embeddings.LayerNorm.weight"
},
{
"name": "roberta.embeddings.LayerNorm.bias"
},
{
"name": "roberta.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "classifier.dense.weight"
},
{
"name": "classifier.dense.bias"
},
{
"name": "classifier.out_proj.weight"
},
{
"name": "classifier.out_proj.bias"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889{
"model_type": "roberta",
"architectures": [
"RobertaForTokenClassification"
],
"pre_weights": [
{
"name": "roberta.embeddings.position_embeddings.weight"
},
{
"name": "roberta.embeddings.word_embeddings.weight"
},
{
"name": "roberta.embeddings.token_type_embeddings.weight"
},
{
"name": "roberta.embeddings.LayerNorm.weight"
},
{
"name": "roberta.embeddings.LayerNorm.bias"
},
{
"name": "roberta.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "classifier.weight"
},
{
"name": "classifier.bias"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889{
"model_type": "roberta",
"architectures": [
"RobertaModel"
],
"pre_weights": [
{
"name": "roberta.embeddings.position_embeddings.weight"
},
{
"name": "roberta.embeddings.word_embeddings.weight"
},
{
"name": "roberta.embeddings.token_type_embeddings.weight"
},
{
"name": "roberta.embeddings.LayerNorm.weight"
},
{
"name": "roberta.embeddings.LayerNorm.bias"
},
{
"name": "roberta.embeddings.position_ids",
"optional": true,
"force_dtype": "int64"
}
],
"post_weights": [
{
"name": "pooler.dense.weight"
},
{
"name": "pooler.dense.bias"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
},
{
"name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
}
]
}
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798{
"model_type": "stablelm_epoch",
"architectures": [
"StableLMEpochForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true,
"output_space": "h_0"
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight",
"input_space": "h_${layer_index}"
},
{
"name": "model.layers.${layer_index}.input_layernorm.bias",
"input_space": "h_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_qk_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight",
"input_space": "h_${layer_index}",
"output_space": "attn_v_${layer_index}"
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight",
"input_space": "attn_v_${layer_index}",
"output_space": "post_attn_${layer_index}"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight",
"input_space": "h_a_${layer_index}"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.bias",
"input_space": "h_a_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight",
"input_space": "h_a_${layer_index}",
"output_space": "up_${layer_index}"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight",
"input_space": "up_${layer_index}",
"output_space": "post_mlp_${layer_index}"
}
],
"procedural_spaces": [
{
"name": "h_a_${layer_index}",
"type": "residual",
"inputs": [
"h_${layer_index}",
"post_attn_${layer_index}"
]
},
{
"name": "h_${layer_index+1}",
"type": "residual",
"inputs": [
"h_a_${layer_index}",
"post_mlp_${layer_index}"
]
}
]
},
"post_weights": [
{
"name": "model.norm.weight",
"input_space": "h_${num_layers}"
},
{
"name": "lm_head.weight",
"input_space": "h_${num_layers}",
"is_embed": true
}
]
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374{
"model_type": "stablelm",
"architectures": [
"StableLmForCausalLM"
],
"pre_weights": [
{
"name": "model.embed_tokens.weight",
"is_embed": true
}
],
"post_weights": [
{
"name": "model.norm.weight"
},
{
"name": "model.norm.bias"
},
{
"name": "lm_head.weight",
"is_embed": true
}
],
"num_layers_config_key": "num_hidden_layers",
"layer_templates": {
"weights": [
{
"name": "model.layers.${layer_index}.input_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.input_layernorm.bias"
},
{
"name": "model.layers.${layer_index}.mlp.down_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.gate_proj.weight"
},
{
"name": "model.layers.${layer_index}.mlp.up_proj.weight"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.weight"
},
{
"name": "model.layers.${layer_index}.post_attention_layernorm.bias"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.q_proj.bias",
"optional": true
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.k_proj.bias",
"optional": true
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.weight"
},
{
"name": "model.layers.${layer_index}.self_attn.v_proj.bias",
"optional": true
},
{
"name": "model.layers.${layer_index}.self_attn.o_proj.weight"
}
]
}
}.github/workflows/pre-commit.ymlAdded+39
.gitignoreAdded+160
.pre-commit-config.yamlAdded+20
LICENSEAdded+165
README.mdAdded+217
config1.ymlAdded+16
config2.yamlAdded+10
docs/evolve.mdAdded+176
docs/moe.mdAdded+124
examples/gradient-slerp.ymlAdded+20
examples/linear.ymlAdded+12
examples/mega.ymlAdded+37
examples/orcamini-platy-44layer.ymlAdded+9
examples/ties.ymlAdded+22
mergekit/__init__.pyAdded
mergekit/_data/__init__.pyAdded
mergekit/_data/architectures/__init__.pyAdded
mergekit/_data/architectures/baichuan.jsonAdded+47
mergekit/_data/architectures/bert-masked-lm.jsonAdded+118
mergekit/_data/architectures/bert-sequence-classification.jsonAdded+118
mergekit/_data/architectures/bert.jsonAdded+175
mergekit/_data/architectures/chatglm.jsonAdded+50
mergekit/_data/architectures/cohere.jsonAdded+53
mergekit/_data/architectures/distilbert-masked-lm.jsonAdded+104
mergekit/_data/architectures/distilbert-sequence-classification.jsonAdded+94
mergekit/_data/architectures/distilbert-token-classification.jsonAdded+88
mergekit/_data/architectures/distilbert.jsonAdded+81
mergekit/_data/architectures/falcon.jsonAdded+53
mergekit/_data/architectures/gemma.jsonAdded+85
mergekit/_data/architectures/gemma2.jsonAdded+62
mergekit/_data/architectures/gpt-neox.jsonAdded+74
mergekit/_data/architectures/gpt2-sequence-classification.jsonAdded+66
mergekit/_data/architectures/gpt2.jsonAdded+64
mergekit/_data/architectures/gptbigcode.jsonAdded+70
mergekit/_data/architectures/jais.jsonAdded+70
mergekit/_data/architectures/llama.jsonAdded+91
mergekit/_data/architectures/mamba.jsonAdded+57
mergekit/_data/architectures/mistral.jsonAdded+90
mergekit/_data/architectures/phi-1.jsonAdded+66
mergekit/_data/architectures/phi2-old.jsonAdded+62
mergekit/_data/architectures/phi2.jsonAdded+74
mergekit/_data/architectures/phi3.jsonAdded+50
mergekit/_data/architectures/qwen.jsonAdded+50
mergekit/_data/architectures/qwen2.jsonAdded+65
mergekit/_data/architectures/roberta-masked-lm.jsonAdded+104
mergekit/_data/architectures/roberta-sequence-classification.jsonAdded+95
mergekit/_data/architectures/roberta-token-classification.jsonAdded+89
mergekit/_data/architectures/roberta.jsonAdded+89
mergekit/_data/architectures/stablelm.jsonAdded+98
mergekit/_data/architectures/stablelm2.jsonAdded+74