Spaces:
Runtime error
Runtime error
| import seaborn as sns | |
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import pandas as pd | |
| # Adjusting the line thickness to better match the provided example | |
| fig, ax = plt.subplots( figsize=(5, 4)) | |
| # 64, 64sqrt2, 128, 128sqrt2, 256, 256sqrt2, 512 | |
| x_values = [2.8, 10.2, 36.9, 174.22, 366.9, 755.9] # | |
| y_values = [6.33, 5.52, 5.25, 5.19, 5.02, 5.02] # , 5.09 | |
| y_values = np.exp(y_values) | |
| # 256sqrt2->700m | |
| # 512->1.3billion | |
| # Set line width for each line plot | |
| line_width = 1.5 | |
| x = [] | |
| # Iterate over each subplot (task) and plot the lines with specified styles, markers, and adjusted line width | |
| # for i, task in enumerate(tasks): | |
| # ax.plot(x_values, y_values, marker='o', linestyle='--', color='#1f78b4', linewidth=line_width) | |
| # # for i, txt in enumerate(y_values): | |
| # # ax.annotate(f"{txt:.1f}", (x_values[i], y_values[i]), textcoords="offset points", xytext=(0,10), ha='center') | |
| # ax.annotate(f"{y_values[-1]:.1f}", (x_values[-1], y_values[-1]), textcoords="offset points", xytext=(0,10), ha='center') | |
| # # Set individual titles and axis labels for each subplot | |
| # ax.set_xlabel("Model Parameters(M)", fontsize=14) | |
| # ax.set_ylabel("Perplexity", fontsize=14) | |
| # ax.set_ylim(0, 1) | |
| fig, ax1 = plt.subplots(figsize=(5, 4)) | |
| INDEX = -2 | |
| # Plot Perplexity (left y-axis) | |
| ax1.plot(x_values, y_values, marker='o', linestyle='-', color='#1f78b4', linewidth=line_width) | |
| ax1.annotate(f"{y_values[INDEX]:.1f}", (x_values[INDEX], y_values[INDEX]), textcoords="offset points", xytext=(0, 10), ha='center') | |
| ax1.set_xscale('log') | |
| ax1.set_xlabel("Model Parameters(M)", fontsize=14) | |
| ax1.set_ylabel("Perplexity", fontsize=14, color='#1f78b4') | |
| ax1.tick_params(axis='y', labelcolor='#1f78b4') | |
| # , 1.18 | |
| # Create a twin y-axis for controllability (right y-axis) | |
| ax2 = ax1.twinx() | |
| controllability_values = [0.11, 1.02, 1.07, 1.12, 1.87, 1.34] # Example values for controllability | |
| ax2.plot(x_values, controllability_values, marker='s', linestyle='--', color='#006400', linewidth=line_width) | |
| ax2.set_ylabel("Delta PSNR", fontsize=14, color='#006400') | |
| ax2.set_ylim(0, np.max(controllability_values) + 0.2) | |
| ax2.tick_params(axis='y', labelcolor='#006400') | |
| ax2.annotate(f"{controllability_values[INDEX]:.1f}", (x_values[INDEX], controllability_values[INDEX]), textcoords="offset points", xytext=(0, 10), ha='center') | |
| # Save the figure in high resolution | |
| plt.tight_layout() | |
| # plt.show() | |
| plt.savefig(f"output/model_sizes.png", dpi=300) | |
| # Adding a centralized legend that appears above the plot | |
| # fig.legend(y_values, loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=3, frameon=False, markerscale=1.5) | |