A minimalistic C++ Jinja templating engine specifically designed for LLM chat templates, used in llama.cpp and other projects.
Minja is a minimalistic C++ implementation of the Jinja templating engine specifically designed for formatting chat templates used by large language models (LLMs). It solves the problem of integrating Jinja-like templating into C++ LLM projects without the bloat of a full general-purpose engine, providing just enough functionality to support templates from models on HuggingFace.
C++ developers working on LLM inference engines, such as those building or integrating with projects like llama.cpp, gemma.cpp, or Jan, who need to process HuggingFace-style chat templates efficiently.
Developers choose Minja for its focused feature set, ease of integration as a header-only library, and lightweight codebase that avoids unnecessary complexity while supporting the exact Jinja subset required for LLM chat templates.
A minimalistic C++ Jinja templating engine for LLM chat templates
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements only the Jinja subset needed for LLM chat templates, keeping the codebase at 2.5k lines and avoiding feature creep, as stated in the design goals.
Header-only with a single dependency on nlohmann::json and no Boost required, making it straightforward to add to projects like llama.cpp with simple CMake integration.
Supports templates from major HuggingFace models and is integrated in projects like Jan and GPT4All, ensuring reliability for its intended use case.
Includes a chat-template wrapper that handles quirks in message history formatting, providing a consistent interface across different model templates.
Lacks many Jinja features such as full filter set, tuples, and template inheritance, making it unsuitable for general templating needs beyond LLM chat templates.
No protection against prompt injection and unsafe for HTML due to lack of escaping, requiring users to implement their own security measures, as warned in the README.
Has known line difference problems on Windows that need fixing, as mentioned in the roadmap, which could affect cross-platform consistency.