Term-Context Sentence Generator (Granite 4.2 3B, v1)

A small model for one job. Given a term, a one-line context and a count n, it returns a JSON array of exactly n natural English sentences (6 to 18 words). Each sentence uses the term once, spelled as given, in the meaning the context describes. It was built to write sentences that get read aloud to record ASR fine-tuning data for specialist vocabulary (romanized Hebrew, Israeli names and places, tech terms). It works for any term.

LoRA fine-tune of ibm-granite/granite-4.2-3b, merged. GGUF: danielrosehill/Contextual-Sentence-Creator-GGUF. Data: danielrosehill/term-context-sentences.

Prompt

System (use exactly this; it is what the model was trained on):

Write exactly n different natural English sentences, 6 to 18 words each, that each use the term once, exactly as given, in the meaning the context describes. Reply with a JSON array of strings.

User: a JSON object. kind is optional (hebrew, yiddish, name, place, street, brand, drug, medical, tech, ai_model, linux, smart_home, jewish_text, english_word, other).

{"term": "gemach", "context": "a free community lending fund or service (money, baby gear, wedding dresses)", "n": 3, "kind": "hebrew"}

Output:

["The gemach has everything from baby monitors to hiking boots.", "Honestly, the gemach saved us a lot of money during the first year.", "My cousin borrowed a couch from the gemach last spring and never returned it."]
from transformers import AutoModelForCausalLM, AutoTokenizer
import json
repo = "danielrosehill/Contextual-Sentence-Creator"
tok = AutoTokenizer.from_pretrained(repo); model = AutoModelForCausalLM.from_pretrained(repo, dtype="auto")
SYSTEM = "Write exactly n different natural English sentences, 6 to 18 words each, that each use the term once, exactly as given, in the meaning the context describes. Reply with a JSON array of strings."
user = json.dumps({"term": "gemach", "context": "a free community lending fund", "n": 5})
ids = tok.apply_chat_template([{"role": "system", "content": SYSTEM}, {"role": "user", "content": user}],
                              add_generation_prompt=True, return_tensors="pt")
out = model.generate(ids, max_new_tokens=60 * 5 + 40, do_sample=True, temperature=0.8, top_p=0.95)
print(json.loads(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True)))

Evaluation (2026-11-03)

309 held-out calls (terms never seen in training, plus 6 fixed benchmark pairs), n = 10, temperature 0.8. "Gate" is the ASR acceptance check: 6 to 18 words, the term exactly once, allowed charset, number rules.

this model Gemini 3.1 Flash-Lite (API baseline, same prompt set)
reply is valid JSON 100% 100%
exactly n sentences 100% 100%
sentences passing the gate 95.7% 99.7%
calls where all n pass first try 72.8% 96.8%

Failures are mostly sentences slightly too long (19 to 22 words) and a missing term (1.8% of sentences). A missing term is usually a rare word swapped for a familiar one, as with arev written as "avrech". The term appears twice in 0.3% of sentences. Recommended use: ask for n + 2 and keep the first n that pass your own checks.

Training

LoRA r = 32, alpha 32, dropout 0.05, all linear layers. lr 2e-4 cosine, 2 epochs, batch 16, 1,676 steps, bf16, one L40S (27 min). Loss on the assistant turn only. 13,408 examples over 8,342 terms.

Limitations

English only. The vocabulary leans heavily Israeli. Much of the training data is LLM-written (Claude, Gemini, DeepSeek). It is not checked for factual accuracy: it writes plausible sentences, not true ones. The gate in the table checks form, not meaning.

Downloads last month
-
Safetensors
Model size
4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for danielrosehill/Contextual-Sentence-Creator

Adapter
(8)
this model
Quantizations
1 model

Dataset used to train danielrosehill/Contextual-Sentence-Creator

Collections including danielrosehill/Contextual-Sentence-Creator