Instructions to use AnuCaro/Carol_JITAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use AnuCaro/Carol_JITAI with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-1.7B") model = PeftModel.from_pretrained(base_model, "AnuCaro/Carol_JITAI") - Notebooks
- Google Colab
- Kaggle
Download scripts/verify_final_project.py from AnuCaro/Carol_JITAI: direct link, hf CLI and curl.
- Browser
- Download file 5.9 kB
-
https://huggingface.co/AnuCaro/Carol_JITAI/resolve/main/scripts/verify_final_project.py
- Command line
-
hf download hf://AnuCaro/Carol_JITAI/scripts/verify_final_project.py
-
curl -L -o verify_final_project.py https://huggingface.co/AnuCaro/Carol_JITAI/resolve/main/scripts/verify_final_project.py
5.9 kB
| """Verify the final local ZIP, its nested run, metrics, source and privacy.""" | |
| import argparse | |
| import ast | |
| import base64 | |
| import hashlib | |
| import importlib.util | |
| import io | |
| import json | |
| import sys | |
| import tempfile | |
| import zipfile | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path[:0] = [str(ROOT / 'scripts'), str(ROOT / 'src')] | |
| from verify_ai_run import inspect | |
| from jitai_training.evaluation import evaluate_predictions | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('archive', type=Path) | |
| args = parser.parse_args() | |
| spec = importlib.util.spec_from_file_location('privacy', ROOT / 'scripts/prepare_huggingface_release.py') | |
| privacy = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(privacy) | |
| findings = [] | |
| checked_python = [] | |
| def scan(name, data): | |
| if name.endswith('.safetensors'): | |
| return | |
| if name.endswith('.zip'): | |
| with zipfile.ZipFile(io.BytesIO(data)) as nested: | |
| assert nested.testzip() is None | |
| for member in nested.namelist(): | |
| scan(name + ':' + member, nested.read(member)) | |
| return | |
| findings.extend(privacy.scan(name, data)) | |
| if name.endswith('.py'): | |
| ast.parse(data.decode('utf-8-sig'), filename=name) | |
| checked_python.append(name) | |
| if name.endswith('.ipynb'): | |
| notebook = json.loads(data) | |
| for cell in notebook['cells']: | |
| if cell['cell_type'] != 'code': | |
| continue | |
| source = ''.join(cell['source']) | |
| try: | |
| tree = ast.parse(source) | |
| except SyntaxError: | |
| continue # Historical IPython magic cells are not Python modules. | |
| for node in tree.body: | |
| if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'PAYLOAD' for t in node.targets): | |
| payload = ast.literal_eval(node.value) | |
| if isinstance(payload, str): | |
| scan(name + ':embedded-input.zip', base64.b64decode(payload)) | |
| data = args.archive.read_bytes() | |
| checksum = hashlib.sha256(data).hexdigest() | |
| assert checksum == args.archive.with_suffix('.zip.sha256').read_text().split()[0] | |
| with zipfile.ZipFile(io.BytesIO(data)) as z: | |
| assert z.testzip() is None | |
| names = z.namelist() | |
| assert len(names) == len(set(names)) | |
| assert all('__pycache__' not in Path(n).parts and not n.endswith('.pyc') for n in names) | |
| assert all(not Path(n).is_absolute() and '..' not in Path(n).parts and '\\' not in n for n in names) | |
| required = {'adapter_model.safetensors', 'adapter_config.json', 'test_evaluation.json', | |
| 'test_evaluation.md', 'base_test_predictions.jsonl', 'adapter_test_predictions.jsonl', | |
| 'FINAL_PROJECT_REPORT.md', 'REPRODUCING.md', 'evaluation_execution.json', | |
| 'run_config.json', 'training_result.json', 'completion.json', | |
| 'data/experimental/ai-reviewed-v1/DATASET_CARD.md', 'SHA256SUMS'} | |
| assert required <= set(names), required - set(names) | |
| manifest = dict((name, expected) for expected, name in | |
| (line.split(' ', 1) for line in z.read('SHA256SUMS').decode().splitlines())) | |
| backups = [n for n in names if n.startswith('private-run-backup/')] | |
| assert len(backups) == 1 | |
| assert set(names) == set(manifest) | {'SHA256SUMS'} | set(backups) | |
| for name, expected in manifest.items(): | |
| assert hashlib.sha256(z.read(name)).hexdigest() == expected, name | |
| original = ROOT / 'artifacts/ai-experiment-v1/training-recovery/adapter/adapter_model.safetensors' | |
| if original.is_file(): | |
| assert z.read('adapter_model.safetensors') == original.read_bytes() | |
| backup_data = z.read(backups[0]) | |
| with zipfile.ZipFile(io.BytesIO(backup_data)) as backup: | |
| adapter_members = [n for n in backup.namelist() if n.endswith('/adapter/adapter_model.safetensors')] | |
| assert len(adapter_members) == 1 | |
| assert backup.read(adapter_members[0]) == z.read('adapter_model.safetensors') | |
| rows = [json.loads(line) for line in z.read('data/experimental/ai-reviewed-v1/test.jsonl').decode().splitlines()] | |
| assert len(rows) == 50 | |
| metrics = json.loads(z.read('test_evaluation.json')) | |
| for variant in ['base', 'adapter']: | |
| predictions = [json.loads(line) for line in z.read(variant + '_test_predictions.jsonl').decode().splitlines()] | |
| recomputed = evaluate_predictions(rows, predictions) | |
| assert all(metrics[variant][key] == value for key, value in recomputed.items()) | |
| for name in names: | |
| scan(name, z.read(name)) | |
| assert not findings, findings | |
| status = json.loads(z.read('PROJECT_STATUS.json')) | |
| assert status['full_project_complete'] and not status['public_upload_performed'] | |
| with tempfile.TemporaryDirectory(dir=args.archive.parent) as temporary: | |
| raw_run = Path(temporary) / 'run-v1-backup.zip' | |
| raw_run.write_bytes(backup_data) | |
| verified_run = inspect(raw_run) | |
| result = dict(final_zip=str(args.archive.resolve()), sha256=checksum, | |
| crc_and_all_manifest_hashes_verified=True, adapter_matches_original=True, | |
| base_and_adapter_metrics_recomputed=True, test_examples=50, | |
| privacy_secret_findings=findings, python_files_parsed=len(checked_python), | |
| publication_performed=False, verified_run=verified_run) | |
| (args.archive.parent / 'FINAL_VERIFICATION.json').write_text(json.dumps(result, indent=2) + '\n') | |
| print(json.dumps(result, indent=2)) | |
| if __name__ == '__main__': | |
| main() | |