12 Downloads Updated 3 months ago
ollama run seancrandall/patent-voice
A voice-transfer rewriter: given a generic, AI-voiced patent paragraph, it rewrites the paragraph in Sean Crandall’s author voice, one paragraph at a time, while preserving all reference numerals and numeric literals.
This is v1, trained via supervised A/B fine-tuning. It is usable but conservative on some paragraphs; see Limitations.
400, 404/406, FIGURE 5, etc.).The system prompt (the exact one used during SFT) is:
Rewrite into author voice. Preserve meaning. Do not add or remove technical content. Preserve all numeric literals and reference numerals. Do not shorten.
| Base model | mistralai/Mistral-Small-24B-Instruct-2501 (24B, has a chat template) |
| Method | QLoRA SFT with assistant-only loss masking (learns the generic→voice mapping, not memorization of the prompt) |
| LoRA | rank 16, alpha 32, dropout 0.05 |
| Quantization | merged to fp16 → quantized to q8_0 GGUF |
| GGUF | voice_sft.q8_0.gguf (24 GB) at /data/models/services/Trainer/modelgen/voice_sft.q8_0.gguf |
| ollama tag | patent-voice:latest (also seancrandall/patent-voice:latest) |
The GGUF bakes the stock Mistral [SYSTEM_PROMPT]…[/SYSTEM_PROMPT] / [INST]…[/INST] chat
template. The custom {% generation %} template used during training was for loss-masking only
— the rendered text is identical, so inference via this Modelfile is unaffected.
A/B pairs (generic AI patent paragraph → Sean's edited paragraph) built from
voice-editor/training_data/paragraphs-clean.db:
emit_mixed_dataset.py → train.jsonl + val.jsonl (each record has a
messages field: system / user / assistant)2-GPU QLoRA pipeline
train.py SFT_MESSAGES=1 branch → SFTConfig(assistant_only_loss=True, max_length=1536,
packing=False) + a custom Mistral training chat template with {% generation %} markers
(trl has no Mistral auto-patch; the stock template lacks markers and crashes at init).podman.sft.env — EPOCHS=3, EVAL_STEPS=200, SAVE_STEPS=200,
MAX_SEQ_LEN=1536, LOAD_BEST_MODEL_AT_END=1, BF16=1, NPROC_PER_NODE=2,
OUTPUT_DIR=/workspace/weights/voice_sft, SKIP_MERGE=0 (auto merge→GGUF).LOAD_BEST_MODEL_AT_END=1. Merged manually via MERGE_ONLY=1 +
MERGE_ADAPTER_DIR=.../checkpoint-2200 (CPU fp16 merge + convert_hf_to_gguf.py q8_0).Two infra notes for anyone re-running: (1) keep
HUGGINGFACE_HUB_CACHE=/workspace/cache/hub+HF_HUB_OFFLINE=1— the old root cache layout causedhuggingface_hubto re-validate and wipe cached weights on launch. (2) For the one-off merge container,podman runrejects--shm-sizetogether with--ipc=host(compose allows both) — drop--shm-size.
ollama run seancrandall/patent-voice
# then paste one paragraph as your message; it returns the rewritten paragraph
Or via API:
ollama run seancrandall/patent-voice "$(cat paragraph.txt)"
Inference parameters (from this Modelfile): temperature 0.5, top_p 0.9,
repeat_penalty 1.1, num_predict 2048, num_ctx 4096.
Feed one paragraph at a time. The model was trained paragraph-by-paragraph; multi-paragraph batches drift.
Tested on held-out val paragraphs + figure5.md:
Higher LoRA rank, stronger de-voicing of the input side of the pairs, and a higher inference temperature to push it past its conservative tendency.