pip install mellea, m CLI available. Training requires a GPU or
Apple Silicon Mac with sufficient VRAM for the chosen base model. Uploading requires a
Hugging Face account.
Backend note: Trained adapters can only be loaded into LocalHFBackend. They do
not work with Ollama, OpenAI, or other remote backends.
LoRA vs aLoRA
Both adapter types fine-tune a base model on your data. The difference is inference cost:| LoRA | aLoRA | |
|---|---|---|
| Inference overhead | Processes full context each call | Activated at a single token — minimal overhead |
| Best for | General fine-tuning | Fast inner-loop checks, requirement validation |
| Training time | Similar | Similar |
--adapter lora if you need a more general fine-tune
and can absorb the inference cost.
Data format
Training data is a.jsonl file with one JSON object per line. Each object must have:
item— the input text to classifylabel— the string classification label
Train an adapter
./checkpoints/my_adapter/.
Parameters
| Flag | Type | Default | Description |
|---|---|---|---|
datafile | str | required | Path to .jsonl training file |
--basemodel | str | required | Hugging Face model ID or local path |
--outfile | str | required | Directory to save adapter weights |
--adapter | str | alora | Adapter type: alora or lora |
--device | str | auto | Device: auto, cpu, cuda, or mps |
--epochs | int | 6 | Number of training epochs |
--learning-rate | float | 6e-6 | Learning rate |
--batch-size | int | 2 | Per-device batch size |
--max-length | int | 1024 | Max tokenized sequence length |
--grad-accum | int | 4 | Gradient accumulation steps |
--promptfile | str | None | JSON file overriding the invocation prompt |
<|start_of_role|>check_requirement<|end_of_role|>.
Provide --promptfile only if your adapter needs a different prompt format. The file
must contain {"invocation_prompt": "..."}.
Upload to Hugging Face
HF_TOKEN set or a prior huggingface-cli login.
Warning: Before uploading to a public repository, review whether your training data includes proprietary, confidential, or personal information. Language models can memorize details from small domain-specific datasets.If you intend to use the adapter as a Mellea intrinsic (so that it can be loaded by model ID rather than local path), pass
--intrinsic and provide an io.yaml file:
Use the adapter in Mellea
Load the trained adapter into aLocalHFBackend using CustomIntrinsicAdapter:
backend.add_adapter() is called, Mellea automatically routes requirement
validation through the adapter for any req() calls on that session. The adapter
runs at the check_requirement prompt position — fast, with minimal context overhead.
Disable adapter validation
To run without adapter validation (for benchmarking or debugging):True to re-enable. This flag is per-backend instance and does not
affect other sessions.
See also: Intrinsics |
The Requirements System |
Write Custom Verifiers