Shpigford/cron-schedule-conversion
Viewer • Updated • 4.09k • 145
How to use Shpigford/cron-mini with MLX:
# Make sure mlx-lm is installed
# pip install --upgrade mlx-lm
# Generate text with mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("Shpigford/cron-mini")
prompt = "Write a story about Einstein"
messages = [{"role": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(
messages, add_generation_prompt=True
)
text = generate(model, tokenizer, prompt=prompt, verbose=True)How to use Shpigford/cron-mini with Pi:
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Shpigford/cron-mini"
# Install Pi:
npm install -g @mariozechner/pi-coding-agent
# Add to ~/.pi/agent/models.json:
{
"providers": {
"mlx-lm": {
"baseUrl": "http://localhost:8080/v1",
"api": "openai-completions",
"apiKey": "none",
"models": [
{
"id": "Shpigford/cron-mini"
}
]
}
}
}# Start Pi in your project directory: pi
How to use Shpigford/cron-mini with Hermes Agent:
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Shpigford/cron-mini"
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Shpigford/cron-mini
hermes
How to use Shpigford/cron-mini with MLX LM:
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Shpigford/cron-mini"
# Install MLX LM
uv tool install mlx-lm
# Start the server
mlx_lm.server --model "Shpigford/cron-mini"
# Calling the OpenAI-compatible server with curl
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Shpigford/cron-mini",
"messages": [
{"role": "user", "content": "Hello"}
]
}'A small fine-tuned language model that converts natural-language schedules into cron expressions and systemd OnCalendar strings.
Input: every Tuesday at 3am except December
Output: {"cron": "0 3 * 1-11 2",
"systemd": "Tue *-01..11-* 03:00:00",
"note": "Months 1-11 only excludes December."}
It handles:
OnBootSec=, Persistent=, RandomizedDelaySec=)TZ= for cron, uses Asia/Tokyo-style for systemd)from mlx_lm import load, generate
model, tokenizer = load("Shpigford/cron-mini")
SYSTEM = ("You convert natural-language schedules into cron expressions and "
"systemd OnCalendar strings. Output JSON with keys: cron, systemd, "
"note. If cron cannot exactly express the schedule, put the closest "
"valid cron and explain in note. Do not output anything else.")
messages = [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": "Convert this schedule to cron and systemd OnCalendar: every weekday at 9am"},
]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
print(generate(model, tokenizer, prompt=prompt, max_tokens=200, temp=0.0))
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Shpigford/cron-mini", torch_dtype="auto", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("Shpigford/cron-mini")
SYSTEM = "..." # same as above
messages = [
{"role": "system", "content": SYSTEM},
{"role": "user", "content": "Convert this schedule to cron and systemd OnCalendar: every weekday at 9am"},
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(inputs, max_new_tokens=200, do_sample=False)
print(tokenizer.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
A GGUF version is available — see the Files tab for .gguf files. Load with llama.cpp or import into Ollama:
ollama create cron-mini -f Modelfile
Held-out test set of 91 cases including all the trick categories above:
See eval_results.json in this repo for per-case results.
Qwen/Qwen2.5-1.5B-Instruct (Apache 2.0)TZ= env var is needed.Apache 2.0, same as the base model.
If you find this useful:
@misc{cron-mini,
author = {Pigford, Josh},
title = {Cron-Mini: A Small Model for Schedule Conversion},
year = {2026},
howpublished = {Hugging Face},
url = {https://huggingface.co/Shpigford/cron-mini}
}
Quantized
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("Shpigford/cron-mini") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True)