Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import yaml | |
| def generate_config(base_model, models, layer_range, merge_method): | |
| slices = [] | |
| for model in models: | |
| slice_config = { | |
| "sources": [ | |
| { | |
| "model": model, | |
| "layer_range": layer_range | |
| } | |
| ] | |
| } | |
| slices.append(slice_config) | |
| config = { | |
| "slices": slices, | |
| "merge_method": merge_method, | |
| "base_model": base_model, | |
| "parameters": { | |
| "t": [ | |
| { | |
| "filter": "self_attn", | |
| "value": [0, 0.5, 0.3, 0.7, 1] | |
| }, | |
| { | |
| "filter": "mlp", | |
| "value": [1, 0.5, 0.7, 0.3, 0] | |
| }, | |
| { | |
| "value": 0.5 | |
| } | |
| ] | |
| }, | |
| "dtype": "bfloat16" | |
| } | |
| return yaml.dump(config) | |
| iface = gr.Interface( | |
| fn=generate_config, | |
| inputs="dropdown", | |
| inputs2="multiselect", | |
| inputs3=gr.inputs.NumberSlider(minimum=0, maximum=32, step=1), | |
| inputs4="dropdown", | |
| output_type="text", | |
| output_formats=["yaml"], | |
| title="Merge Config Builder", | |
| description="Build a merge config file for your models" | |
| ) | |
| iface.launch() | |
| ''' | |
| We define a function generate_config that takes in the base model, a list of additional models, the layer range, and the merge method as inputs. | |
| We create a list of slices, where each slice contains the configuration for a single model. | |
| We create the final config dictionary, which includes the slices, merge method, base model, parameters, and data type. | |
| We use the yaml.dump function to convert the config dictionary to a YAML string. | |
| We create a Gradio interface using the gr.Interface function. | |
| We define the input and output components of the interface. | |
| We launch the interface using the launch method. | |
| ''' | |