Astheral / release_tools /finalize_release.py
SEE7's picture
Publish release evaluation and inference tools
2b66baf verified
Raw History Blame Contribute Delete
9.05 kB
"""Publish the measured v2 model page after the merged checkpoint passes."""
import json,hashlib
from huggingface_hub import HfApi,hf_hub_download,CommitOperationAdd
from pathlib import Path
api=HfApi();repo="SEE7/Astheral"
def read(name):return Path(hf_hub_download(repo,name)).read_text()
m=json.loads(read("evaluation.json"))
assert m["version"]=="2" and m["quality_gate_passed"]
base=m["base_scores"];new=m["merged_scores"]
assert new["regression"]["passed"]==2
assert new["number"]["passed"]>=base["number"]["passed"]
assert new["fresh"]["passed"]==new["fresh"]["total"]
assert m["mode_adherence"]["passed"]==m["mode_adherence"]["total"]
def fraction(s,key):return str(s[key]["passed"])+"/"+str(s[key]["total"])
def formats(s):return str(s["exact"]["passed"]+s["json"]["passed"])+"/"+str(s["exact"]["total"]+s["json"]["total"])
page="""---
language:
- en
license: llama3.1
library_name: transformers
pipeline_tag: text-generation
base_model: NousResearch/DeepHermes-3-Llama-3-8B-Preview
base_model_relation: finetune
model_name: Llama-3.1-Astheral
tags:
- astheral
- llama
- instruct
- reasoning
- qlora
---
# Astheral
**Built with Llama.** Astheral is SEE7's 8.03B assistant for instruction following, coding, concise explanations and fictional roleplay.
## Instruct and thinking
Choose **instruct** for direct answers or **thinking** for a worked solution before the final answer. Both modes use the same trained weights. The included inference script selects the mode and accepts your own system instructions with --system.
## What's changed in v2
- Balanced training across general instruction tasks, formatting, text editing, Python, and multi-step mathematics.
- Rank-32 adapters across attention and feed-forward projections.
- Explicit training to account for all groups in counting problems and preserve requested output structure.
- Short, complete worked solutions in thinking mode.
- A saved, merged BF16 checkpoint plus the separately downloadable adapter.
"""
page+=f"Training used **{m['training_examples']:,} examples**, **{m['optimizer_steps']} optimizer steps**, and **{m['trainable_parameters']:,} trainable adapter parameters** on a remote **{m['hardware']}**. The original DeepHermes weights provide the starting model.\n\n"
page+="## Measured results\n\nBoth models used identical prompts and deterministic generation settings: up to 384 new tokens for instruct and 1,024 for thinking. The core suite contains 14 formatting tasks, 16 numerical reasoning tasks and six executable Python tasks.\n\n"
page+="| Check | DeepHermes base | Astheral v2 |\n|---|---:|---:|\n"
page+=f"| Formatting | {formats(base)} | {formats(new)} |\n| Numerical reasoning | {fraction(base,'number')} | {fraction(new,'number')} |\n| Executable Python | {fraction(base,'code')} | {fraction(new,'code')} |\n| Core checks total | {fraction(base,'fresh')} | {fraction(new,'fresh')} |\n| Known regression cases | {fraction(base,'regression')} | {fraction(new,'regression')} |\n\n"
page+="The two regression cases cover the alpha/omega line format and counting the remaining red and blue balls together. Full prompts, answers, checker code and run metrics are available in evaluate.py, base_outputs.json, astheral_merged_outputs.json and evaluation.json. Six additional samples cover roleplay, prompt design, authorized networking explanations, uncertainty, debugging and summarization.\n\n"
page+=f"Default mode formatting was verified in **{m['mode_adherence']['passed']}/{m['mode_adherence']['total']} responses**: instruct responses omit thinking tags; thinking responses contain a completed thinking block.\n\n"
if "confirmation" in new:
assert new["confirmation"]["passed"]==new["confirmation"]["total"]
page+=f"The saved checkpoint also passed **{new['confirmation']['passed']}/{new['confirmation']['total']} additional confirmation cases** covering new CSV records, literal copying, fraction-based balances, time conversion and complete Python functions. Their prompts and answers are in confirmation_outputs.json.\n\n"
if any(item.rfilename=="holdout_evaluation.json" for item in api.model_info(repo).siblings):
h=json.loads(read("holdout_evaluation.json"))
assert h["no_material_regression_gate"]
page+="## Independent test subsets\n\n| Test subset | DeepHermes base | Astheral v2 |\n|---|---:|---:|\n"
for key,label in [("number","GSM8K test problems"),("code","HumanEval functions")]:
old=h["scores"]["base"][key];new_h=h["scores"]["astheral"][key]
page+=f"| {label} | {old['passed']}/{old['total']} | {new_h['passed']}/{new_h['total']} |\n"
page+="\nExact task IDs, generation limits, source revisions, outputs and executable tests are in holdout_evaluation.json, holdout_outputs.json and holdout_eval.py.\n\n"
page+="## Run on a remote GPU\n\nInstall a CUDA-enabled PyTorch build and requirements.txt, then download inference.py from this repository.\n\n"
page+=" python inference.py \"Explain Python generators.\" --mode instruct\n python inference.py \"A box has 23 red and 17 blue beads; 6 red are removed. How many remain?\" --mode thinking\n python inference.py \"Write a fictional starship announcement.\" --mode instruct --load-in-4bit\n\n"
page+="Use --system \"Your instructions\" to replace the default assistant instructions. Decoding is deterministic by default; add --sample for creative variation. BF16 weights occupy about 16 GB; --load-in-4bit loads the weights in NF4 for lower GPU memory use. The script loads SEE7/Astheral directly. Dockerfile includes the CUDA runtime and compiler dependencies for the 4-bit backend.\n\n"
if any(item.rfilename=="cli_smoke_test.json" for item in api.model_info(repo).siblings):
cli=json.loads(read("cli_smoke_test.json"));assert cli["all_passed"]
page+="The published inference script was executed on a remote GPU and verified in instruct mode, thinking mode and with a replacement system instruction. The actual arguments and generated answers are recorded in cli_smoke_test.json.\n\n"
if api.repo_exists("SEE7/Astheral-NF4"):
compact=json.loads(Path(hf_hub_download("SEE7/Astheral-NF4","evaluation.json")).read_text())
assert compact["quality_gate_passed"] and compact["saved_checkpoint_cli_verified"]
page+=f"## Compact download\n\n[Astheral NF4](https://huggingface.co/SEE7/Astheral-NF4) provides a prequantized **{compact['weight_bytes']/1e9:.2f} GB** checkpoint. It was evaluated separately and reloaded through the inference script in both modes. Its complete results are included in that repository.\n\n"
page+="## Files and reproducibility\n\nThe repository includes merged Safetensors weights, the adapter folder, train.py, prepare_data.py, the exact training and validation examples, trainer logs, data source revisions, output comparisons and artifact hashes. The merged checkpoint was saved, reloaded, and evaluated before release.\n\n"
page+="## Training data and attribution\n\nTraining combines original Astheral examples with selected components of HuggingFaceTB/smoltalk (Apache 2.0), the openai/gsm8k training split (MIT), and bigcode/self-oss-instruct-sc2-exec-filter-50k (ODC Attribution). See data_sources.json, DATA.md, DATA_LICENSE files and NOTICE.\n\n"
page+="Astheral is fine-tuned from NousResearch/DeepHermes-3-Llama-3-8B-Preview, revision 53d902c7dcfa4c749a3b455149064f82af2e2549, built on Meta Llama 3.1 8B. The project is Astheral; the distributed model name is Llama-3.1-Astheral. See LICENSE and UPSTREAM_LLAMA3_LICENSE.\n"
manifest=json.loads(read("artifact_manifest.json"))
# README is added after the model artifacts were hashed.
generation=json.loads(read("generation_config.json"))
generation.update(do_sample=False,temperature=1.0,top_p=1.0,top_k=50,max_new_tokens=1024)
inference=Path(__file__).with_name("inference.py").read_text()
compile(inference,"inference.py","exec")
docker=Path(__file__).with_name("Dockerfile").read_text()
changed={"README.md":page,"inference.py":inference,"Dockerfile":docker,"generation_config.json":json.dumps(generation,indent=2)}
for name,body in changed.items():manifest[name]={"bytes":len(body.encode()),"sha256":hashlib.sha256(body.encode()).hexdigest()}
changed["artifact_manifest.json"]=json.dumps(manifest,indent=2)
api.create_commit(repo_id=repo,operations=[CommitOperationAdd(path_in_repo=name,path_or_fileobj=body.encode()) for name,body in changed.items()],commit_message="Present Astheral v2 capabilities, measured comparisons and deterministic inference defaults")
info=api.model_info(repo,files_metadata=True)
assert not info.private
if any(tag.name=="v2" for tag in api.list_repo_refs(repo).tags):api.delete_tag(repo_id=repo,tag="v2")
api.create_tag(repo_id=repo,tag="v2",revision=info.sha,exist_ok=True)
assert next(tag for tag in api.list_repo_refs(repo).tags if tag.name=="v2").target_commit==info.sha
print("RELEASE_VERIFIED",json.dumps({"revision":info.sha,"base":base,"astheral":new,"training_examples":m["training_examples"],"trainable_parameters":m["trainable_parameters"],"hardware":m["hardware"]}),flush=True)