Detect chat template mismatches in LLM fine-tuning
Project description
Chat Template Detector
Detect chat template mismatches between training and inference in LLM fine-tuning.
The Problem
You fine-tune an LLM with one chat template format. You run inference with a different format. The model outputs garbage. No error message. Hours wasted debugging.
This tool catches template mismatches before they waste your time and GPU credits.
Installation
pip install chat-template-detector
Usage
# Validate training data against inference config
chat-template-detector validate \
--training-file train.jsonl \
--inference-config config.yaml
# Validate against a specific model
chat-template-detector validate \
--training-file train.jsonl \
--model meta-llama/Llama-2-7b-chat-hf
# Check a single formatted text file
chat-template-detector check samples/sample_chatml.txt
Common Issues Detected
- ChatML vs Llama format mismatch
- Missing special tokens
- Incorrect token ordering
- BOS/EOS token mismatches
- Role name inconsistencies
Examples
Training file uses ChatML:
{"messages": [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}]}
Inference expects Llama format:
<s>[INST] Hello [/INST] Hi</s>
Detector catches this mismatch and shows exactly what's wrong.
Contributing
See CONTRIBUTING.md
License
MIT License - see LICENSE for details
Author
Built by ClarifyIntel - We clarify complex tech. Kubernetes, AI/ML, DevOps, Security — we write, we teach, we solve.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chat_template_detector-0.1.0.tar.gz.
File metadata
- Download URL: chat_template_detector-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
281b34f628f820966fde8e6760b8142f4002fea28802ea7d3024d5286415a249
|
|
| MD5 |
4a2973a7455042d95b59837864fed588
|
|
| BLAKE2b-256 |
dcf0860c2d8748c233292a526700e4826d41ca890eb8442033a1d318302eb868
|
File details
Details for the file chat_template_detector-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chat_template_detector-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
022c5ab15c0e1c8b85e54c4ded2a0489348167320d562cb9f59be6eb7685e28e
|
|
| MD5 |
ab4da1d45033a0f4121d7d493483a5cb
|
|
| BLAKE2b-256 |
d116422a574aabf9c70dcb91aed91c7bd3f85704833b75e823ee891156ce886f
|