Auber commited on
Commit
83a9b56
1 Parent(s): 06f82f3

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .github/workflows/pre-commit.yml +39 -0
  2. .gitignore +160 -0
  3. .pre-commit-config.yaml +20 -0
  4. LICENSE +165 -0
  5. README.md +217 -0
  6. config1.yml +16 -0
  7. config2.yaml +10 -0
  8. docs/evolve.md +176 -0
  9. docs/moe.md +124 -0
  10. examples/gradient-slerp.yml +20 -0
  11. examples/linear.yml +12 -0
  12. examples/mega.yml +37 -0
  13. examples/orcamini-platy-44layer.yml +9 -0
  14. examples/ties.yml +22 -0
  15. mergekit/__init__.py +0 -0
  16. mergekit/_data/__init__.py +0 -0
  17. mergekit/_data/architectures/__init__.py +0 -0
  18. mergekit/_data/architectures/baichuan.json +47 -0
  19. mergekit/_data/architectures/bert-masked-lm.json +118 -0
  20. mergekit/_data/architectures/bert-sequence-classification.json +118 -0
  21. mergekit/_data/architectures/bert.json +175 -0
  22. mergekit/_data/architectures/chatglm.json +50 -0
  23. mergekit/_data/architectures/cohere.json +53 -0
  24. mergekit/_data/architectures/distilbert-masked-lm.json +104 -0
  25. mergekit/_data/architectures/distilbert-sequence-classification.json +94 -0
  26. mergekit/_data/architectures/distilbert-token-classification.json +88 -0
  27. mergekit/_data/architectures/distilbert.json +81 -0
  28. mergekit/_data/architectures/falcon.json +53 -0
  29. mergekit/_data/architectures/gemma.json +85 -0
  30. mergekit/_data/architectures/gemma2.json +62 -0
  31. mergekit/_data/architectures/gpt-neox.json +74 -0
  32. mergekit/_data/architectures/gpt2-sequence-classification.json +66 -0
  33. mergekit/_data/architectures/gpt2.json +64 -0
  34. mergekit/_data/architectures/gptbigcode.json +70 -0
  35. mergekit/_data/architectures/jais.json +70 -0
  36. mergekit/_data/architectures/llama.json +91 -0
  37. mergekit/_data/architectures/mamba.json +57 -0
  38. mergekit/_data/architectures/mistral.json +90 -0
  39. mergekit/_data/architectures/phi-1.json +66 -0
  40. mergekit/_data/architectures/phi2-old.json +62 -0
  41. mergekit/_data/architectures/phi2.json +74 -0
  42. mergekit/_data/architectures/phi3.json +50 -0
  43. mergekit/_data/architectures/qwen.json +50 -0
  44. mergekit/_data/architectures/qwen2.json +65 -0
  45. mergekit/_data/architectures/roberta-masked-lm.json +104 -0
  46. mergekit/_data/architectures/roberta-sequence-classification.json +95 -0
  47. mergekit/_data/architectures/roberta-token-classification.json +89 -0
  48. mergekit/_data/architectures/roberta.json +89 -0
  49. mergekit/_data/architectures/stablelm.json +98 -0
  50. mergekit/_data/architectures/stablelm2.json +74 -0
