interplane-mv
INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.
Brought by drakestapleton
interplane-mv / provenance / fixtures / real-waldo-aien-chain / run-inputs / train-and-export.sh
| 1 | #!/bin/sh |
| 2 | # Train the tool-call model: structured conversations -> SFT with chatml-v1 -> Hugging Face export. |
| 3 | set -eu |
| 4 | T=$HOME/.claude/jobs/6c731f18/tmp/ipx76; S=$HOME/.claude/jobs/bb9e2577/tmp/waldo29 |
| 5 | export PATH=$S/venvB/bin:$S/tools/go/bin:$PATH GOPATH=$S/gopath GOCACHE=$S/gocache GOFLAGS=-buildvcs=false |
| 6 | W=$T/train2/work; rm -rf $W; mkdir -p $W/source/raw |
| 7 | binary=$W/waldo; (cd $T/waldo && go build -o $binary ./cmd/waldo) |
| 8 | export WALDO_CONFIG=$W/config.json |
| 9 | cp $T/train2/conversations.jsonl $W/source/raw/conversations.jsonl |
| 10 | fb=$(wc -c < $W/source/raw/conversations.jsonl | tr -d ' ') |
| 11 | fs=$(sha256sum $W/source/raw/conversations.jsonl | awk '{print $1}') |
| 12 | tree=$(printf '%s\t%s\t%s\n' "$fs" "$fb" conversations.jsonl | sha256sum | awk '{print $1}') |
| 13 | cat > $W/source/manifest.json <<EOM |
| 14 | {"kind":"waldo-source-directory","schema":1,"retrieved_at":"2026-10-07T00:00:00Z", |
| 15 | "corpus":{"id":"aien-toolcall-own","title":"AIEN tool-call conversations","description":"Own tiny corpus: write_file tool calls, written for the provenance fixture"}, |
| 16 | "sources":[{"id":"aien-toolcall-own","path":"","license":"CC0-1.0", |
| 17 | "source":{"name":"aien-toolcall-own","version":"1","url":"https://example.invalid/aien-toolcall-own","category":"public-dataset","license_evidence":{"declaration":"CC0-1.0"}}, |
| 18 | "input":{"format":"jsonl","type":"chat-messages","fields":{"id":"id"},"messages":{"role":"conversations[].from","content":"conversations[].value","role_aliases":{"human":"user","gpt":"assistant"}}}, |
| 19 | "artifacts":[]}], |
| 20 | "fetcher":{"name":"aien-toolcall-own"}, |
| 21 | "raw":{"path":"raw","file_count":1,"byte_count":$fb,"tree_sha256":"$tree"}} |
| 22 | EOM |
| 23 | $binary index init $W/idx >/dev/null |
| 24 | $binary config set index $W/idx >/dev/null |
| 25 | $binary config set lookaside file://$W/look >/dev/null |
| 26 | $binary config set lookaside.cache $W/cache >/dev/null |
| 27 | $binary config set lookaside.cache.max-size 64MiB >/dev/null |
| 28 | $binary config set lookaside.scratch $W/scratch >/dev/null |
| 29 | $binary config set ingest.staging $W/staging >/dev/null |
| 30 | $binary config set model.root $W/models >/dev/null |
| 31 | $binary config set model.backend pytorch >/dev/null |
| 32 | cat > $W/provider.json <<EOP |
| 33 | {"kind":"waldo-disclosure-provider","schema":1,"provider":{"name":"AIEN provenance fixture","address":"Local","contact":"test@example.invalid"},"code_of_practice_status":"not-assessed","copyright_policy_url":"https://example.invalid/copyright"} |
| 34 | EOP |
| 35 | $binary config set disclosure.provider $W/provider.json >/dev/null |
| 36 | dest=$W/idx/post-train/sft/aien-toolcall-own |
| 37 | $binary index ingest $W/source $dest >/dev/null |
| 38 | c=; for d in $W/staging/*/contribution; do [ -d $d ] && c=$d; done |
| 39 | cp -R $c/. $W/idx/ |
| 40 | cat > $W/model.yaml <<EOY |
| 41 | kind: waldo-model-compose |
| 42 | schema: 1 |
| 43 | interaction: |
| 44 | template: chatml-v1 |
| 45 | architecture: |
| 46 | family: decoder-transformer |
| 47 | context_tokens: 2048 |
| 48 | vocabulary_size: 259 |
| 49 | hidden_size: 128 |
| 50 | intermediate_size: 256 |
| 51 | layers: 2 |
| 52 | attention_heads: 4 |
| 53 | key_value_heads: 2 |
| 54 | tie_embeddings: true |
| 55 | parameter_dtype: bfloat16 |
| 56 | tokenizer: |
| 57 | name: byte |
| 58 | revision: builtin-byte-schema-1 |
| 59 | stages: |
| 60 | - name: toolcall-sft |
| 61 | type: fine-tuning |
| 62 | objective: assistant-response-modeling |
| 63 | conversation: |
| 64 | template: chatml-v1 |
| 65 | supervised_roles: [assistant] |
| 66 | corpora: |
| 67 | - post-train/sft/aien-toolcall-own |
| 68 | parameters: |
| 69 | epochs: ${EPOCHS:-30} |
| 70 | batch_size: 4 |
| 71 | sequence_length: 256 |
| 72 | learning_rate: ${LR:-0.003} |
| 73 | seed: 7 |
| 74 | evaluation_max_records: 1 |
| 75 | evaluation_max_bytes: 1048576 |
| 76 | EOY |
| 77 | $binary model train toolcall-tiny $W/model.yaml --audit |
| 78 | $binary model export toolcall-tiny $W/hf --format huggingface --allow-incomplete |
| 79 | ls $W/hf |