Rebuild the repo so its spine is a real, reproducible demonstration of
licensing an actual model capability, not payload-agnostic crypto on
stand-in blobs. The clean-room Ed25519 + AES-256-GCM primitives stay as
the fast mechanism layer; the real thing is now the headline.
New demo/ walkthrough (steps 1-7), each a standalone script printing
machine-checked evidence:
1 download Qwen2.5-0.5B-Instruct from Hugging Face (gitignored cache)
2 base scores 0.000 on an invented tool-call protocol (capability C)
3 train a PEFT LoRA on C, base frozen (SHA-256 byte-identical proof)
4 base + LoRA scores 0.925 on a held-out set with unseen arguments
5 seal the adapter as an AES-256-GCM unit under an Ed25519 leaf cert
6 valid licence decrypts-at-load and runs C at 0.925
7 access-gate then crypto-erase: original and exfiltrated copy both
permanently undecryptable, base alone back to 0.000
Reference run on an RTX 4090 captured the observed numbers now in the
README. keystore.py gains export_state/load_state so the authority (and
crypto-erasure) persists across the separate demo commands. A single
run_demo.sh drives steps 1-7; run_all.sh + pytest remain the fast
crypto-only mechanism tests.
Ships code only: base weights, HF cache, trained adapter, wrapping keys
and every sealed unit are gitignored and never committed. README rewritten
to lead with the demo and the observed numbers, with honest bounds
(in-memory adapter during a live licence needs a hardware enclave) and a
capability-tree scale-up as future work.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
54 lines
2 KiB
Bash
Executable file
54 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# End-to-end demonstration: license a real, LoRA-carried model capability,
|
|
# gate its use, and cryptographically revoke it. Runs steps 1-7 in order and
|
|
# stops on the first failure.
|
|
#
|
|
# Prerequisites (one-time):
|
|
# python3 -m venv .venv-demo
|
|
# . .venv-demo/bin/activate
|
|
# pip install -r requirements-demo.txt
|
|
#
|
|
# A CUDA GPU is recommended (the reference run used an RTX 4090). CPU works but
|
|
# training and evaluation are much slower.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
if [ -x ".venv-demo/bin/python" ]; then
|
|
PYTHON="${PYTHON:-.venv-demo/bin/python}"
|
|
else
|
|
PYTHON="${PYTHON:-python3}"
|
|
fi
|
|
|
|
if ! "$PYTHON" -c "import torch, transformers, peft" 2>/dev/null; then
|
|
echo "The demo dependencies are not installed for: $PYTHON"
|
|
echo "Run: python3 -m venv .venv-demo && . .venv-demo/bin/activate && pip install -r requirements-demo.txt"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=================================================================="
|
|
echo " Capability licensing: real end-to-end model-capability demo"
|
|
echo " python: $($PYTHON -c 'import sys; print(sys.version.split()[0])')"
|
|
echo " device: $($PYTHON -c 'import torch; print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else "cpu")')"
|
|
echo "=================================================================="
|
|
|
|
for step in \
|
|
demo/01_download_base.py \
|
|
demo/02_eval_base.py \
|
|
demo/03_train_lora.py \
|
|
demo/04_eval_lora.py \
|
|
demo/05_package_unit.py \
|
|
demo/06_serve_licensed.py \
|
|
demo/07_revoke_erase.py
|
|
do
|
|
echo
|
|
echo "------------------------------------------------------------------"
|
|
"$PYTHON" "$step"
|
|
done
|
|
|
|
echo
|
|
echo "=================================================================="
|
|
echo " END-TO-END DEMO COMPLETE"
|
|
echo " Base could not do C; the LoRA taught it; the adapter was sealed,"
|
|
echo " licensed, served, revoked, and crypto-erased. The escaped copy is"
|
|
echo " inert and the base alone still cannot do C."
|
|
echo "=================================================================="
|