Instructions to use Project-KERN/KERN-Lab-0.5-624M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Project-KERN/KERN-Lab-0.5-624M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Project-KERN/KERN-Lab-0.5-624M", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Project-KERN/KERN-Lab-0.5-624M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Project-KERN/KERN-Lab-0.5-624M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Project-KERN/KERN-Lab-0.5-624M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Project-KERN/KERN-Lab-0.5-624M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Project-KERN/KERN-Lab-0.5-624M
- SGLang
How to use Project-KERN/KERN-Lab-0.5-624M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Project-KERN/KERN-Lab-0.5-624M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Project-KERN/KERN-Lab-0.5-624M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Project-KERN/KERN-Lab-0.5-624M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Project-KERN/KERN-Lab-0.5-624M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Project-KERN/KERN-Lab-0.5-624M with Docker Model Runner:
docker model run hf.co/Project-KERN/KERN-Lab-0.5-624M
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Project-KERN/KERN-Lab-0.5-624M", trust_remote_code=True, device_map="auto")KERN-Lab-0.5-624M
An experimental Project KERN adaptation for text continuation. It replaces one feed-forward block of Qwen3-0.6B-Base with a sparse mixture of experts and retains the upstream tokenizer and the rest of the pretrained backbone.
| Property | Value |
|---|---|
| Public model name | KERN-Lab-0.5-624M |
| Unique resident parameters | 624,364,544 |
| Active parameters per token (counting convention) | 614,927,360 |
| Transformer layers | 28 |
| Base / tokenizer | Qwen3-0.6B-Base, original tokenizer |
| Sparse block | Zero-based layer 14, one shared expert and three routed experts, top-2 |
| Weight precision | BF16, with an FP32 router |
| Configured context | 32,768 tokens, inherited from Qwen |
| Adaptation | 200 optimizer steps, 203,948 useful tokens |
| License | Apache-2.0 |
The 624M model name uses a rounded family label. The table gives exact counts.
Development results
Bits per UTF-8 byte (BPB), lower is better. The development samples contain 45,088 bytes (A) and 262,144 bytes (B). Set B was used to select the checkpoint.
| Model | Set A BPB | Set B BPB |
|---|---|---|
| Original Qwen | 0.728382 | 1.091826 |
| Trained dense control | 0.720180 | 1.090734 |
| KERN MoE seed 42 (release checkpoint) | 0.720886 | 1.088243 |
| KERN MoE seed 1337 | 0.720581 | 1.088777 |
The result on B is a development observation. An independent final test would be needed to establish a general quality gain. The 155 passing tests were from the project's internal engineering suite. Short generation and KV-cache checks cover their tested inputs. Long-context quality, overall reasoning gains, runtime speedups and semantic expert specialization remain unverified.
Run the model
Open the Google Colab notebook for a guided setup. For a local run, use Python 3.12 and install PyTorch for your platform. Choose the CUDA build to run on an NVIDIA GPU.
python -m pip install "huggingface_hub>=1.0"
hf download Project-KERN/KERN-Lab-0.5-624M --local-dir ./model
python -m pip install -r model/requirements.txt
python model/generate.py --model-dir ./model --prompt "The capital of France is" --max-new-tokens 16 --device cpu --dtype float32
For GPU, change the last two options to --device cuda --dtype bfloat16 on a BF16-capable NVIDIA GPU. Use --dtype float32 for GPU devices without BF16 support. Treat the prompt as a text prefix for the base model.
Transformers AutoClass
AutoClass reconstructs the sparse layer using the model repository's Python module. Review that module and set trust_remote_code=True for the reviewed snapshot. The example below uses the downloaded local copy. For a reproducible download, pass --revision with the Hub commit SHA to hf download.
import torch
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
path = "./model"
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" and torch.cuda.is_bf16_supported() else torch.float32
config = AutoConfig.from_pretrained(path, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(path, config=config, local_files_only=True)
model = AutoModelForCausalLM.from_pretrained(
path, config=config, dtype=dtype, trust_remote_code=True, local_files_only=True
).to(device).eval()
inputs = tokenizer("The capital of France is", return_tensors="pt").to(device)
with torch.inference_mode():
generated = model.generate(**inputs, max_new_tokens=16, do_sample=False, use_cache=True)
print(tokenizer.decode(generated[0, inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Optional local web interface
python -m pip install -r model/requirements-ui.txt
python model/app.py --model-dir ./model --device auto
Open the localhost URL printed by Gradio. One text box accepts a prefix and returns its continuation.
Scope and provenance
This is an experimental base model for text continuation. It has no instruction tuning or chat alignment. Outputs can be incorrect, repetitive, or unsafe. Review outputs before relying on them.
The pinned upstream revision is da87bfb608c14b7cf20ba1ce41287e8de496c0cd. The approved release weights have SHA-256 cc1ac73225ccc6013b1e73d91a6299078f7acd1b67940bf5277328dac43b0fd2. See NOTICE for source attribution and modifications, LICENSE for license terms, and TRADEMARK.md for guidance on the Project KERN name.
- Downloads last month
- 37
Model tree for Project-KERN/KERN-Lab-0.5-624M
Base model
Qwen/Qwen3-0.6B-Base
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Project-KERN/KERN-Lab-0.5-624M", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)