Any-to-Any
Transformers
Safetensors
gemma4
image-text-to-text
heretic
uncensored
decensored
abliterated
ara
Run this model with HF Jobs
Run coder3101/gemma-4-E4B-it-heretic on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/coder3101/gemma-4-E4B-it-heretic. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/coder3101/gemma-4-E4B-it-heretic on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use coder3101/gemma-4-E4B-it-heretic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use coder3101/gemma-4-E4B-it-heretic with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("coder3101/gemma-4-E4B-it-heretic") model = AutoModelForMultimodalLM.from_pretrained("coder3101/gemma-4-E4B-it-heretic", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update chat_template.jinja
Browse files10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434426 unmodified lines71727374757672 unmodified lines1491501511521531541551561571581591601611621631641651661671681691701711721732 unmodified lines17617717817918018118218318418518618718818919019112 unmodified lines2042052062072082092102112122132142152162172182192202212222232242252262272282299 unmodified lines23924024124224324424524624724824925025125225325425525625725825926026126226310 unmodified linesdescription:<|"|>{{ value['description'] }}<|"|>{%- set add_comma = true -%}{%- endif -%}{%- if value['nullable'] %}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}nullable:true{%- endif -%}{%- if value['type'] | upper == 'STRING' -%}{%- if value['enum'] -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}enum:{{ format_argument(value['enum']) }}{%- endif -%}{%- elif value['type'] | upper == 'OBJECT' -%},properties:{{%- if value['properties'] is defined and value['properties'] is mapping -%}{{- format_parameters(value['properties'], value['required'] | default([])) -}}{%- elif value is mapping -%}{{- format_parameters(value, value['required'] | default([])) -}}{%- endif -%}}{%- if value['required'] -%},required:[{%- for item in value['required'] | default([]) -%}<|"|>{{- item -}}<|"|>{%- if not loop.last %},{% endif -%}{%- endfor -%}]{%- endif -%}{%- elif value['type'] | upper == 'ARRAY' -%}{%- if value['items'] is mapping and value['items'] -%},items:{{%- set ns_items = namespace(found_first=false) -%}{%- for item_key, item_value in value['items'] | dictsort -%}{%- if item_value is not none -%}26 unmodified lines}{%- endif -%}{%- endif -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}type:<|"|>{{ value['type'] | upper }}<|"|>}{%- endif -%}72 unmodified lines{%- endfor -%}{{- ns.result | trim -}}{%- endmacro -%}{%- set ns = namespace(prev_message_type=None) -%}{%- set loop_messages = messages -%}{{ bos_token }}{#- Handle System/Tool Definitions Block -#}{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}{{- '<|turn>system\n' -}}{#- Inject Thinking token at the very top of the FIRST system turn -#}{%- if enable_thinking is defined and enable_thinking -%}{{- '<|think|>' -}}{%- set ns.prev_message_type = 'think' -%}{%- endif -%}{%- if messages[0]['role'] in ['system', 'developer'] -%}{{- messages[0]['content'] | trim -}}{%- set loop_messages = messages[1:] -%}{%- endif -%}{%- if tools -%}{%- for tool in tools %}{{- '<|tool>' -}}2 unmodified lines{%- endfor %}{%- set ns.prev_message_type = 'tool' -%}{%- endif -%}{{- '<turn|>\n' -}}{%- endif %}{#- Loop through messages -#}{%- for message in loop_messages -%}{%- set ns.prev_message_type = None -%}{%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}{{- '<|turn>' + role + '\n' }}{%- if message['tool_calls'] -%}{%- for tool_call in message['tool_calls'] -%}{%- set function = tool_call['function'] -%}12 unmodified lines{%- endfor -%}{%- set ns.prev_message_type = 'tool_call' -%}{%- endif -%}{%- if message['tool_responses'] -%}{#- Tool Response handling -#}{%- for tool_response in message['tool_responses'] -%}{{- '<|tool_response>' -}}{%- if tool_response['response'] is mapping -%}{{- 'response:' + tool_response['name'] | default('unknown') + '{' -}}{%- for key, value in tool_response['response'] | dictsort -%}{{- key -}}:{{- format_argument(value, escape_keys=False) -}}{%- if not loop.last %},{% endif -%}{%- endfor -%}{{- '}' -}}{%- else -%}{{- 'response:' + tool_response['name'] | default('unknown') + '{value:' + format_argument(tool_response['response'], escape_keys=False) + '}' -}}{%- endif -%}{{- '<tool_response|>' -}}{%- endfor -%}{%- set ns.prev_message_type = 'tool_response' -%}{%- endif -%}{%- if message['content'] is string -%}{%- if role == 'model' -%}{{- strip_thinking(message['content']) -}}9 unmodified lines{{- item['text'] | trim -}}{%- endif -%}{%- elif item['type'] == 'image' -%}{{- '\n\n<|image|>\n\n' -}}{%- set ns.prev_message_type = 'image' -%}{%- elif item['type'] == 'audio' -%}{{- '<|audio|>' -}}{%- set ns.prev_message_type = 'audio' -%}{%- elif item['type'] == 'video' -%}{{- '\n\n<|video|>\n\n' -}}{%- set ns.prev_message_type = 'video' -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- if not (message['tool_responses'] and not message['content']) -%}{{- '<turn|>\n' -}}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{%- if ns.prev_message_type != 'tool_response' -%}{{- '<|turn>model\n' -}}{%- endif -%}{%- endif -%}10 unmodified lines11121314151617181920212223242526 unmodified lines525354555657585960616263646566676869707172737475767778798081828372 unmodified lines1561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891902 unmodified lines19319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223312 unmodified lines2462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942959 unmodified lines30530630730830931031131231331431531631731831932032132232332432532632732832933010 unmodified linesdescription:<|"|>{{ value['description'] }}<|"|>{%- set add_comma = true -%}{%- endif -%}{%- if value['type'] | upper == 'STRING' -%}{%- if value['enum'] -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}enum:{{ format_argument(value['enum']) }}{%- endif -%}{%- elif value['type'] | upper == 'ARRAY' -%}{%- if value['items'] is mapping and value['items'] -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}items:{{%- set ns_items = namespace(found_first=false) -%}{%- for item_key, item_value in value['items'] | dictsort -%}{%- if item_value is not none -%}26 unmodified lines}{%- endif -%}{%- endif -%}{%- if value['nullable'] %}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}nullable:true{%- endif -%}{%- if value['type'] | upper == 'OBJECT' -%}{%- if value['properties'] is defined and value['properties'] is mapping -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}properties:{{{- format_parameters(value['properties'], value['required'] | default([])) -}}}{%- elif value is mapping -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}properties:{{{- format_parameters(value, value['required'] | default([])) -}}}{%- endif -%}{%- if value['required'] -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}required:[{%- for item in value['required'] | default([]) -%}<|"|>{{- item -}}<|"|>{%- if not loop.last %},{% endif -%}{%- endfor -%}]{%- endif -%}{%- endif -%}{%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}type:<|"|>{{ value['type'] | upper }}<|"|>}{%- endif -%}72 unmodified lines{%- endfor -%}{{- ns.result | trim -}}{%- endmacro -%}{%- macro format_tool_response_block(tool_name, response) -%}{{- '<|tool_response>' -}}{%- if response is mapping -%}{{- 'response:' + tool_name + '{' -}}{%- for key, value in response | dictsort -%}{{- key -}}:{{- format_argument(value, escape_keys=False) -}}{%- if not loop.last %},{% endif -%}{%- endfor -%}{{- '}' -}}{%- else -%}{{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}{%- endif -%}{{- '<tool_response|>' -}}{%- endmacro -%}{%- set ns = namespace(prev_message_type=None) -%}{%- set loop_messages = messages -%}{{- bos_token -}}{#- Handle System/Tool Definitions Block -#}{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}{{- '<|turn>system\n' -}}{#- Inject Thinking token at the very top of the FIRST system turn -#}{%- if enable_thinking is defined and enable_thinking -%}{{- '<|think|>\n' -}}{%- set ns.prev_message_type = 'think' -%}{%- endif -%}{%- if messages[0]['role'] in ['system', 'developer'] -%}{{- messages[0]['content'] | trim -}}{%- set loop_messages = messages[1:] -%}{%- endif -%}{%- if tools -%}{%- for tool in tools %}{{- '<|tool>' -}}2 unmodified lines{%- endfor %}{%- set ns.prev_message_type = 'tool' -%}{%- endif -%}{{- '<turn|>\n' -}}{%- endif %}{#- Pre-scan: find last user message index for reasoning guard -#}{%- set ns_turn = namespace(last_user_idx=-1) -%}{%- for i in range(loop_messages | length) -%}{%- if loop_messages[i]['role'] == 'user' -%}{%- set ns_turn.last_user_idx = i -%}{%- endif -%}{%- endfor -%}{#- Loop through messages -#}{%- for message in loop_messages -%}{%- if message['role'] != 'tool' -%}{%- set ns.prev_message_type = None -%}{%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}{#- Detect continuation: suppress duplicate <|turn>model when previous non-tool message was also assistant -#}{%- set prev_nt = namespace(role=None, found=false) -%}{%- if loop.index0 > 0 -%}{%- for j in range(loop.index0 - 1, -1, -1) -%}{%- if not prev_nt.found -%}{%- if loop_messages[j]['role'] != 'tool' -%}{%- set prev_nt.role = loop_messages[j]['role'] -%}{%- set prev_nt.found = true -%}{%- endif -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- set continue_same_model_turn = (role == 'model' and prev_nt.role == 'assistant') -%}{%- if not continue_same_model_turn -%}{{- '<|turn>' + role + '\n' }}{%- endif -%}{#- Render reasoning/reasoning_content as thinking channel -#}{%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}{%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}{{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}{%- endif -%}{%- if message['tool_calls'] -%}{%- for tool_call in message['tool_calls'] -%}{%- set function = tool_call['function'] -%}12 unmodified lines{%- endfor -%}{%- set ns.prev_message_type = 'tool_call' -%}{%- endif -%}{%- set ns_tr_out = namespace(flag=false) -%}{%- if message.get('tool_responses') -%}{#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}{%- for tool_response in message['tool_responses'] -%}{{- format_tool_response_block(tool_response['name'] | default('unknown'), tool_response['response']) -}}{%- set ns_tr_out.flag = true -%}{%- set ns.prev_message_type = 'tool_response' -%}{%- endfor -%}{%- elif message.get('tool_calls') -%}{#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}{%- set ns_tool_scan = namespace(stopped=false) -%}{%- for k in range(loop.index0 + 1, loop_messages | length) -%}{%- if ns_tool_scan.stopped -%}{%- elif loop_messages[k]['role'] != 'tool' -%}{%- set ns_tool_scan.stopped = true -%}{%- else -%}{%- set follow = loop_messages[k] -%}{#- Resolve tool_call_id to function name -#}{%- set ns_tname = namespace(name=follow.get('name') | default('unknown')) -%}{%- for tc in message['tool_calls'] -%}{%- if tc.get('id') == follow.get('tool_call_id') -%}{%- set ns_tname.name = tc['function']['name'] -%}{%- endif -%}{%- endfor -%}{#- Handle content as string or content-parts array -#}{%- set tool_body = follow.get('content') -%}{%- if tool_body is string -%}{{- format_tool_response_block(ns_tname.name, tool_body) -}}{%- elif tool_body is sequence and tool_body is not string -%}{%- set ns_txt = namespace(s='') -%}{%- for part in tool_body -%}{%- if part.get('type') == 'text' -%}{%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}{%- endif -%}{%- endfor -%}{{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}{%- else -%}{{- format_tool_response_block(ns_tname.name, tool_body) -}}{%- endif -%}{%- set ns_tr_out.flag = true -%}{%- set ns.prev_message_type = 'tool_response' -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- if message['content'] is string -%}{%- if role == 'model' -%}{{- strip_thinking(message['content']) -}}9 unmodified lines{{- item['text'] | trim -}}{%- endif -%}{%- elif item['type'] == 'image' -%}{{- '<|image|>' -}}{%- set ns.prev_message_type = 'image' -%}{%- elif item['type'] == 'audio' -%}{{- '<|audio|>' -}}{%- set ns.prev_message_type = 'audio' -%}{%- elif item['type'] == 'video' -%}{{- '<|video|>' -}}{%- set ns.prev_message_type = 'video' -%}{%- endif -%}{%- endfor -%}{%- endif -%}{%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}{{- '<|tool_response>' -}}{%- elif not (ns_tr_out.flag and not message.get('content')) -%}{{- '<turn|>\n' -}}{%- endif -%}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}{{- '<|turn>model\n' -}}{%- endif -%}{%- endif -%}
chat_template.jinja+118-51