Text Generation
MLX
Safetensors
English
qwen3_5
grug
reasoning
token-efficient
agentic
tool-use
mlx-my-repo
conversational
8-bit precision
Instructions to use mlx-community/grug-27b-Text-mlx-8Bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/grug-27b-Text-mlx-8Bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/grug-27b-Text-mlx-8Bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/grug-27b-Text-mlx-8Bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/grug-27b-Text-mlx-8Bit"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/grug-27b-Text-mlx-8Bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use mlx-community/grug-27b-Text-mlx-8Bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/grug-27b-Text-mlx-8Bit"
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 mlx-community/grug-27b-Text-mlx-8Bit
Run Hermes
hermes
- OpenClaw new
How to use mlx-community/grug-27b-Text-mlx-8Bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/grug-27b-Text-mlx-8Bit"
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 "mlx-community/grug-27b-Text-mlx-8Bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- MLX LM
How to use mlx-community/grug-27b-Text-mlx-8Bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/grug-27b-Text-mlx-8Bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/grug-27b-Text-mlx-8Bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/grug-27b-Text-mlx-8Bit", "messages": [ {"role": "user", "content": "Hello"} ] }'
| """Custom Hugging Face Inference Endpoints handler for ProCreations/grug-27b. | |
| Deploy: create an Inference Endpoint from this repo with a GPU holding >=60GB | |
| VRAM for bf16 (1x A100-80GB / H100 / H200). The endpoint auto-detects this | |
| handler. | |
| Request formats accepted: | |
| {"inputs": "plain user prompt", "parameters": {...}} | |
| {"inputs": {"messages": [{"role": "user", "content": "..."}], | |
| "tools": [...optional OpenAI-style tool schemas...]}, | |
| "parameters": {"max_new_tokens": 1024, "temperature": 0.6, ...}} | |
| Response: | |
| [{"generated_text": "<full raw completion>", | |
| "think": "<grug reasoning>", "answer": "<final answer>"}] | |
| """ | |
| from typing import Any, Dict, List | |
| import torch | |
| from transformers import AutoModelForImageTextToText, AutoTokenizer | |
| DEFAULTS = {"max_new_tokens": 1024, "temperature": 0.6, "top_p": 0.95, "top_k": 20, | |
| "do_sample": True} | |
| MAX_NEW_TOKENS_CAP = 8192 | |
| class EndpointHandler: | |
| def __init__(self, path: str = ""): | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForImageTextToText.from_pretrained( | |
| path, dtype=torch.bfloat16, device_map="auto", | |
| attn_implementation="sdpa") | |
| self.model.eval() | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, str]]: | |
| inputs = data.get("inputs", "") | |
| params = dict(DEFAULTS) | |
| params.update(data.get("parameters") or {}) | |
| params["max_new_tokens"] = min(int(params.get("max_new_tokens", 1024)), | |
| MAX_NEW_TOKENS_CAP) | |
| if params.get("temperature", 1.0) <= 0: | |
| params["do_sample"] = False | |
| params.pop("temperature", None) | |
| params.pop("top_p", None) | |
| params.pop("top_k", None) | |
| tools = None | |
| if isinstance(inputs, dict): | |
| messages = inputs.get("messages") or [ | |
| {"role": "user", "content": str(inputs.get("text", ""))}] | |
| tools = inputs.get("tools") or None | |
| elif isinstance(inputs, list): | |
| messages = inputs | |
| else: | |
| messages = [{"role": "user", "content": str(inputs)}] | |
| prompt = self.tokenizer.apply_chat_template( | |
| messages, tools=tools, add_generation_prompt=True, tokenize=False) | |
| enc = self.tokenizer(prompt, return_tensors="pt").to(self.model.device) | |
| gen_kwargs = {k: v for k, v in params.items() | |
| if k in ("max_new_tokens", "temperature", "top_p", "top_k", | |
| "do_sample", "repetition_penalty", "seed")} | |
| gen_kwargs.pop("seed", None) | |
| with torch.inference_mode(): | |
| out = self.model.generate(**enc, **gen_kwargs, | |
| pad_token_id=self.tokenizer.pad_token_id) | |
| text = self.tokenizer.decode(out[0][enc["input_ids"].shape[1]:], | |
| skip_special_tokens=True) | |
| if "</think>" in text: | |
| think, answer = text.split("</think>", 1) | |
| think = think.replace("<think>", "").strip() | |
| answer = answer.strip() | |
| else: | |
| think, answer = "", text.strip() | |
| return [{"generated_text": text, "think": think, "answer": answer}] | |