Instructions to use lthn/lemrd 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 lthn/lemrd 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 lthn/lemrd:Q4_K_M # Run inference directly in the terminal: llama cli -hf lthn/lemrd:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf lthn/lemrd:Q4_K_M # Run inference directly in the terminal: llama cli -hf lthn/lemrd: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 lthn/lemrd:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf lthn/lemrd:Q4_K_M
Use Docker
docker model run hf.co/lthn/lemrd:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use lthn/lemrd with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lthn/lemrd" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lthn/lemrd", "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/lthn/lemrd:Q4_K_M
- Ollama
How to use lthn/lemrd with Ollama:
ollama run hf.co/lthn/lemrd:Q4_K_M
- Unsloth Desktop
- Pi
How to use lthn/lemrd with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lthn/lemrd: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:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "lthn/lemrd:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use lthn/lemrd with Docker Model Runner:
docker model run hf.co/lthn/lemrd:Q4_K_M
- Lemonade
How to use lthn/lemrd with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull lthn/lemrd:Q4_K_M
Run and chat with the model
lemonade run user.lemrd-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use lthn/lemrd with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lthn/lemrd: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:9931/v1 hermes config set model.default lthn/lemrd:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use lthn/lemrd with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lthn/lemrd: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:9931/v1 \ --custom-model-id "lthn/lemrd: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"
Snider Virgil commited on
Commit ·
203a38c
1
Parent(s): 6ac4b6c
docs: update README for LEK-merged Lemma family
Browse filesUpdate model card to reflect LEK (Lethean Ethical Kernel) merged into
weights, align all four variants with the family template, and correct
the pre-merge subtitle language where present.
Co-Authored-By: Virgil <virgil@lethean.io>
123456789---library_name: mlxlicense: eupl-1.2pipeline_tag: image-text-to-textbase_model:- LetheanNetwork/lemrdtags:- mlx---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358---license: eupl-1.2pipeline_tag: image-text-to-textlibrary_name: ggufbase_model:- LetheanNetwork/lemrdbase_model_relation: quantizedtags:- gemma4- gemma- gguf- safetensors- mlx- multimodal- vision- lemma- lethean- lem- apple-silicon- on-device- conversational---<!--This content is subject to the European Union Public Licence (EUPL-1.2).For full licence details, please refer to: https://huggingface.co/lthn/lemrd/tree/main/LICENSEOrigin URL: https://huggingface.co/lthn/lemrd/tree/main--># Lemrd — Gemma 4 31B DenseThe largest dense member of the [Lemma model family](https://huggingface.co/collections/lthn/lemma) by [Lethean](https://lthn.ai). An EUPL-1.2 fork of [Gemma 4 31B](https://huggingface.co/google/gemma-4-31B-it) with the **Lethean Ethical Kernel (LEK) merged into the weights** — consent-based reasoning baked into the attention projections via LoRA finetune, then merged so inference uses a single standalone model with no PEFT runtime required. GGUF and MLX builds with text and vision support, distributed from a single repo. Use GGUF with Ollama, llama.cpp, GPT4All, or LM Studio. Use MLX safetensors with `mlx-lm` and `mlx-vlm` for native Apple Silicon inference. The unmodified Gemma 4 31B fork lives at [LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd) for users who want the raw Google weights without the LEK shift.**MLX-only quant variants:** [Q8](https://huggingface.co/lthn/lemrd-mlx-q8) | [BF16](https://huggingface.co/lthn/lemrd-mlx-bf16) — Q4 multimodal is bundled in this repo.> A **lemma** is "something assumed" — an intermediate theorem on the path to a larger proof, or a heading that signals the subject of what follows. The Lemma model family is named for that role: each variant is a stepping stone between raw capability and ethical application.## GGUF Variants| File | Quant | Size | Use Case ||------|-------|------|----------|| `lemrd-q4_k_m.gguf` | Q4_K_M | 17 GB | **Recommended** — best size/quality balance || `lemrd-q5_k_m.gguf` | Q5_K_M | 20 GB | Higher quality, moderate size || `lemrd-q6_k.gguf` | Q6_K | 23 GB | Near-lossless || `lemrd-q8_0.gguf` | Q8_0 | 30 GB | Maximum quality quantised || `lemrd-bf16.gguf` | BF16 | 57 GB | Full precision reference |All variants verified locally on Apple Silicon via Ollama, llama-cpp-python, mlx-lm, and mlx-vlm.### Repo Files| File | Format | Purpose ||------|--------|---------|| `lemrd-*.gguf` | GGUF | Ollama, llama.cpp, GPT4All, LM Studio || `model-*-of-00006.safetensors` | MLX safetensors (sharded) | Native Apple Silicon via `mlx-lm` and `mlx-vlm` (Q4 multimodal) || `model.safetensors.index.json` | JSON | Tensor index for the sharded safetensors weights || `config.json` | JSON | Multimodal model config (architecture, quantisation, vision tower) || `tokenizer.json` | JSON | Tokenizer vocabulary (262K tokens) || `tokenizer_config.json` | JSON | Tokenizer settings and special tokens || `chat_template.jinja` | Jinja2 | Chat template for transformers, mlx-lm, mlx-vlm || `processor_config.json` | JSON | Image processor config (mlx-vlm) || `generation_config.json` | JSON | Default generation parameters (temperature, top_p, top_k) || `LICENSE` | Text | EUPL-1.2 licence text || `README.md` | Markdown | This file — model card |## Quick Start### Apps & CLI<details><summary>Ollama</summary>```bashollama run hf.co/lthn/lemrd:Q4_K_M```</details><details><summary>Docker</summary>```bashdocker model run hf.co/lthn/lemrd```Or from Docker Hub:```bashdocker model run lthn/lemrd```</details><details><summary>Unsloth Studio</summary>```bash# macOS / Linux / WSLcurl -fsSL https://unsloth.ai/install.sh | sh# Windowsirm https://unsloth.ai/install.ps1 | iex``````bashunsloth studio -H 0.0.0.0 -p 8888# Open http://localhost:8888 — search for lthn/lemrd```Or use [HuggingFace Spaces](https://huggingface.co/spaces/unsloth/studio) — no install, search for `lthn/lemrd`.</details><details><summary>llama.cpp</summary>Install via brew (macOS/Linux), winget (Windows), or build from source:```bashbrew install llama.cpp # macOS/Linuxwinget install llama.cpp # Windows``````bash# Start a local OpenAI-compatible server with a web UI:llama-server -hf lthn/lemrd:Q4_K_M# Run inference directly in the terminal:llama-cli -hf lthn/lemrd:Q4_K_M```Or build from source:```bashgit clone https://github.com/ggerganov/llama.cpp.gitcd llama.cppcmake -B buildcmake --build build -j --target llama-server llama-cli./build/bin/llama-server -hf lthn/lemrd:Q4_K_M./build/bin/llama-cli -hf lthn/lemrd:Q4_K_M```</details><details><summary>MLX (Apple Silicon native)</summary>```bashuv tool install mlx-lmmlx_lm.chat --model lthn/lemrdmlx_lm.generate --model lthn/lemrd --prompt "Hello, how are you?"```</details>### Python Libraries<details><summary>llama-cpp-python</summary>```bashuv pip install llama-cpp-python``````pythonfrom llama_cpp import Llamallm = Llama.from_pretrained(repo_id="lthn/lemrd",filename="lemrd-q4_k_m.gguf",)# Textllm.create_chat_completion(messages=[{"role": "user", "content": "Hello, how are you?"}])# Vision (multimodal)llm.create_chat_completion(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"}}]}])```</details><details><summary>mlx-vlm (vision)</summary>```bashuv tool install mlx-vlm``````pythonfrom mlx_vlm import load, generatefrom mlx_vlm.prompt_utils import apply_chat_templatefrom mlx_vlm.utils import load_configmodel, processor = load("lthn/lemrd")config = load_config("lthn/lemrd")image = ["http://images.cocodataset.org/val2017/000000039769.jpg"]prompt = "Describe this image."formatted_prompt = apply_chat_template(processor, config, prompt, num_images=1)output = generate(model, processor, formatted_prompt, image)print(output.text)```</details>### Servers (OpenAI-compatible API)<details><summary>MLX Server</summary>`lemrd` is multimodal (text + image), so use `mlx_vlm.server` — the vision-aware variant. The text-only `mlx_lm.server` does not correctly route multimodal tensors for Gemma 4.```bashmlx_vlm.server --model lthn/lemrd``````bashcurl -X POST "http://localhost:8080/v1/chat/completions" \-H "Content-Type: application/json" \--data '{"model": "lthn/lemrd","messages": [{"role": "user", "content": "Hello, how are you?"}],"max_tokens": 200}'```Works with any OpenAI-compatible client at `http://localhost:8080/v1`.</details><details><summary>vLLM</summary>> vLLM requires the original (non-quantised) safetensors weights from [LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd) — it does not load GGUF or MLX-quantised safetensors. Linux + NVIDIA GPU with adequate VRAM for a 31B dense model.```bashuv pip install vllmvllm serve "LetheanNetwork/lemrd"```</details>## Model Details| Property | Value ||----------|-------|| **Architecture** | Gemma 4 31B Dense || **Total Parameters** | 30.7B || **Layers** | 42 || **Context Length** | 256K tokens || **Vocabulary** | 262K tokens || **Modalities** | Text, Image || **Sliding Window** | 1024 tokens || **Vision Encoder** | ~550M params || **Base Model** | [LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd) || **Licence** | EUPL-1.2 |## The Lemma Family| Name | Source (BF16 weights) | Params | Context | Modalities | Consumer Repo ||------|----------------------|--------|---------|------------|---------------|| **Lemer** | [LetheanNetwork/lemer](https://huggingface.co/LetheanNetwork/lemer) | 2.3B eff | 128K | Text, Image, Audio | [lthn/lemer](https://huggingface.co/lthn/lemer) || **Lemma** | [LetheanNetwork/lemma](https://huggingface.co/LetheanNetwork/lemma) | 4.5B eff | 128K | Text, Image, Audio | [lthn/lemma](https://huggingface.co/lthn/lemma) || **Lemmy** | [LetheanNetwork/lemmy](https://huggingface.co/LetheanNetwork/lemmy) | 3.8B active | 256K | Text, Image | [lthn/lemmy](https://huggingface.co/lthn/lemmy) || **Lemrd** | [LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd) | 30.7B | 256K | Text, Image | You are here |## Capabilities- Configurable thinking mode (`<|think|>` token in system prompt enables it; off by default in our examples via `enable_thinking=False`)- Native function calling and system prompt support- Variable aspect ratio image understanding- Multilingual support (140+ languages)- Hybrid attention (sliding window + global)- Long context (256K tokens) for document-scale reasoning## RoadmapThis release of `lemrd` is **Gemma 4 31B Dense with the Lethean Ethical Kernel (LEK) merged in** — axiom-based reasoning baked into the attention weights via LoRA finetune, then merged into the base so inference uses a single standalone model with no PEFT runtime required. The unmodified Gemma 4 31B fork lives at [LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd) for users who want the raw Google weights without the LEK shift.| Phase | Status | What it adds ||-------|--------|--------------|| **Base fork** ([LetheanNetwork/lemrd](https://huggingface.co/LetheanNetwork/lemrd)) | ✅ Released | EUPL-1.2 fork of Gemma 4 31B — unmodified Google weights || **LEK merged** (this repo) | ✅ Released | Lethean Ethical Kernel — axiom-based reasoning via LoRA merge || **8-PAC eval results** | 🚧 In progress | Continuous benchmarking on the homelab, published to [lthn/LEM-benchmarks](https://huggingface.co/datasets/lthn/LEM-benchmarks) |The LEK axioms are public domain and published at [Snider/ai-ethics](https://github.com/Snider/ai-ethics). Track research progress at [LetheanNetwork](https://github.com/LetheanNetwork) and the [LEM-research dataset](https://huggingface.co/datasets/lthn/LEM-research).## Why EUPL-1.2Lemrd is licensed under the [European Union Public Licence v1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12) — not Apache 2.0 or MIT. This is a deliberate choice:- **23 official languages, one legal meaning.** EUPL is the only OSS licence designed by lawmakers across multiple legal systems. "Derivative work" means the same thing in German, French, Estonian, and Maltese law.- **Copyleft with compatibility.** Modifications must be shared back, but the licence plays cleanly with GPL, LGPL, MPL, and other major OSS licences. No accidental relicensing.- **No proprietary capture.** Anyone can use lemrd commercially — but they cannot fork it, train a competitor model on it, and close-source the result. The ethical layer stays in the open.- **Built for institutions.** Government, research, and enterprise users get a licence designed for cross-border compliance, not a US-centric one.## Recommended SamplingUse Google's standardised settings across all use cases:| Parameter | Value ||-----------|-------|| `temperature` | 1.0 || `top_p` | 0.95 || `top_k` | 64 || `stop` | `<turn|>`, `<eos>` |> Gemma 4 is calibrated for `temperature: 1.0` — this is **not** the same as the typical 0.7 default for other models. Lower values reduce diversity without improving quality. These defaults are pre-configured in the `params` file (Ollama) and `generation_config.json` (transformers/MLX).## Variable Image ResolutionGemma 4 supports a configurable visual token budget that controls how many tokens represent each image. Higher = more detail, lower = faster inference.| Token Budget | Use Case ||--------------|----------|| 70 | Classification, captioning, video frame processing || 140 | General image understanding || **280** | Default — balanced quality and speed || 560 | OCR, document parsing, fine-grained detail || 1120 | Maximum detail (small text, complex documents) |For multimodal prompts, place image content **before** text for best results.The default budget (`280`) is set in `processor_config.json` via `image_seq_length` and `max_soft_tokens`. Override per call by adjusting those fields, or by passing explicit `image_seq_length` to the processor where supported.## BenchmarksLive evaluation results published to the [LEM-benchmarks dataset](https://huggingface.co/datasets/lthn/LEM-benchmarks). The lemrd-specific results live at [LEM-benchmarks/results/lemrd](https://huggingface.co/datasets/lthn/LEM-benchmarks/tree/main/results/lemrd).The 8-PAC eval pipeline runs continuously on our homelab and publishes results as they complete. Categories: ethics, reasoning, instruction-following, coding, multilingual, safety, knowledge, creativity.## Resources| Resource | Link ||----------|------|| **Benchmark results** | [lthn/LEM-benchmarks](https://huggingface.co/datasets/lthn/LEM-benchmarks) || **LiveBench results** | [lthn/livebench](https://huggingface.co/datasets/lthn/livebench) || **Research notes** | [lthn/LEM-research](https://huggingface.co/datasets/lthn/LEM-research) || **Lemma model collection** | [lthn/lemma](https://huggingface.co/collections/lthn/lemma) |## About Lethean[Lethean](https://lthn.ai) is a social enterprise building ethical AI infrastructure. The Lemma model family is part of the [LEM (Lethean Ethical Model)](https://github.com/LetheanNetwork) project — training protocol and tooling for intrinsic ethical alignment of language models.- Website: [lthn.ai](https://lthn.ai)- GitHub: [LetheanNetwork](https://github.com/LetheanNetwork)- Licence: [EUPL-1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
README.md+351-2