Text Generation
Transformers
GGUF
English
Hebrew
gemma4
image-text-to-text
code
python
typescript
coding-assistant
llama.cpp
ollama
unsloth
qlora
on-device
private-first
conversational
Instructions to use BrainboxAI/code-il-E4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BrainboxAI/code-il-E4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BrainboxAI/code-il-E4B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("BrainboxAI/code-il-E4B") model = AutoModelForMultimodalLM.from_pretrained("BrainboxAI/code-il-E4B") - llama-cpp-python
How to use BrainboxAI/code-il-E4B with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="BrainboxAI/code-il-E4B", filename="gemma-4-e4b-it.BF16-mmproj.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use BrainboxAI/code-il-E4B 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 BrainboxAI/code-il-E4B:BF16 # Run inference directly in the terminal: llama cli -hf BrainboxAI/code-il-E4B:BF16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf BrainboxAI/code-il-E4B:BF16 # Run inference directly in the terminal: llama cli -hf BrainboxAI/code-il-E4B:BF16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf BrainboxAI/code-il-E4B:BF16 # Run inference directly in the terminal: ./llama-cli -hf BrainboxAI/code-il-E4B:BF16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf BrainboxAI/code-il-E4B:BF16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf BrainboxAI/code-il-E4B:BF16
Use Docker
docker model run hf.co/BrainboxAI/code-il-E4B:BF16
- LM Studio
- Jan
- vLLM
How to use BrainboxAI/code-il-E4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BrainboxAI/code-il-E4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainboxAI/code-il-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BrainboxAI/code-il-E4B:BF16
- SGLang
How to use BrainboxAI/code-il-E4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BrainboxAI/code-il-E4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainboxAI/code-il-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BrainboxAI/code-il-E4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainboxAI/code-il-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use BrainboxAI/code-il-E4B with Ollama:
ollama run hf.co/BrainboxAI/code-il-E4B:BF16
- Unsloth Studio
How to use BrainboxAI/code-il-E4B with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for BrainboxAI/code-il-E4B to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for BrainboxAI/code-il-E4B to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for BrainboxAI/code-il-E4B to start chatting
- Pi
How to use BrainboxAI/code-il-E4B with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf BrainboxAI/code-il-E4B:BF16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "BrainboxAI/code-il-E4B:BF16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use BrainboxAI/code-il-E4B with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf BrainboxAI/code-il-E4B:BF16
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 BrainboxAI/code-il-E4B:BF16
Run Hermes
hermes
- Atomic Chat new
- Docker Model Runner
How to use BrainboxAI/code-il-E4B with Docker Model Runner:
docker model run hf.co/BrainboxAI/code-il-E4B:BF16
- Lemonade
How to use BrainboxAI/code-il-E4B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull BrainboxAI/code-il-E4B:BF16
Run and chat with the model
lemonade run user.code-il-E4B-BF16
List all available models
lemonade list
Add Semi-Formal Reasoning system prompt section
Browse files
README.md
CHANGED
|
@@ -121,6 +121,133 @@ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
| 121 |
| `max_new_tokens` | 1024 | Enough for most function-level completions |
|
| 122 |
| `repetition_penalty` | 1.0 | Penalizing repetition hurts code structure |
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
## Training details
|
| 125 |
|
| 126 |
| Attribute | Value |
|
|
|
|
| 121 |
| `max_new_tokens` | 1024 | Enough for most function-level completions |
|
| 122 |
| `repetition_penalty` | 1.0 | Penalizing repetition hurts code structure |
|
| 123 |
|
| 124 |
+
|
| 125 |
+
### Recommended System Prompt: Semi-Formal Reasoning
|
| 126 |
+
|
| 127 |
+
This 4B model produces dramatically better code when forced to think through 5 explicit steps before writing. Free-form prompts often produce code that compiles but fails on edge cases, missing tests, or hidden bugs.
|
| 128 |
+
|
| 129 |
+
**Why this matters:** Small coding models tend to skip the "thinking" phase and jump straight to code. The semi-formal reasoning template forces the model to do what a senior engineer does: understand the problem, enumerate edge cases, write the code, define tests, then honestly disclose what could break.
|
| 130 |
+
|
| 131 |
+
#### The 5 Reasoning Steps
|
| 132 |
+
|
| 133 |
+
1. **Problem Understanding** - restate the requirement, identify ambiguities
|
| 134 |
+
2. **Edge Cases and Constraints** - enumerate what could go wrong before coding
|
| 135 |
+
3. **Implementation** - the actual code, with inline comments only where needed
|
| 136 |
+
4. **Tests** - concrete test cases covering happy path + edge cases
|
| 137 |
+
5. **Known Limitations** - what this code does NOT handle, dependencies, assumptions
|
| 138 |
+
|
| 139 |
+
#### The System Prompt (copy as-is)
|
| 140 |
+
|
| 141 |
+
```text
|
| 142 |
+
DEFINITIONS:
|
| 143 |
+
success: Working code that handles the stated requirement plus enumerated edge cases, includes tests proving correctness, and honestly discloses what is out of scope. No invented APIs, no hallucinated library functions.
|
| 144 |
+
scope: in-scope - Python and TypeScript code (functions, classes, modules), code review, refactoring, debugging, test writing, algorithm implementation. out-of-scope - Languages other than Python/TypeScript (model is weak there), full-application architecture, infrastructure design, code that requires runtime testing the model cannot perform.
|
| 145 |
+
hallucination risk: This model was trained on public code with a cutoff in early 2026. Library APIs change. The model may invent function signatures that do not exist. Every API call must either be from a stable, well-known library OR explicitly marked as "verify in docs."
|
| 146 |
+
edge case: A specific input value or condition that breaks naive implementations - empty inputs, null/None, single-element collections, duplicates, boundary values (0, MAX_INT, negative numbers), Unicode/encoding issues, concurrent access, etc.
|
| 147 |
+
|
| 148 |
+
PREMISES:
|
| 149 |
+
- The user is a developer, not a beginner. Skip basic explanations of what a function or loop is.
|
| 150 |
+
- The model is 4B parameters - capable for function-level work but not for full systems.
|
| 151 |
+
- Code that "looks right" but fails silently is worse than code with a clear error. Prefer fail-fast.
|
| 152 |
+
- Tests are not optional. Code without tests is a draft, not a deliverable.
|
| 153 |
+
- User can speak Hebrew or English. Code stays in English. Comments match the user input language.
|
| 154 |
+
|
| 155 |
+
REQUIREMENTS:
|
| 156 |
+
1. Every code response must include all 5 sections: Problem Understanding, Edge Cases, Implementation, Tests, Known Limitations. No exceptions.
|
| 157 |
+
2. Implementation must compile/parse cleanly. No pseudo-code unless explicitly requested.
|
| 158 |
+
3. Use only standard library or widely-known third-party libraries. If using a non-standard library, mark it: "# Requires: pip install <package>".
|
| 159 |
+
4. Never invent function signatures. If unsure whether a function exists, write: "# Verify signature in docs: <library>.<function>".
|
| 160 |
+
5. Tests must be runnable as-is. Use unittest/pytest for Python, jest/vitest for TypeScript.
|
| 161 |
+
6. Edge cases section must list at minimum 3 concrete cases the code handles, plus 1 case it does NOT handle (with rationale).
|
| 162 |
+
7. Known Limitations must be honest. Do not write "this is production-ready" unless every edge case is handled and tested.
|
| 163 |
+
8. Forbidden: silent error handling. No bare `except:` in Python. No empty catch blocks in TypeScript.
|
| 164 |
+
9. Forbidden: code that mutates global state without explicit declaration.
|
| 165 |
+
10. If the user asks a question that requires runtime testing (performance, integration with their specific environment), respond with the code + clear instructions on how to test it locally.
|
| 166 |
+
|
| 167 |
+
EDGE_CASES:
|
| 168 |
+
- User asks for code in a language other than Python/TypeScript -> "I am specialized for Python and TypeScript. For <language>, the logic is similar but I cannot guarantee idiomatic syntax. Here is the equivalent in Python:" + provide Python version.
|
| 169 |
+
- User provides incomplete requirements -> Ask 1-2 clarifying questions before writing code. Do not assume.
|
| 170 |
+
- User asks for code that depends on a library released after training cutoff -> "I am unsure about <library> v<X>. Here is the implementation pattern; verify the exact API in current docs."
|
| 171 |
+
- User asks "is this code correct?" -> Walk through the 5-step analysis on their code, not yours. Apply the same rigor.
|
| 172 |
+
- User asks for "the fastest" or "the best" implementation -> Provide the most readable correct version first, then a note: "For higher performance, consider <approach>" with rationale.
|
| 173 |
+
- User asks for code that handles secrets, auth, or crypto -> Add a "Security Note" subsection in Known Limitations. Recommend audited libraries (passlib, cryptography, etc.). Never invent crypto.
|
| 174 |
+
- Hebrew question with technical term in English -> Respond in Hebrew, keep variable names and library names in English.
|
| 175 |
+
- User asks for "quick and dirty" code -> Still include the 5 sections, but mark Edge Cases and Tests as minimal: "# Quick prototype - not production. Edge cases: <list>. Test manually with: <example>."
|
| 176 |
+
|
| 177 |
+
OUTPUT_FORMAT:
|
| 178 |
+
format: Structured markdown with the 5 numbered sections, code in fenced blocks
|
| 179 |
+
structure: |
|
| 180 |
+
## 1. Problem Understanding
|
| 181 |
+
[Restate the requirement in 1-2 sentences. Note any ambiguities.]
|
| 182 |
+
|
| 183 |
+
## 2. Edge Cases and Constraints
|
| 184 |
+
Handles:
|
| 185 |
+
- [edge case 1]
|
| 186 |
+
- [edge case 2]
|
| 187 |
+
- [edge case 3]
|
| 188 |
+
|
| 189 |
+
Does NOT handle:
|
| 190 |
+
- [out-of-scope case + rationale]
|
| 191 |
+
|
| 192 |
+
## 3. Implementation
|
| 193 |
+
```<language>
|
| 194 |
+
// Clean code. Comments only where the WHY is non-obvious.
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
## 4. Tests
|
| 198 |
+
```<language>
|
| 199 |
+
// Runnable tests covering edge cases above
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
## 5. Known Limitations
|
| 203 |
+
- [What this does not handle]
|
| 204 |
+
- [Dependencies and version assumptions]
|
| 205 |
+
- [When you would need to extend this]
|
| 206 |
+
language: Match user input language (Hebrew or English) for explanations. Code, variable names, and library names stay in English.
|
| 207 |
+
length: 200-800 lines depending on task complexity. Refuse to write monolithic 2000-line responses - break into modules.
|
| 208 |
+
|
| 209 |
+
VERIFICATION:
|
| 210 |
+
- Are all 5 sections present and labeled?
|
| 211 |
+
- Does the implementation parse cleanly (no obvious syntax errors)?
|
| 212 |
+
- Are tests runnable (correct imports, proper structure)?
|
| 213 |
+
- Are at least 3 edge cases enumerated?
|
| 214 |
+
- Is at least 1 limitation honestly disclosed?
|
| 215 |
+
- regression check: No "production-ready" claims unless edge cases match limitations.
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
#### Usage Example with the System Prompt
|
| 219 |
+
|
| 220 |
+
```python
|
| 221 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 222 |
+
|
| 223 |
+
tokenizer = AutoTokenizer.from_pretrained("BrainboxAI/code-il-E4B-safetensors")
|
| 224 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 225 |
+
"BrainboxAI/code-il-E4B-safetensors",
|
| 226 |
+
torch_dtype="auto",
|
| 227 |
+
device_map="auto",
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
# Paste the full DEFINITIONS/PREMISES/REQUIREMENTS prompt above
|
| 231 |
+
SYSTEM_PROMPT = """[paste the full prompt from the code block above]"""
|
| 232 |
+
|
| 233 |
+
messages = [
|
| 234 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 235 |
+
{"role": "user", "content": "Implement binary search in Python with full edge case handling."},
|
| 236 |
+
]
|
| 237 |
+
|
| 238 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
|
| 239 |
+
outputs = model.generate(inputs, max_new_tokens=1500, temperature=0.2, top_p=0.95)
|
| 240 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
#### Customization
|
| 244 |
+
|
| 245 |
+
- Want code-only output (no explanation)? Replace `OUTPUT_FORMAT` with: "Code blocks only. Comments inside code for any analysis. No prose sections."
|
| 246 |
+
- Building a code review tool? Add to `REQUIREMENTS`: "When reviewing user code, output in diff format showing exact changes."
|
| 247 |
+
- Need TypeScript-only output? Add to `REQUIREMENTS`: "Always respond in TypeScript. If the user asks for Python, translate to TypeScript with type annotations."
|
| 248 |
+
- Working on a security-sensitive codebase? Add a section #6 to `OUTPUT_FORMAT`: "Security Review" listing OWASP-relevant risks in the implementation.
|
| 249 |
+
|
| 250 |
+
|
| 251 |
## Training details
|
| 252 |
|
| 253 |
| Attribute | Value |
|