Skip to content

Commit

Permalink
udpate ties_merging doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tanganke committed May 16, 2024
1 parent d890bbf commit d47d682
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ defaults:

fast_dev_run: false # Run a single batch of data to test the model or method
print_config: true # Print the configuration to the console
save_report: false # path to save the result report

Binary file added docs/algorithms/images/ties_merging.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/algorithms/ties_merging.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Ties Merging

<figure markdown="span">
![Image title](images/ties_merging.jpg){ width="750" }
<figcaption>Ties-Merging. Credit to <sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></figcaption>
</figure>

Ties-Merging[^1] represents a novel and structured approach to consolidating multiple task-specific models into a single, efficient multi-task model. This method employs a sequence of deliberate steps to systematically merge task vectors, ensuring that the final model effectively integrates the strengths of each individual task-specific model and resolves potential conflicts between them.

The Ties-Merging algorithm operates through three primary steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
!!! note

- Any questions or comments can be directed to the [GitHub Issues](https://github.com/tanganke/fusion_bench/issues) page for this project.
- Any contributions or pull requests are welcome.
- Any contributions or pull requests are welcome. If you find any mistakes or have suggestions for improvements, please feel free to raise an issue or submit a pull request.


## Introduction to Deep Model Fusion
Expand Down
2 changes: 1 addition & 1 deletion fusion_bench/method/simple_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ def fuse(self, modelpool: ModelPool):

sd = state_dict_mul(sd, 1 / len(modelpool.model_names))
forward_model.load_state_dict(sd)
return simple_average(forward_model)
return forward_model
8 changes: 7 additions & 1 deletion fusion_bench/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from omegaconf import DictConfig, OmegaConf
from rich import print as rich_print
from rich.syntax import Syntax
import json

from ..method import load_algorithm_from_config
from ..modelpool import load_modelpool_from_config
Expand All @@ -32,7 +33,12 @@ def run_model_fusion(cfg: DictConfig):

if hasattr(cfg, "taskpool") and cfg.taskpool is not None:
taskpool = load_taskpool_from_config(cfg.taskpool)
taskpool.evaluate(merged_model)
report = taskpool.evaluate(merged_model)
if cfg.get("save_report", False):
# save report (Dict) to a file
# if the directory of `save_report` does not exists, create it
os.makedirs(os.path.dirname(cfg.save_report), exist_ok=True)
json.dump(report, open(cfg.save_report, "w"))
else:
print("No task pool specified. Skipping evaluation.")

Expand Down

0 comments on commit d47d682

Please sign in to comment.