Hjgugugjhuhjggg commited on
Commit
6ef37cd
·
verified ·
1 Parent(s): 75d1ef3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -18
app.py CHANGED
@@ -27,6 +27,43 @@ The fastest way to perform a model merge 🔥
27
  Specify a YAML configuration file (see examples below) and a HF token and this app will perform the merge and upload the merged model to your user profile.
28
  """
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  examples = [[str(f)] for f in pathlib.Path("examples").glob("*.yaml")]
31
  COMMUNITY_HF_TOKEN = os.getenv("COMMUNITY_HF_TOKEN")
32
 
@@ -124,26 +161,12 @@ def generate_example_yaml(methods: List[str]) -> str:
124
  },
125
  'tokenizer_source': 'union', # Definir el tokenizer
126
  }
127
- # Agregar los métodos de fusión aplicados
128
- example_yaml['merge_method_sequence'] = methods
129
 
 
 
130
  return yaml.dump(example_yaml)
131
 
132
- def merge(yaml_config: str, hf_token: str, repo_name: str, profile_name: str) -> Iterable[List[Log]]:
133
- runner = LogsViewRunner()
134
-
135
- if not yaml_config:
136
- yield runner.log("Empty yaml, pick an example below", level="ERROR")
137
- return
138
-
139
- try:
140
- merge_config = MergeConfiguration.model_validate(yaml.safe_load(yaml_config))
141
- except Exception as e:
142
- yield runner.log(f"Invalid yaml {e}", level="ERROR")
143
- return
144
-
145
- yield from merge_multiple_methods(yaml_config, hf_token, repo_name, profile_name)
146
-
147
  with gr.Blocks() as demo:
148
  gr.Markdown(MARKDOWN_DESCRIPTION)
149
 
@@ -180,7 +203,7 @@ with gr.Blocks() as demo:
180
  )
181
  gr.Markdown(MARKDOWN_ARTICLE)
182
 
183
- button.click(fn=merge, inputs=[config, token, repo_name, profile_name], outputs=[logs])
184
 
185
  def _garbage_collect_every_hour():
186
  while True:
 
27
  Specify a YAML configuration file (see examples below) and a HF token and this app will perform the merge and upload the merged model to your user profile.
28
  """
29
 
30
+ MARKDOWN_ARTICLE = """
31
+ ___
32
+ ## Merge Configuration
33
+ [Mergekit](https://github.com/arcee-ai/mergekit) configurations are YAML documents specifying the operations to perform in order to produce your merged model.
34
+ Below are the primary elements of a configuration file:
35
+ - `merge_method`: Specifies the method to use for merging models. See [Merge Methods](https://github.com/arcee-ai/mergekit#merge-methods) for a list.
36
+ - `slices`: Defines slices of layers from different models to be used. This field is mutually exclusive with `models`.
37
+ - `models`: Defines entire models to be used for merging. This field is mutually exclusive with `slices`.
38
+ - `base_model`: Specifies the base model used in some merging methods.
39
+ - `parameters`: Holds various parameters such as weights and densities, which can also be specified at different levels of the configuration.
40
+ - `dtype`: Specifies the data type used for the merging operation.
41
+ - `tokenizer_source`: Determines how to construct a tokenizer for the merged model.
42
+ ## Merge Methods
43
+ A quick overview of the currently supported merge methods:
44
+ | Method | `merge_method` value | Multi-Model | Uses base model |
45
+ | -------------------------------------------------------------------------------------------- | -------------------- | ----------- | --------------- |
46
+ | Linear ([Model Soups](https://arxiv.org/abs/2203.05482)) | `linear` | ✅ | ❌ |
47
+ | SLERP | `slerp` | ❌ | ✅ |
48
+ | [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `task_arithmetic` | ✅ | ✅ |
49
+ | [TIES](https://arxiv.org/abs/2306.01708) | `ties` | ✅ | ✅ |
50
+ | [DARE](https://arxiv.org/abs/2311.03099) [TIES](https://arxiv.org/abs/2306.01708) | `dare_ties` | ✅ | ✅ |
51
+ | [DARE](https://arxiv.org/abs/2311.03099) [Task Arithmetic](https://arxiv.org/abs/2212.04089) | `dare_linear` | ✅ | ✅ |
52
+ | Passthrough | `passthrough` | ❌ | ❌ |
53
+ | [Model Stock](https://arxiv.org/abs/2403.19522) | `model_stock` | ✅ | ✅ |
54
+ ## Citation
55
+ This GUI is powered by [Arcee's MergeKit](https://arxiv.org/abs/2403.13257).
56
+ If you use it in your research, please cite the following paper:
57
+ @article{goddard2024arcee,
58
+ title={Arcee's MergeKit: A Toolkit for Merging Large Language Models},
59
+ author={Goddard, Charles and Siriwardhana, Shamane and Ehghaghi, Malikeh and Meyers, Luke and Karpukhin, Vlad and Benedict, Brian and McQuade, Mark and Solawetz, Jacob},
60
+ journal={arXiv preprint arXiv:2403.13257},
61
+ year={2024}
62
+ }
63
+
64
+ This Space is heavily inspired by LazyMergeKit by Maxime Labonne (see [Colab](https://colab.research.google.com/drive/1obulZ1ROXHjYLn6PPZJwRR6GzgQogxxb)).
65
+ """
66
+
67
  examples = [[str(f)] for f in pathlib.Path("examples").glob("*.yaml")]
68
  COMMUNITY_HF_TOKEN = os.getenv("COMMUNITY_HF_TOKEN")
69
 
 
161
  },
162
  'tokenizer_source': 'union', # Definir el tokenizer
163
  }
164
+ # Ag
 
165
 
166
+ regar la secuencia de métodos de fusión realizados
167
+ example_yaml['merge_method_sequence'] = methods
168
  return yaml.dump(example_yaml)
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  with gr.Blocks() as demo:
171
  gr.Markdown(MARKDOWN_DESCRIPTION)
172
 
 
203
  )
204
  gr.Markdown(MARKDOWN_ARTICLE)
205
 
206
+ button.click(fn=merge_multiple_methods, inputs=[config, token, repo_name, profile_name], outputs=[logs])
207
 
208
  def _garbage_collect_every_hour():
209
  while True: