Instructions to use sneedjak/Adelic-Gemma-4-31B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sneedjak/Adelic-Gemma-4-31B-it with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sneedjak/Adelic-Gemma-4-31B-it", device_map="auto") - llama-cpp-python
How to use sneedjak/Adelic-Gemma-4-31B-it with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="sneedjak/Adelic-Gemma-4-31B-it", filename="adelic-gemma4-31b-Q4_K_M.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use sneedjak/Adelic-Gemma-4-31B-it 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 sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M # Run inference directly in the terminal: llama cli -hf sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M # Run inference directly in the terminal: llama cli -hf sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
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 sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
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 sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
Use Docker
docker model run hf.co/sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use sneedjak/Adelic-Gemma-4-31B-it with Ollama:
ollama run hf.co/sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
- Unsloth Studio
How to use sneedjak/Adelic-Gemma-4-31B-it 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 sneedjak/Adelic-Gemma-4-31B-it 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 sneedjak/Adelic-Gemma-4-31B-it to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for sneedjak/Adelic-Gemma-4-31B-it to start chatting
- Atomic Chat new
- Docker Model Runner
How to use sneedjak/Adelic-Gemma-4-31B-it with Docker Model Runner:
docker model run hf.co/sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
- Lemonade
How to use sneedjak/Adelic-Gemma-4-31B-it with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sneedjak/Adelic-Gemma-4-31B-it:Q4_K_M
Run and chat with the model
lemonade run user.Adelic-Gemma-4-31B-it-Q4_K_M
List all available models
lemonade list
Adelic-Gemma-4-31B-it
This repository contains the custom Adèlic Cache topological architecture wrapper for Gemma 4 (31B Multimodal), available in uncompressed and highly-optimized quantized (Q4_K_M, Q5_K_M) GGUF formats.
By injecting the Adèlic DynamicTopologyRouter and Medoid-Value similarity clustering into the attention layers, this architecture aggressively condenses the Key-Value (KV) cache into a $p$-adic Bruhat-Tits tree. This bounds the physical VRAM footprint to $\mathcal{O}(\log N)$, allowing for infinite context length generation on consumer hardware without Out-Of-Memory (OOM) crashes.
You can run this model using two different methods:
- Natively via PyTorch/Transformers using our custom SRAM-accelerated Triton kernel patch.
- Via
llama.cppusing the pre-compiled.ggufweights, which natively incorporates the topological condensation kernel directly into the CUDA backend.
Method 1: PyTorch & Triton Patch (Native Hugging Face)
You do NOT need trust_remote_code=True because the patch applies cleanly onto native loaded models. Simply download the patch_adelic.py script from this repo and run it on your loaded model!
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import huggingface_hub
# 1. Download the Adèlic patch script
huggingface_hub.hf_hub_download(
repo_id="sneedjak/Adelic-Gemma-4-31B-it",
filename="patch_adelic.py",
local_dir="."
)
from patch_adelic import apply_adelic_topology
# 2. Load the official Gemma tokenizer and model
model_id = "google/gemma-4-31B-it"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=BitsAndBytesConfig(load_in_4bit=True),
device_map="auto"
)
# 3. Inject the Adèlic Topology (Triton Accelerated)
model = apply_adelic_topology(model)
# 4. Generate with infinite context!
prompt = "The quick brown fox jumps over the lazy dog. " * 50000
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# The KV-cache will automatically condense, preventing your GPU from crashing.
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Method 2: llama.cpp (Pre-compiled GGUF)
For maximum efficiency and consumer hardware support, we have compiled the Adèlic condensation kernel natively into a custom fork of llama.cpp and uploaded the ready-to-run .gguf files to this repository.
Available Quants
adelic-gemma4-31b.gguf(UncompressedQ8/F16Master Archive - Extremely High VRAM requirement)adelic-gemma4-31b-Q5_K_M.gguf(The "Sweet Spot" - Virtually indistinguishable from uncompressed, fits in 24GB VRAM)adelic-gemma4-31b-Q4_K_M.gguf(Fastest inference, lowest VRAM footprint)
The
.gguffiles contained in this repository require a custom fork ofllama.cppto run, as standardllama.cppdoes not have theggml_adelic_condenseCUDA kernel.
Installation
- Clone our custom
llama.cppfork containing the Adèlic kernels:
git clone -b feature/gemma4-adelic https://github.com/sneed-and-feed/llama.cpp.git
cd llama.cpp
- Compile the binary (CUDA backend strictly required for the topological kernel!):
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j 8
- Download your preferred
.ggufquantization from this Hugging Face repository.
Running Inference
Once compiled, you can run the model directly. The topology router will automatically and unconditionally mask out unneeded keys in the kq_mask on a per-layer basis using the hardware-accelerated CUDA condensation kernel!
./build/bin/llama-cli \
-m adelic-gemma4-31b-Q4_K_M.gguf \
-p "Explain the significance of the Bruhat-Tits tree in p-adic geometry." \
-n 512 \
-c 4096 \
-ngl 999 \
--color on
Performance, Fixes & Limitations
- Multimodal Hallucination Fix: The custom
llama.cppengine associated with this repository includes a hardcoded-INFINITYlogit bias suppression for Gemma 4's multimodal tokens (e.g.<image|>,<audio|>). This permanently cures the token leakage bug where Gemma models randomly hallucinate visual control tokens during long-context pure-text generation. - Semantic Fact Retrieval: On the LongBench QASPER dataset, this architecture successfully retrieved grounded facts from 10,000+ tokens away despite the massive topological compression of the KV-cache, proving that the Medoid-Value clustering strategy preserves Strict RoPE Coherence.
- Triton / CUDA Speedups: The cache condensation runs completely $\mathcal{O}(1)$ inside SRAM, avoiding thousands of slow sequential Python loops, allowing for decoding speeds up to ~50 t/s even while actively pruning the cache.
- Formatting Degradation: Because topological compression is lossy, the model's surface-level syntactic formatting (e.g., RLHF alignment
<think>tags) may degrade into a stream-of-consciousness format over extreme context lengths. While semantic facts are preserved, raw string-matching $n$-gram benchmark scores (like exact-match F1) may be lower than an uncompressed baseline.
For full mathematical proofs of the RoPE coherence under topological compression, see the paper: Llama Surgery: Injecting Differentiable p-Adic Topology into Pre-Trained LLMs.
- Downloads last month
- 87