Agnes-3.0-Flash-GGUF / build /model_card_usage.py
0xKitkat's picture
Upload provenance, runtime files and measured evaluations
2fcc4a8 verified
Raw History Blame
1.37 kB
"""Shared, editable GGUF usage guide for all release cards."""
from pathlib import Path
def enhance_gguf_card(card, repo, model, llama_revision):
usage = (Path(__file__).parent / "GGUF-USAGE.md").read_text(encoding="utf-8")
for key, value in {"__REPO__": repo, "__MODEL__": model, "__LLAMA_REV__": llama_revision}.items():
usage = usage.replace(key, value)
begin, end = "<!-- GGUF-USAGE-BEGIN -->", "<!-- GGUF-USAGE-END -->"
section = begin + "\n" + usage.rstrip() + "\n" + end + "\n\n"
if begin in card:
start = card.index(begin)
stop = card.index(end, start) + len(end)
return card[:start] + section.rstrip() + card[stop:]
# Replace the old short run recipe with the full guide before evaluations.
if "\n## Run\n" in card:
start = card.index("\n## Run\n")
stops = [card.find(marker, start) for marker in ("\nOriginal model and implementation:", "\n## Attribution")]
stops = [stop for stop in stops if stop >= 0]
if not stops:
raise ValueError("Cannot locate end of old GGUF run instructions")
card = card[:start] + "\n" + card[min(stops):]
for marker in ("## Validation\n", "## Measured checks\n"):
if marker in card:
return card.replace(marker, section + marker, 1)
raise ValueError("Cannot locate GGUF evaluation section")