.github/workflows/pre-commit.yml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: pre-commit
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+
7
+ jobs:
8
+ pre-commit:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: actions/setup-python@v4
13
+ with:
14
+ python-version: "3.11"
15
+ cache: "pip"
16
+ - uses: pre-commit/action@v3.0.0
17
+
18
+ pytest:
19
+ if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
20
+ name: PyTest
21
+ needs: [pre-commit]
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ python_version: ["3.9", "3.10", "3.11"]
27
+ timeout-minutes: 5
28
+
29
+ steps:
30
+ - uses: actions/checkout@v3
31
+ - name: Setup Python
32
+ uses: actions/setup-python@v4
33
+ with:
34
+ python-version: ${{ matrix.python_version }}
35
+ cache: "pip"
36
+ - name: Install dependencies
37
+ run: pip3 install -U -e .[test]
38
+ - name: Run tests
39
+ run: pytest .
.gitignore ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
.pre-commit-config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v3.2.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ - id: check-yaml
7
+ args: ["--allow-multiple-documents"]
8
+ - repo: https://github.com/PyCQA/isort
9
+ rev: 5.12.0
10
+ hooks:
11
+ - id: isort
12
+ - repo: https://github.com/psf/black
13
+ rev: 23.11.0
14
+ hooks:
15
+ - id: black
16
+ - repo: https://github.com/pre-commit/pre-commit-hooks
17
+ rev: v3.2.0
18
+ hooks:
19
+ - id: trailing-whitespace
20
+ - id: end-of-file-fixer
LICENSE ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
README.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mergekit
2
+
3
+ `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.
4
+
5
+ Features:
6
+
7
+ - Supports Llama, Mistral, GPT-NeoX, StableLM, and more
8
+ - Many [merge methods](#merge-methods)
9
+ - GPU or CPU execution
10
+ - Lazy loading of tensors for low memory use
11
+ - Interpolated gradients for parameter values (inspired by Gryphe's [BlockMerge_Gradient](https://github.com/Gryphe/BlockMerge_Gradient) script)
12
+ - Piecewise assembly of language models from layers ("Frankenmerging")
13
+ - [Mixture of Experts merging](#mixture-of-experts-merging)
14
+
15
+ 🔊 Call to Evolve - to solve evolutionary merge methods as a community - please see <https://github.com/arcee-ai/mergekit/issues/207>.
16
+
17
+ 🌐 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).
18
+
19
+ ## Installation
20
+
21
+ ```sh
22
+ git clone https://github.com/arcee-ai/mergekit.git
23
+ cd mergekit
24
+
25
+ pip install -e . # install the package and make scripts available
26
+ ```
27
+
28
+ If the above fails with the error of:
29
+
30
+ ```
31
+ ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode:
32
+ (A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)
33
+ ```
34
+
35
+ You may need to upgrade pip to > 21.3 with the command `python3 -m pip install --upgrade pip`
36
+
37
+ ## Usage
38
+
39
+ The script `mergekit-yaml` is the main entry point for `mergekit`. It takes a YAML configuration file and an output path, like so:
40
+
41
+ ```sh
42
+ mergekit-yaml path/to/your/config.yml ./output-model-directory [--cuda] [--lazy-unpickle] [--allow-crimes] [... other options]
43
+ ```
44
+
45
+ This will run the merge and write your merged model to `./output-model-directory`.
46
+
47
+ For more information on the arguments accepted by `mergekit-yaml` run the command `mergekit-yaml --help`.
48
+
49
+ ### Uploading to Huggingface
50
+
51
+ 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.
52
+
53
+ 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.
54
+
55
+ ```
56
+ # log in to huggingface with an access token (must have write permission)
57
+ huggingface-cli login
58
+ # upload your model
59
+ huggingface-cli upload your_hf_username/my-cool-model ./output-model-directory .
60
+ ```
61
+
62
+ 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.
63
+
64
+ ## Merge Configuration
65
+
66
+ Merge configurations are YAML documents specifying the operations to perform in order to produce your merged model.
67
+ Below are the primary elements of a configuration file:
68
+
69
+ - `merge_method`: Specifies the method to use for merging models. See [Merge Methods](#merge-methods) for a list.
70
+ - `slices`: Defines slices of layers from different models to be used. This field is mutually exclusive with `models`.
71
+ - `models`: Defines entire models to be used for merging. This field is mutually exclusive with `slices`.
72
+ - `base_model`: Specifies the base model used in some merging methods.
73
+ - `parameters`: Holds various parameters such as weights and densities, which can also be specified at different levels of the configuration.
74
+ - `dtype`: Specifies the data type used for the merging operation.
75
+ - `tokenizer_source`: Determines how to construct a tokenizer for the merged model.
76
+
77
+ ### Parameter Specification
78
+
79
+ 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.
80
+
81
+ Parameters can be specified as:
82
+
83
+ - **Scalars**: Single floating-point values.
84
+ - **Gradients**: List of floating-point values, specifying an interpolated gradient.
85
+
86
+ The parameters can be set at different levels, with decreasing precedence as follows:
87
+
88
+ 1. `slices.*.sources.parameters` - applying to a specific input slice
89
+ 2. `slices.*.parameters` - applying to a specific output slice
90
+ 3. `models.*.parameters` or `input_model_parameters` - applying to any tensors coming from specific input models
91
+ 4. `parameters` - catchall
92
+
93
+ ### Tokenizer Source
94
+
95
+ 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.
96
+
97
+ This functionality is still experimental and may break. Please file an issue if you encounter any issues with it.
98
+
99
+ Valid values:
100
+
101
+ - `base`: use the tokenizer from the base model
102
+ - `union`: construct a tokenizer with all tokens from all models
103
+ - `model:<model_path>`: use the tokenizer from a specific model
104
+
105
+ 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.
106
+
107
+ `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.
108
+
109
+ 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.
110
+
111
+ ### Examples
112
+
113
+ Several examples of merge configurations are available in [`examples/`](examples/).
114
+
115
+ ## Merge Methods
116
+
117
+ A quick overview of the currently supported merge methods:
118
+
119
+ | Method | `merge_method` value | Multi-Model | Uses base model |
120
+ | ------------------------------------------------------------------------------------------------ | -------------------- | ----------- | --------------- |
121
+ | Linear ([Model Soups](https://arxiv.org/abs/2203.05482)) | `linear` | ✅ | ❌ |
122
+ | SLERP | `slerp` | ❌ | ✅ |
123
+ | [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `task_arithmetic` | ✅ | ✅ |
124
+ | [TIES](https://arxiv.org/abs/2306.01708) | `ties` | ✅ | ✅ |
125
+ | [DARE](https://arxiv.org/abs/2311.03099) [TIES](https://arxiv.org/abs/2306.01708) | `dare_ties` | ✅ | ✅ |
126
+ | [DARE](https://arxiv.org/abs/2311.03099) [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `dare_linear` | ✅ | ✅ |
127
+ | Passthrough | `passthrough` | ❌ | ❌ |
128
+ | [Model Breadcrumbs](https://arxiv.org/abs/2312.06795) | `breadcrumbs` | ✅ | ✅ |
129
+ | [Model Breadcrumbs](https://arxiv.org/abs/2312.06795) + [TIES](https://arxiv.org/abs/2306.01708) | `breadcrumbs_ties` | ✅ | ✅ |
130
+ | [Model Stock](https://arxiv.org/abs/2403.19522) | `model_stock` | ✅ | ✅ |
131
+
132
+ ### Linear
133
+
134
+ The classic merge method - a simple weighted average.
135
+
136
+ Parameters:
137
+
138
+ - `weight` - relative (or absolute if `normalize=False`) weighting of a given tensor
139
+ - `normalize` - if true, the weights of all models contributing to a tensor will be normalized. Default behavior.
140
+
141
+ ### SLERP
142
+
143
+ Spherically interpolate the parameters of two models. One must be set as `base_model`.
144
+
145
+ Parameters:
146
+
147
+ - `t` - interpolation factor. At `t=0` will return `base_model`, at `t=1` will return the other one.
148
+
149
+ ### [Task Arithmetic](https://arxiv.org/abs/2212.04089)
150
+
151
+ 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.
152
+
153
+ Parameters: same as [Linear](#linear)
154
+
155
+ ### [TIES](https://arxiv.org/abs/2306.01708)
156
+
157
+ 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.
158
+
159
+ Parameters: same as [Linear](#linear), plus:
160
+
161
+ - `density` - fraction of weights in differences from the base model to retain
162
+
163
+ ### [DARE](https://arxiv.org/abs/2311.03099)
164
+
165
+ 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`).
166
+
167
+ Parameters: same as [TIES](#ties) for `dare_ties`, or [Linear](#linear) for `dare_linear`
168
+
169
+ ### Passthrough
170
+
171
+ `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.
172
+
173
+ ### [Model Breadcrumbs](https://arxiv.org/abs/2312.06795)
174
+
175
+ 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.
176
+
177
+ Parameters: same as [Linear](#linear), plus:
178
+
179
+ - `density` - fraction of weights in differences from the base model to retain
180
+ - `gamma` - fraction of largest magnitude differences to remove
181
+
182
+ 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`.
183
+
184
+ ### [Model Stock](https://arxiv.org/abs/2403.19522)
185
+
186
+ 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.
187
+
188
+ Parameters:
189
+
190
+ - `filter_wise`: if true, weight calculation will be per-row rather than per-tensor. Not recommended.
191
+
192
+ ## LoRA extraction
193
+
194
+ Mergekit allows extracting PEFT-compatible low-rank approximations of finetuned models.
195
+
196
+ ### Usage
197
+
198
+ ```sh
199
+ mergekit-extract-lora finetuned_model_id_or_path base_model_id_or_path output_path [--no-lazy-unpickle] --rank=desired_rank
200
+ ```
201
+
202
+ ## Mixture of Experts merging
203
+
204
+ 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).
205
+
206
+ ## Citation
207
+
208
+ We now have a [paper](https://arxiv.org/abs/2403.13257) you can cite for the MergeKit library:
209
+
210
+ ```bibtex
211
+ @article{goddard2024arcee,
212
+ title={Arcee's MergeKit: A Toolkit for Merging Large Language Models},
213
+ author={Goddard, Charles and Siriwardhana, Shamane and Ehghaghi, Malikeh and Meyers, Luke and Karpukhin, Vlad and Benedict, Brian and McQuade, Mark and Solawetz, Jacob},
214
+ journal={arXiv preprint arXiv:2403.13257},
215
+ year={2024}
216
+ }
217
+ ```
config1.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ slices:
2
+ - sources:
3
+ - model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
4
+ layer_range: [0, 32]
5
+ - model: NousResearch/Hermes-2-Theta-Llama-3-8B
6
+ layer_range: [0, 32]
7
+ merge_method: slerp
8
+ base_model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
9
+ parameters:
10
+ t:
11
+ - filter: self_attn
12
+ value: [0, 0.5, 0.3, 0.7, 1]
13
+ - filter: mlp
14
+ value: [1, 0.5, 0.7, 0.3, 0]
15
+ - value: 0.5
16
+ dtype: bfloat16
config2.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ models:
2
+ - model: NousResearch/Hermes-2-Theta-Llama-3-8B
3
+ parameters:
4
+ weight: 0.6
5
+ - model: MaziyarPanahi/Llama-3-8B-Instruct-v0.8
6
+ parameters:
7
+ weight: 0.4
8
+ merge_method: task_arithmetic
9
+ base_model: UCLA-AGI/Llama-3-Instruct-8B-SPPO-Iter3
10
+ dtype: bfloat16
docs/evolve.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mergekit-evolve
2
+
3
+ `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.
4
+
5
+ ## Installation
6
+
7
+ Install `mergekit` with the `evolve` (and optionally `vllm`) features:
8
+
9
+ ```sh
10
+ git clone https://github.com/arcee-ai/mergekit.git
11
+ cd mergekit
12
+
13
+ pip install -e .[evolve,vllm]
14
+ ```
15
+
16
+ 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:
17
+
18
+ ```sh
19
+ pip uninstall flash-attn
20
+ pip cache purge
21
+ pip install flash-attn
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ `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:
27
+
28
+ ```yml
29
+ genome:
30
+ models:
31
+ - model_1
32
+ - model_2
33
+ ...
34
+ - model_n
35
+ merge_method: dare_ties
36
+ base_model: base_model_if_needed
37
+ tokenizer_source: null # optional
38
+ layer_granularity: 8
39
+
40
+ # optional:
41
+ normalize: false
42
+ allow_negative_weights: false
43
+ smooth: false
44
+ filters: ...
45
+ tasks:
46
+ - name: lm_eval_task_name
47
+ weight: 1.0 # optional
48
+ metric: "acc,none" # defaults to acc,none
49
+ - name: ... # as many as you want
50
+ ```
51
+
52
+ ### Genome Definition
53
+
54
+ The `genome` section of the configuration file defines the parameter space that `mergekit-evolve` will be optimizing in.
55
+
56
+ #### `models`
57
+
58
+ 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.
59
+
60
+ #### `merge_method`
61
+
62
+ Merge method to be used. Currently supported values are `linear`, `dare_ties`, `task_arithmetic`, `ties`, and `slerp`.
63
+
64
+ #### `base_model`
65
+
66
+ The base model for the merge, if applicable.
67
+
68
+ #### `layer_granularity`
69
+
70
+ 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.
71
+
72
+ When not set, one set of parameters will be used for all layers.
73
+
74
+ #### `normalize`
75
+
76
+ 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.
77
+
78
+ #### `allow_negative_weights`
79
+
80
+ 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`.
81
+
82
+ #### `smooth`
83
+
84
+ If set to `true`, then parameter values will be interpolated across layers instead of assigning a single, fixed value to each block.
85
+
86
+ #### `filters`
87
+
88
+ 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:
89
+
90
+ ```yaml
91
+ filters:
92
+ - self_attn
93
+ - mlp
94
+ ```
95
+
96
+ 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!
97
+
98
+ ### Task Definition
99
+
100
+ 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.
101
+
102
+ `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.
103
+
104
+ ## Running `mergekit-evolve`
105
+
106
+ ```sh
107
+ mergekit-evolve [OPTIONS] --storage-path PATH GENOME_CONFIG_PATH
108
+ ```
109
+
110
+ `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.
111
+
112
+ Some important options:
113
+
114
+ ### Scheduling Strategy (`--strategy`)
115
+
116
+ There are three different strategies implemented for scheduling merging and evaluation jobs.
117
+
118
+ #### `pool`
119
+
120
+ 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.
121
+
122
+ #### `buffered`
123
+
124
+ 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.
125
+
126
+ #### `serial`
127
+
128
+ 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.
129
+
130
+ ### Evaluation LLM Backend
131
+
132
+ By default `mergekit-evolve` will use the `hf` backend for `lm-eval`. To use vLLM instead, pass the `--vllm` flag.
133
+
134
+ ### On-Disk vs. In-Memory
135
+
136
+ 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.
137
+
138
+ ### Task search path
139
+
140
+ 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.
141
+
142
+ ### Batch size
143
+
144
+ Override the batch size used during merge evaluation. If using vLLM `auto` is recommended (default).
145
+
146
+ ### CMA-ES options
147
+
148
+ #### `--max-fevals`
149
+
150
+ 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.
151
+
152
+ #### `--sigma0`
153
+
154
+ Initial value of sigma for CMA-ES. No need to play with this unless you really know what you're doing.
155
+
156
+ ### WandB logging
157
+
158
+ `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.
159
+
160
+ ### Example
161
+
162
+ ```sh
163
+ mergekit-evolve --strategy pool --wandb --wandb-project mergekit-evolve --wandb-entity arcee-ai --storage-path /path/to/mergekit-evolve/ ./config.yml
164
+ ```
165
+
166
+ ## Output
167
+
168
+ `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.
169
+
170
+ ## Caveats
171
+
172
+ `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!
173
+
174
+ ## Acknowledgements
175
+
176
+ Thanks to SakanaAI for the inspiration and the EleutherAI team for the LM evaluation harness.
docs/moe.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mergekit-moe
2
+
3
+ `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.
4
+
5
+ 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.
6
+
7
+ ## Configuration
8
+
9
+ `mergekit-moe` uses its own YML configuration syntax, which looks like so:
10
+
11
+ ```yml
12
+ base_model: path/to/self_attn_donor
13
+ gate_mode: hidden # one of "hidden", "cheap_embed", or "random"
14
+ dtype: bfloat16 # output dtype (float32, float16, or bfloat16)
15
+ ## (optional)
16
+ # experts_per_token: 2
17
+ experts:
18
+ - source_model: expert_model_1
19
+ positive_prompts:
20
+ - "This is a prompt that is demonstrative of what expert_model_1 excels at"
21
+ ## (optional)
22
+ # negative_prompts:
23
+ # - "This is a prompt expert_model_1 should not be used for"
24
+ - source_model: expert_model_2
25
+ # ... and so on
26
+ ```
27
+
28
+ The script takes two arguments, an input config and an output path: `mergekit-moe ./config.yml ./my-clowncar-moe-12x180B`
29
+
30
+ 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:
31
+
32
+ ```yml
33
+ base_model: path/to/self_attn_donor
34
+ gate_mode: hidden # one of "hidden", "cheap_embed", or "random"
35
+ dtype: bfloat16 # output dtype (float32, float16, or bfloat16)
36
+ experts:
37
+ ...
38
+ shared_experts:
39
+ - source_model: model_name
40
+ positive_prompts: # required by Qwen MoE for "hidden" gate mode, otherwise not allowed
41
+ - "blah blah"
42
+ # (optional, but recommended:)
43
+ residual_scale: 0.1 # downweight output from shared expert to prevent overcooking the model
44
+ ```
45
+
46
+ Currently only up to one shared expert is supported.
47
+
48
+ 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:
49
+
50
+ ```yml
51
+ base_model: path/to/self_attn_donor
52
+ architecture: qwen
53
+ # ... and so on
54
+ ```
55
+
56
+ ### Gate Modes
57
+
58
+ There are three methods for populating the MoE gates implemented.
59
+
60
+ #### "hidden"
61
+
62
+ 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.
63
+
64
+ #### "cheap_embed"
65
+
66
+ 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.
67
+
68
+ #### "random"
69
+
70
+ 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.
71
+
72
+ ## Example Configurations
73
+
74
+ Sparse upcycling of smol_llama into a 8x220M MoE:
75
+
76
+ ```yml
77
+ base_model: BEE-spoke-data/smol_llama-220M-GQA
78
+ gate_mode: random
79
+ dtype: bfloat16
80
+ experts:
81
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
82
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
83
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
84
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
85
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
86
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
87
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
88
+ - source_model: BEE-spoke-data/smol_llama-220M-GQA
89
+ # and then train the sucker!
90
+ ```
91
+
92
+ Shove some Mistral models in a clown car:
93
+
94
+ ```yml
95
+ base_model: NousResearch/Hermes-2-Pro-Mistral-7B
96
+ gate_mode: hidden
97
+ dtype: bfloat16
98
+ experts:
99
+ - source_model: NousResearch/Hermes-2-Pro-Mistral-7B
100
+ positive_prompts:
101
+ - "<|im_start|>user\nHello, who are you?<|im_end|>"
102
+ - "<|im_start|>user\nI need help with"
103
+ - source_model: BioMistral/BioMistral-7B-DARE
104
+ positive_prompts:
105
+ - "As a doctor of medicine,"
106
+ - source_model: PocketDoc/Dans-AdventurousWinds-7b
107
+ positive_prompts:
108
+ - "[Genres: Science Fiction]\n[Tags: humor, old school, sci fi]"
109
+ - "> get ye flask"
110
+ - "[Mode: Interactive Storyteller]"
111
+ - source_model: VAGOsolutions/SauerkrautLM-7b-HerO
112
+ positive_prompts:
113
+ - "<|im_start|>user\nWie geht es dir?<|im_end|>"
114
+ - "Das ist ein Satz auf Deutsch."
115
+ ```
116
+
117
+ ## FAQ
118
+
119
+ ### What does the "Your model has duplicated tensors but the --clone-tensors flag is not set" warning mean?
120
+
121
+ Answer from [Charles O. Goddard (cg123)](https://github.com/cg123)
122
+ (also see [this GitHub issue](https://github.com/arcee-ai/mergekit/issues/279#issuecomment-2081818104)):
123
+
124
+ > 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.
examples/gradient-slerp.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ slices:
2
+ - sources:
3
+ - model: psmathur/orca_mini_v3_13b
4
+ layer_range: [0, 40]
5
+ - model: garage-bAInd/Platypus2-13B
6
+ layer_range: [0, 40]
7
+ # or, the equivalent models: syntax:
8
+ # models:
9
+ # - model: psmathur/orca_mini_v3_13b
10
+ # - model: garage-bAInd/Platypus2-13B
11
+ merge_method: slerp
12
+ base_model: psmathur/orca_mini_v3_13b
13
+ parameters:
14
+ t:
15
+ - filter: self_attn
16
+ value: [0, 0.5, 0.3, 0.7, 1]
17
+ - filter: mlp
18
+ value: [1, 0.5, 0.7, 0.3, 0]
19
+ - value: 0.5 # fallback for rest of tensors
20
+ dtype: float16
examples/linear.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ models:
2
+ - model: psmathur/orca_mini_v3_13b
3
+ parameters:
4
+ weight: 1.0
5
+ - model: WizardLM/WizardLM-13B-V1.2
6
+ parameters:
7
+ weight: 0.3
8
+ - model: garage-bAInd/Platypus2-13B
9
+ parameters:
10
+ weight: 0.5
11
+ merge_method: linear
12
+ dtype: float16
examples/mega.yml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ slices:
2
+ - sources:
3
+ - model: psmathur/orca_mini_v3_13b
4
+ layer_range: [0, 40]
5
+ - model: garage-bAInd/Platypus2-13B
6
+ layer_range: [0, 40]
7
+ merge_method: slerp
8
+ base_model: psmathur/orca_mini_v3_13b
9
+ parameters:
10
+ t:
11
+ - filter: self_attn
12
+ value: [0, 0.5, 0.3, 0.7, 1]
13
+ - filter: mlp
14
+ value: [1, 0.5, 0.7, 0.3, 0]
15
+ - value: 0.5 # fallback for rest of tensors
16
+ dtype: float16
17
+ name: gradient-slerp
18
+ ---
19
+ models:
20
+ - model: gradient-slerp
21
+ parameters:
22
+ density: [1, 0.7, 0.1] # density gradient
23
+ weight: 1.0
24
+ - model: WizardLM/WizardMath-13B-V1.0
25
+ parameters:
26
+ density: 0.33
27
+ weight:
28
+ - filter: mlp
29
+ value: 0.5
30
+ - value: 0
31
+ merge_method: ties
32
+ base_model: TheBloke/Llama-2-13B-fp16
33
+ parameters:
34
+ normalize: true
35
+ int8_mask: true
36
+ dtype: float16
37
+ name: gradient-slerp-ties
examples/orcamini-platy-44layer.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ slices:
2
+ - sources:
3
+ - model: psmathur/orca_mini_v3_13b
4
+ layer_range: [0, 24]
5
+ - sources:
6
+ - model: garage-bAInd/Platypus2-13B
7
+ layer_range: [20, 40]
8
+ merge_method: passthrough
9
+ dtype: float16
examples/ties.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ models:
2
+ - model: psmathur/orca_mini_v3_13b
3
+ parameters:
4
+ density: [1, 0.7, 0.1] # density gradient
5
+ weight: 1.0
6
+ - model: garage-bAInd/Platypus2-13B
7
+ parameters:
8
+ density: 0.5
9
+ weight: [0, 0.3, 0.7, 1] # weight gradient
10
+ - model: WizardLM/WizardMath-13B-V1.0
11
+ parameters:
12
+ density: 0.33
13
+ weight:
14
+ - filter: mlp
15
+ value: 0.5
16
+ - value: 0
17
+ merge_method: ties
18
+ base_model: TheBloke/Llama-2-13B-fp16
19
+ parameters:
20
+ normalize: true
21
+ int8_mask: true
22
+ dtype: float16
mergekit/__init__.py ADDED
File without changes
mergekit/_data/__init__.py ADDED
File without changes
mergekit/_data/architectures/__init__.py ADDED
File without changes
mergekit/_data/architectures/baichuan.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "baichuan",
3
+ "architectures": [
4
+ "BaichuanForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "model.norm.weight"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true
19
+ }
20
+ ],
21
+ "num_layers_config_key": "num_hidden_layers",
22
+ "layer_templates": {
23
+ "weights": [
24
+ {
25
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
26
+ },
27
+ {
28
+ "name": "model.layers.${layer_index}.self_attn.W_pack.weight"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight"
44
+ }
45
+ ]
46
+ }
47
+ }
mergekit/_data/architectures/bert-masked-lm.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "bert",
3
+ "architectures": [
4
+ "BertForMaskedLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "bert.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "bert.embeddings.token_type_embeddings.weight"
12
+ },
13
+ {
14
+ "name": "bert.embeddings.word_embeddings.weight",
15
+ "is_embed": true
16
+ },
17
+ {
18
+ "name": "bert.embeddings.LayerNorm.bias",
19
+ "aliases": [
20
+ "bert.embeddings.LayerNorm.beta"
21
+ ]
22
+ },
23
+ {
24
+ "name": "bert.embeddings.LayerNorm.weight",
25
+ "aliases": [
26
+ "bert.embeddings.LayerNorm.gamma"
27
+ ]
28
+ },
29
+ {
30
+ "name": "bert.embeddings.position_ids",
31
+ "optional": true,
32
+ "force_dtype": "int64"
33
+ }
34
+ ],
35
+ "post_weights": [
36
+ {
37
+ "name": "bert.pooler.dense.weight"
38
+ },
39
+ {
40
+ "name": "bert.pooler.dense.bias"
41
+ },
42
+ {
43
+ "name": "cls.predictions.bias"
44
+ },
45
+ {
46
+ "name": "cls.predictions.decoder.weight",
47
+ "aliases": [
48
+ "bert.embeddings.word_embeddings.weight"
49
+ ],
50
+ "is_embed": true
51
+ }
52
+ ],
53
+ "num_layers_config_key": "num_hidden_layers",
54
+ "layer_templates": {
55
+ "weights": [
56
+ {
57
+ "name": "bert.encoder.layer.${layer_index}.attention.self.query.weight"
58
+ },
59
+ {
60
+ "name": "bert.encoder.layer.${layer_index}.attention.self.query.bias"
61
+ },
62
+ {
63
+ "name": "bert.encoder.layer.${layer_index}.attention.self.key.weight"
64
+ },
65
+ {
66
+ "name": "bert.encoder.layer.${layer_index}.attention.self.key.bias"
67
+ },
68
+ {
69
+ "name": "bert.encoder.layer.${layer_index}.attention.self.value.weight"
70
+ },
71
+ {
72
+ "name": "bert.encoder.layer.${layer_index}.attention.self.value.bias"
73
+ },
74
+ {
75
+ "name": "bert.encoder.layer.${layer_index}.attention.output.dense.weight"
76
+ },
77
+ {
78
+ "name": "bert.encoder.layer.${layer_index}.attention.output.dense.bias"
79
+ },
80
+ {
81
+ "name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
82
+ "aliases": [
83
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
84
+ ]
85
+ },
86
+ {
87
+ "name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
88
+ "aliases": [
89
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
90
+ ]
91
+ },
92
+ {
93
+ "name": "bert.encoder.layer.${layer_index}.intermediate.dense.weight"
94
+ },
95
+ {
96
+ "name": "bert.encoder.layer.${layer_index}.intermediate.dense.bias"
97
+ },
98
+ {
99
+ "name": "bert.encoder.layer.${layer_index}.output.dense.weight"
100
+ },
101
+ {
102
+ "name": "bert.encoder.layer.${layer_index}.output.dense.bias"
103
+ },
104
+ {
105
+ "name": "bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
106
+ "aliases": [
107
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
108
+ ]
109
+ },
110
+ {
111
+ "name": "bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
112
+ "aliases": [
113
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
114
+ ]
115
+ }
116
+ ]
117
+ }
118
+ }
mergekit/_data/architectures/bert-sequence-classification.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "bert",
3
+ "architectures": [
4
+ "BertForSequenceClassification",
5
+ "BertForMultipleChoice",
6
+ "BertForTokenClassification"
7
+ ],
8
+ "pre_weights": [
9
+ {
10
+ "name": "bert.embeddings.position_embeddings.weight"
11
+ },
12
+ {
13
+ "name": "bert.embeddings.token_type_embeddings.weight"
14
+ },
15
+ {
16
+ "name": "bert.embeddings.word_embeddings.weight",
17
+ "is_embed": true
18
+ },
19
+ {
20
+ "name": "bert.embeddings.LayerNorm.bias",
21
+ "aliases": [
22
+ "bert.embeddings.LayerNorm.beta"
23
+ ]
24
+ },
25
+ {
26
+ "name": "bert.embeddings.LayerNorm.weight",
27
+ "aliases": [
28
+ "bert.embeddings.LayerNorm.gamma"
29
+ ]
30
+ },
31
+ {
32
+ "name": "bert.embeddings.position_ids",
33
+ "optional": true,
34
+ "force_dtype": "int64"
35
+ }
36
+ ],
37
+ "post_weights": [
38
+ {
39
+ "name": "bert.pooler.dense.weight",
40
+ "optional": true
41
+ },
42
+ {
43
+ "name": "bert.pooler.dense.bias",
44
+ "optional": true
45
+ },
46
+ {
47
+ "name": "classifier.bias"
48
+ },
49
+ {
50
+ "name": "classifier.weight"
51
+ }
52
+ ],
53
+ "num_layers_config_key": "num_hidden_layers",
54
+ "layer_templates": {
55
+ "weights": [
56
+ {
57
+ "name": "bert.encoder.layer.${layer_index}.attention.self.query.weight"
58
+ },
59
+ {
60
+ "name": "bert.encoder.layer.${layer_index}.attention.self.query.bias"
61
+ },
62
+ {
63
+ "name": "bert.encoder.layer.${layer_index}.attention.self.key.weight"
64
+ },
65
+ {
66
+ "name": "bert.encoder.layer.${layer_index}.attention.self.key.bias"
67
+ },
68
+ {
69
+ "name": "bert.encoder.layer.${layer_index}.attention.self.value.weight"
70
+ },
71
+ {
72
+ "name": "bert.encoder.layer.${layer_index}.attention.self.value.bias"
73
+ },
74
+ {
75
+ "name": "bert.encoder.layer.${layer_index}.attention.output.dense.weight"
76
+ },
77
+ {
78
+ "name": "bert.encoder.layer.${layer_index}.attention.output.dense.bias"
79
+ },
80
+ {
81
+ "name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
82
+ "aliases": [
83
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
84
+ ]
85
+ },
86
+ {
87
+ "name": "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
88
+ "aliases": [
89
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
90
+ ]
91
+ },
92
+ {
93
+ "name": "bert.encoder.layer.${layer_index}.intermediate.dense.weight"
94
+ },
95
+ {
96
+ "name": "bert.encoder.layer.${layer_index}.intermediate.dense.bias"
97
+ },
98
+ {
99
+ "name": "bert.encoder.layer.${layer_index}.output.dense.weight"
100
+ },
101
+ {
102
+ "name": "bert.encoder.layer.${layer_index}.output.dense.bias"
103
+ },
104
+ {
105
+ "name": "bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
106
+ "aliases": [
107
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
108
+ ]
109
+ },
110
+ {
111
+ "name": "bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
112
+ "aliases": [
113
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
114
+ ]
115
+ }
116
+ ]
117
+ }
118
+ }
mergekit/_data/architectures/bert.json ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "bert",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "embeddings.position_embeddings.weight",
9
+ "aliases": [
10
+ "bert.embeddings.position_embeddings.weight"
11
+ ]
12
+ },
13
+ {
14
+ "name": "embeddings.token_type_embeddings.weight",
15
+ "aliases": [
16
+ "bert.embeddings.token_type_embeddings.weight"
17
+ ]
18
+ },
19
+ {
20
+ "name": "embeddings.word_embeddings.weight",
21
+ "is_embed": true,
22
+ "aliases": [
23
+ "bert.embeddings.word_embeddings.weight"
24
+ ]
25
+ },
26
+ {
27
+ "name": "embeddings.LayerNorm.bias",
28
+ "aliases": [
29
+ "embeddings.LayerNorm.beta",
30
+ "bert.embeddings.LayerNorm.bias",
31
+ "bert.embeddings.LayerNorm.beta"
32
+ ]
33
+ },
34
+ {
35
+ "name": "embeddings.LayerNorm.weight",
36
+ "aliases": [
37
+ "embeddings.LayerNorm.gamma",
38
+ "bert.embeddings.LayerNorm.weight",
39
+ "bert.embeddings.LayerNorm.gamma",
40
+ "bert.embeddings.LayerNorm.weight"
41
+ ]
42
+ },
43
+ {
44
+ "name": "embeddings.position_ids",
45
+ "optional": true,
46
+ "force_dtype": "int64",
47
+ "aliases": [
48
+ "bert.embeddings.position_ids"
49
+ ]
50
+ }
51
+ ],
52
+ "post_weights": [
53
+ {
54
+ "name": "pooler.dense.weight",
55
+ "aliases": [
56
+ "bert.pooler.dense.weight"
57
+ ]
58
+ },
59
+ {
60
+ "name": "pooler.dense.bias",
61
+ "aliases": [
62
+ "bert.pooler.dense.bias"
63
+ ]
64
+ }
65
+ ],
66
+ "num_layers_config_key": "num_hidden_layers",
67
+ "layer_templates": {
68
+ "weights": [
69
+ {
70
+ "name": "encoder.layer.${layer_index}.attention.self.query.weight",
71
+ "aliases": [
72
+ "bert.encoder.layer.${layer_index}.attention.self.query.weight"
73
+ ]
74
+ },
75
+ {
76
+ "name": "encoder.layer.${layer_index}.attention.self.query.bias",
77
+ "aliases": [
78
+ "bert.encoder.layer.${layer_index}.attention.self.query.bias"
79
+ ]
80
+ },
81
+ {
82
+ "name": "encoder.layer.${layer_index}.attention.self.key.weight",
83
+ "aliases": [
84
+ "bert.encoder.layer.${layer_index}.attention.self.key.weight"
85
+ ]
86
+ },
87
+ {
88
+ "name": "encoder.layer.${layer_index}.attention.self.key.bias",
89
+ "aliases": [
90
+ "bert.encoder.layer.${layer_index}.attention.self.key.bias"
91
+ ]
92
+ },
93
+ {
94
+ "name": "encoder.layer.${layer_index}.attention.self.value.weight",
95
+ "aliases": [
96
+ "bert.encoder.layer.${layer_index}.attention.self.value.weight"
97
+ ]
98
+ },
99
+ {
100
+ "name": "encoder.layer.${layer_index}.attention.self.value.bias",
101
+ "aliases": [
102
+ "bert.encoder.layer.${layer_index}.attention.self.value.bias"
103
+ ]
104
+ },
105
+ {
106
+ "name": "encoder.layer.${layer_index}.attention.output.dense.weight",
107
+ "aliases": [
108
+ "bert.encoder.layer.${layer_index}.attention.output.dense.weight"
109
+ ]
110
+ },
111
+ {
112
+ "name": "encoder.layer.${layer_index}.attention.output.dense.bias",
113
+ "aliases": [
114
+ "bert.encoder.layer.${layer_index}.attention.output.dense.bias"
115
+ ]
116
+ },
117
+ {
118
+ "name": "encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
119
+ "aliases": [
120
+ "encoder.layer.${layer_index}.attention.output.LayerNorm.beta",
121
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.bias",
122
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.beta"
123
+ ]
124
+ },
125
+ {
126
+ "name": "encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
127
+ "aliases": [
128
+ "encoder.layer.${layer_index}.attention.output.LayerNorm.gamma",
129
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.weight",
130
+ "bert.encoder.layer.${layer_index}.attention.output.LayerNorm.gamma"
131
+ ]
132
+ },
133
+ {
134
+ "name": "encoder.layer.${layer_index}.intermediate.dense.weight",
135
+ "aliases": [
136
+ "bert.encoder.layer.${layer_index}.intermediate.dense.weight"
137
+ ]
138
+ },
139
+ {
140
+ "name": "encoder.layer.${layer_index}.intermediate.dense.bias",
141
+ "aliases": [
142
+ "bert.encoder.layer.${layer_index}.intermediate.dense.bias"
143
+ ]
144
+ },
145
+ {
146
+ "name": "encoder.layer.${layer_index}.output.dense.weight",
147
+ "aliases": [
148
+ "bert.encoder.layer.${layer_index}.output.dense.weight"
149
+ ]
150
+ },
151
+ {
152
+ "name": "encoder.layer.${layer_index}.output.dense.bias",
153
+ "aliases": [
154
+ "bert.encoder.layer.${layer_index}.output.dense.bias"
155
+ ]
156
+ },
157
+ {
158
+ "name": "encoder.layer.${layer_index}.output.LayerNorm.bias",
159
+ "aliases": [
160
+ "encoder.layer.${layer_index}.output.LayerNorm.beta",
161
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.bias",
162
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.beta"
163
+ ]
164
+ },
165
+ {
166
+ "name": "encoder.layer.${layer_index}.output.LayerNorm.weight",
167
+ "aliases": [
168
+ "encoder.layer.${layer_index}.output.LayerNorm.gamma",
169
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.weight",
170
+ "bert.encoder.layer.${layer_index}.output.LayerNorm.gamma"
171
+ ]
172
+ }
173
+ ]
174
+ }
175
+ }
mergekit/_data/architectures/chatglm.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "chatglm",
3
+ "architectures": [
4
+ "ChatGLMModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.embedding.word_embeddings.weight",
9
+ "is_embed": true
10
+ },
11
+ {
12
+ "name": "transformer.rotary_pos_emb.inv_freq"
13
+ }
14
+ ],
15
+ "post_weights": [
16
+ {
17
+ "name": "transformer.encoder.final_layernorm.weight"
18
+ },
19
+ {
20
+ "name": "transformer.output_layer.weight",
21
+ "is_embed": true
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "transformer.encoder.layers.${layer_index}.input_layernorm.weight"
29
+ },
30
+ {
31
+ "name": "transformer.encoder.layers.${layer_index}.mlp.dense_4h_to_h.weight"
32
+ },
33
+ {
34
+ "name": "transformer.encoder.layers.${layer_index}.mlp.dense_h_to_4h.weight"
35
+ },
36
+ {
37
+ "name": "transformer.encoder.layers.${layer_index}.post_attention_layernorm.weight"
38
+ },
39
+ {
40
+ "name": "transformer.encoder.layers.${layer_index}.self_attention.dense.weight"
41
+ },
42
+ {
43
+ "name": "transformer.encoder.layers.${layer_index}.self_attention.query_key_value.bias"
44
+ },
45
+ {
46
+ "name": "transformer.encoder.layers.${layer_index}.self_attention.query_key_value.weight"
47
+ }
48
+ ]
49
+ }
50
+ }
mergekit/_data/architectures/cohere.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "cohere",
3
+ "architectures": [
4
+ "CohereForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "model.norm.weight"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true,
19
+ "aliases": [
20
+ "model.embed_tokens.weight"
21
+ ]
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight"
47
+ },
48
+ {
49
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight"
50
+ }
51
+ ]
52
+ }
53
+ }
mergekit/_data/architectures/distilbert-masked-lm.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "distilbert",
3
+ "architectures": [
4
+ "DistilBertForMaskedLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "distilbert.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "distilbert.embeddings.word_embeddings.weight",
12
+ "is_embed": true
13
+ },
14
+ {
15
+ "name": "distilbert.embeddings.LayerNorm.bias",
16
+ "aliases": [
17
+ "distilbert.embeddings.LayerNorm.beta"
18
+ ]
19
+ },
20
+ {
21
+ "name": "distilbert.embeddings.LayerNorm.weight",
22
+ "aliases": [
23
+ "distilbert.embeddings.LayerNorm.gamma"
24
+ ]
25
+ }
26
+ ],
27
+ "post_weights": [
28
+ {
29
+ "name": "vocab_transform.weight"
30
+ },
31
+ {
32
+ "name": "vocab_transform.bias"
33
+ },
34
+ {
35
+ "name": "vocab_layer_norm.bias"
36
+ },
37
+ {
38
+ "name": "vocab_layer_norm.weight"
39
+ },
40
+ {
41
+ "name": "vocab_projector.weight",
42
+ "is_embed": true,
43
+ "aliases": [
44
+ "distilbert.embeddings.word_embeddings.weight"
45
+ ]
46
+ },
47
+ {
48
+ "name": "vocab_projector.bias"
49
+ }
50
+ ],
51
+ "num_layers_config_key": "num_hidden_layers",
52
+ "layer_templates": {
53
+ "weights": [
54
+ {
55
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
56
+ },
57
+ {
58
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
59
+ },
60
+ {
61
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
62
+ },
63
+ {
64
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
65
+ },
66
+ {
67
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
68
+ },
69
+ {
70
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
71
+ },
72
+ {
73
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
74
+ },
75
+ {
76
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
77
+ },
78
+ {
79
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
80
+ },
81
+ {
82
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
83
+ },
84
+ {
85
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
86
+ },
87
+ {
88
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
89
+ },
90
+ {
91
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
92
+ },
93
+ {
94
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
95
+ },
96
+ {
97
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
98
+ },
99
+ {
100
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
101
+ }
102
+ ]
103
+ }
104
+ }
mergekit/_data/architectures/distilbert-sequence-classification.json ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "distilbert",
3
+ "architectures": [
4
+ "DistilBertForSequenceClassification"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "distilbert.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "distilbert.embeddings.word_embeddings.weight",
12
+ "is_embed": true
13
+ },
14
+ {
15
+ "name": "distilbert.embeddings.LayerNorm.bias",
16
+ "aliases": [
17
+ "distilbert.embeddings.LayerNorm.beta"
18
+ ]
19
+ },
20
+ {
21
+ "name": "distilbert.embeddings.LayerNorm.weight",
22
+ "aliases": [
23
+ "distilbert.embeddings.LayerNorm.gamma"
24
+ ]
25
+ }
26
+ ],
27
+ "post_weights": [
28
+ {
29
+ "name": "classifier.bias"
30
+ },
31
+ {
32
+ "name": "classifier.weight"
33
+ },
34
+ {
35
+ "name": "pre_classifier.bias"
36
+ },
37
+ {
38
+ "name": "pre_classifier.weight"
39
+ }
40
+ ],
41
+ "num_layers_config_key": "num_hidden_layers",
42
+ "layer_templates": {
43
+ "weights": [
44
+ {
45
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
46
+ },
47
+ {
48
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
49
+ },
50
+ {
51
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
52
+ },
53
+ {
54
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
55
+ },
56
+ {
57
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
58
+ },
59
+ {
60
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
61
+ },
62
+ {
63
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
64
+ },
65
+ {
66
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
67
+ },
68
+ {
69
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
70
+ },
71
+ {
72
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
73
+ },
74
+ {
75
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
76
+ },
77
+ {
78
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
79
+ },
80
+ {
81
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
82
+ },
83
+ {
84
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
85
+ },
86
+ {
87
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
88
+ },
89
+ {
90
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
91
+ }
92
+ ]
93
+ }
94
+ }
mergekit/_data/architectures/distilbert-token-classification.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "distilbert",
3
+ "architectures": [
4
+ "DistilBertForTokenClassification"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "distilbert.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "distilbert.embeddings.word_embeddings.weight",
12
+ "is_embed": true
13
+ },
14
+ {
15
+ "name": "distilbert.embeddings.LayerNorm.bias",
16
+ "aliases": [
17
+ "distilbert.embeddings.LayerNorm.beta"
18
+ ]
19
+ },
20
+ {
21
+ "name": "distilbert.embeddings.LayerNorm.weight",
22
+ "aliases": [
23
+ "distilbert.embeddings.LayerNorm.gamma"
24
+ ]
25
+ }
26
+ ],
27
+ "post_weights": [
28
+ {
29
+ "name": "classifier.bias"
30
+ },
31
+ {
32
+ "name": "classifier.weight"
33
+ }
34
+ ],
35
+ "num_layers_config_key": "num_hidden_layers",
36
+ "layer_templates": {
37
+ "weights": [
38
+ {
39
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
40
+ },
41
+ {
42
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
43
+ },
44
+ {
45
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
46
+ },
47
+ {
48
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
49
+ },
50
+ {
51
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
52
+ },
53
+ {
54
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
55
+ },
56
+ {
57
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
58
+ },
59
+ {
60
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
61
+ },
62
+ {
63
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
64
+ },
65
+ {
66
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
67
+ },
68
+ {
69
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
70
+ },
71
+ {
72
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
73
+ },
74
+ {
75
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
76
+ },
77
+ {
78
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
79
+ },
80
+ {
81
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
82
+ },
83
+ {
84
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
85
+ }
86
+ ]
87
+ }
88
+ }
mergekit/_data/architectures/distilbert.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "distilbert",
3
+ "architectures": [
4
+ "DistilBertModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "distilbert.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "distilbert.embeddings.word_embeddings.weight",
12
+ "is_embed": true
13
+ },
14
+ {
15
+ "name": "distilbert.embeddings.LayerNorm.bias",
16
+ "aliases": [
17
+ "distilbert.embeddings.LayerNorm.beta"
18
+ ]
19
+ },
20
+ {
21
+ "name": "distilbert.embeddings.LayerNorm.weight",
22
+ "aliases": [
23
+ "distilbert.embeddings.LayerNorm.gamma"
24
+ ]
25
+ }
26
+ ],
27
+ "post_weights": [],
28
+ "num_layers_config_key": "num_hidden_layers",
29
+ "layer_templates": {
30
+ "weights": [
31
+ {
32
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.weight"
33
+ },
34
+ {
35
+ "name": "distilbert.transformer.layer.${layer_index}.attention.k_lin.bias"
36
+ },
37
+ {
38
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.weight"
39
+ },
40
+ {
41
+ "name": "distilbert.transformer.layer.${layer_index}.attention.q_lin.bias"
42
+ },
43
+ {
44
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.weight"
45
+ },
46
+ {
47
+ "name": "distilbert.transformer.layer.${layer_index}.attention.v_lin.bias"
48
+ },
49
+ {
50
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.weight"
51
+ },
52
+ {
53
+ "name": "distilbert.transformer.layer.${layer_index}.attention.out_lin.bias"
54
+ },
55
+ {
56
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.bias"
57
+ },
58
+ {
59
+ "name": "distilbert.transformer.layer.${layer_index}.sa_layer_norm.weight"
60
+ },
61
+ {
62
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.weight"
63
+ },
64
+ {
65
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin1.bias"
66
+ },
67
+ {
68
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.weight"
69
+ },
70
+ {
71
+ "name": "distilbert.transformer.layer.${layer_index}.ffn.lin2.bias"
72
+ },
73
+ {
74
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.bias"
75
+ },
76
+ {
77
+ "name": "distilbert.transformer.layer.${layer_index}.output_layer_norm.weight"
78
+ }
79
+ ]
80
+ }
81
+ }
mergekit/_data/architectures/falcon.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "falcon",
3
+ "architectures": [
4
+ "FalconForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.word_embeddings.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "transformer.ln_f.weight"
15
+ },
16
+ {
17
+ "name": "transformer.ln_f.bias"
18
+ },
19
+ {
20
+ "name": "lm_head.weight",
21
+ "is_embed": true
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "transformer.h.${layer_index}.ln_attn.bias"
29
+ },
30
+ {
31
+ "name": "transformer.h.${layer_index}.ln_attn.weight"
32
+ },
33
+ {
34
+ "name": "transformer.h.${layer_index}.ln_mlp.bias"
35
+ },
36
+ {
37
+ "name": "transformer.h.${layer_index}.ln_mlp.weight"
38
+ },
39
+ {
40
+ "name": "transformer.h.${layer_index}.mlp.dense_4h_to_h.weight"
41
+ },
42
+ {
43
+ "name": "transformer.h.${layer_index}.mlp.dense_h_to_4h.weight"
44
+ },
45
+ {
46
+ "name": "transformer.h.${layer_index}.self_attention.dense.weight"
47
+ },
48
+ {
49
+ "name": "transformer.h.${layer_index}.self_attention.query_key_value.weight"
50
+ }
51
+ ]
52
+ }
53
+ }
mergekit/_data/architectures/gemma.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gemma",
3
+ "architectures": [
4
+ "GemmaForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true,
10
+ "output_space": "h_0"
11
+ }
12
+ ],
13
+ "num_layers_config_key": "num_hidden_layers",
14
+ "layer_templates": {
15
+ "weights": [
16
+ {
17
+ "name": "model.layers.${layer_index}.input_layernorm.weight",
18
+ "input_space": "h_${layer_index}"
19
+ },
20
+ {
21
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight",
22
+ "input_space": "h_${layer_index}",
23
+ "output_space": "attn_qk_${layer_index}"
24
+ },
25
+ {
26
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight",
27
+ "input_space": "h_${layer_index}",
28
+ "output_space": "attn_qk_${layer_index}"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight",
32
+ "input_space": "h_${layer_index}",
33
+ "output_space": "attn_v_${layer_index}"
34
+ },
35
+ {
36
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight",
37
+ "input_space": "attn_v_${layer_index}",
38
+ "output_space": "post_attn_${layer_index}"
39
+ },
40
+ {
41
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight",
42
+ "input_space": "h_a_${layer_index}"
43
+ },
44
+ {
45
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight",
46
+ "input_space": "h_a_${layer_index}",
47
+ "output_space": "up_${layer_index}"
48
+ },
49
+ {
50
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight",
51
+ "input_space": "h_a_${layer_index}",
52
+ "output_space": "up_${layer_index}"
53
+ },
54
+ {
55
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight",
56
+ "input_space": "up_${layer_index}",
57
+ "output_space": "post_mlp_${layer_index}"
58
+ }
59
+ ],
60
+ "procedural_spaces": [
61
+ {
62
+ "name": "h_a_${layer_index}",
63
+ "type": "residual",
64
+ "inputs": [
65
+ "h_${layer_index}",
66
+ "post_attn_${layer_index}"
67
+ ]
68
+ },
69
+ {
70
+ "name": "h_${layer_index+1}",
71
+ "type": "residual",
72
+ "inputs": [
73
+ "h_a_${layer_index}",
74
+ "post_mlp_${layer_index}"
75
+ ]
76
+ }
77
+ ]
78
+ },
79
+ "post_weights": [
80
+ {
81
+ "name": "model.norm.weight",
82
+ "input_space": "h_${num_layers}"
83
+ }
84
+ ]
85
+ }
mergekit/_data/architectures/gemma2.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gemma2",
3
+ "architectures": [
4
+ "Gemma2ForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "num_layers_config_key": "num_hidden_layers",
13
+ "layer_templates": {
14
+ "weights": [
15
+ {
16
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
17
+ },
18
+ {
19
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight"
20
+ },
21
+ {
22
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight"
23
+ },
24
+ {
25
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight"
26
+ },
27
+ {
28
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.pre_feedforward_layernorm.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.post_feedforward_layernorm.weight"
47
+ }
48
+ ]
49
+ },
50
+ "post_weights": [
51
+ {
52
+ "name": "model.norm.weight"
53
+ },
54
+ {
55
+ "name": "lm_head.weight",
56
+ "is_embed": true,
57
+ "aliases": [
58
+ "model.embed_tokens.weight"
59
+ ]
60
+ }
61
+ ]
62
+ }
mergekit/_data/architectures/gpt-neox.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gpt_neox",
3
+ "architectures": [
4
+ "GPTNeoXForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "gpt_neox.embed_in.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "gpt_neox.final_layer_norm.bias"
15
+ },
16
+ {
17
+ "name": "gpt_neox.final_layer_norm.weight"
18
+ },
19
+ {
20
+ "name": "embed_out.weight",
21
+ "is_embed": true
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "gpt_neox.layers.${layer_index}.attention.dense.weight"
29
+ },
30
+ {
31
+ "name": "gpt_neox.layers.${layer_index}.attention.dense.bias"
32
+ },
33
+ {
34
+ "name": "gpt_neox.layers.${layer_index}.attention.query_key_value.weight"
35
+ },
36
+ {
37
+ "name": "gpt_neox.layers.${layer_index}.attention.query_key_value.bias"
38
+ },
39
+ {
40
+ "name": "gpt_neox.layers.${layer_index}.input_layernorm.weight"
41
+ },
42
+ {
43
+ "name": "gpt_neox.layers.${layer_index}.input_layernorm.bias"
44
+ },
45
+ {
46
+ "name": "gpt_neox.layers.${layer_index}.mlp.dense_4h_to_h.weight"
47
+ },
48
+ {
49
+ "name": "gpt_neox.layers.${layer_index}.mlp.dense_4h_to_h.bias"
50
+ },
51
+ {
52
+ "name": "gpt_neox.layers.${layer_index}.mlp.dense_h_to_4h.weight"
53
+ },
54
+ {
55
+ "name": "gpt_neox.layers.${layer_index}.mlp.dense_h_to_4h.bias"
56
+ },
57
+ {
58
+ "name": "gpt_neox.layers.${layer_index}.post_attention_layernorm.weight"
59
+ },
60
+ {
61
+ "name": "gpt_neox.layers.${layer_index}.post_attention_layernorm.bias"
62
+ },
63
+ {
64
+ "name": "gpt_neox.layers.${layer_index}.attention.bias"
65
+ },
66
+ {
67
+ "name": "gpt_neox.layers.${layer_index}.attention.masked_bias"
68
+ },
69
+ {
70
+ "name": "gpt_neox.layers.${layer_index}.attention.rotary_emb.inv_freq"
71
+ }
72
+ ]
73
+ }
74
+ }
mergekit/_data/architectures/gpt2-sequence-classification.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gpt2",
3
+ "architectures": [
4
+ "GPT2ForSequenceClassification"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.wte.weight"
9
+ },
10
+ {
11
+ "name": "transformer.wpe.weight"
12
+ }
13
+ ],
14
+ "post_weights": [
15
+ {
16
+ "name": "transformer.ln_f.weight"
17
+ },
18
+ {
19
+ "name": "transformer.ln_f.bias"
20
+ },
21
+ {
22
+ "name": "score.weight"
23
+ }
24
+ ],
25
+ "num_layers_config_key": "n_layer",
26
+ "layer_templates": {
27
+ "weights": [
28
+ {
29
+ "name": "transformer.h.${layer_index}.attn.c_attn.weight"
30
+ },
31
+ {
32
+ "name": "transformer.h.${layer_index}.attn.c_attn.bias"
33
+ },
34
+ {
35
+ "name": "transformer.h.${layer_index}.attn.c_proj.weight"
36
+ },
37
+ {
38
+ "name": "transformer.h.${layer_index}.attn.c_proj.bias"
39
+ },
40
+ {
41
+ "name": "transformer.h.${layer_index}.ln_1.weight"
42
+ },
43
+ {
44
+ "name": "transformer.h.${layer_index}.ln_1.bias"
45
+ },
46
+ {
47
+ "name": "transformer.h.${layer_index}.ln_2.weight"
48
+ },
49
+ {
50
+ "name": "transformer.h.${layer_index}.ln_2.bias"
51
+ },
52
+ {
53
+ "name": "transformer.h.${layer_index}.mlp.c_proj.weight"
54
+ },
55
+ {
56
+ "name": "transformer.h.${layer_index}.mlp.c_proj.bias"
57
+ },
58
+ {
59
+ "name": "transformer.h.${layer_index}.mlp.c_fc.weight"
60
+ },
61
+ {
62
+ "name": "transformer.h.${layer_index}.mlp.c_fc.bias"
63
+ }
64
+ ]
65
+ }
66
+ }
mergekit/_data/architectures/gpt2.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gpt2",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "wte.weight",
9
+ "is_embed": true
10
+ },
11
+ {
12
+ "name": "wpe.weight"
13
+ }
14
+ ],
15
+ "post_weights": [
16
+ {
17
+ "name": "ln_f.weight"
18
+ },
19
+ {
20
+ "name": "ln_f.bias"
21
+ }
22
+ ],
23
+ "num_layers_config_key": "n_layer",
24
+ "layer_templates": {
25
+ "weights": [
26
+ {
27
+ "name": "h.${layer_index}.attn.c_attn.weight"
28
+ },
29
+ {
30
+ "name": "h.${layer_index}.attn.c_attn.bias"
31
+ },
32
+ {
33
+ "name": "h.${layer_index}.attn.c_proj.weight"
34
+ },
35
+ {
36
+ "name": "h.${layer_index}.attn.c_proj.bias"
37
+ },
38
+ {
39
+ "name": "h.${layer_index}.ln_1.weight"
40
+ },
41
+ {
42
+ "name": "h.${layer_index}.ln_1.bias"
43
+ },
44
+ {
45
+ "name": "h.${layer_index}.ln_2.weight"
46
+ },
47
+ {
48
+ "name": "h.${layer_index}.ln_2.bias"
49
+ },
50
+ {
51
+ "name": "h.${layer_index}.mlp.c_proj.weight"
52
+ },
53
+ {
54
+ "name": "h.${layer_index}.mlp.c_proj.bias"
55
+ },
56
+ {
57
+ "name": "h.${layer_index}.mlp.c_fc.weight"
58
+ },
59
+ {
60
+ "name": "h.${layer_index}.mlp.c_fc.bias"
61
+ }
62
+ ]
63
+ }
64
+ }
mergekit/_data/architectures/gptbigcode.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gpt_bigcode",
3
+ "architectures": [
4
+ "GPTBigCodeForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.wte.weight",
9
+ "is_embed": true
10
+ },
11
+ {
12
+ "name": "transformer.wpe.weight"
13
+ }
14
+ ],
15
+ "post_weights": [
16
+ {
17
+ "name": "transformer.ln_f.weight"
18
+ },
19
+ {
20
+ "name": "transformer.ln_f.bias"
21
+ },
22
+ {
23
+ "name": "lm_head.weight",
24
+ "aliases": [
25
+ "transformer.wte.weight"
26
+ ]
27
+ }
28
+ ],
29
+ "num_layers_config_key": "n_layer",
30
+ "layer_templates": {
31
+ "weights": [
32
+ {
33
+ "name": "transformer.h.${layer_index}.attn.c_attn.weight"
34
+ },
35
+ {
36
+ "name": "transformer.h.${layer_index}.attn.c_attn.bias"
37
+ },
38
+ {
39
+ "name": "transformer.h.${layer_index}.attn.c_proj.weight"
40
+ },
41
+ {
42
+ "name": "transformer.h.${layer_index}.attn.c_proj.bias"
43
+ },
44
+ {
45
+ "name": "transformer.h.${layer_index}.ln_1.weight"
46
+ },
47
+ {
48
+ "name": "transformer.h.${layer_index}.ln_1.bias"
49
+ },
50
+ {
51
+ "name": "transformer.h.${layer_index}.ln_2.weight"
52
+ },
53
+ {
54
+ "name": "transformer.h.${layer_index}.ln_2.bias"
55
+ },
56
+ {
57
+ "name": "transformer.h.${layer_index}.mlp.c_proj.weight"
58
+ },
59
+ {
60
+ "name": "transformer.h.${layer_index}.mlp.c_proj.bias"
61
+ },
62
+ {
63
+ "name": "transformer.h.${layer_index}.mlp.c_fc.weight"
64
+ },
65
+ {
66
+ "name": "transformer.h.${layer_index}.mlp.c_fc.bias"
67
+ }
68
+ ]
69
+ }
70
+ }
mergekit/_data/architectures/jais.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "jais",
3
+ "architectures": [
4
+ "JAISLMHeadModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.wte.weight",
9
+ "is_embed": true
10
+ },
11
+ {
12
+ "name": "transformer.relative_pe.slopes"
13
+ }
14
+ ],
15
+ "post_weights": [
16
+ {
17
+ "name": "transformer.ln_f.weight"
18
+ },
19
+ {
20
+ "name": "transformer.ln_f.bias"
21
+ }
22
+ ],
23
+ "num_layers_config_key": "n_layer",
24
+ "layer_templates": {
25
+ "weights": [
26
+ {
27
+ "name": "transformer.h.${layer_index}.attn.c_attn.weight"
28
+ },
29
+ {
30
+ "name": "transformer.h.${layer_index}.attn.c_attn.bias"
31
+ },
32
+ {
33
+ "name": "transformer.h.${layer_index}.attn.c_proj.weight"
34
+ },
35
+ {
36
+ "name": "transformer.h.${layer_index}.attn.c_proj.bias"
37
+ },
38
+ {
39
+ "name": "transformer.h.${layer_index}.ln_1.weight"
40
+ },
41
+ {
42
+ "name": "transformer.h.${layer_index}.ln_1.bias"
43
+ },
44
+ {
45
+ "name": "transformer.h.${layer_index}.ln_2.weight"
46
+ },
47
+ {
48
+ "name": "transformer.h.${layer_index}.ln_2.bias"
49
+ },
50
+ {
51
+ "name": "transformer.h.${layer_index}.mlp.c_fc.weight"
52
+ },
53
+ {
54
+ "name": "transformer.h.${layer_index}.mlp.c_fc.bias"
55
+ },
56
+ {
57
+ "name": "transformer.h.${layer_index}.mlp.c_fc2.weight"
58
+ },
59
+ {
60
+ "name": "transformer.h.${layer_index}.mlp.c_fc2.bias"
61
+ },
62
+ {
63
+ "name": "transformer.h.${layer_index}.mlp.c_proj.weight"
64
+ },
65
+ {
66
+ "name": "transformer.h.${layer_index}.mlp.c_proj.bias"
67
+ }
68
+ ]
69
+ }
70
+ }
mergekit/_data/architectures/llama.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "llama",
3
+ "architectures": [
4
+ "LlamaForCausalLM",
5
+ "LLaMaForCausalLM"
6
+ ],
7
+ "pre_weights": [
8
+ {
9
+ "name": "model.embed_tokens.weight",
10
+ "is_embed": true,
11
+ "output_space": "h_0"
12
+ }
13
+ ],
14
+ "num_layers_config_key": "num_hidden_layers",
15
+ "layer_templates": {
16
+ "weights": [
17
+ {
18
+ "name": "model.layers.${layer_index}.input_layernorm.weight",
19
+ "input_space": "h_${layer_index}"
20
+ },
21
+ {
22
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight",
23
+ "input_space": "h_${layer_index}",
24
+ "output_space": "attn_qk_${layer_index}"
25
+ },
26
+ {
27
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight",
28
+ "input_space": "h_${layer_index}",
29
+ "output_space": "attn_qk_${layer_index}"
30
+ },
31
+ {
32
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight",
33
+ "input_space": "h_${layer_index}",
34
+ "output_space": "attn_v_${layer_index}"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight",
38
+ "input_space": "attn_v_${layer_index}",
39
+ "output_space": "post_attn_${layer_index}"
40
+ },
41
+ {
42
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight",
43
+ "input_space": "h_a_${layer_index}"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight",
47
+ "input_space": "h_a_${layer_index}",
48
+ "output_space": "up_${layer_index}"
49
+ },
50
+ {
51
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight",
52
+ "input_space": "h_a_${layer_index}",
53
+ "output_space": "up_${layer_index}"
54
+ },
55
+ {
56
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight",
57
+ "input_space": "up_${layer_index}",
58
+ "output_space": "post_mlp_${layer_index}"
59
+ }
60
+ ],
61
+ "procedural_spaces": [
62
+ {
63
+ "name": "h_a_${layer_index}",
64
+ "type": "residual",
65
+ "inputs": [
66
+ "h_${layer_index}",
67
+ "post_attn_${layer_index}"
68
+ ]
69
+ },
70
+ {
71
+ "name": "h_${layer_index+1}",
72
+ "type": "residual",
73
+ "inputs": [
74
+ "h_a_${layer_index}",
75
+ "post_mlp_${layer_index}"
76
+ ]
77
+ }
78
+ ]
79
+ },
80
+ "post_weights": [
81
+ {
82
+ "name": "model.norm.weight",
83
+ "input_space": "h_${num_layers}"
84
+ },
85
+ {
86
+ "name": "lm_head.weight",
87
+ "input_space": "h_${num_layers}",
88
+ "is_embed": true
89
+ }
90
+ ]
91
+ }
mergekit/_data/architectures/mamba.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "mamba",
3
+ "architectures": [
4
+ "MambaForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "backbone.embeddings.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "backbone.norm_f.weight"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true,
19
+ "aliases": ["backbone.embeddings.weight"]
20
+ }
21
+ ],
22
+ "num_layers_config_key": "num_hidden_layers",
23
+ "layer_templates": {
24
+ "weights": [
25
+ {
26
+ "name": "backbone.layers.${layer_index}.mixer.A_log"
27
+ },
28
+ {
29
+ "name": "backbone.layers.${layer_index}.mixer.conv1d.bias"
30
+ },
31
+ {
32
+ "name": "backbone.layers.${layer_index}.mixer.conv1d.weight"
33
+ },
34
+ {
35
+ "name": "backbone.layers.${layer_index}.mixer.D"
36
+ },
37
+ {
38
+ "name": "backbone.layers.${layer_index}.mixer.dt_proj.bias"
39
+ },
40
+ {
41
+ "name": "backbone.layers.${layer_index}.mixer.dt_proj.weight"
42
+ },
43
+ {
44
+ "name": "backbone.layers.${layer_index}.mixer.in_proj.weight"
45
+ },
46
+ {
47
+ "name": "backbone.layers.${layer_index}.mixer.out_proj.weight"
48
+ },
49
+ {
50
+ "name": "backbone.layers.${layer_index}.mixer.x_proj.weight"
51
+ },
52
+ {
53
+ "name": "backbone.layers.${layer_index}.norm.weight"
54
+ }
55
+ ]
56
+ }
57
+ }
mergekit/_data/architectures/mistral.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "mistral",
3
+ "architectures": [
4
+ "MistralForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true,
10
+ "output_space": "h_0"
11
+ }
12
+ ],
13
+ "num_layers_config_key": "num_hidden_layers",
14
+ "layer_templates": {
15
+ "weights": [
16
+ {
17
+ "name": "model.layers.${layer_index}.input_layernorm.weight",
18
+ "input_space": "h_${layer_index}"
19
+ },
20
+ {
21
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight",
22
+ "input_space": "h_${layer_index}",
23
+ "output_space": "attn_qk_${layer_index}"
24
+ },
25
+ {
26
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight",
27
+ "input_space": "h_${layer_index}",
28
+ "output_space": "attn_qk_${layer_index}"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight",
32
+ "input_space": "h_${layer_index}",
33
+ "output_space": "attn_v_${layer_index}"
34
+ },
35
+ {
36
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight",
37
+ "input_space": "attn_v_${layer_index}",
38
+ "output_space": "post_attn_${layer_index}"
39
+ },
40
+ {
41
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight",
42
+ "input_space": "h_a_${layer_index}"
43
+ },
44
+ {
45
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight",
46
+ "input_space": "h_a_${layer_index}",
47
+ "output_space": "up_${layer_index}"
48
+ },
49
+ {
50
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight",
51
+ "input_space": "h_a_${layer_index}",
52
+ "output_space": "up_${layer_index}"
53
+ },
54
+ {
55
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight",
56
+ "input_space": "up_${layer_index}",
57
+ "output_space": "post_mlp_${layer_index}"
58
+ }
59
+ ],
60
+ "procedural_spaces": [
61
+ {
62
+ "name": "h_a_${layer_index}",
63
+ "type": "residual",
64
+ "inputs": [
65
+ "h_${layer_index}",
66
+ "post_attn_${layer_index}"
67
+ ]
68
+ },
69
+ {
70
+ "name": "h_${layer_index+1}",
71
+ "type": "residual",
72
+ "inputs": [
73
+ "h_a_${layer_index}",
74
+ "post_mlp_${layer_index}"
75
+ ]
76
+ }
77
+ ]
78
+ },
79
+ "post_weights": [
80
+ {
81
+ "name": "model.norm.weight",
82
+ "input_space": "h_${num_layers}"
83
+ },
84
+ {
85
+ "name": "lm_head.weight",
86
+ "input_space": "h_${num_layers}",
87
+ "is_embed": true
88
+ }
89
+ ]
90
+ }
mergekit/_data/architectures/phi-1.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "mixformer-sequential",
3
+ "architectures": [
4
+ "MixFormerSequentialForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "layers.0.wte.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "num_layers_config_key": "n_layer",
13
+ "layer_templates": {
14
+ "weights": [
15
+ {
16
+ "name": "layers.${layer_index}.ln.bias"
17
+ },
18
+ {
19
+ "name": "layers.${layer_index}.ln.weight"
20
+ },
21
+ {
22
+ "name": "layers.${layer_index}.mixer.Wqkv.bias"
23
+ },
24
+ {
25
+ "name": "layers.${layer_index}.mixer.Wqkv.weight"
26
+ },
27
+ {
28
+ "name": "layers.${layer_index}.mixer.out_proj.bias"
29
+ },
30
+ {
31
+ "name": "layers.${layer_index}.mixer.out_proj.weight"
32
+ },
33
+ {
34
+ "name": "layers.${layer_index}.mixer.rotary_emb.inv_freq"
35
+ },
36
+ {
37
+ "name": "layers.${layer_index}.mlp.fc1.bias"
38
+ },
39
+ {
40
+ "name": "layers.${layer_index}.mlp.fc1.weight"
41
+ },
42
+ {
43
+ "name": "layers.${layer_index}.mlp.fc2.bias"
44
+ },
45
+ {
46
+ "name": "layers.${layer_index}.mlp.fc2.weight"
47
+ }
48
+ ]
49
+ },
50
+ "post_weights": [
51
+ {
52
+ "name": "layers.${num_layers}.linear.bias",
53
+ "is_embed": true
54
+ },
55
+ {
56
+ "name": "layers.${num_layers}.linear.weight",
57
+ "is_embed": true
58
+ },
59
+ {
60
+ "name": "layers.${num_layers}.ln.bias"
61
+ },
62
+ {
63
+ "name": "layers.${num_layers}.ln.weight"
64
+ }
65
+ ]
66
+ }
mergekit/_data/architectures/phi2-old.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "phi-msft",
3
+ "architectures": [
4
+ "PhiForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.embd.wte.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "lm_head.linear.bias"
15
+ },
16
+ {
17
+ "name": "lm_head.linear.weight",
18
+ "is_embed": true
19
+ },
20
+ {
21
+ "name": "lm_head.ln.bias"
22
+ },
23
+ {
24
+ "name": "lm_head.ln.weight"
25
+ }
26
+ ],
27
+ "num_layers_config_key": "n_layer",
28
+ "layer_templates": {
29
+ "weights": [
30
+ {
31
+ "name": "transformer.h.${layer_index}.ln.bias"
32
+ },
33
+ {
34
+ "name": "transformer.h.${layer_index}.ln.weight"
35
+ },
36
+ {
37
+ "name": "transformer.h.${layer_index}.mixer.out_proj.bias"
38
+ },
39
+ {
40
+ "name": "transformer.h.${layer_index}.mixer.out_proj.weight"
41
+ },
42
+ {
43
+ "name": "transformer.h.${layer_index}.mixer.Wqkv.bias"
44
+ },
45
+ {
46
+ "name": "transformer.h.${layer_index}.mixer.Wqkv.weight"
47
+ },
48
+ {
49
+ "name": "transformer.h.${layer_index}.mlp.fc1.bias"
50
+ },
51
+ {
52
+ "name": "transformer.h.${layer_index}.mlp.fc1.weight"
53
+ },
54
+ {
55
+ "name": "transformer.h.${layer_index}.mlp.fc2.bias"
56
+ },
57
+ {
58
+ "name": "transformer.h.${layer_index}.mlp.fc2.weight"
59
+ }
60
+ ]
61
+ }
62
+ }
mergekit/_data/architectures/phi2.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "phi",
3
+ "architectures": [
4
+ "PhiForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "lm_head.bias"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true
19
+ },
20
+ {
21
+ "name": "model.final_layernorm.bias"
22
+ },
23
+ {
24
+ "name": "model.final_layernorm.weight"
25
+ }
26
+ ],
27
+ "num_layers_config_key": "num_hidden_layers",
28
+ "layer_templates": {
29
+ "weights": [
30
+ {
31
+ "name": "model.layers.${layer_index}.input_layernorm.bias"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.self_attn.dense.bias"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.self_attn.dense.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.self_attn.q_proj.bias"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight"
47
+ },
48
+ {
49
+ "name": "model.layers.${layer_index}.self_attn.k_proj.bias"
50
+ },
51
+ {
52
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight"
53
+ },
54
+ {
55
+ "name": "model.layers.${layer_index}.self_attn.v_proj.bias"
56
+ },
57
+ {
58
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight"
59
+ },
60
+ {
61
+ "name": "model.layers.${layer_index}.mlp.fc1.bias"
62
+ },
63
+ {
64
+ "name": "model.layers.${layer_index}.mlp.fc1.weight"
65
+ },
66
+ {
67
+ "name": "model.layers.${layer_index}.mlp.fc2.bias"
68
+ },
69
+ {
70
+ "name": "model.layers.${layer_index}.mlp.fc2.weight"
71
+ }
72
+ ]
73
+ }
74
+ }
mergekit/_data/architectures/phi3.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "phi",
3
+ "architectures": [
4
+ "Phi3ForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "lm_head.weight",
15
+ "is_embed": true
16
+ },
17
+ {
18
+ "name": "model.norm.weight"
19
+ }
20
+ ],
21
+ "num_layers_config_key": "num_hidden_layers",
22
+ "layer_templates": {
23
+ "weights": [
24
+ {
25
+ "name": "model.layers.${layer_index}.input_layernorm.weight",
26
+ "is_embed": false
27
+ },
28
+ {
29
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight",
30
+ "is_embed": false
31
+ },
32
+ {
33
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight",
34
+ "is_embed": false
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.self_attn.qkv_proj.weight",
38
+ "is_embed": false
39
+ },
40
+ {
41
+ "name": "model.layers.${layer_index}.mlp.gate_up_proj.weight",
42
+ "is_embed": false
43
+ },
44
+ {
45
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight",
46
+ "is_embed": false
47
+ }
48
+ ]
49
+ }
50
+ }
mergekit/_data/architectures/qwen.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "qwen",
3
+ "architectures": [
4
+ "QWenLMHeadModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "transformer.wte.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "transformer.ln_f.weight"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true
19
+ }
20
+ ],
21
+ "num_layers_config_key": "num_hidden_layers",
22
+ "layer_templates": {
23
+ "weights": [
24
+ {
25
+ "name": "transformer.h.${layer_index}.attn.c_attn.bias"
26
+ },
27
+ {
28
+ "name": "transformer.h.${layer_index}.attn.c_attn.weight"
29
+ },
30
+ {
31
+ "name": "transformer.h.${layer_index}.attn.c_proj.weight"
32
+ },
33
+ {
34
+ "name": "transformer.h.${layer_index}.ln_1.weight"
35
+ },
36
+ {
37
+ "name": "transformer.h.${layer_index}.ln_2.weight"
38
+ },
39
+ {
40
+ "name": "transformer.h.${layer_index}.mlp.c_proj.weight"
41
+ },
42
+ {
43
+ "name": "transformer.h.${layer_index}.mlp.w1.weight"
44
+ },
45
+ {
46
+ "name": "transformer.h.${layer_index}.mlp.w2.weight"
47
+ }
48
+ ]
49
+ }
50
+ }
mergekit/_data/architectures/qwen2.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "qwen2",
3
+ "architectures": [
4
+ "Qwen2ForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "model.norm.weight"
15
+ },
16
+ {
17
+ "name": "lm_head.weight",
18
+ "is_embed": true,
19
+ "aliases": [
20
+ "model.embed_tokens.weight"
21
+ ]
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.self_attn.k_proj.bias"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight"
47
+ },
48
+ {
49
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight"
50
+ },
51
+ {
52
+ "name": "model.layers.${layer_index}.self_attn.q_proj.bias"
53
+ },
54
+ {
55
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight"
56
+ },
57
+ {
58
+ "name": "model.layers.${layer_index}.self_attn.v_proj.bias"
59
+ },
60
+ {
61
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight"
62
+ }
63
+ ]
64
+ }
65
+ }
mergekit/_data/architectures/roberta-masked-lm.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "roberta",
3
+ "architectures": [
4
+ "RobertaForMaskedLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "roberta.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "roberta.embeddings.word_embeddings.weight"
12
+ },
13
+ {
14
+ "name": "roberta.embeddings.token_type_embeddings.weight"
15
+ },
16
+ {
17
+ "name": "roberta.embeddings.LayerNorm.weight"
18
+ },
19
+ {
20
+ "name": "roberta.embeddings.LayerNorm.bias"
21
+ },
22
+ {
23
+ "name": "roberta.embeddings.position_ids",
24
+ "optional": true,
25
+ "force_dtype": "int64"
26
+ }
27
+ ],
28
+ "post_weights": [
29
+ {
30
+ "name": "lm_head.bias"
31
+ },
32
+ {
33
+ "name": "lm_head.dense.weight"
34
+ },
35
+ {
36
+ "name": "lm_head.dense.bias"
37
+ },
38
+ {
39
+ "name": "lm_head.layer_norm.weight"
40
+ },
41
+ {
42
+ "name": "lm_head.layer_norm.bias"
43
+ },
44
+ {
45
+ "name": "lm_head.decoder.weight",
46
+ "aliases": [
47
+ "roberta.embeddings.word_embeddings.weight"
48
+ ]
49
+ }
50
+ ],
51
+ "num_layers_config_key": "num_hidden_layers",
52
+ "layer_templates": {
53
+ "weights": [
54
+ {
55
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
56
+ },
57
+ {
58
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
59
+ },
60
+ {
61
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
62
+ },
63
+ {
64
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
65
+ },
66
+ {
67
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
68
+ },
69
+ {
70
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
71
+ },
72
+ {
73
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
74
+ },
75
+ {
76
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
77
+ },
78
+ {
79
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
80
+ },
81
+ {
82
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
83
+ },
84
+ {
85
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
86
+ },
87
+ {
88
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
89
+ },
90
+ {
91
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
92
+ },
93
+ {
94
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
95
+ },
96
+ {
97
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
98
+ },
99
+ {
100
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
101
+ }
102
+ ]
103
+ }
104
+ }
mergekit/_data/architectures/roberta-sequence-classification.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "roberta",
3
+ "architectures": [
4
+ "RobertaForSequenceClassification"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "roberta.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "roberta.embeddings.word_embeddings.weight"
12
+ },
13
+ {
14
+ "name": "roberta.embeddings.token_type_embeddings.weight"
15
+ },
16
+ {
17
+ "name": "roberta.embeddings.LayerNorm.weight"
18
+ },
19
+ {
20
+ "name": "roberta.embeddings.LayerNorm.bias"
21
+ },
22
+ {
23
+ "name": "roberta.embeddings.position_ids",
24
+ "optional": true,
25
+ "force_dtype": "int64"
26
+ }
27
+ ],
28
+ "post_weights": [
29
+ {
30
+ "name": "classifier.dense.weight"
31
+ },
32
+ {
33
+ "name": "classifier.dense.bias"
34
+ },
35
+ {
36
+ "name": "classifier.out_proj.weight"
37
+ },
38
+ {
39
+ "name": "classifier.out_proj.bias"
40
+ }
41
+ ],
42
+ "num_layers_config_key": "num_hidden_layers",
43
+ "layer_templates": {
44
+ "weights": [
45
+ {
46
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
47
+ },
48
+ {
49
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
50
+ },
51
+ {
52
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
53
+ },
54
+ {
55
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
56
+ },
57
+ {
58
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
59
+ },
60
+ {
61
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
62
+ },
63
+ {
64
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
65
+ },
66
+ {
67
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
68
+ },
69
+ {
70
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
71
+ },
72
+ {
73
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
74
+ },
75
+ {
76
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
77
+ },
78
+ {
79
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
80
+ },
81
+ {
82
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
83
+ },
84
+ {
85
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
86
+ },
87
+ {
88
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
89
+ },
90
+ {
91
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
92
+ }
93
+ ]
94
+ }
95
+ }
mergekit/_data/architectures/roberta-token-classification.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "roberta",
3
+ "architectures": [
4
+ "RobertaForTokenClassification"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "roberta.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "roberta.embeddings.word_embeddings.weight"
12
+ },
13
+ {
14
+ "name": "roberta.embeddings.token_type_embeddings.weight"
15
+ },
16
+ {
17
+ "name": "roberta.embeddings.LayerNorm.weight"
18
+ },
19
+ {
20
+ "name": "roberta.embeddings.LayerNorm.bias"
21
+ },
22
+ {
23
+ "name": "roberta.embeddings.position_ids",
24
+ "optional": true,
25
+ "force_dtype": "int64"
26
+ }
27
+ ],
28
+ "post_weights": [
29
+ {
30
+ "name": "classifier.weight"
31
+ },
32
+ {
33
+ "name": "classifier.bias"
34
+ }
35
+ ],
36
+ "num_layers_config_key": "num_hidden_layers",
37
+ "layer_templates": {
38
+ "weights": [
39
+ {
40
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
41
+ },
42
+ {
43
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
44
+ },
45
+ {
46
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
47
+ },
48
+ {
49
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
50
+ },
51
+ {
52
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
53
+ },
54
+ {
55
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
56
+ },
57
+ {
58
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
59
+ },
60
+ {
61
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
62
+ },
63
+ {
64
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
65
+ },
66
+ {
67
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
68
+ },
69
+ {
70
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
71
+ },
72
+ {
73
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
74
+ },
75
+ {
76
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
77
+ },
78
+ {
79
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
80
+ },
81
+ {
82
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
83
+ },
84
+ {
85
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
86
+ }
87
+ ]
88
+ }
89
+ }
mergekit/_data/architectures/roberta.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "roberta",
3
+ "architectures": [
4
+ "RobertaModel"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "roberta.embeddings.position_embeddings.weight"
9
+ },
10
+ {
11
+ "name": "roberta.embeddings.word_embeddings.weight"
12
+ },
13
+ {
14
+ "name": "roberta.embeddings.token_type_embeddings.weight"
15
+ },
16
+ {
17
+ "name": "roberta.embeddings.LayerNorm.weight"
18
+ },
19
+ {
20
+ "name": "roberta.embeddings.LayerNorm.bias"
21
+ },
22
+ {
23
+ "name": "roberta.embeddings.position_ids",
24
+ "optional": true,
25
+ "force_dtype": "int64"
26
+ }
27
+ ],
28
+ "post_weights": [
29
+ {
30
+ "name": "pooler.dense.weight"
31
+ },
32
+ {
33
+ "name": "pooler.dense.bias"
34
+ }
35
+ ],
36
+ "num_layers_config_key": "num_hidden_layers",
37
+ "layer_templates": {
38
+ "weights": [
39
+ {
40
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.weight"
41
+ },
42
+ {
43
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.dense.bias"
44
+ },
45
+ {
46
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.weight"
47
+ },
48
+ {
49
+ "name": "roberta.encoder.layer.${layer_index}.attention.output.LayerNorm.bias"
50
+ },
51
+ {
52
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.weight"
53
+ },
54
+ {
55
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.query.bias"
56
+ },
57
+ {
58
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.weight"
59
+ },
60
+ {
61
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.key.bias"
62
+ },
63
+ {
64
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.weight"
65
+ },
66
+ {
67
+ "name": "roberta.encoder.layer.${layer_index}.attention.self.value.bias"
68
+ },
69
+ {
70
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.weight"
71
+ },
72
+ {
73
+ "name": "roberta.encoder.layer.${layer_index}.intermediate.dense.bias"
74
+ },
75
+ {
76
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.weight"
77
+ },
78
+ {
79
+ "name": "roberta.encoder.layer.${layer_index}.output.dense.bias"
80
+ },
81
+ {
82
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.weight"
83
+ },
84
+ {
85
+ "name": "roberta.encoder.layer.${layer_index}.output.LayerNorm.bias"
86
+ }
87
+ ]
88
+ }
89
+ }
mergekit/_data/architectures/stablelm.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "stablelm_epoch",
3
+ "architectures": [
4
+ "StableLMEpochForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true,
10
+ "output_space": "h_0"
11
+ }
12
+ ],
13
+ "num_layers_config_key": "num_hidden_layers",
14
+ "layer_templates": {
15
+ "weights": [
16
+ {
17
+ "name": "model.layers.${layer_index}.input_layernorm.weight",
18
+ "input_space": "h_${layer_index}"
19
+ },
20
+ {
21
+ "name": "model.layers.${layer_index}.input_layernorm.bias",
22
+ "input_space": "h_${layer_index}"
23
+ },
24
+ {
25
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight",
26
+ "input_space": "h_${layer_index}",
27
+ "output_space": "attn_qk_${layer_index}"
28
+ },
29
+ {
30
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight",
31
+ "input_space": "h_${layer_index}",
32
+ "output_space": "attn_qk_${layer_index}"
33
+ },
34
+ {
35
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight",
36
+ "input_space": "h_${layer_index}",
37
+ "output_space": "attn_v_${layer_index}"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight",
41
+ "input_space": "attn_v_${layer_index}",
42
+ "output_space": "post_attn_${layer_index}"
43
+ },
44
+ {
45
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight",
46
+ "input_space": "h_a_${layer_index}"
47
+ },
48
+ {
49
+ "name": "model.layers.${layer_index}.post_attention_layernorm.bias",
50
+ "input_space": "h_a_${layer_index}"
51
+ },
52
+ {
53
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight",
54
+ "input_space": "h_a_${layer_index}",
55
+ "output_space": "up_${layer_index}"
56
+ },
57
+ {
58
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight",
59
+ "input_space": "h_a_${layer_index}",
60
+ "output_space": "up_${layer_index}"
61
+ },
62
+ {
63
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight",
64
+ "input_space": "up_${layer_index}",
65
+ "output_space": "post_mlp_${layer_index}"
66
+ }
67
+ ],
68
+ "procedural_spaces": [
69
+ {
70
+ "name": "h_a_${layer_index}",
71
+ "type": "residual",
72
+ "inputs": [
73
+ "h_${layer_index}",
74
+ "post_attn_${layer_index}"
75
+ ]
76
+ },
77
+ {
78
+ "name": "h_${layer_index+1}",
79
+ "type": "residual",
80
+ "inputs": [
81
+ "h_a_${layer_index}",
82
+ "post_mlp_${layer_index}"
83
+ ]
84
+ }
85
+ ]
86
+ },
87
+ "post_weights": [
88
+ {
89
+ "name": "model.norm.weight",
90
+ "input_space": "h_${num_layers}"
91
+ },
92
+ {
93
+ "name": "lm_head.weight",
94
+ "input_space": "h_${num_layers}",
95
+ "is_embed": true
96
+ }
97
+ ]
98
+ }
mergekit/_data/architectures/stablelm2.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "stablelm",
3
+ "architectures": [
4
+ "StableLmForCausalLM"
5
+ ],
6
+ "pre_weights": [
7
+ {
8
+ "name": "model.embed_tokens.weight",
9
+ "is_embed": true
10
+ }
11
+ ],
12
+ "post_weights": [
13
+ {
14
+ "name": "model.norm.weight"
15
+ },
16
+ {
17
+ "name": "model.norm.bias"
18
+ },
19
+ {
20
+ "name": "lm_head.weight",
21
+ "is_embed": true
22
+ }
23
+ ],
24
+ "num_layers_config_key": "num_hidden_layers",
25
+ "layer_templates": {
26
+ "weights": [
27
+ {
28
+ "name": "model.layers.${layer_index}.input_layernorm.weight"
29
+ },
30
+ {
31
+ "name": "model.layers.${layer_index}.input_layernorm.bias"
32
+ },
33
+ {
34
+ "name": "model.layers.${layer_index}.mlp.down_proj.weight"
35
+ },
36
+ {
37
+ "name": "model.layers.${layer_index}.mlp.gate_proj.weight"
38
+ },
39
+ {
40
+ "name": "model.layers.${layer_index}.mlp.up_proj.weight"
41
+ },
42
+ {
43
+ "name": "model.layers.${layer_index}.post_attention_layernorm.weight"
44
+ },
45
+ {
46
+ "name": "model.layers.${layer_index}.post_attention_layernorm.bias"
47
+ },
48
+ {
49
+ "name": "model.layers.${layer_index}.self_attn.q_proj.weight"
50
+ },
51
+ {
52
+ "name": "model.layers.${layer_index}.self_attn.q_proj.bias",
53
+ "optional": true
54
+ },
55
+ {
56
+ "name": "model.layers.${layer_index}.self_attn.k_proj.weight"
57
+ },
58
+ {
59
+ "name": "model.layers.${layer_index}.self_attn.k_proj.bias",
60
+ "optional": true
61
+ },
62
+ {
63
+ "name": "model.layers.${layer_index}.self_attn.v_proj.weight"
64
+ },
65
+ {
66
+ "name": "model.layers.${layer_index}.self_attn.v_proj.bias",
67
+ "optional": true
68
+ },
69
+ {
70
+ "name": "model.layers.${layer_index}.self_attn.o_proj.weight"
71
+ }
72
+ ]
73
+ }
74
+ }