Downloads · 30 days
25
18% of all-time downloads
uncommonstash/cronformer
cronformer is a feature extraction model from uncommonstash. Use it when you need embeddings to search or compare text. It is set up for transformers. The card lists the license as agpl-3.0.
Cronformer is a compact model for converting short English schedule requests into standard five-field cron expressions:
Downloads · 30 days
25
18% of all-time downloads
All-time downloads
140
Public
Parameters
6.3M
25.4 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors25.4 MB · 99%
From the Hugging Face model README
Cronformer is a compact model for converting short English schedule requests into standard five-field cron expressions:
every night at 5pm on tuesdays and wednesdays -> 0 17 * * 2,3
The model is not a text generator. It uses a small BERT encoder and a structured decoder that predicts the cron fields directly: minute, hour, day-of-month, month, and day-of-week.
This repository contains custom Transformers model code. Loading the model
requires trust_remote_code=True.
import importlib.util
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoModel, AutoTokenizer
repo_id = "impalasys/cronformer"
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(repo_id)
cron_py = hf_hub_download(repo_id, "cron.py")
spec = importlib.util.spec_from_file_location("cronformer_release_cron", cron_py)
cron_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(cron_module)
inputs = tokenizer(
"every night at 5pm on tuesdays and wednesdays",
return_tensors="pt",
max_length=128,
truncation=True,
padding="max_length",
)
with torch.no_grad():
output = model(**inputs)
cron = cron_module.logits_to_cron(output)[0].to_vixie_cron()
print(cron)
Expected output:
0 17 * * 2,3
Cronformer is an encoder-only structured prediction model for cron expressions. It does not decode cron as text. Instead, it predicts the cron schema directly.
The model has three main parts:
google/bert_uncased_L-2_H-128_A-2, encodes the
input prompt.The output is a structured CronOutput object. The bundled cron.py helper
turns those logits into a five-field Vixie-style cron string:
minute hour day-of-month month day-of-week
Cronformer does not predict seconds, years, timezone rules, holiday calendars, or execution history.
This is the initial public Cronformer release.
v0.1.0google/bert_uncased_L-2_H-128_A-2The released checkpoint was selected from internal Cronformer development as the best current all-around checkpoint for this architecture. The evaluation suites below are project-specific schedule fixtures, not public benchmark datasets.
| Suite | Top-1 | Top-2 | Top-3 |
|---|---|---|---|
| Sampled broad schedule fixture | 99.50% | 100.00% | 100.00% |
| Hard language fixture | 100.00% | 100.00% | 100.00% |
| Human-authored JSONL fixture | 100.00% | 100.00% | 100.00% |
| Manual smoke prompts | 100.00% | 100.00% | 100.00% |
| Full broad schedule fixture | 99.61% | 99.81% | 99.81% |
Known top-1 misses on the full broad fixture:
late evening at 11 PM dailyevery 30 minutes from 9 to 5 on Monday through FridayFor ambiguous business-hour language, showing top-k candidates or confirming the cron expression with the user is recommended.
Cronformer is intended for schedule-authoring interfaces, developer tools, and automation products that need a small local model to propose cron expressions from concise English prompts.
Good fits:
Poor fits: