Buckets:
| """Run a saved adapter checkpoint over a dataset split and write predictions plus a metrics report. | |
| python -m training.evaluate --checkpoint checkpoints/<run>/final --data datasets/policy_30k/validation.jsonl | |
| Works for both backbones and for older DoRA checkpoints, because the base model, adapter type and | |
| input format are all read from the checkpoint itself. Runs on CPU when no GPU is available. | |
| """ | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from training.common import read_rows, write_rows | |
| from training.engine import evaluation_report, load_trained_classifier, predict_logits, prediction_rows | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| parser.add_argument("--checkpoint", required=True, help="Directory with adapter + input_format.json") | |
| parser.add_argument("--data", required=True, help="JSONL split to score") | |
| parser.add_argument("--output", help="Output directory (default: <checkpoint>/eval_<split name>)") | |
| parser.add_argument("--batch-size", type=int, default=32) | |
| args = parser.parse_args() | |
| import torch | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| rows = read_rows(args.data) | |
| model, tokenizer, recipe = load_trained_classifier(args.checkpoint, device) | |
| records = prediction_rows(rows, predict_logits(model, tokenizer, rows, recipe, args.batch_size, device)) | |
| report = evaluation_report(records) | |
| output = Path(args.output or Path(args.checkpoint) / f"eval_{Path(args.data).stem}") | |
| output.mkdir(parents=True, exist_ok=True) | |
| write_rows(output / "predictions.jsonl", records) | |
| (output / "report.json").write_text(json.dumps(report, indent=2), encoding="utf-8") | |
| print(report["classification_report"]) | |
| print(json.dumps(report["confusion_matrix"], indent=2)) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 1.88 kB
- Xet hash:
- 6b8200e19462f565543da316b9479bb7fc0696db22761d04e5626ffd104e2330
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.