ModelMeta: expose chat template, special tokens, and full GGUF metadata#286
Merged
bernardladenthin merged 1 commit intoJul 1, 2026
Merged
Conversation
Enrich the existing getModelMetaJson native method and the ModelMeta wrapper with three read-only introspection fields, so callers can inspect a loaded model without a second round-trip: - chat_template - the model's resolved Jinja template (getChatTemplate) - special_tokens - bos/eos/eot (plus sep/nl/pad in the JSON) via getBosTokenId/getEosTokenId/getEotTokenId - metadata - the full GGUF key/value map via getMetadata(key), capped at 2 KB per value so large array metadata (tokenizer tokens/merges) cannot bloat the JSON No new native method or JNI signature change: the fields ride the existing getModelMetaJson payload, and absent fields default cleanly on the Java side. Verified: libjllama builds and links against b9842, loads cleanly (NativeLibraryLoadSmokeTest), and the ModelMeta unit tests pass (11 total).
Owner
|
Hey again @vaiju1981! Great PRs. I'll move now many files to integrate the longchain as artifact. May wait some hours with new code changes. It will be hard to merge :) |
93f48c0
into
bernardladenthin:main
30 of 36 checks passed
bernardladenthin
pushed a commit
that referenced
this pull request
Jul 1, 2026
Pre-existing formatting violation in special_tokens_json (the token-id map added by #286 / ModelMeta) that this branch inherited unchanged through the move. The reactor PR's clang-format check surfaced it. Reflowed with the pinned clang-format 22.1.5; no logic change. (Implies main currently carries the same violation — it self-resolves when this merges.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rt1paYztGJ2AKUuBuAGDXE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enriches the existing
getModelMetaJsonnative method and theModelMetawrapper with threeread-only introspection fields, so callers can inspect a loaded model without a second round-trip:
chat_template— the model's resolved Jinja template (ModelMeta.getChatTemplate())special_tokens— bos/eos/eot (plus sep/nl/pad in the JSON) viagetBosTokenId()/getEosTokenId()/getEotTokenId()metadata— the full GGUF key/value map viagetMetadata(key)(e.g."general.architecture"),capped at 2 KB/value so large array metadata (tokenizer tokens/merges) can't bloat the payload
Why
ModelMetaalready exposesn_ctx_train/n_embd/n_vocab/n_params/size/architecture/name. These three fill the common remaining gaps: callers frequently also needthe model's own chat template (to drive prompting), its special-token IDs (chat/FIM), and arbitrary
GGUF metadata — all of which previously required going outside the binding.
Design
getModelMetaJsonJSON payload, and the new
ModelMetagetters default cleanly when a field is absent (so a mismatchedolder native lib still works).
special_tokens_jsonhelper.than dumping the whole tokenizer into the JSON.
Testing
ModelMetaunit tests (JSON-based, no model): 11 total, green — 2 new cover the added gettersand their absent-field defaults.
libjllamabuilds and links against b9842 and loads cleanly (NativeLibraryLoadSmokeTest).Field population over a real GGUF is exercised by CI's model-backed suite.