Text Generation
GGUF
Japanese
English
llama.cpp
Mixture of Experts
expert-pruning
intel-mac
cpu
local-agent
imatrix
conversational
Instructions to use miutti/intel-mac-local-llm 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 miutti/intel-mac-local-llm 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 miutti/intel-mac-local-llm:UD-Q2_K_XL # Run inference directly in the terminal: llama cli -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf miutti/intel-mac-local-llm:UD-Q2_K_XL # Run inference directly in the terminal: llama cli -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
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 miutti/intel-mac-local-llm:UD-Q2_K_XL # Run inference directly in the terminal: ./llama-cli -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
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 miutti/intel-mac-local-llm:UD-Q2_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
Use Docker
docker model run hf.co/miutti/intel-mac-local-llm:UD-Q2_K_XL
- LM Studio
- Jan
- vLLM
How to use miutti/intel-mac-local-llm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "miutti/intel-mac-local-llm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "miutti/intel-mac-local-llm", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/miutti/intel-mac-local-llm:UD-Q2_K_XL
- Ollama
How to use miutti/intel-mac-local-llm with Ollama:
ollama run hf.co/miutti/intel-mac-local-llm:UD-Q2_K_XL
- Unsloth Desktop
- Pi
How to use miutti/intel-mac-local-llm with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
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": "miutti/intel-mac-local-llm:UD-Q2_K_XL" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use miutti/intel-mac-local-llm with Docker Model Runner:
docker model run hf.co/miutti/intel-mac-local-llm:UD-Q2_K_XL
- Lemonade
How to use miutti/intel-mac-local-llm with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull miutti/intel-mac-local-llm:UD-Q2_K_XL
Run and chat with the model
lemonade run user.intel-mac-local-llm-UD-Q2_K_XL
List all available models
lemonade list
- Hermes Agent
How to use miutti/intel-mac-local-llm with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
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 miutti/intel-mac-local-llm:UD-Q2_K_XL
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use miutti/intel-mac-local-llm with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf miutti/intel-mac-local-llm:UD-Q2_K_XL
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 "miutti/intel-mac-local-llm:UD-Q2_K_XL" \ --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"
Download source/lib/forward.py from miutti/intel-mac-local-llm: direct link, hf CLI and curl.
- Browser
- Download file 5.08 kB
-
https://huggingface.co/miutti/intel-mac-local-llm/resolve/main/source/lib/forward.py
- Command line
-
hf download hf://miutti/intel-mac-local-llm/source/lib/forward.py
-
curl -L -o forward.py https://huggingface.co/miutti/intel-mac-local-llm/resolve/main/source/lib/forward.py
5.08 kB
| """qwen2 の順伝播をnumpyで実装し、各層の「本物の入力」を捕まえる。 | |
| なぜ必要か: | |
| 層ごとの出力を元モデルに合わせ込む「再構成」には、その層に実際に入ってくる | |
| 活性化そのものが要る。imatrixはチャンネルごとの平均二乗しか持たず足りない。 | |
| llama.cppに吐き出す機能がないので自前で回す。 | |
| 速度は求めない。数百トークン分の活性化が採れれば目的を果たす。 | |
| """ | |
| import numpy as np | |
| import gguf | |
| class Model: | |
| def __init__(self, path, in_memory=False): | |
| self.r = gguf.Reader(path, in_memory=in_memory) | |
| m = self.r.meta | |
| self.n_layer = m["qwen2.block_count"] | |
| self.d = m["qwen2.embedding_length"] | |
| self.n_head = m["qwen2.attention.head_count"] | |
| self.n_kv = m["qwen2.attention.head_count_kv"] | |
| self.hd = self.d // self.n_head | |
| self.eps = m["qwen2.attention.layer_norm_rms_epsilon"] | |
| self.theta = m["qwen2.rope.freq_base"] | |
| self._cache = {} | |
| def T(self, name): | |
| if name not in self._cache: | |
| a, _ = self.r.load(name) | |
| self._cache[name] = np.ascontiguousarray(a.astype(np.float32)) | |
| return self._cache[name] | |
| def drop(self, name): | |
| self._cache.pop(name, None) | |
| def rms_norm(x, w, eps): | |
| return x / np.sqrt((x * x).mean(-1, keepdims=True) + eps) * w | |
| def rope(x, pos, theta): | |
| """x: (T, n_head, hd)。回転位置埋め込み。""" | |
| T, H, hd = x.shape | |
| half = hd // 2 | |
| inv = 1.0 / (theta ** (np.arange(0, half, dtype=np.float64) * 2 / hd)) | |
| ang = pos[:, None] * inv[None, :] # (T, half) | |
| c, s = np.cos(ang)[:, None, :], np.sin(ang)[:, None, :] | |
| x1, x2 = x[..., :half], x[..., half:] | |
| return np.concatenate([x1 * c - x2 * s, x1 * s + x2 * c], -1).astype(np.float32) | |
| def run(model, tokens, capture=None, replace=None, quantizer=None): | |
| """トークン列を流す。capture に層名を入れると、その層への入力を集めて返す。 | |
| replace={テンソル名: 行列} で重みを差し替えられる(圧縮版の評価用)。""" | |
| M, r = model, model.r | |
| T = len(tokens) | |
| pos = np.arange(T) | |
| emb = M.T("token_embd.weight") # (vocab, d) | |
| x = emb[tokens].astype(np.float32) | |
| caught = {} | |
| quantized = {} | |
| def W(name): | |
| if replace and name in replace: | |
| return replace[name] | |
| return M.T(name) | |
| def lin(h, name): | |
| """h:(T,in) → (T,out)。GGUFは (out,in) 格納なので転置して掛ける。""" | |
| if capture is not None and name in capture: | |
| caught.setdefault(name, []).append(h.copy()) | |
| if quantizer is not None and name in quantizer[0]: | |
| # この層に実際に入ってくる活性化を使って、その場で量子化する。 | |
| # 以降の層は量子化済みの重みで動くので、誤差の伝播も現実的に扱える。 | |
| if name not in quantized: | |
| quantized[name] = quantizer[1](name, M.T(name), h) | |
| w = quantized[name] | |
| y = h @ w.T | |
| b = name.replace(".weight", ".bias") | |
| if b in r.tensors: | |
| y = y + M.T(b) | |
| return y | |
| w = W(name) | |
| y = h @ w.T | |
| b = name.replace(".weight", ".bias") | |
| if b in r.tensors: | |
| y = y + M.T(b) | |
| return y | |
| for L in range(M.n_layer): | |
| p = f"blk.{L}." | |
| h = rms_norm(x, M.T(p + "attn_norm.weight"), M.eps) | |
| q = lin(h, p + "attn_q.weight").reshape(T, M.n_head, M.hd) | |
| k = lin(h, p + "attn_k.weight").reshape(T, M.n_kv, M.hd) | |
| v = lin(h, p + "attn_v.weight").reshape(T, M.n_kv, M.hd) | |
| q = rope(q, pos, M.theta); k = rope(k, pos, M.theta) | |
| rep = M.n_head // M.n_kv | |
| k = np.repeat(k, rep, axis=1); v = np.repeat(v, rep, axis=1) | |
| # 因果マスク付きattention | |
| att = np.einsum("thd,shd->hts", q, k) / np.sqrt(M.hd) | |
| mask = np.triu(np.full((T, T), -1e9, np.float32), 1) | |
| att = att + mask | |
| att -= att.max(-1, keepdims=True) | |
| np.exp(att, out=att) | |
| att /= att.sum(-1, keepdims=True) | |
| o = np.einsum("hts,shd->thd", att, v).reshape(T, M.d) | |
| x = x + lin(o, p + "attn_output.weight") | |
| h = rms_norm(x, M.T(p + "ffn_norm.weight"), M.eps) | |
| g = lin(h, p + "ffn_gate.weight") | |
| u = lin(h, p + "ffn_up.weight") | |
| act = g / (1.0 + np.exp(-g)) * u # SwiGLU | |
| x = x + lin(act, p + "ffn_down.weight") | |
| for n in ("attn_q", "attn_k", "attn_v", "attn_output", | |
| "ffn_gate", "ffn_up", "ffn_down"): | |
| M.drop(p + n + ".weight") # メモリを抱え込まない | |
| x = rms_norm(x, M.T("output_norm.weight"), M.eps) | |
| logits = x @ M.T("token_embd.weight").T # 重み共有 | |
| if quantizer is not None: | |
| return logits, quantized | |
| if capture is not None: | |
| return logits, {k: np.concatenate(v, 0) for k, v in caught.items()} | |
| return logits | |