|
Download docs/huggingface.md from ElderRyan/lispm-llm: direct link, hf CLI and curl.
- Browser
- Download file 14.5 kB
-
https://huggingface.co/ElderRyan/lispm-llm/resolve/main/docs/huggingface.md
- Command line
-
hf download hf://ElderRyan/lispm-llm/docs/huggingface.md
-
curl -L -o huggingface.md https://huggingface.co/ElderRyan/lispm-llm/resolve/main/docs/huggingface.md
14.5 kB
| # Hugging Face model artifacts | |
| The public repository is | |
| [ElderRyan/lispm-llm](https://huggingface.co/ElderRyan/lispm-llm). Its model format | |
| is `config.json` plus `model.safetensors`, accompanied by Rust source, portable | |
| datasets, documentation, tests and evaluation reports. **Rust + tch-rs 0.22.0 / | |
| LibTorch 2.9.0 is the primary training and inference implementation.** Python is | |
| optional for the original reference implementation and release maintenance. | |
| This is a custom command classifier. The Hub stores the artifacts; a hosted | |
| inference provider, inference widget and Transformers `pipeline` are not | |
| provided. The card's `library_name: pytorch` describes the underlying model | |
| technology, and `pipeline_tag: text-classification` describes the task. Neither | |
| field registers a serving backend. See the official | |
| [model-card metadata guide](https://huggingface.co/docs/hub/model-cards). | |
| ## Download and run with Rust | |
| Clone the published repository with Git LFS installed: | |
| ```sh | |
| git clone https://huggingface.co/ElderRyan/lispm-llm | |
| cd lispm-llm | |
| git lfs install --local | |
| git lfs pull | |
| ``` | |
| Install Rust and matching native libraries. On macOS Apple Silicon, the helper | |
| verifies a pinned official archive and extracts C++ headers and libraries: | |
| ```sh | |
| bash scripts/setup-libtorch.sh | |
| export LIBTORCH="$PWD/.libtorch/2.9.0/torch" | |
| cargo run --release --locked -- infer --model . 'save the current buffer' | |
| cargo run --release --locked -- infer --model . 'open file "notes.el"' --format json | |
| cargo run --release --locked -- infer --model . 'open file "notes.el" then search forward for "TODO"' | |
| ``` | |
| The helper and native commands do not install or run Python. For other platforms, | |
| set `LIBTORCH` to a compatible LibTorch 2.9.0 directory containing `include/` and | |
| `lib/`; see the [native build guide](rust.md). Keep the native libraries available | |
| at runtime. Cargo resolves the executable location, including configurations | |
| with an explicit target architecture. | |
| `--model` is a local directory containing the two artifact files. The published | |
| snapshot has them at its root; a locally staged release may use | |
| `--model dist/huggingface`. The native CLI does not resolve Hub repository IDs. | |
| JSON output contains an `actions` array with typed argument fields. Both formats | |
| are proposals; `infer` does not execute them. Invalid input, unsupported intent | |
| and uncertain predictions produce a refusal. Valid syntax does not establish | |
| that the model selected the intended action. | |
| ## Train and evaluate natively | |
| From the repository root with `LIBTORCH` configured: | |
| ```sh | |
| cargo run --release --locked -- train --data data/training.json --output experiments/my-rust-model --steps 3200 --seed 42 | |
| cargo run --release --locked -- evaluate --model experiments/my-rust-model --data data/benchmark.json --output experiments/my-rust-evaluation.json | |
| cargo run --release --locked -- infer --model experiments/my-rust-model 'save the current buffer' | |
| ``` | |
| Training requires a new output directory. It writes `config.json`, | |
| `model.safetensors` and `training-report.json` only after selecting an eligible | |
| checkpoint using calibration data. The original calibration coverage/error | |
| constraints remain in force. An unsuccessful selection does not replace an | |
| existing model. Evaluation requires a new report path and does not change | |
| weights or thresholds. | |
| The portable training dataset includes the training/calibration split, hard | |
| examples and selection reference. Training does not read evaluation data. | |
| The [native training guide](rust.md) describes validation and optimizer settings. | |
| `data/training.json` preserves the original 16,404 training rows. | |
| `data/semantic-training.json` appends 593 reviewed training examples while keeping | |
| the same 1,182 calibration rows and selection reference. Use the latter explicitly | |
| for the first semantic candidates; it does not replace the historical training | |
| input. The final follow-up candidate has a separate append-only input, | |
| `data/refined-semantic-training.json`, with 235 additional contrast examples | |
| (17,232 training rows total), so earlier runs remain reproducible. Its calibration | |
| rows and selection reference are also unchanged. | |
| For explicit native fine-tuning, provide an initial artifact and learning rate | |
| together, with a new output directory: | |
| ```sh | |
| cargo run --release --locked -- train --data data/semantic-training.json --output experiments/my-finetuned-model --steps 3200 --seed 42 --init-model python-reference --learning-rate 0.0002 | |
| ``` | |
| This example retains the source vocabulary and character architecture, starts a | |
| fresh AdamW optimizer and records the exact initial artifact hashes. The rate is | |
| an example, not a universal recommendation. A selected step of zero preserves | |
| the initial tensors rather than demonstrating a learned improvement. The | |
| [native training guide](rust.md#fine-tune-an-explicit-artifact) explains these | |
| boundaries. Emacs/C FFI project training still starts from scratch. | |
| The default command benchmark includes single-action cohorts and 2,256 | |
| two-action recombinations. A separate `task-benchmark` command runs real core | |
| Emacs tasks in disposable fixtures and measures final-state success. See the | |
| [benchmark guide](benchmarks.md) for both commands, report identities and metric | |
| definitions. The original `data/evaluation.json` remains unchanged for historical | |
| regression reports. | |
| Emacs users can install `emacs/lispm-llm-0.3.0.tar` and create a personal project | |
| with **M-x lispm-llm-train-create**. New projects freeze both the expanded command | |
| benchmark and the task suite. The [collect → retrain → benchmark → use workflow](training-workflow.md) | |
| compares the baseline and candidate before explicit finalization and activation. | |
| The original Python checkpoint is preserved in `python-reference/`, independently | |
| of which artifact is selected at the repository root. It supplies the historical | |
| baseline and frozen numerical parity checks. Rust uses a different sampling RNG | |
| and LibTorch version, so the same seed does not imply the same trained weights. | |
| Evaluate each native checkpoint separately and tie published metrics to its | |
| exact configuration and weight bytes. Migration checks on previously exposed | |
| corpora are regression measurements, not a new blind benchmark. | |
| ## Archived models and native candidates | |
| Each artifact has its own configuration and SafeTensors weights. Native training | |
| artifacts also retain `training-report.json`: | |
| | Directory | Role | Training input | | |
| | --- | --- | --- | | |
| | `python-reference/` | Historical Python model and numerical parity reference | Original Python training provenance | | |
| | `rust-trained/` | Earlier independent Rust retraining candidate | `data/training.json` | | |
| | `semantic-from-scratch/` | Expanded-data Rust run; not promoted because historical false acceptance regressed | `data/semantic-training.json` | | |
| | `semantic-warm-start/` | Expanded-data fine-tuning from the historical model; not promoted because supported errors and refusals regressed | `data/semantic-training.json` | | |
| | `semantic-trained/` | Final refined-data candidate; improved aggregate and blind results, but failed historical nonregression gates | `data/refined-semantic-training.json` | | |
| **The root remains byte-identical to `python-reference/`.** The final candidate | |
| improved aggregate two-action accuracy and the independently authored blind | |
| audit, but increased some LispM refusals and historical false accepts, including | |
| the duplicate-tab family. It is an opt-in candidate, not a replacement default: | |
| ```sh | |
| cargo run --release --locked -- infer --model semantic-trained 'save the current buffer' | |
| cargo run --release --locked -- infer --model python-reference 'save the current buffer' | |
| ``` | |
| `rust-training-evaluation.json` records the earlier `rust-trained/` candidate's single-action | |
| results. `rust-evaluation.json` records `python-reference/` on the same original | |
| benchmark, and | |
| `rust-migration-validation.json` records migration checks. The reports identify | |
| their model and data bytes; the candidate's training report also identifies the | |
| complete portable training input. Local `experiments/` directories are not | |
| required to use or verify either included artifact. | |
| `benchmark-evaluation.json` and `emacs-task-evaluation.json` always describe the | |
| selected root artifact. The preserved Python reports live inside | |
| `python-reference/`. The earlier Rust candidate uses | |
| `benchmark-rust-training-evaluation.json` and | |
| `emacs-task-rust-training-evaluation.json`. | |
| The expanded-data scratch run has `semantic-from-scratch-evaluation.json`, | |
| `semantic-from-scratch-benchmark-evaluation.json` and | |
| `semantic-from-scratch-task-evaluation.json`. Its follow-up candidate uses | |
| `semantic-warm-start-evaluation.json`, | |
| `semantic-warm-start-benchmark-evaluation.json` and | |
| `semantic-warm-start-task-evaluation.json`. The final refined-data candidate uses | |
| `semantic-evaluation.json`, `semantic-benchmark-evaluation.json` and | |
| `semantic-task-evaluation.json`. Compare their bound artifact, dataset and runtime | |
| identities as well as scores. The [native training guide](rust.md) records each | |
| training method; the [benchmark guide](benchmarks.md) records the final comparison | |
| and failed promotion gates. | |
| The final blind comparison uses [the frozen 277-case suite](../data/nov28-blind.json), | |
| with [preserved source](../data/nov28-blind-source.json) and | |
| [authorship/filtering audit](../data/nov28-blind-audit.json). | |
| [Baseline results](../blind-baseline-evaluation.json) and | |
| [candidate results](../blind-semantic-evaluation.json) were measured after final | |
| checkpoint selection. These synthetic, independently agent-authored cases were | |
| not human-validated; authoring overlapped initial training, while prompts and | |
| outcomes remained hidden from model selection. They are now public regression | |
| evidence for future iterations. | |
| ## Prepare the current release locally | |
| `export_hf.py` is an optional **Python release-maintenance adapter** for the | |
| current published checkpoint and its existing provenance reports: | |
| ```sh | |
| python -m pip install -r requirements.txt | |
| python export_hf.py --output dist/huggingface | |
| cargo run --release --locked -- infer --model dist/huggingface 'save the current buffer' --format json | |
| ``` | |
| Run this from the source checkout. The curated upload root is `dist/huggingface`, | |
| not the checkout itself. The exporter checks provenance and copies an explicit | |
| allowlist of source, data, documentation and verification assets. It excludes | |
| local environments, native libraries/build output, unlisted experiments and the | |
| pickle-format checkpoint `model.pt`. Explicit archived artifacts such as | |
| `python-reference/` remain on the allowlist. It refuses a | |
| nonempty output directory and performs no authentication or upload. | |
| The adapter copies `config.json` and `model.safetensors` **byte for byte**, | |
| including their original serialization. It loads the SafeTensors pair for | |
| validation and never imports or re-exports the local `model.pt` checkpoint. | |
| A stale `model.pt` cannot select or overwrite the default. The release manifest | |
| records the copied files' hashes, and export verifies them again after staging. | |
| The adapter packages the selected default, the `python-reference/` archive and | |
| the separately named native candidates with their own reports and training | |
| inputs. Promoting an artifact to the root requires matching provenance and | |
| model-card metrics; changing a directory name does not establish improvement. | |
| ## Publish a curated release | |
| Publishing is separate from local training and export. The existing repository | |
| accepts Git over SSH from an account with write access. Configure the intended | |
| Git author and signing key, then copy the curated release into a separate clone: | |
| ```sh | |
| git clone git@hf.co:ElderRyan/lispm-llm publish/lispm-llm | |
| git -C publish/lispm-llm lfs install --local | |
| rsync -a dist/huggingface/ publish/lispm-llm/ | |
| git -C publish/lispm-llm status --short | |
| git -C publish/lispm-llm add . | |
| git -C publish/lispm-llm diff --cached --stat | |
| git -C publish/lispm-llm commit -S -m "Publish evaluated Emacs and LispM classifier" | |
| git -C publish/lispm-llm verify-commit HEAD | |
| git -C publish/lispm-llm push origin HEAD:main | |
| ``` | |
| Review the staged content before committing. Copying without deletion preserves | |
| remote-only files, which also need review. Verify the remote commit and downloaded | |
| weight hash against `release-manifest.json` after publishing. SSH authentication | |
| and commit signing are separate configurations; see the official | |
| [Git over SSH guide](https://huggingface.co/docs/hub/security-git-ssh). | |
| The optional Python Hub CLI can also download a complete snapshot or upload the | |
| curated folder. Token uploads create a Hub-side commit rather than preserving a | |
| local signed commit: | |
| ```sh | |
| hf download ElderRyan/lispm-llm --local-dir downloaded-model | |
| hf auth login | |
| hf upload ElderRyan/lispm-llm dist/huggingface . --repo-type model | |
| ``` | |
| The optional dependency set pins `huggingface_hub==2.4.0`. See the official | |
| [CLI guide](https://huggingface.co/docs/huggingface_hub/guides/cli). | |
| ## Optional Python reference API | |
| After installing `requirements.txt`, the local reference facade remains usable: | |
| ```python | |
| from hub_model import EmacsCommandModel | |
| model = EmacsCommandModel.from_pretrained(".", local_files_only=True) | |
| program = model.predict('open file "notes.el" then search forward for "TODO"') | |
| print(program.to_lisp()) | |
| print(model.predict_json('open file "notes.el"')) | |
| ``` | |
| `predict` returns a validated `Program`; a refusal raises `actions.InputError`. | |
| These methods do not execute their output. `save_pretrained(directory)` writes | |
| only configuration and SafeTensors weights, preserving an existing README. | |
| Use `from_pretrained("python-reference", local_files_only=True)` for the archived | |
| Python model specifically; `"."` selects the current root artifact. | |
| The Python facade can also resolve a remote artifact using the already imported | |
| local implementation: | |
| ```python | |
| model = EmacsCommandModel.from_pretrained("ElderRyan/lispm-llm", revision="main") | |
| ``` | |
| Use a commit hash for a pinned revision. Only `config.json` and | |
| `model.safetensors` are downloaded; repository Python code is not fetched and | |
| executed. `local_files_only=True` limits remote identifiers to cached snapshots. | |
| See the official [Hub download guide](https://huggingface.co/docs/huggingface_hub/guides/download). | |
| Code, synthetic data and weights are **AGPL-3.0-only**. The | |
| [license](../LICENSE) is included in the release. The broader Emacs agent | |
| environment is **[LispM at lispm.ai](https://lispm.ai)**. | |