Download scripts/eval_model_registry.py from ar-mine/e5-c3-code: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/datasets/ar-mine/e5-c3-code/resolve/main/scripts/eval_model_registry.py
- Command line
-
hf download hf://datasets/ar-mine/e5-c3-code/scripts/eval_model_registry.py
-
curl -L -o eval_model_registry.py https://huggingface.co/datasets/ar-mine/e5-c3-code/resolve/main/scripts/eval_model_registry.py
2.85 kB
| """Portable release identity adapter; original loading and rollout math are unchanged.""" | |
| import hashlib | |
| import json | |
| import os | |
| from pathlib import Path | |
| MODEL_NAMES = ('e5',) | |
| def file_sha256(path): | |
| digest = hashlib.sha256() | |
| with Path(path).open('rb') as stream: | |
| for block in iter(lambda: stream.read(8*1024*1024), b''): | |
| digest.update(block) | |
| return digest.hexdigest() | |
| def profile(root): | |
| epoch = os.environ.get('E5_EPOCH', '') | |
| if epoch not in ('ep2', 'ep6'): | |
| raise ValueError('Set E5_EPOCH to ep2 or ep6') | |
| value = json.loads((Path(root)/'configs/evaluation'/(epoch+'.json')).read_text()) | |
| if value['epoch'] != int(epoch[2:]) or value['step'] != {'ep2':17180,'ep6':17178}[epoch]: | |
| raise ValueError('Release identity mismatch') | |
| return value | |
| def expected_metadata(root): | |
| value = profile(root) | |
| return {'checkpoint_source_kind':'original_public_e5_c3', 'repo_id':value['repo_id'], | |
| 'training_epoch':value['epoch'], 'training_step':value['step'], | |
| 'checkpoint_index_sha256':value['files']['model.safetensors.index.json']['sha256'], | |
| 'checkpoint_config_sha256':value['files']['config.json']['sha256'], | |
| 'checkpoint_files_verified':True, 'action_history_mode':'summary', | |
| 'action_history_length':8, 'action_history_mlp_hidden_size':1024, | |
| 'visual_history_mode':'none', 'state_history_mode':'tokens', | |
| 'state_history_length':2, 'state_history_stride':50} | |
| def verify_checkpoint(root): | |
| root = Path(root) | |
| value = profile(root) | |
| checkpoint = root/'checkpoints'/('ep'+str(value['epoch'])) | |
| for name, expected in value['files'].items(): | |
| if Path(name).name != name: | |
| raise ValueError('Invalid checkpoint filename') | |
| path = checkpoint/name | |
| if path.stat().st_size != expected['bytes'] or file_sha256(path) != expected['sha256']: | |
| raise ValueError('Checkpoint file hash mismatch: '+name) | |
| index = json.loads((checkpoint/'model.safetensors.index.json').read_text()) | |
| if len(index['weight_map']) != 1716 or set(index['weight_map'].values()) != { | |
| f'model-{i:05d}-of-00006.safetensors' for i in range(1,7)}: | |
| raise ValueError('Checkpoint tensor/shard membership mismatch') | |
| norm = root/'manifests/norm_stats/robotwin_clean_train_s7.json' | |
| if file_sha256(norm) != value['normalization_sha256']: | |
| raise ValueError('Normalization identity mismatch') | |
| return checkpoint,norm,expected_metadata(root) | |
| def validate_server_identity(metadata,root): | |
| if any(metadata.get(k) != v for k,v in expected_metadata(root).items()): | |
| raise ValueError('Server did not load the selected original release') | |
| def validate_lora_identity(metadata,root): | |
| raise ValueError('This release supports original E5+C3 checkpoints only') | |