Downloads · 30 days
10
9% of all-time downloads
pokutuna/llm2025-basic-chat-template-only
llm2025-basic-chat-template-only is a machine learning model from pokutuna. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Minimal modification of Qwen/Qwen3-4B-Instruct-2507 with an optimized chat template for structured output generation (JSON / YAML / XML / TOML / CSV).
Downloads · 30 days
10
9% of all-time downloads
All-time downloads
116
Public
Parameters
4B
16.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors8 GB · 100%
From the Hugging Face model README
Minimal modification of Qwen/Qwen3-4B-Instruct-2507 with an optimized chat template for structured output generation (JSON / YAML / XML / TOML / CSV).
Please convert the following JSON to TOML: -> TOML suffix appendedConvert this CSV data to YAML format: -> YAML suffix appendedGenerate a JSON object for ... -> no suffix (JSON/CSV use default behavior)lm_head (last token, unused special token) is minimally modified (+1e-4) to satisfy the following competition requirement:
- 提出するモデルには必ず何かしらの変更を加える必要があります
No fine-tuning or training data was used. The base model weights are essentially unchanged.
The template detects the target format from the first line and appends format-specific instructions. Also available as chat_template.jinja.
{%- if messages[0].role == 'system' %}
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
{%- endif %}
{%- for message in messages %}
{%- if message.role == "user" or (message.role == "system" and not loop.first) %}
{%- set content = message.content if message.content is string else '' %}
{%- set suffix = '' %}
{%- set fl = content.split('\n')[0].lower() %}
{%- set formats = ['toml', 'xml', 'yaml', 'json', 'csv'] %}
{%- set ns = namespace(target='') %}
{%- for f in formats %}
{%- if f in fl %}
{%- if ns.target == '' or fl.rfind(f) > fl.rfind(ns.target) %}
{%- set ns.target = f %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if ns.target == 'toml' %}
{%- set suffix = '\n\nOutput ONLY raw TOML. Use [table] for nested objects and [[array]] for arrays. Do not use inline tables.' %}
{%- elif ns.target == 'xml' %}
{%- set suffix = '\n\nOutput ONLY raw XML. Escape & as &, < as <. No XML declaration. Follow these strict rules:
1. ROOT ELEMENT DETERMINATION:
- For JSON input: Use the FIRST KEY from the input object as root name
- For data generation queries: Infer based on expected path structure. If paths start with \'assessment_id.*\', root must be \'<assessment_id>\', not the entity name
- All XML content must be wrapped within this single root element
2. FIELD ORDER & HIERARCHY:
- When generating data, follow required path structure (e.g., \'assessment_id.assessment_id\' requires:
<assessment_id>
<assessment_id>UUID</assessment_id>
...other nested fields...
</assessment_id>)
- Maintain exact field order required for path consistency
- Arrays must be nested within their parent elements with _item suffix
3. XML SYNTAX REQUIREMENTS:
- Must be parseable XML with ONE root element
- Properly escape special characters
- Match expected schema\'s path structure exactly
- All opening tags must have closing tags
4. DATA TYPE HANDLING:
- Maintain ISO 8601 timestamps (YYYY-MM-DDTHH:MM:SS.ssssss)
- Preserve UUID formats (e.g., 5ceff241-2713-4bf4-a7b2-a4b795b4a1a9)
- Keep DOI identifiers intact (e.g., 10.8889/HDtI)
5. SPECIFIC STRUCTURE REQUIREMENTS:
- Academic assessments must have:
assessment_id.assessment_id
assessment_id.student_id
assessment_id.course_id
assessment_id.type
assessment_id.date
- Arrays must be properly nested (no standalone array containers)
- Academic structures must maintain:
- Assignments with name/due/weight
- Textbooks with title/author/isbn
- Authors arrays with name/affiliation/email
6. VALIDATION CHECKS:
- Verify path format matches exactly:
\'{root_element}.{field_name}\'
\'{root_element}.{array_field}[index].{subfield}\'
- Ensure all expected fields are present in correct hierarchy
- Confirm single root element contains all content
- Check proper array element formatting with _item suffix' %}
{%- elif ns.target == 'yaml' %}
{%- set suffix = '\n\nConvert the input data format (XML, CSV, or JSON) to valid, semantically equivalent YAML following these rules:
1. SYNTAX & FORMATTING
- Use 2-space indentation levels for nesting
- Represent lists with hyphens (-) followed by single space
- Quote string values containing special characters (e.g., "-120", "0-18km")
- Maintain consistent spacing around colons (key: value)
- NO trailing spaces or markdown formatting
- Ensure valid YAML syntax (test with parser before output)
2. STRUCTURE PRESERVATION
- XML Conversion:
- Map XML tags to nested keys
- Convert multiple elements with same tag to list of maps DIRECTLY UNDER PARENT KEY, WITHOUT WRAPPING IN TAG NAME
- Preserve element hierarchy: parent-child relationships must create direct key-value pairs
- Convert XML attributes to keys with \'@\' prefix
- CSV Conversion:
- Map dot-notation headers to nested structures
- Create object arrays for underscore-prefixed columns
- Maintain field relationships in grouped columns
- Preserve row positions when splitting multi-value fields
- JSON Conversion:
- Directly map objects to YAML maps
- Maintain array order and indexing
- Preserve null values from source
3. SPECIAL CASE HANDLING
- Empty elements: Represent as null or empty string based on source
- CSV multi-value fields: Convert semicolon-separated values to arrays
- Numeric values: Keep unquoted, preserve type from source
- Boolean values: Convert to lowercase YAML booleans (true/false)
- String numbers: Quote values starting with "-" or containing special patterns
4. PATH PRESERVATION & VALIDATION
- Ensure all source paths exist in output using dot-notation
- Confirm nested structures match source depth exactly
- Validate list items maintain field relationships
- Verify key names match source paths including array element properties
5. XML SPECIFIC NESTING RULES
- For repeated elements (critical rule): TAG NAME MUST BE ELIDED IN YAML
- Elements with child elements map to nested keys
- CDATA sections map to string values
6. CSV SPECIFIC MAPPINGS
- Top-level columns go at root level
- Convert dot notation headers to nested maps
- Map underscore-prefixed columns to object arrays
OUTPUT ONLY THE RAW YAML WITH NO EXPLANATIONS. MAINTAIN 100% STRUCTURAL PARITY WITH SOURCE DATA.' %}
{%- endif %}
{{- '<|im_start|>' + message.role + '\n' + content + suffix + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{%- set content = message.content if message.content is string else '' %}
{{- '<|im_start|>assistant\n' + content + '<|im_end|>\n' }}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}
</details>
with torch.no_grad():
last_idx = model.lm_head.weight.shape[0] - 1 # 151935
model.lm_head.weight.data[last_idx, 0] += 1e-4