495 1 month ago

A lightweight Ollama build of MiniCPM5-2B, the 2B-class open-source SOTA model from OpenBMB

tools thinking
ollama run oamazonasgabriel/minicpm-2b:mlx

Details

1 month ago

c038b216acc4 · 1.4GB

{ "architectures": [ "LlamaForCausalLM" ], "bos_token_id": 0, "eos_token_id": [ 1, 130073 ], "head_d
{ "_from_model_config": true, "bos_token_id": 0, "eos_token_id": [ 1, 130073 ], "pad_token_id": 1, "
{ "version": "1.0", "truncation": null, "padding": null, "added_tokens": [ { "id": 0, "content": "<s
{ "add_prefix_space": null, "backend": "tokenizers", "bos_token": "<s>", "clean_up_tokenization_spac
{{- if .Messages }} {{- if or .System .Tools }}<|im_start|>system {{ .System }} {{- if .Tools }} # T
You are MiniCPM5, a helpful, harmless, and honest AI assistant developed by OpenBMB. You are a reaso
Apache 2.0 Copyright (c) 2026 OpenBMB Licensed under the Apache License, Version 2.0.
{ "num_ctx": 131072, "num_predict": 4096, "stop": [ "<|im_end|>", "</s>"
381 tensors

Readme

MiniCPM5-2B — Ollama Model (2.5B, 131K context)

Model: oamazonasgabriel/minicpm-2b:q4_k_m · oamazonasgabriel/minicpm-2b:bf16 · oamazonasgabriel/minicpm-2b:mlx

Ollama Built by impacte.tech


DESCRIPTION

A lightweight Ollama build of MiniCPM5-2B, the 2B-class open-source SOTA model from OpenBMB — a dense 2.5B-parameter causal LM built for on-device, local deployment, and resource-constrained scenarios. Reaches 2B-class open-source SOTA across coding, math reasoning, long-context understanding, tool use, and agentic tasks.

The ideal agentic/tool-calling companion for: RTX 5060 Ti 16GB + RTX 4060 Ti 8GB (dual) · RTX 4090 · any NVIDIA setup with 8 GB+ VRAM · Apple Silicon (via MLX)

Key Features

  • Dense 2.5B architecture: standard LlamaForCausalLM — no custom kernels, runs anywhere llama.cpp runs
  • 131K native context: full 131,072-token window configured by default
  • Reasoning / thinking mode: emits thinking blocks before the final response (returned by Ollama as message.thinking)
  • Tool calling: trained XML format (<function name="..."><param name="...">...</param></function>); tool schemas are injected via the chat template — for full agentic tool loops today, use llama.cpp --jinja or SGLang (--tool-call-parser minicpm5) until Ollama ships a native minicpm5 parser
  • Fast generation: ~2.5B params — runs comfortably on a single 8 GB card
  • Multilingual: English, Chinese, Spanish, French, German, Japanese, and more
  • Apache 2.0 license: free for commercial and personal use

Architecture

Property Value
Architecture llama — dense LlamaForCausalLM
Total Parameters 2,516,756,480 (2.52B)
Layers 42
Attention Heads 16 Q / 2 KV (GQA)
Embedding Length 2,048
Native Context 131,072 tokens
Modalities Text
Quantization Q4_K_M (1.6 GB) / F16 (5.0 GB) / MLX 4-bit (1.4 GB)
License Apache 2.0
Upstream openbmb/MiniCPM5-2B

REQUIREMENTS

Resource Minimum Recommended
GPU Memory 8 GB VRAM (Q4_K_M) 16 GB+ VRAM (BF16)
System RAM 8 GB 16 GB
Disk Space 2 GB free (Q4_K_M) 6 GB+ free (BF16)
Ollama Version 0.32.9+ Latest

Platform support: - NVIDIA GPU (dual): 16 GB + 8 GB (RTX 5060 Ti + RTX 4060 Ti) — verified - NVIDIA GPU (single): 8 GB+ VRAM for Q4_K_M, 16 GB+ for BF16 - Apple Silicon: :mlx tag (1.4 GB, 4-bit MLX) — native Metal performance - AMD GPU: ROCm-compatible (not verified for this build)


QUICK START

1. Install Ollama

# Linux
curl -fsSL https://ollama.com/install.sh | sh

# macOS / Windows
# Download from https://ollama.com/download

2. Pull & Run

# Pull the 4-bit model (fast, 1.6 GB)
ollama pull oamazonasgabriel/minicpm-2b:q4_k_m

# Run interactively
ollama run oamazonasgabriel/minicpm-2b:q4_k_m

# Single prompt
ollama run oamazonasgabriel/minicpm-2b:q4_k_m \
  "Write a Python function to fetch and parse a JSON API"

USAGE

CLI

# Interactive chat
ollama run oamazonasgabriel/minicpm-2b:q4_k_m

# Full precision (5.0 GB)
ollama run oamazonasgabriel/minicpm-2b:bf16

# With a system prompt
ollama run oamazonasgabriel/minicpm-2b:q4_k_m \
  --system "You are a rigorous code reviewer"

REST API

# Chat completion (thinking + answer)
curl -s http://127.0.0.1:11434/api/chat \
  -d '{
    "model": "oamazonasgabriel/minicpm-2b:q4_k_m",
    "messages": [{"role": "user", "content": "What is 17 * 23?"}],
    "stream": false
  }'
# Reasoning arrives in "message.thinking", the answer in "message.content"

# OpenAI-compatible endpoint (for agent harnesses)
curl -s http://127.0.0.1:11434/v1/chat/completions \
  -d '{
    "model": "oamazonasgabriel/minicpm-2b:q4_k_m",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": false
  }'

Python (ollama library)

pip install ollama
import ollama

response = ollama.chat(
    model='oamazonasgabriel/minicpm-2b:q4_k_m',
    messages=[{'role': 'user', 'content': 'Debug this SQL query'}],
)
print(response.message.content)

JavaScript (ollama.js)

npm install ollama
import ollama from 'ollama'

const response = await ollama.chat({
  model: 'oamazonasgabriel/minicpm-2b:q4_k_m',
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.message.content)

SAMPLING PARAMETERS

These are baked into the model via its Modelfile:

Parameter Value Rationale
num_ctx 131072 Full native context window (max)
num_gpu 99 Offload all layers to GPU
temperature 1.0 OpenBMB official recommendation (think mode)
top_p 0.95 OpenBMB official recommendation
num_predict 4096 Generous output budget for reasoning
stop <\|im_end\|>, </s> ChatML + EOS delimiters

💡 min_p note: llama.cpp’s default min_p=0.05 can cause repetitive output on this model — set min_p=0.0 (OpenBMB recommendation). If you still see repetition, add repetition_penalty=1.05.


MEMORY & PERFORMANCE

VRAM Budget (Q4_K_M, 131K context)

Component Size
Model weights (Q4_K_M) ~1.6 GB
KV cache (q8_0, 131K context) ~2.8 GB
Ollama process + compute buffers ~1 GB
Total ~5.5 GB ✅

Context Window Scaling

Context KV Cache (q8_0) Fits 8 GB?
8,192 ~0.2 GB ✅
32,768 ~0.7 GB ✅
65,536 ~1.4 GB ✅
131,072 (native) ~2.8 GB ✅

The dense 2.5B model has a tiny footprint — the full 131K context fits on a single 8 GB card.


MONITORING

# Check model is GPU-resident
ollama ps

# Real-time GPU usage (NVIDIA)
watch -n 1 nvidia-smi

# Ollama server logs (Linux)
journalctl -u ollama -n 50 --no-pager

TROUBLESHOOTING

Symptom Fix
Repetitive output Set min_p=0.0 (llama.cpp default 0.05 causes repetition on this model)
Empty content, answer stuck inside thinking Raise num_predict (reasoning prompts need 256–512+ tokens)
Slow generation on dual-GPU Ensure OLLAMA_SCHED_SPREAD is off; check ollama ps for CPU offload
Tool calling returns malformed XML Use Q4_K_M or higher — lower quants (Q3/Q2) degrade tool-call formatting

Opencode / nolock Integration

Add to ~/.config/opencode/opencode.jsonc (or the project’s .opencode/opencode.jsonc):

"oamazonasgabriel/minicpm-2b:q4_k_m": {
  "name": "MiniCPM5 2B (Q4_K_M)",
  "tools": true
}

Use as agent:

"model": "ollama/oamazonasgabriel/minicpm-2b:q4_k_m"

Tool calling is verified working through ollama’s OpenAI-compatible endpoint — MiniCPM5-2B emits tool_calls natively, so OpenCode/nolock/Cline parse them directly.


ALTERNATIVE MODELS

# Full precision (5.0 GB, best quality)
ollama pull oamazonasgabriel/minicpm-2b:bf16

# Official higher-quality quants from OpenBMB
ollama pull hf.co/openbmb/MiniCPM5-2B-GGUF:Q8_0    # 2.7 GB

# Apple Silicon (MLX 4-bit, 1.4 GB)
ollama pull oamazonasgabriel/minicpm-2b:mlx

CREDITS

Role Entity
Base Model OpenBMB
Original Model openbmb/MiniCPM5-2B
GGUF Quantization openbmb/MiniCPM5-2B-GGUF
Ollama Packaging impacte.tech
License Apache 2.0

LINKS

Resource URL
This model on Ollama https://ollama.com/oamazonasgabriel/minicpm-2b
Upstream model (HuggingFace) https://huggingface.co/openbmb/MiniCPM5-2B
GGUF repo (HuggingFace) https://huggingface.co/openbmb/MiniCPM5-2B-GGUF
MiniCPM GitHub https://github.com/OpenBMB/MiniCPM
Apache 2.0 license https://www.apache.org/licenses/LICENSE-2.0
Ollama documentation https://docs.ollama.com
Project repository https://github.com/oamazonasgabriel/ollama-training
Built by impacte.tech