Datasets:
Download src/plot_version_growth.py from SlayerLab/polish-dynaword: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/main/src/plot_version_growth.py
- Command line
-
hf download hf://datasets/SlayerLab/polish-dynaword/src/plot_version_growth.py
-
curl -L -o plot_version_growth.py https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/main/src/plot_version_growth.py
2.31 kB
| #!/usr/bin/env python3 | |
| """Plot stable Polish DynaWord corpus growth across released versions.""" | |
| from pathlib import Path | |
| import matplotlib.pyplot as plt | |
| from matplotlib.ticker import FuncFormatter | |
| ROOT = Path(__file__).resolve().parent.parent | |
| OUTPUT = ROOT / "artifacts" / "dataset_size_by_version.png" | |
| VERSIONS = ["v0.2.0", "v0.2.1", "v0.2.2", "v0.2.3", "v0.2.4", "v0.2.5"] | |
| DOCUMENTS = [ | |
| 2_490_773, | |
| 2_491_773, | |
| 2_579_963, | |
| 2_710_974, | |
| 4_246_429, | |
| 4_319_200, | |
| ] | |
| TOKENS = [ | |
| 6_221_393_871, | |
| 6_281_911_234, | |
| 6_362_577_363, | |
| 6_881_277_362, | |
| 9_597_908_067, | |
| 9_639_062_573, | |
| ] | |
| def millions(value, _position): | |
| return f"{value / 1_000_000:.1f}M" | |
| def billions(value, _position): | |
| return f"{value / 1_000_000_000:.1f}B" | |
| def main(): | |
| plt.style.use("seaborn-v0_8-whitegrid") | |
| fig, axes = plt.subplots(1, 2, figsize=(12, 4.8)) | |
| panels = [ | |
| (axes[0], DOCUMENTS, "Documents", millions, lambda v: f"{v / 1_000_000:.3f}M", "#2563eb"), | |
| (axes[1], TOKENS, "Tokens (cl100k proxy)", billions, lambda v: f"{v / 1_000_000_000:.3f}B", "#0f766e"), | |
| ] | |
| for axis, values, ylabel, formatter, labeler, color in panels: | |
| axis.plot(VERSIONS, values, marker="o", linewidth=2.5, color=color) | |
| axis.fill_between(VERSIONS, values, alpha=0.12, color=color) | |
| axis.set_ylabel(ylabel) | |
| axis.yaxis.set_major_formatter(FuncFormatter(formatter)) | |
| axis.spines[["top", "right"]].set_visible(False) | |
| axis.grid(axis="x", visible=False) | |
| padding = (max(values) - min(values)) * 0.3 or max(values) * 0.02 | |
| axis.set_ylim(min(values) - padding, max(values) + padding) | |
| for version, value in zip(VERSIONS, values): | |
| axis.annotate( | |
| labeler(value), | |
| (version, value), | |
| xytext=(0, 9), | |
| textcoords="offset points", | |
| ha="center", | |
| fontsize=9, | |
| fontweight="bold", | |
| color=color, | |
| ) | |
| fig.suptitle("Polish DynaWord — stable dataset growth by version", fontsize=15) | |
| fig.tight_layout() | |
| OUTPUT.parent.mkdir(parents=True, exist_ok=True) | |
| fig.savefig(OUTPUT, dpi=180, bbox_inches="tight") | |
| plt.close(fig) | |
| print(OUTPUT) | |
| if __name__ == "__main__": | |
| main() | |