Draw bar chart w.r.t affiliations or time.
(model_list)
| 139 | |
| 140 | |
| 141 | def plot_bar(model_list): |
| 142 | """ |
| 143 | Draw bar chart w.r.t affiliations or time. |
| 144 | """ |
| 145 | |
| 146 | cnt_affiliation = defaultdict(int) |
| 147 | params_affiliation = defaultdict(int) |
| 148 | cnt_time = defaultdict(int) |
| 149 | params_time = defaultdict(int) |
| 150 | |
| 151 | last_updated = model_list[0]["last_updated"] |
| 152 | for model in model_list[1:]: |
| 153 | affiliation_list = model["affiliation"] |
| 154 | |
| 155 | param_list = list() |
| 156 | if "parameters_MoE" in model: |
| 157 | param_list += model["parameters_MoE"] |
| 158 | if "parameters_dense" in model: |
| 159 | param_list += model["parameters_dense"] |
| 160 | param_list = sorted( |
| 161 | list(map(lambda x: float(x.split("~")[-1].split("B")[0]), param_list)) |
| 162 | ) |
| 163 | |
| 164 | for affiliation in affiliation_list: |
| 165 | if affiliation == "Facebook" or affiliation == "Meta": |
| 166 | affiliation = "Meta(Facebook)" |
| 167 | |
| 168 | cnt_affiliation[affiliation] += 1 |
| 169 | params_affiliation[affiliation] += param_list[-1] # only count the largest model |
| 170 | |
| 171 | date = model["release_date"] |
| 172 | y_m = date.rsplit('/', 1)[0] |
| 173 | cnt_time[y_m] += 1 |
| 174 | params_time[y_m] += param_list[-1] # only count the largest model |
| 175 | |
| 176 | x, y_cnt = list(zip(*sorted(cnt_affiliation.items(), key=lambda x: x[1], reverse=True))) |
| 177 | fig_cnt = plt.figure(dpi=300, figsize=(12, 6)) |
| 178 | plt.bar(x, y_cnt, width=0.4, alpha=0.8, color="blue") |
| 179 | plt.xticks(rotation=90) |
| 180 | plt.ylabel("# Models") |
| 181 | plt.text(0.01, 0.96, f"Last Updated: {last_updated}\n@OpenBMB", fontsize=6, c='gray', alpha=0.4, transform=plt.gca().transAxes) |
| 182 | plt.savefig("figures/affiliation_cnt.png", dpi=fig_cnt.dpi, bbox_inches="tight") |
| 183 | print("[DONE] Draw bar chart (X: affiliation, Y: number of models).") |
| 184 | |
| 185 | x, y_cnt = list(zip(*sorted(cnt_time.items(), key=lambda x: x[0], reverse=False))) |
| 186 | fig_cnt = plt.figure(dpi=300, figsize=(12, 6)) |
| 187 | plt.bar(x, y_cnt, width=0.4, alpha=0.8, color="blue") |
| 188 | plt.xticks(rotation=90) |
| 189 | plt.ylabel("# Models") |
| 190 | plt.text(0.01, 0.96, f"Last Updated: {last_updated}\n@OpenBMB", fontsize=6, c='gray', alpha=0.4, transform=plt.gca().transAxes) |
| 191 | plt.savefig("figures/time_cnt.png", dpi=fig_cnt.dpi, bbox_inches="tight") |
| 192 | print("[DONE] Draw bar chart (X: time, Y: number of models).") |
| 193 | |
| 194 | fig_params = plt.figure(dpi=300, figsize=(12, 6)) |
| 195 | x, y_params = list( |
| 196 | zip(*sorted(params_affiliation.items(), key=lambda x: x[1], reverse=True)) |
| 197 | ) |
| 198 | plt.bar(x, y_params, width=0.4, alpha=0.8, color="blue") |