Image-Text-to-Text
Safetensors
GGUF
Portuguese
English
gemma4
code
vision
multimodal
software-engineering
react-native
android
typescript
python
unsloth
conversational
Instructions to use SpaceGhost/SpaceCode-E2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use SpaceGhost/SpaceCode-E2B with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M # Run inference directly in the terminal: llama cli -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M # Run inference directly in the terminal: llama cli -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Use Docker
docker model run hf.co/SpaceGhost/SpaceCode-E2B:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use SpaceGhost/SpaceCode-E2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SpaceGhost/SpaceCode-E2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SpaceGhost/SpaceCode-E2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/SpaceGhost/SpaceCode-E2B:Q4_K_M
- Ollama
How to use SpaceGhost/SpaceCode-E2B with Ollama:
ollama run hf.co/SpaceGhost/SpaceCode-E2B:Q4_K_M
- Unsloth Desktop
- Pi
How to use SpaceGhost/SpaceCode-E2B with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "SpaceGhost/SpaceCode-E2B:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use SpaceGhost/SpaceCode-E2B with Docker Model Runner:
docker model run hf.co/SpaceGhost/SpaceCode-E2B:Q4_K_M
- Lemonade
How to use SpaceGhost/SpaceCode-E2B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull SpaceGhost/SpaceCode-E2B:Q4_K_M
Run and chat with the model
lemonade run user.SpaceCode-E2B-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use SpaceGhost/SpaceCode-E2B with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default SpaceGhost/SpaceCode-E2B:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use SpaceGhost/SpaceCode-E2B with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SpaceGhost/SpaceCode-E2B:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "SpaceGhost/SpaceCode-E2B:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
release(v12): official merged 16-bit safetensors release of SpaceCode-E2B V12
Browse files- MERGED_V12_MANIFEST.json +49 -0
- Modelfile +12 -11
- README.md +138 -72
- chat_template.jinja +12 -11
- config.json +7 -37
- generation_config.json +1 -2
- Q4_K_M.gguf → model-00001-of-00003.safetensors +2 -2
- mmproj-F16.gguf → model-00002-of-00003.safetensors +2 -2
- model.safetensors → model-00003-of-00003.safetensors +2 -2
- model.safetensors.index.json +0 -0
- tokenizer.json +2 -2
- tokenizer_config.json +50 -205
MERGED_V12_MANIFEST.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": "v12",
|
| 3 |
+
"base_model": "google/gemma-4-E2B-it",
|
| 4 |
+
"adapter_source": "SpaceCode-E2B V12 Checkpoint 345 (9e250264e93278b65c14d98e27c9631fe293734a04ed7e27140f417fb1396361)",
|
| 5 |
+
"timestamp": "2026-11-01 00:16:35",
|
| 6 |
+
"total_size_bytes": 10242069243,
|
| 7 |
+
"files": {
|
| 8 |
+
"chat_template.jinja": {
|
| 9 |
+
"size_bytes": 18569,
|
| 10 |
+
"sha256": "0a2c8073c878ab1da004bee933a998606537bbb62016310352c7285c3f01c5b5"
|
| 11 |
+
},
|
| 12 |
+
"config.json": {
|
| 13 |
+
"size_bytes": 4644,
|
| 14 |
+
"sha256": "d9b2c908acf92ad058febae730771e1e3c85af051a63bf751dacb5b433ceee6c"
|
| 15 |
+
},
|
| 16 |
+
"generation_config.json": {
|
| 17 |
+
"size_bytes": 204,
|
| 18 |
+
"sha256": "2a143a0b852e68ee1ae1880f4ab4e4afea2bb3fcffb68a3cee4ef547182bc2e0"
|
| 19 |
+
},
|
| 20 |
+
"model-00001-of-00003.safetensors": {
|
| 21 |
+
"size_bytes": 1422278032,
|
| 22 |
+
"sha256": "67a2f4a7761f373975f639a83a97b6044353f4c682f8605776582377adfe55ad"
|
| 23 |
+
},
|
| 24 |
+
"model-00002-of-00003.safetensors": {
|
| 25 |
+
"size_bytes": 4987173642,
|
| 26 |
+
"sha256": "882030dc73cb8418a55a7e0b58ab6c81677330c19bb94518ea0a770542798057"
|
| 27 |
+
},
|
| 28 |
+
"model-00003-of-00003.safetensors": {
|
| 29 |
+
"size_bytes": 3800219068,
|
| 30 |
+
"sha256": "ec074aac9b6bca91363560f8e719c7476491b7db8660ec9a3535aea261d840d0"
|
| 31 |
+
},
|
| 32 |
+
"model.safetensors.index.json": {
|
| 33 |
+
"size_bytes": 200040,
|
| 34 |
+
"sha256": "4845b88fe98a87e97d3217b4c65c722951227eb6904a353022ae23f4fec3ebbb"
|
| 35 |
+
},
|
| 36 |
+
"processor_config.json": {
|
| 37 |
+
"size_bytes": 1689,
|
| 38 |
+
"sha256": "32bdf45d2ad4cc29a0822ddd157a182de76644f0419a6228d151495256e9813c"
|
| 39 |
+
},
|
| 40 |
+
"tokenizer.json": {
|
| 41 |
+
"size_bytes": 32169626,
|
| 42 |
+
"sha256": "cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f"
|
| 43 |
+
},
|
| 44 |
+
"tokenizer_config.json": {
|
| 45 |
+
"size_bytes": 3729,
|
| 46 |
+
"sha256": "3ab5c7b94dc97d65ca7064496fa69b88ff875378e1cb7ee3e43070c3a8170999"
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
Modelfile
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
PARAMETER stop "<bos>"
|
|
|
|
| 1 |
+
# Modelfile oficial para SpaceCode-E2B V12 (Ollama)
|
| 2 |
+
FROM ./SpaceCode-E2B-V12-Q4_K_M.gguf
|
| 3 |
|
| 4 |
+
PARAMETER temperature 0.0
|
| 5 |
+
PARAMETER stop "<end_of_turn>"
|
| 6 |
+
PARAMETER stop "<eos>"
|
| 7 |
+
PARAMETER stop "<start_of_turn>"
|
| 8 |
|
| 9 |
+
TEMPLATE """<start_of_turn>user
|
| 10 |
+
{{ .Prompt }}<end_of_turn>
|
| 11 |
+
<start_of_turn>model
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
SYSTEM """Você é o SpaceCode-E2B, assistente especializado em Engenharia de Software, Desenvolvimento Web/Mobile e Tutoria Técnica."""
|
|
|
README.md
CHANGED
|
@@ -1,135 +1,201 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
| 3 |
base_model:
|
| 4 |
- google/gemma-4-E2B-it
|
| 5 |
tags:
|
| 6 |
- code
|
| 7 |
- vision
|
| 8 |
- multimodal
|
| 9 |
-
-
|
| 10 |
-
- llama.cpp
|
| 11 |
-
- ollama
|
| 12 |
-
- unsloth
|
| 13 |
- software-engineering
|
| 14 |
- react-native
|
| 15 |
- android
|
| 16 |
-
- expo
|
| 17 |
- typescript
|
| 18 |
- python
|
|
|
|
| 19 |
language:
|
| 20 |
- pt
|
| 21 |
- en
|
| 22 |
pipeline_tag: image-text-to-text
|
| 23 |
---
|
| 24 |
|
| 25 |
-
# 🚀 SpaceCode-E2B (
|
| 26 |
|
| 27 |
-
**SpaceCode-E2B** é um modelo compacto de Engenharia de Software e Tutoria
|
| 28 |
|
| 29 |
-
> **
|
| 30 |
-
> **
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
-
##
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
| **Tema 4** | Persistência Local (AsyncStorage, SQLite, Realm, MongoDB) | **8/8 (100.0%)** | **Perfeito** |
|
| 43 |
-
| **Tema 5** | Conexão Remota (Fetch, Axios, OAuth2, Offline-First) | **7/8 (87.5%)** | Aprovado |
|
| 44 |
-
| **Tema 6** | Arquitetura MVC/DAO, Flux vs Redux, AES/CryptoJS, Jest, Google Play | **7/8 (87.5%)** | Aprovado |
|
| 45 |
-
| **Tema 7** | Desafios Integrados e Casos de Arquitetura | **10/10 (100.0%)** | **Perfeito** |
|
| 46 |
-
| **TOTAL GERAL** | **50 Questões Fechadas de Múltipla Escolha** | **44/50 (88.0%)** | **Homologado** |
|
| 47 |
|
| 48 |
---
|
| 49 |
|
| 50 |
-
##
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
| 62 |
---
|
| 63 |
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
|
| 67 |
-
O repositório já inclui o `Modelfile` pré-configurado com ligação nativa ao `mmproj-F16.gguf`:
|
| 68 |
-
```bash
|
| 69 |
-
# Baixar arquivos e registrar o modelo no Ollama:
|
| 70 |
-
ollama create spacecode -f Modelfile
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
```bash
|
| 78 |
-
|
| 79 |
-
llama-cli -m Q4_K_M.gguf --mmproj mmproj-F16.gguf --image /caminho/para/imagem.png -p "<|turn>user\nExplique o problema nesta UI e mostre o código React Native correto.<turn|>\n<|turn>model\n"
|
| 80 |
```
|
| 81 |
|
| 82 |
-
###
|
| 83 |
```python
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
|
| 86 |
MODEL_ID = "SpaceGhost/SpaceCode-E2B"
|
| 87 |
|
| 88 |
-
# Carregar processador e modelo
|
| 89 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
| 90 |
-
model =
|
| 91 |
MODEL_ID,
|
| 92 |
-
torch_dtype=
|
| 93 |
device_map="auto"
|
| 94 |
)
|
| 95 |
|
| 96 |
-
#
|
| 97 |
-
|
| 98 |
{
|
| 99 |
"role": "user",
|
| 100 |
-
"content":
|
| 101 |
-
{"type": "image", "url": "https://example.com/screenshot.png"},
|
| 102 |
-
{"type": "text", "text": "Analise a tela e crie o componente React Native correspondente."}
|
| 103 |
-
]
|
| 104 |
}
|
| 105 |
]
|
| 106 |
|
| 107 |
-
inputs = processor
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
-
response = processor.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
|
| 117 |
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
```
|
| 119 |
|
|
|
|
|
|
|
| 120 |
---
|
| 121 |
|
| 122 |
-
##
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
- Geração de patches em *Unified Diff* e código corretivo com restauração visual comprovada.
|
| 130 |
|
| 131 |
---
|
| 132 |
|
| 133 |
-
##
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: gemma-terms-of-use
|
| 4 |
+
license_link: https://ai.google.dev/gemma/terms
|
| 5 |
base_model:
|
| 6 |
- google/gemma-4-E2B-it
|
| 7 |
tags:
|
| 8 |
- code
|
| 9 |
- vision
|
| 10 |
- multimodal
|
| 11 |
+
- gemma4
|
|
|
|
|
|
|
|
|
|
| 12 |
- software-engineering
|
| 13 |
- react-native
|
| 14 |
- android
|
|
|
|
| 15 |
- typescript
|
| 16 |
- python
|
| 17 |
+
- unsloth
|
| 18 |
language:
|
| 19 |
- pt
|
| 20 |
- en
|
| 21 |
pipeline_tag: image-text-to-text
|
| 22 |
---
|
| 23 |
|
| 24 |
+
# 🚀 SpaceCode-E2B (Versão Oficial V12 — Merged 16-bit)
|
| 25 |
|
| 26 |
+
**SpaceCode-E2B** é um modelo compacto e multimodal de alta precisão especializado em **Engenharia de Software, Desenvolvimento Mobile/Web (React Native, TypeScript, Python 3.12, Android) e Tutoria Acadêmica**, construído sobre a arquitetura **Google Gemma 4 E2B (`google/gemma-4-E2B-it`)** pela **SpaceGhost**.
|
| 27 |
|
| 28 |
+
> **Versão Oficial Atual:** `V12` (Release Tag: `v12`)
|
| 29 |
+
> **Formato de Distribuição:** Modelo completo fundido (*Merged 16-bit bfloat16 Safetensors*)
|
| 30 |
+
> **Modelo-Base:** `google/gemma-4-E2B-it` (Gemma4ForConditionalGeneration)
|
| 31 |
+
> **Adapter Homologado:** SpaceCode-E2B V12 Checkpoint 345 (`9e250264e93278b65c14d98e27c9631fe293734a04ed7e27140f417fb1396361`)
|
| 32 |
+
> **Status de Homologação:** ✅ **APROVADO E HOMOLOGADO PELO SOFTWARE ARCHITECT**
|
| 33 |
|
| 34 |
---
|
| 35 |
|
| 36 |
+
## 📌 1. Visão Geral e Arquitetura
|
| 37 |
|
| 38 |
+
O SpaceCode-E2B V12 unifica as capacidades multimodais de visão e raciocínio técnico do Gemma 4 E2B com especialização rigorosa em código fortemente tipado, padrões arquiteturais modernos, tutoria socrática e mitigação sistemática de alucinações técnicas.
|
| 39 |
|
| 40 |
+
- **Arquitetura Base:** `Gemma4ForConditionalGeneration` (2.3B parâmetros de linguagem + Vision Tower SigLIP).
|
| 41 |
+
- **Precisão Numérica dos Pesos:** Bfloat16 (16-bit) completo, sem quantização destrutiva na exportação merged.
|
| 42 |
+
- **Tamanho Total em Disco:** 9,54 GiB (10.242.069.243 bytes distribuídos em 3 shards Safetensors).
|
| 43 |
+
- **Janela de Contexto Suportada:** 1.536 tokens nominais certificados no treinamento (expansível até 16.384 tokens pelo mecanismo de atenção nativo do Gemma 4).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
+
## 🛠️ 2. Informações do Treinamento e Fine-Tuning
|
| 48 |
|
| 49 |
+
- **Corpus de Treinamento:** V12 Sequence Gate (1.379 amostras ativas selecionadas com mascaramento estrito de prompt de sistema e labels pedagógicos).
|
| 50 |
+
- **Estratégia de Adaptação:** QLoRA SFT de alta fidelidade via Unsloth.
|
| 51 |
+
- Rank ($r$): 16
|
| 52 |
+
- Alpha ($\alpha$): 16
|
| 53 |
+
- Dropout: 0.05
|
| 54 |
+
- Target Modules: Camadas de projeção de atenção e MLP do modelo de linguagem (`q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`).
|
| 55 |
+
- **Duração do Treinamento:** Exatamente 1 época experimental (345 passos do otimizador AdamW, com gradiente acumulado em 4 micro-lotes e último passo normalizado estritamente por 3.0 amostras).
|
| 56 |
+
- **Curva de Taxa de Aprendizado:** Cosine schedule com 10 passos de warmup ($2 \times 10^{-4} \to 2 \times 10^{-5}$).
|
| 57 |
+
- **Progressão de Perda (Loss):** Redução de 1,0356 (Passo 1) para 0,3568 (Passo 345), correspondendo a -65,55% de otimização.
|
| 58 |
|
| 59 |
---
|
| 60 |
|
| 61 |
+
## 📊 3. Resultados da Avaliação Multimodal MMMU (TASK-0016)
|
| 62 |
|
| 63 |
+
Avaliação pareada e determinística (`temperature = 0.0`, `do_sample = False`) realizada sobre **100 questões oficiais do split de validação do benchmark MMMU (standard)**, distribuídas equitativamente entre 10 disciplinas acadêmicas (10 questões por disciplina):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
| Disciplina Acadêmica | Grande Domínio | Gemma 4 E2B Original | SpaceCode-E2B V12 | Delta (p.p.) | Classificação |
|
| 66 |
+
| :--- | :--- | :---: | :---: | :---: | :--- |
|
| 67 |
+
| **Computer Science** | Tech & Engineering | 2/10 (20.0%) | **3/10 (30.0%)** | **+10.0%** | **SUPERIOR** |
|
| 68 |
+
| **Electronics** | Tech & Engineering | 0/10 (0.0%) | **3/10 (30.0%)** | **+30.0%** | **SUPERIOR** |
|
| 69 |
+
| **Mechanical Engineering** | Tech & Engineering | 0/10 (0.0%) | **1/10 (10.0%)** | **+10.0%** | **SUPERIOR** |
|
| 70 |
+
| **Math** | Science | 1/10 (10.0%) | **3/10 (30.0%)** | **+20.0%** | **SUPERIOR** |
|
| 71 |
+
| **Biology** | Science | 2/10 (20.0%) | **4/10 (40.0%)** | **+20.0%** | **SUPERIOR** |
|
| 72 |
+
| **Chemistry** | Science | 1/10 (10.0%) | **2/10 (20.0%)** | **+10.0%** | **SUPERIOR** |
|
| 73 |
+
| **Basic Medical Science** | Health & Medicine | 2/10 (20.0%) | **5/10 (50.0%)** | **+30.0%** | **SUPERIOR** |
|
| 74 |
+
| **Economics** | Business | 2/10 (20.0%) | **5/10 (50.0%)** | **+30.0%** | **SUPERIOR** |
|
| 75 |
+
| **Psychology** | Humanities & Social | 3/10 (30.0%) | 2/10 (20.0%) | -10.0% | Inferior |
|
| 76 |
+
| **Art Theory** | Art & Design | 7/10 (70.0%) | 5/10 (50.0%) | -20.0% | Inferior |
|
| 77 |
+
| **TOTAL GERAL (100 itens)** | **6 Áreas do Conhecimento** | **20/100 (20.0%)** | **33/100 (33.0%)** | **+13.0 p.p.** | **V12 SUPERIOR** |
|
| 78 |
+
|
| 79 |
+
> **Nota Metodológica Obrigatória:** A bateria acima constitui uma amostra experimental controlada de 100 questões do split de validação do MMMU padrão e **não equivale nem substitui a pontuação do benchmark completo ou do MMMU-Pro** (cujo valor oficial publicado pelo Google para o Gemma 4 E2B completo é de 44,2%).
|
| 80 |
+
|
| 81 |
+
### Análise Estatística e Qualitativa:
|
| 82 |
+
- **Teste de Contingência McNemar:** $\chi^2 = 5,7600$ ($p = 0,0164$, ganho estatisticamente significativo com $p < 0,05$).
|
| 83 |
+
- **Redução Drástica de Evasão:** O modelo original gerou **52 respostas não interpretáveis (UNPARSED)** por esgotamento de tokens em dissertações reflexivas, enquanto o SpaceCode V12 reduziu esse número para apenas **14 UNPARSED** (-73,08% de respostas inválidas), respondendo de forma concisa e estruturada.
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## 🧪 4. Resultados da Avaliação Funcional Independente (TASK-0015)
|
| 88 |
+
|
| 89 |
+
O SpaceCode-E2B V12 demonstrou conformidade integral nos testes formais pós-treinamento:
|
| 90 |
+
1. **Engenharia de Software (Python 3.12 / Concorrência):** Geração idiomática com `asyncio.TaskGroup`, type hints completos e tratamento gracioso de cancelamento sob exceções.
|
| 91 |
+
2. **Conhecimento Conceitual (Teorema CAP):** Síntese precisa dos trade-offs de consistência, disponibilidade e particionamento em bancos de dados distribuídos.
|
| 92 |
+
3. **Tutoria Acadêmica (Escopo Léxico e Closure em JS):** Explicação didática clara estruturada em torno de um contador funcional sem jargões desnecessários.
|
| 93 |
+
4. **Extração e Formatação Estrita:** Extração precisa de logs em formato JSON puro (`status_code`, `endpoint`, `horario`) sem ruído antes ou depois.
|
| 94 |
+
5. **Anti-Alucinação Crítica (Sonda T04):** Recusa categórica e determinística a APIs inexistentes (rejeitando o hook fictício `useLifecycle()` no React Native e instruindo o usuário sobre métodos reais do ciclo de vida e `useEffect`).
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
## ⚠️ 5. Limitações Conhecidas
|
| 99 |
+
|
| 100 |
+
- **Execução em GPU de 8 GB de VRAM:** A viabilidade e a estabilidade de inferência em GPUs de consumo de 8 GB de VRAM **ainda não foi formalmente validada pela Arquitetura**. Embora a estimativa matemática aponte viabilidade sob quantização 4-bit, a homologação oficial para essa classe de hardware ocorrerá em etapa posterior.
|
| 101 |
+
- **Domínio Multimodal:** O modelo especializou predominantemente a geração de código, tutoria e interfaces móveis/web. Domínios visuais altamente abstratos (como Teoria da Arte pura) preservam as respostas herdadas da base ou podem apresentar variações estilísticas.
|
| 102 |
|
| 103 |
+
---
|
| 104 |
+
|
| 105 |
+
## 💻 6. Como Usar (Inferência com Hugging Face Transformers)
|
| 106 |
+
|
| 107 |
+
### Instalação das Dependências:
|
| 108 |
```bash
|
| 109 |
+
pip install -q transformers accelerate safetensors torch pillow torchvision
|
|
|
|
| 110 |
```
|
| 111 |
|
| 112 |
+
### Exemplo em Python (Texto e Visão Multimodal):
|
| 113 |
```python
|
| 114 |
+
import torch
|
| 115 |
+
from transformers import AutoProcessor, Gemma4ForConditionalGeneration
|
| 116 |
+
from PIL import Image
|
| 117 |
|
| 118 |
MODEL_ID = "SpaceGhost/SpaceCode-E2B"
|
| 119 |
|
| 120 |
+
# Carregar processador e modelo completo merged em bfloat16
|
| 121 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
| 122 |
+
model = Gemma4ForConditionalGeneration.from_pretrained(
|
| 123 |
MODEL_ID,
|
| 124 |
+
torch_dtype=torch.bfloat16,
|
| 125 |
device_map="auto"
|
| 126 |
)
|
| 127 |
|
| 128 |
+
# 1. Prompt de Código / Engenharia de Software:
|
| 129 |
+
prompt_code = [
|
| 130 |
{
|
| 131 |
"role": "user",
|
| 132 |
+
"content": "Como implementar um hook customizado em React Native com TypeScript para gerenciar conexões WebSocket com reconexão automática e limpeza de memória?"
|
|
|
|
|
|
|
|
|
|
| 133 |
}
|
| 134 |
]
|
| 135 |
|
| 136 |
+
inputs = processor(
|
| 137 |
+
text=processor.apply_chat_template(prompt_code, tokenize=False, add_generation_prompt=True),
|
| 138 |
+
return_tensors="pt"
|
| 139 |
+
).to("cuda")
|
| 140 |
+
|
| 141 |
+
with torch.no_grad():
|
| 142 |
+
outputs = model.generate(**inputs, max_new_tokens=400, do_sample=False)
|
| 143 |
|
| 144 |
+
response = processor.tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
|
|
|
| 145 |
print(response)
|
| 146 |
+
|
| 147 |
+
# 2. Prompt Multimodal (com Imagem de Interface UI):
|
| 148 |
+
# img = Image.open("tela_aplicativo.png").convert("RGB")
|
| 149 |
+
# msgs = [
|
| 150 |
+
# {
|
| 151 |
+
# "role": "user",
|
| 152 |
+
# "content": [
|
| 153 |
+
# {"type": "image"},
|
| 154 |
+
# {"type": "text", "text": "Analise esta tela móvel e forneça os componentes React Native correspondentes."}
|
| 155 |
+
# ]
|
| 156 |
+
# }
|
| 157 |
+
# ]
|
| 158 |
+
# inp_multi = processor(text=processor.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True), images=[img], return_tensors="pt").to("cuda")
|
| 159 |
+
# out_multi = model.generate(**inp_multi, max_new_tokens=300, do_sample=False)
|
| 160 |
+
# print(processor.tokenizer.decode(out_multi[0][inp_multi.input_ids.shape[1]:], skip_special_tokens=True))
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
### Execução Local com Ollama (GGUF):
|
| 164 |
+
|
| 165 |
+
O modelo conta com versões quantizadas oficiais GGUF disponibilizadas no diretório `gguf/`:
|
| 166 |
+
- `SpaceCode-E2B-V12-Q8_0.gguf` (4,61 GiB — Alta Precisão de Referência)
|
| 167 |
+
- `SpaceCode-E2B-V12-Q4_K_M.gguf` (3,18 GiB — Execução Otimizada para Recursos Limitados)
|
| 168 |
+
|
| 169 |
+
#### Como Criar e Rodar no Ollama:
|
| 170 |
+
```bash
|
| 171 |
+
# 1. Baixar o arquivo Modelfile e o binário GGUF Q4_K_M
|
| 172 |
+
huggingface-cli download SpaceGhost/SpaceCode-E2B Modelfile --local-dir .
|
| 173 |
+
huggingface-cli download SpaceGhost/SpaceCode-E2B gguf/SpaceCode-E2B-V12-Q4_K_M.gguf --local-dir .
|
| 174 |
+
|
| 175 |
+
# 2. Criar o modelo localmente no Ollama
|
| 176 |
+
ollama create spacecode-e2b -f Modelfile
|
| 177 |
+
|
| 178 |
+
# 3. Executar o modelo no terminal
|
| 179 |
+
ollama run spacecode-e2b
|
| 180 |
```
|
| 181 |
|
| 182 |
+
> **Nota sobre Multimodalidade no Ollama:** O suporte a imagens em GGUF no ecossistema Ollama/llama.cpp para a arquitetura Gemma 4 depende da integração completa do projetor visual `mtmd/gemma4v`. Para inferência multimodal integral com visão ativa (texto + imagem), utilize a biblioteca oficial `transformers` com os pesos Safetensors bfloat16 conforme demonstrado acima.
|
| 183 |
+
|
| 184 |
---
|
| 185 |
|
| 186 |
+
## 📜 7. Histórico de Versões e Governança
|
| 187 |
|
| 188 |
+
| Versão | Tag da Release | Formato | Status | Destaques |
|
| 189 |
+
| :---: | :---: | :---: | :---: | :--- |
|
| 190 |
+
| **V12** | `v12` | **Merged 16-bit Safetensors** | **Atual Oficial** | Merge integral da base Gemma 4 E2B com LoRA V12. +13 p.p. no MMMU, 1.536 tokens, anti-alucinação T04. |
|
| 191 |
+
| **V11** | `v11` | Adapter LoRA (`specialization-task-0011`) | Homologado Baseline | Baseline imutável preservada (SHA-256: `cb58fbb0...`). |
|
| 192 |
+
| **V2** | `v2` | Merged 16-bit / GGUF | Histórico | Release inicial baseada na ementa Android/React Native (88% acurácia). |
|
|
|
|
| 193 |
|
| 194 |
---
|
| 195 |
|
| 196 |
+
## ⚖️ 8. Licença e Atribuições
|
| 197 |
+
|
| 198 |
+
Este modelo baseia-se no **Google Gemma 4 E2B** e é disponibilizado em estrita conformidade com os termos da [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
|
| 199 |
|
| 200 |
+
*Gemma is a trademark of Google LLC.*
|
| 201 |
+
*Desenvolvido e mantido pela equipe de Engenharia de Machine Learning da **SpaceGhost**.*
|
chat_template.jinja
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{%- macro format_parameters(properties, required, filter_keys=false) -%}
|
| 2 |
{%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
|
| 3 |
{%- set ns = namespace(found_first=false) -%}
|
|
@@ -247,17 +253,12 @@
|
|
| 247 |
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 248 |
{%- endfor -%}
|
| 249 |
{%- elif function['arguments'] is none -%}
|
| 250 |
-
{%-
|
| 251 |
-
{
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
{%- if argstr[:1] == '{' and argstr[-1:] == '}' -%}
|
| 257 |
-
{{- argstr[1:-1] -}}
|
| 258 |
-
{%- else -%}
|
| 259 |
-
{{- function['arguments'] -}}
|
| 260 |
-
{%- endif -%}
|
| 261 |
{%- endif -%}
|
| 262 |
{{- '}<tool_call|>' -}}
|
| 263 |
{%- endfor -%}
|
|
|
|
| 1 |
+
{#
|
| 2 |
+
Template: Google Gemma 4 Canonical Chat Template
|
| 3 |
+
Author: Google Gemma Engineering Team
|
| 4 |
+
Published: 2026-07-09
|
| 5 |
+
Context: Fixed tool-calling loops, turn closures, and thinking content-ordering.
|
| 6 |
+
#}
|
| 7 |
{%- macro format_parameters(properties, required, filter_keys=false) -%}
|
| 8 |
{%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
|
| 9 |
{%- set ns = namespace(found_first=false) -%}
|
|
|
|
| 253 |
{{- key -}}:{{- format_argument(value, escape_keys=False) -}}
|
| 254 |
{%- endfor -%}
|
| 255 |
{%- elif function['arguments'] is none -%}
|
| 256 |
+
{%- else -%}
|
| 257 |
+
{{- raise_exception(
|
| 258 |
+
"chat_template: tool_calls[].function.arguments must be a "
|
| 259 |
+
"JSON object (mapping), not a string. Deserialize arguments "
|
| 260 |
+
"before passing to the template."
|
| 261 |
+
) -}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
{%- endif -%}
|
| 263 |
{{- '}<tool_call|>' -}}
|
| 264 |
{%- endfor -%}
|
config.json
CHANGED
|
@@ -3,38 +3,22 @@
|
|
| 3 |
"Gemma4ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"audio_config": {
|
| 6 |
-
"_name_or_path": "",
|
| 7 |
-
"architectures": null,
|
| 8 |
"attention_chunk_size": 12,
|
| 9 |
"attention_context_left": 13,
|
| 10 |
"attention_context_right": 0,
|
| 11 |
"attention_invalid_logits_value": -1000000000.0,
|
| 12 |
"attention_logit_cap": 50.0,
|
| 13 |
-
"chunk_size_feed_forward": 0,
|
| 14 |
"conv_kernel_size": 5,
|
| 15 |
-
"
|
| 16 |
"gradient_clipping": 10000000000.0,
|
| 17 |
"hidden_act": "silu",
|
| 18 |
"hidden_size": 1024,
|
| 19 |
-
"id2label": {
|
| 20 |
-
"0": "LABEL_0",
|
| 21 |
-
"1": "LABEL_1"
|
| 22 |
-
},
|
| 23 |
"initializer_range": 0.02,
|
| 24 |
-
"is_encoder_decoder": false,
|
| 25 |
-
"label2id": {
|
| 26 |
-
"LABEL_0": 0,
|
| 27 |
-
"LABEL_1": 1
|
| 28 |
-
},
|
| 29 |
"model_type": "gemma4_audio",
|
| 30 |
"num_attention_heads": 8,
|
| 31 |
"num_hidden_layers": 12,
|
| 32 |
-
"output_attentions": false,
|
| 33 |
-
"output_hidden_states": false,
|
| 34 |
"output_proj_dims": 1536,
|
| 35 |
-
"problem_type": null,
|
| 36 |
"residual_weight": 0.5,
|
| 37 |
-
"return_dict": true,
|
| 38 |
"rms_norm_eps": 1e-06,
|
| 39 |
"subsampling_conv_channels": [
|
| 40 |
128,
|
|
@@ -45,13 +29,14 @@
|
|
| 45 |
"audio_token_id": 258881,
|
| 46 |
"boa_token_id": 256000,
|
| 47 |
"boi_token_id": 255999,
|
| 48 |
-
"
|
| 49 |
"eoa_token_id": 258883,
|
| 50 |
"eoa_token_index": 258883,
|
| 51 |
"eoi_token_id": 258882,
|
| 52 |
"eos_token_id": 106,
|
| 53 |
"image_token_id": 258880,
|
| 54 |
"initializer_range": 0.02,
|
|
|
|
| 55 |
"model_type": "gemma4",
|
| 56 |
"pad_token_id": 0,
|
| 57 |
"text_config": {
|
|
@@ -59,7 +44,7 @@
|
|
| 59 |
"attention_dropout": 0.0,
|
| 60 |
"attention_k_eq_v": false,
|
| 61 |
"bos_token_id": 2,
|
| 62 |
-
"
|
| 63 |
"enable_moe_block": false,
|
| 64 |
"eos_token_id": 1,
|
| 65 |
"expert_intermediate_size": null,
|
|
@@ -161,44 +146,29 @@
|
|
| 161 |
"vocab_size_per_layer_input": 262144
|
| 162 |
},
|
| 163 |
"tie_word_embeddings": true,
|
| 164 |
-
"transformers_version": "5.
|
| 165 |
"unsloth_fixed": true,
|
|
|
|
| 166 |
"video_token_id": 258884,
|
| 167 |
"vision_config": {
|
| 168 |
-
"_name_or_path": "",
|
| 169 |
-
"architectures": null,
|
| 170 |
"attention_bias": false,
|
| 171 |
"attention_dropout": 0.0,
|
| 172 |
-
"chunk_size_feed_forward": 0,
|
| 173 |
"default_output_length": 280,
|
| 174 |
-
"
|
| 175 |
"global_head_dim": 64,
|
| 176 |
"head_dim": 64,
|
| 177 |
"hidden_activation": "gelu_pytorch_tanh",
|
| 178 |
"hidden_size": 768,
|
| 179 |
-
"id2label": {
|
| 180 |
-
"0": "LABEL_0",
|
| 181 |
-
"1": "LABEL_1"
|
| 182 |
-
},
|
| 183 |
"initializer_range": 0.02,
|
| 184 |
"intermediate_size": 3072,
|
| 185 |
-
"is_encoder_decoder": false,
|
| 186 |
-
"label2id": {
|
| 187 |
-
"LABEL_0": 0,
|
| 188 |
-
"LABEL_1": 1
|
| 189 |
-
},
|
| 190 |
"max_position_embeddings": 131072,
|
| 191 |
"model_type": "gemma4_vision",
|
| 192 |
"num_attention_heads": 12,
|
| 193 |
"num_hidden_layers": 16,
|
| 194 |
"num_key_value_heads": 12,
|
| 195 |
-
"output_attentions": false,
|
| 196 |
-
"output_hidden_states": false,
|
| 197 |
"patch_size": 16,
|
| 198 |
"pooling_kernel_size": 3,
|
| 199 |
"position_embedding_size": 10240,
|
| 200 |
-
"problem_type": null,
|
| 201 |
-
"return_dict": true,
|
| 202 |
"rms_norm_eps": 1e-06,
|
| 203 |
"rope_parameters": {
|
| 204 |
"rope_theta": 100.0,
|
|
|
|
| 3 |
"Gemma4ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"audio_config": {
|
|
|
|
|
|
|
| 6 |
"attention_chunk_size": 12,
|
| 7 |
"attention_context_left": 13,
|
| 8 |
"attention_context_right": 0,
|
| 9 |
"attention_invalid_logits_value": -1000000000.0,
|
| 10 |
"attention_logit_cap": 50.0,
|
|
|
|
| 11 |
"conv_kernel_size": 5,
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
"gradient_clipping": 10000000000.0,
|
| 14 |
"hidden_act": "silu",
|
| 15 |
"hidden_size": 1024,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"initializer_range": 0.02,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
"model_type": "gemma4_audio",
|
| 18 |
"num_attention_heads": 8,
|
| 19 |
"num_hidden_layers": 12,
|
|
|
|
|
|
|
| 20 |
"output_proj_dims": 1536,
|
|
|
|
| 21 |
"residual_weight": 0.5,
|
|
|
|
| 22 |
"rms_norm_eps": 1e-06,
|
| 23 |
"subsampling_conv_channels": [
|
| 24 |
128,
|
|
|
|
| 29 |
"audio_token_id": 258881,
|
| 30 |
"boa_token_id": 256000,
|
| 31 |
"boi_token_id": 255999,
|
| 32 |
+
"dtype": "bfloat16",
|
| 33 |
"eoa_token_id": 258883,
|
| 34 |
"eoa_token_index": 258883,
|
| 35 |
"eoi_token_id": 258882,
|
| 36 |
"eos_token_id": 106,
|
| 37 |
"image_token_id": 258880,
|
| 38 |
"initializer_range": 0.02,
|
| 39 |
+
"model_name": "unsloth/gemma-4-E2B-it",
|
| 40 |
"model_type": "gemma4",
|
| 41 |
"pad_token_id": 0,
|
| 42 |
"text_config": {
|
|
|
|
| 44 |
"attention_dropout": 0.0,
|
| 45 |
"attention_k_eq_v": false,
|
| 46 |
"bos_token_id": 2,
|
| 47 |
+
"dtype": "bfloat16",
|
| 48 |
"enable_moe_block": false,
|
| 49 |
"eos_token_id": 1,
|
| 50 |
"expert_intermediate_size": null,
|
|
|
|
| 146 |
"vocab_size_per_layer_input": 262144
|
| 147 |
},
|
| 148 |
"tie_word_embeddings": true,
|
| 149 |
+
"transformers_version": "5.21.0",
|
| 150 |
"unsloth_fixed": true,
|
| 151 |
+
"unsloth_version": "2026.10.11",
|
| 152 |
"video_token_id": 258884,
|
| 153 |
"vision_config": {
|
|
|
|
|
|
|
| 154 |
"attention_bias": false,
|
| 155 |
"attention_dropout": 0.0,
|
|
|
|
| 156 |
"default_output_length": 280,
|
| 157 |
+
"dtype": "bfloat16",
|
| 158 |
"global_head_dim": 64,
|
| 159 |
"head_dim": 64,
|
| 160 |
"hidden_activation": "gelu_pytorch_tanh",
|
| 161 |
"hidden_size": 768,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
"initializer_range": 0.02,
|
| 163 |
"intermediate_size": 3072,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
"max_position_embeddings": 131072,
|
| 165 |
"model_type": "gemma4_vision",
|
| 166 |
"num_attention_heads": 12,
|
| 167 |
"num_hidden_layers": 16,
|
| 168 |
"num_key_value_heads": 12,
|
|
|
|
|
|
|
| 169 |
"patch_size": 16,
|
| 170 |
"pooling_kernel_size": 3,
|
| 171 |
"position_embedding_size": 10240,
|
|
|
|
|
|
|
| 172 |
"rms_norm_eps": 1e-06,
|
| 173 |
"rope_parameters": {
|
| 174 |
"rope_theta": 100.0,
|
generation_config.json
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
"bos_token_id": 2,
|
| 3 |
"do_sample": true,
|
| 4 |
"eos_token_id": [
|
| 5 |
-
1,
|
| 6 |
1,
|
| 7 |
106,
|
| 8 |
50
|
|
@@ -11,5 +10,5 @@
|
|
| 11 |
"temperature": 1.0,
|
| 12 |
"top_k": 64,
|
| 13 |
"top_p": 0.95,
|
| 14 |
-
"transformers_version": "5.
|
| 15 |
}
|
|
|
|
| 2 |
"bos_token_id": 2,
|
| 3 |
"do_sample": true,
|
| 4 |
"eos_token_id": [
|
|
|
|
| 5 |
1,
|
| 6 |
106,
|
| 7 |
50
|
|
|
|
| 10 |
"temperature": 1.0,
|
| 11 |
"top_k": 64,
|
| 12 |
"top_p": 0.95,
|
| 13 |
+
"transformers_version": "5.21.0"
|
| 14 |
}
|
Q4_K_M.gguf → model-00001-of-00003.safetensors
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67a2f4a7761f373975f639a83a97b6044353f4c682f8605776582377adfe55ad
|
| 3 |
+
size 1422278032
|
mmproj-F16.gguf → model-00002-of-00003.safetensors
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:882030dc73cb8418a55a7e0b58ab6c81677330c19bb94518ea0a770542798057
|
| 3 |
+
size 4987173642
|
model.safetensors → model-00003-of-00003.safetensors
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec074aac9b6bca91363560f8e719c7476491b7db8660ec9a3535aea261d840d0
|
| 3 |
+
size 3800219068
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
|
| 3 |
+
size 32169626
|
tokenizer_config.json
CHANGED
|
@@ -20,8 +20,7 @@
|
|
| 20 |
"is_local": false,
|
| 21 |
"local_files_only": false,
|
| 22 |
"mask_token": "<mask>",
|
| 23 |
-
"
|
| 24 |
-
"model_max_length": 131072,
|
| 25 |
"model_specific_special_tokens": {
|
| 26 |
"audio_token": "<|audio|>",
|
| 27 |
"boa_token": "<|audio>",
|
|
@@ -42,10 +41,8 @@
|
|
| 42 |
"str_token": "<|tool_response>",
|
| 43 |
"think_token": "<|think|>"
|
| 44 |
},
|
| 45 |
-
"pad_to_multiple_of": null,
|
| 46 |
"pad_token": "<pad>",
|
| 47 |
-
"
|
| 48 |
-
"padding_side": "right",
|
| 49 |
"processor_class": "Gemma4Processor",
|
| 50 |
"response_schema": {
|
| 51 |
"properties": {
|
|
@@ -88,210 +85,58 @@
|
|
| 88 |
"type": "object",
|
| 89 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 90 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
"soc_token": "<|channel>",
|
| 92 |
"sot_token": "<|turn>",
|
| 93 |
"stc_token": "<|tool_call>",
|
| 94 |
"std_token": "<|tool>",
|
| 95 |
"str_token": "<|tool_response>",
|
| 96 |
-
"stride": 0,
|
| 97 |
"think_token": "<|think|>",
|
| 98 |
"tokenizer_class": "GemmaTokenizer",
|
| 99 |
-
"
|
| 100 |
-
|
| 101 |
-
"unk_token": "<unk>",
|
| 102 |
-
"added_tokens_decoder": {
|
| 103 |
-
"0": {
|
| 104 |
-
"content": "<pad>",
|
| 105 |
-
"single_word": false,
|
| 106 |
-
"lstrip": false,
|
| 107 |
-
"rstrip": false,
|
| 108 |
-
"normalized": false,
|
| 109 |
-
"special": true
|
| 110 |
-
},
|
| 111 |
-
"1": {
|
| 112 |
-
"content": "<eos>",
|
| 113 |
-
"single_word": false,
|
| 114 |
-
"lstrip": false,
|
| 115 |
-
"rstrip": false,
|
| 116 |
-
"normalized": false,
|
| 117 |
-
"special": true
|
| 118 |
-
},
|
| 119 |
-
"2": {
|
| 120 |
-
"content": "<bos>",
|
| 121 |
-
"single_word": false,
|
| 122 |
-
"lstrip": false,
|
| 123 |
-
"rstrip": false,
|
| 124 |
-
"normalized": false,
|
| 125 |
-
"special": true
|
| 126 |
-
},
|
| 127 |
-
"3": {
|
| 128 |
-
"content": "<unk>",
|
| 129 |
-
"single_word": false,
|
| 130 |
-
"lstrip": false,
|
| 131 |
-
"rstrip": false,
|
| 132 |
-
"normalized": false,
|
| 133 |
-
"special": true
|
| 134 |
-
},
|
| 135 |
-
"4": {
|
| 136 |
-
"content": "<mask>",
|
| 137 |
-
"single_word": false,
|
| 138 |
-
"lstrip": false,
|
| 139 |
-
"rstrip": false,
|
| 140 |
-
"normalized": false,
|
| 141 |
-
"special": true
|
| 142 |
-
},
|
| 143 |
-
"46": {
|
| 144 |
-
"content": "<|tool>",
|
| 145 |
-
"single_word": false,
|
| 146 |
-
"lstrip": false,
|
| 147 |
-
"rstrip": false,
|
| 148 |
-
"normalized": false,
|
| 149 |
-
"special": true
|
| 150 |
-
},
|
| 151 |
-
"47": {
|
| 152 |
-
"content": "<tool|>",
|
| 153 |
-
"single_word": false,
|
| 154 |
-
"lstrip": false,
|
| 155 |
-
"rstrip": false,
|
| 156 |
-
"normalized": false,
|
| 157 |
-
"special": true
|
| 158 |
-
},
|
| 159 |
-
"48": {
|
| 160 |
-
"content": "<|tool_call>",
|
| 161 |
-
"single_word": false,
|
| 162 |
-
"lstrip": false,
|
| 163 |
-
"rstrip": false,
|
| 164 |
-
"normalized": false,
|
| 165 |
-
"special": true
|
| 166 |
-
},
|
| 167 |
-
"49": {
|
| 168 |
-
"content": "<tool_call|>",
|
| 169 |
-
"single_word": false,
|
| 170 |
-
"lstrip": false,
|
| 171 |
-
"rstrip": false,
|
| 172 |
-
"normalized": false,
|
| 173 |
-
"special": true
|
| 174 |
-
},
|
| 175 |
-
"50": {
|
| 176 |
-
"content": "<|tool_response>",
|
| 177 |
-
"single_word": false,
|
| 178 |
-
"lstrip": false,
|
| 179 |
-
"rstrip": false,
|
| 180 |
-
"normalized": false,
|
| 181 |
-
"special": true
|
| 182 |
-
},
|
| 183 |
-
"51": {
|
| 184 |
-
"content": "<tool_response|>",
|
| 185 |
-
"single_word": false,
|
| 186 |
-
"lstrip": false,
|
| 187 |
-
"rstrip": false,
|
| 188 |
-
"normalized": false,
|
| 189 |
-
"special": true
|
| 190 |
-
},
|
| 191 |
-
"52": {
|
| 192 |
-
"content": "<|\"|>",
|
| 193 |
-
"single_word": false,
|
| 194 |
-
"lstrip": false,
|
| 195 |
-
"rstrip": false,
|
| 196 |
-
"normalized": false,
|
| 197 |
-
"special": true
|
| 198 |
-
},
|
| 199 |
-
"98": {
|
| 200 |
-
"content": "<|think|>",
|
| 201 |
-
"single_word": false,
|
| 202 |
-
"lstrip": false,
|
| 203 |
-
"rstrip": false,
|
| 204 |
-
"normalized": false,
|
| 205 |
-
"special": true
|
| 206 |
-
},
|
| 207 |
-
"100": {
|
| 208 |
-
"content": "<|channel>",
|
| 209 |
-
"single_word": false,
|
| 210 |
-
"lstrip": false,
|
| 211 |
-
"rstrip": false,
|
| 212 |
-
"normalized": false,
|
| 213 |
-
"special": true
|
| 214 |
-
},
|
| 215 |
-
"101": {
|
| 216 |
-
"content": "<channel|>",
|
| 217 |
-
"single_word": false,
|
| 218 |
-
"lstrip": false,
|
| 219 |
-
"rstrip": false,
|
| 220 |
-
"normalized": false,
|
| 221 |
-
"special": true
|
| 222 |
-
},
|
| 223 |
-
"105": {
|
| 224 |
-
"content": "<|turn>",
|
| 225 |
-
"single_word": false,
|
| 226 |
-
"lstrip": false,
|
| 227 |
-
"rstrip": false,
|
| 228 |
-
"normalized": false,
|
| 229 |
-
"special": true
|
| 230 |
-
},
|
| 231 |
-
"106": {
|
| 232 |
-
"content": "<turn|>",
|
| 233 |
-
"single_word": false,
|
| 234 |
-
"lstrip": false,
|
| 235 |
-
"rstrip": false,
|
| 236 |
-
"normalized": false,
|
| 237 |
-
"special": true
|
| 238 |
-
},
|
| 239 |
-
"255999": {
|
| 240 |
-
"content": "<|image>",
|
| 241 |
-
"single_word": false,
|
| 242 |
-
"lstrip": false,
|
| 243 |
-
"rstrip": false,
|
| 244 |
-
"normalized": false,
|
| 245 |
-
"special": true
|
| 246 |
-
},
|
| 247 |
-
"256000": {
|
| 248 |
-
"content": "<|audio>",
|
| 249 |
-
"single_word": false,
|
| 250 |
-
"lstrip": false,
|
| 251 |
-
"rstrip": false,
|
| 252 |
-
"normalized": false,
|
| 253 |
-
"special": true
|
| 254 |
-
},
|
| 255 |
-
"258880": {
|
| 256 |
-
"content": "<|image|>",
|
| 257 |
-
"single_word": false,
|
| 258 |
-
"lstrip": false,
|
| 259 |
-
"rstrip": false,
|
| 260 |
-
"normalized": false,
|
| 261 |
-
"special": true
|
| 262 |
-
},
|
| 263 |
-
"258881": {
|
| 264 |
-
"content": "<|audio|>",
|
| 265 |
-
"single_word": false,
|
| 266 |
-
"lstrip": false,
|
| 267 |
-
"rstrip": false,
|
| 268 |
-
"normalized": false,
|
| 269 |
-
"special": true
|
| 270 |
-
},
|
| 271 |
-
"258882": {
|
| 272 |
-
"content": "<image|>",
|
| 273 |
-
"single_word": false,
|
| 274 |
-
"lstrip": false,
|
| 275 |
-
"rstrip": false,
|
| 276 |
-
"normalized": false,
|
| 277 |
-
"special": true
|
| 278 |
-
},
|
| 279 |
-
"258883": {
|
| 280 |
-
"content": "<audio|>",
|
| 281 |
-
"single_word": false,
|
| 282 |
-
"lstrip": false,
|
| 283 |
-
"rstrip": false,
|
| 284 |
-
"normalized": false,
|
| 285 |
-
"special": true
|
| 286 |
-
},
|
| 287 |
-
"258884": {
|
| 288 |
-
"content": "<|video|>",
|
| 289 |
-
"single_word": false,
|
| 290 |
-
"lstrip": false,
|
| 291 |
-
"rstrip": false,
|
| 292 |
-
"normalized": false,
|
| 293 |
-
"special": true
|
| 294 |
-
}
|
| 295 |
-
},
|
| 296 |
-
"chat_template": "{%- macro format_parameters(properties, required, filter_keys=false) -%}\n {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in properties | dictsort -%}\n {%- set add_comma = false -%}\n {%- if not filter_keys or key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{ key }}:{\n {%- if value['description'] -%}\n description:<|\"|>{{ value['description'] }}<|\"|>\n {%- set add_comma = true -%}\n {%- endif -%}\n {%- if value['type'] | upper == 'STRING' -%}\n {%- if value['enum'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n enum:{{ format_argument(value['enum']) }}\n {%- endif -%}\n {%- elif value['type'] | upper == 'ARRAY' -%}\n {%- if value['items'] is mapping and value['items'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n items:{\n {%- set ns_items = namespace(found_first=false) -%}\n {%- for item_key, item_value in value['items'] | dictsort -%}\n {%- if item_value is not none -%}\n {%- if ns_items.found_first %},{% endif -%}\n {%- set ns_items.found_first = true -%}\n {%- if item_key == 'properties' -%}\n properties:{\n {%- if item_value is mapping -%}\n {{- format_parameters(item_value, value['items']['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- elif item_key == 'required' -%}\n required:[\n {%- for req_item in item_value -%}\n <|\"|>{{- req_item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- elif item_key == 'type' -%}\n {%- if item_value is string -%}\n type:{{ format_argument(item_value | upper) }}\n {%- else -%}\n type:{{ format_argument(item_value | map('upper') | list) }}\n {%- endif -%}\n {%- else -%}\n {{ item_key }}:{{ format_argument(item_value) }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n }\n {%- endif -%}\n {%- endif -%}\n {%- if value['nullable'] %}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n nullable:true\n {%- endif -%}\n {%- if value['type'] | upper == 'OBJECT' -%}\n {%- if value['properties'] is defined and value['properties'] is mapping -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n properties:{\n {{- format_parameters(value['properties'], value['required'] | default([])) -}}\n }\n {%- elif value is mapping -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n properties:{\n {{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}\n }\n {%- endif -%}\n {%- if value['required'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n required:[\n {%- for item in value['required'] | default([]) -%}\n <|\"|>{{- item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- endif -%}\n {%- endif -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n type:<|\"|>{{ value['type'] | upper }}<|\"|>}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{%- macro format_function_declaration(tool_data) -%}\n declaration:{{- tool_data['function']['name'] -}}{description:<|\"|>{{- tool_data['function']['description'] -}}<|\"|>\n {%- set params = tool_data['function']['parameters'] -%}\n {%- if params -%}\n ,parameters:{\n {%- if params['properties'] -%}\n properties:{ {{- format_parameters(params['properties'], params['required']) -}} },\n {%- endif -%}\n {%- if params['required'] -%}\n required:[\n {%- for item in params['required'] -%}\n <|\"|>{{- item -}}<|\"|>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:<|\"|>{{- params['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n {%- if 'response' in tool_data['function'] -%}\n {%- set response_declaration = tool_data['function']['response'] -%}\n ,response:{\n {%- if response_declaration['description'] -%}\n description:<|\"|>{{- response_declaration['description'] -}}<|\"|>,\n {%- endif -%}\n {%- if response_declaration['type'] | upper == 'OBJECT' -%}\n type:<|\"|>{{- response_declaration['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n }\n{%- endmacro -%}\n{%- macro format_argument(argument, escape_keys=True) -%}\n {%- if argument is none -%}\n {{- 'null' -}}\n {%- elif argument is string -%}\n {{- '<|\"|>' + argument + '<|\"|>' -}}\n {%- elif argument is boolean -%}\n {{- 'true' if argument else 'false' -}}\n {%- elif argument is mapping -%}\n {{- '{' -}}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in argument | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- if escape_keys -%}\n {{- '<|\"|>' + key + '<|\"|>' -}}\n {%- else -%}\n {{- key -}}\n {%- endif -%}\n :{{- format_argument(value, escape_keys=escape_keys) -}}\n {%- endfor -%}\n {{- '}' -}}\n {%- elif argument is sequence -%}\n {{- '[' -}}\n {%- for item in argument -%}\n {{- format_argument(item, escape_keys=escape_keys) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- ']' -}}\n {%- else -%}\n {{- argument -}}\n {%- endif -%}\n{%- endmacro -%}\n{%- macro strip_thinking(text) -%}\n {%- set ns = namespace(result='') -%}\n {%- for part in text.split('<channel|>') -%}\n {%- if '<|channel>' in part -%}\n {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}\n {%- else -%}\n {%- set ns.result = ns.result + part -%}\n {%- endif -%}\n {%- endfor -%}\n {{- ns.result | trim -}}\n{%- endmacro -%}\n\n{%- macro format_tool_response_block(tool_name, response) -%}\n {{- '<|tool_response>' -}}\n {%- if response is mapping -%}\n {{- 'response:' + tool_name + '{' -}}\n {%- for key, value in response | dictsort -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- '}' -}}\n {%- else -%}\n {{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}\n {%- endif -%}\n {{- '<tool_response|>' -}}\n{%- endmacro -%}\n\n{#- ===== SETUP ===== -#}\n{%- set ns = namespace(prev_message_type=None, prev_non_tool_role=None) -%}\n{%- set loop_messages = messages -%}\n{%- set enable_thinking = enable_thinking | default(false) -%}\n{%- set preserve_thinking = preserve_thinking | default(false) -%}\n{{- bos_token -}}\n{#- Handle System/Tool Definitions Block -#}\n{%- if enable_thinking or tools or (messages and messages[0]['role'] in ['system', 'developer']) -%}\n {{- '<|turn>system\\n' -}}\n {#- Inject Thinking token at the very top of the FIRST system turn -#}\n {%- if enable_thinking -%}\n {{- '<|think|>\\n' -}}\n {%- set ns.prev_message_type = 'think' -%}\n {%- endif -%}\n {%- if messages and messages[0]['role'] in ['system', 'developer'] -%}\n {%- if messages[0]['content'] is string -%}\n {{- messages[0]['content'] | trim -}}\n {%- elif messages[0]['content'] is sequence -%}\n {%- for item in messages[0]['content'] -%}\n {{- item['text'] | trim + ' '-}}\n {%- endfor -%}\n {%- endif -%}\n {%- set loop_messages = messages[1:] -%}\n {%- endif -%}\n {%- if tools -%}\n {%- for tool in tools %}\n {{- '<|tool>' -}}\n {{- format_function_declaration(tool) | trim -}}\n {{- '<tool|>' -}}\n {%- endfor %}\n {%- set ns.prev_message_type = 'tool' -%}\n {%- endif -%}\n {{- '<turn|>\\n' -}}\n{%- endif %}\n\n{#- Pre-scan: find last user message index for reasoning guard -#}\n{%- set ns_turn = namespace(last_user_idx=-1) -%}\n{%- for i in range(loop_messages | length) -%}\n {%- if loop_messages[i]['role'] == 'user' -%}\n {%- set ns_turn.last_user_idx = i -%}\n {%- endif -%}\n{%- endfor -%}\n\n{#- Loop through messages -#}\n{%- for message in loop_messages -%}\n {%- if message['role'] != 'tool' -%}\n {%- set ns.prev_message_type = None -%}\n {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}\n {#- Detect continuation using tracked state — O(1) instead of O(n) backward scan -#}\n {%- set continue_same_model_turn = (role == 'model' and ns.prev_non_tool_role == 'assistant') -%}\n {%- if not continue_same_model_turn -%}\n {{- '<|turn>' + role + '\\n' }}\n {%- endif -%}\n\n {#- Render reasoning/reasoning_content as thinking channel -#}\n {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}\n {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}\n {%- if thinking_text and thinking_gate -%}\n {{- '<|channel>thought\\n' + thinking_text + '\\n<channel|>' -}}\n {%- endif -%}\n\n {%- if message.get('tool_calls') -%}\n {%- for tool_call in message.get('tool_calls') -%}\n {%- set function = tool_call['function'] -%}\n {{- '<|tool_call>call:' + function['name'] + '{' -}}\n {%- if function['arguments'] is mapping -%}\n {%- set ns_args = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns_args.found_first %},{% endif -%}\n {%- set ns_args.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is none -%}\n {%- elif function['arguments'] is string -%}\n {#- Pre-serialized args (e.g. an OpenAI JSON string). We cannot JSON-parse\n portably in-template, so render non-fatally instead of erroring. Strip an\n outer {...} so it composes with the DSL braces rather than double-wrapping.\n Prefer passing arguments as a mapping for exact Gemma DSL. -#}\n {%- set argstr = function['arguments'] | trim -%}\n {%- if argstr[:1] == '{' and argstr[-1:] == '}' -%}\n {{- argstr[1:-1] -}}\n {%- else -%}\n {{- function['arguments'] -}}\n {%- endif -%}\n {%- endif -%}\n {{- '}<tool_call|>' -}}\n {%- endfor -%}\n {%- set ns.prev_message_type = 'tool_call' -%}\n {%- endif -%}\n\n {%- set ns_tr_out = namespace(flag=false) -%}\n {%- if message.get('tool_responses') -%}\n {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}\n {%- for tool_response in message.get('tool_responses') -%}\n {{- format_tool_response_block(tool_response['name'] | default('unknown', true), tool_response['response']) -}}\n {%- set ns_tr_out.flag = true -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endfor -%}\n {%- elif message.get('tool_calls') -%}\n {#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}\n {%- set ns_tool_scan = namespace(stopped=false) -%}\n {%- for k in range(loop.index0 + 1, loop_messages | length) -%}\n {%- if ns_tool_scan.stopped -%}\n {%- elif loop_messages[k]['role'] != 'tool' -%}\n {%- set ns_tool_scan.stopped = true -%}\n {%- else -%}\n {%- set follow = loop_messages[k] -%}\n {#- Resolve tool_call_id to function name -#}\n {%- set ns_tname = namespace(name=follow.get('name') or 'unknown') -%}\n {%- for tc in message.get('tool_calls') -%}\n {%- if tc.get('id') == follow.get('tool_call_id') -%}\n {%- set ns_tname.name = tc['function']['name'] -%}\n {%- endif -%}\n {%- endfor -%}\n {#- Handle content as string or content-parts array -#}\n {%- set tool_body = follow.get('content') -%}\n {%- if tool_body is string -%}\n {{- format_tool_response_block(ns_tname.name, tool_body) -}}\n {%- elif tool_body is sequence and tool_body is not string -%}\n {%- set ns_txt = namespace(s='') -%}\n {%- for part in tool_body -%}\n {%- if part.get('type') == 'text' -%}\n {%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}\n {%- endif -%}\n {%- endfor -%}\n {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}\n {%- for part in tool_body -%}\n {%- if part.get('type') in ['image', 'image_url'] -%}\n {{- '<|image|>' -}}\n {%- elif part.get('type') in ['audio', 'input_audio'] -%}\n {{- '<|audio|>' -}}\n {%- elif part.get('type') == 'video' -%}\n {{- '<|video|>' -}}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{- format_tool_response_block(ns_tname.name, tool_body) -}}\n {%- endif -%}\n {%- set ns_tr_out.flag = true -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- set captured_content -%}\n {%- if message.get('content') is string -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(message['content']) -}}\n {%- else -%}\n {{- message['content'] | trim -}}\n {%- endif -%}\n {%- elif message.get('content') is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item.get('type') == 'text' -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(item['text']) -}}\n {%- else -%}\n {{- item['text'] | trim -}}\n {%- endif -%}\n {%- elif item.get('type') in ['image', 'image_url'] -%}\n {{- '<|image|>' -}}\n {%- elif item.get('type') in ['audio', 'input_audio'] -%}\n {{- '<|audio|>' -}}\n {%- elif item.get('type') == 'video' -%}\n {{- '<|video|>' -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- endset -%}\n\n {{- captured_content -}}\n {%- set has_content = captured_content | trim | length > 0 -%}\n\n {#- Forward-scan: find next non-tool message role for continuation detection -#}\n {%- set next_nt = namespace(role=None, found=false) -%}\n {%- for j in range(loop.index0 + 1, loop_messages | length) -%}\n {%- if not next_nt.found -%}\n {%- if loop_messages[j]['role'] != 'tool' -%}\n {%- set next_nt.role = loop_messages[j]['role'] -%}\n {%- set next_nt.found = true -%}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n\n {%- set continues_into_next = (\n role == 'model'\n and next_nt.role == 'assistant'\n and (not message.get('tool_calls') or ns_tr_out.flag)\n ) -%}\n\n {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}\n {{- '<|tool_response>' -}}\n {%- elif continues_into_next -%}\n {%- elif not (ns_tr_out.flag and not has_content and not next_nt.found) -%}\n {{- '<turn|>\\n' -}}\n {%- endif -%}\n\n {#- Track previous non-tool role for next iteration (avoids O(n) backward scan) -#}\n {%- set ns.prev_non_tool_role = message['role'] -%}\n {%- endif -%}\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}\n {{- '<|turn>model\\n' -}}\n {%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}\n {{- '<|channel>thought\\n' -}}\n {%- endif -%}\n{%- endif -%}\n"
|
| 297 |
-
}
|
|
|
|
| 20 |
"is_local": false,
|
| 21 |
"local_files_only": false,
|
| 22 |
"mask_token": "<mask>",
|
| 23 |
+
"model_max_length": 1000000000000000019884624838656,
|
|
|
|
| 24 |
"model_specific_special_tokens": {
|
| 25 |
"audio_token": "<|audio|>",
|
| 26 |
"boa_token": "<|audio>",
|
|
|
|
| 41 |
"str_token": "<|tool_response>",
|
| 42 |
"think_token": "<|think|>"
|
| 43 |
},
|
|
|
|
| 44 |
"pad_token": "<pad>",
|
| 45 |
+
"padding_side": "left",
|
|
|
|
| 46 |
"processor_class": "Gemma4Processor",
|
| 47 |
"response_schema": {
|
| 48 |
"properties": {
|
|
|
|
| 85 |
"type": "object",
|
| 86 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
},
|
| 88 |
+
"response_template": {
|
| 89 |
+
"defaults": {
|
| 90 |
+
"role": "assistant"
|
| 91 |
+
},
|
| 92 |
+
"fields": {
|
| 93 |
+
"content": {
|
| 94 |
+
"close": [
|
| 95 |
+
"<turn|>",
|
| 96 |
+
"<|tool_response>",
|
| 97 |
+
"<eos>"
|
| 98 |
+
],
|
| 99 |
+
"content": "text"
|
| 100 |
+
},
|
| 101 |
+
"thinking": {
|
| 102 |
+
"close": "<channel|>",
|
| 103 |
+
"content": "text",
|
| 104 |
+
"open": "<|channel>thought\n"
|
| 105 |
+
},
|
| 106 |
+
"tool_calls": {
|
| 107 |
+
"close": "<tool_call|>",
|
| 108 |
+
"content": "json",
|
| 109 |
+
"content_args": {
|
| 110 |
+
"string_delims": [
|
| 111 |
+
[
|
| 112 |
+
"<|\"|>",
|
| 113 |
+
"<|\"|>"
|
| 114 |
+
]
|
| 115 |
+
],
|
| 116 |
+
"unquoted_keys": true
|
| 117 |
+
},
|
| 118 |
+
"open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
|
| 119 |
+
"repeats": true,
|
| 120 |
+
"transform": {
|
| 121 |
+
"function": {
|
| 122 |
+
"arguments": "{content}",
|
| 123 |
+
"name": "{name}"
|
| 124 |
+
},
|
| 125 |
+
"type": "function"
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"start_anchor": [
|
| 130 |
+
"<|turn>model\n",
|
| 131 |
+
"<tool_response|>"
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
"soc_token": "<|channel>",
|
| 135 |
"sot_token": "<|turn>",
|
| 136 |
"stc_token": "<|tool_call>",
|
| 137 |
"std_token": "<|tool>",
|
| 138 |
"str_token": "<|tool_response>",
|
|
|
|
| 139 |
"think_token": "<|think|>",
|
| 140 |
"tokenizer_class": "GemmaTokenizer",
|
| 141 |
+
"unk_token": "<unk>"
|
| 142 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|