Downloads · 30 days
243
42% of all-time downloads
jamal-ibrahim/qwen2.5-1.5b-json-repair
qwen2.5-1.5b-json-repair is a text generation model from jamal-ibrahim. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This model is a lightweight (~1.5B parameter) transformer specialized in repairing malformed JSON outputs generated by large language models.
Downloads · 30 days
243
42% of all-time downloads
All-time downloads
577
Public
Parameters
1.7B
3.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.4 GB · 100%
From the Hugging Face model README
This model is a lightweight (~1.5B parameter) transformer specialized in repairing malformed JSON outputs generated by large language models.
It was created by:
The objective is syntactic repair and structural correction of JSON under realistic LLM failure patterns.
This is a specialized structural model — not a general-purpose reasoning model.
This uses structured depth pruning rather than magnitude pruning.
Transformers contain significant redundancy across layers. Retaining alternating layers preserves representation diversity while reducing compute and memory.
Source dataset: glaiveai/glaive-function-calling-v2
Procedure:
The corruption strategy simulates realistic LLM output failures:
Training uses Knowledge Distillation combining:
Loss formulation:
L = α * CE(student, target) + (1 - α) * KL(student || teacher)
The teacher model remained frozen during training.
Evaluation was conducted on 100 samples from the test split.
Robust parsing was performed using:
json.JSONDecoder().raw_decode
This allows extraction of valid JSON even if trailing text exists.
Valid JSON Rate: Percentage of outputs that can be successfully parsed as JSON.
Exact Match Accuracy: Percentage of predictions that are semantically identical to ground truth (Python dict equality).
Interpretation:
The model frequently reconstructs syntactically valid JSON but sometimes:
This behavior is expected given:
Designed for:
Not designed for:
Observed behaviors:
These are typical in partially converged distilled models.
Potential improvements:
With these changes, validity rate is expected to increase significantly (>80%).
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "jamal-ibrahim/qwen2.5-1.5b-json-repair"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
malformed_json = '{"status": "success", "message" "QR code generated successfully"}'
prompt = f"User: Repair this JSON: {malformed_json}\n\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
This model demonstrates that:
Structural knowledge survives aggressive pruning.
Distillation can preserve formal syntax understanding.
Small specialized models can effectively act as structural validators.
Instead of relying on large general models for everything, a modular architecture using lightweight structural validators can be more efficient and robust.
Training Compute Summary
Hardware: NVIDIA A100
Precision: bfloat16
Epochs: 3
Total training time: ~40 minutes
Approximate CO₂ estimate: 0.3 kg (estimated)
License
Apache 2.0 (inherits from base model license).
Citation
If you use this model in research or production systems, please cite this repository.