Klea
Collection
Klea — Lightweight, frontier-class AI models. • 1 item • Updated • 1
How to use surajkumarmallick/Klea-1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="surajkumarmallick/Klea-1")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("surajkumarmallick/Klea-1")
model = AutoModelForCausalLM.from_pretrained("surajkumarmallick/Klea-1", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use surajkumarmallick/Klea-1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "surajkumarmallick/Klea-1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "surajkumarmallick/Klea-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/surajkumarmallick/Klea-1
How to use surajkumarmallick/Klea-1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "surajkumarmallick/Klea-1" \
--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": "surajkumarmallick/Klea-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "surajkumarmallick/Klea-1" \
--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": "surajkumarmallick/Klea-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use surajkumarmallick/Klea-1 with Docker Model Runner:
docker model run hf.co/surajkumarmallick/Klea-1
Klea-1 is an advanced, lightweight reasoning model developed by Suraj Kumar Mallick. It packs strong step-by-step thinking, instruction following, and long-context understanding into a footprint small enough to run on modest hardware.
| Developer | Suraj Kumar Mallick |
| Model type | Decoder-only language model, reasoning-focused |
| Total parameters | 543,456,768 (~540M) |
| Active parameters | ~430M |
| Knowledge Cutoff | Early September 2026 |
| Context window | 256K tokens |
| License | Apache 2.0 |
| Language | English |
| Stage | Phase | What happens |
|---|---|---|
| 1 | Primary pretraining | Trained on large-scale raw web text to build broad language and world knowledge. |
| 2 | Secondary pretraining | Trained on highly curated, specialized data to sharpen domain depth and quality. |
| 3 | Reasoning + instruction tuning | Fine-tuned on reasoning data with instruction following. |
| 4 | Preference tuning | Aligned with human preferences using RLHF. |
| Benchmark | Setting | Score |
|---|---|---|
| GPQA Diamond | – | 89.4 |
| HLE | – | 53.5 |
| AGIEval (EM) | 3–5-shot | 83.5 |
| C-Eval (EM) | 5-shot | 92.1 |
| HellaSwag (EM) | 0-shot | 85.0 |
| SimpleQA-Verified (EM) | 25-shot | 0.1 |
| Benchmark | Setting | Score |
|---|---|---|
| GSM8K | 8-shot | 93.5 |
| HumanEval (Pass@1) | 0-shot | 62.0 |
| Benchmark | Score |
|---|---|
| Terminal-Bench 2.1 | 76.5 |
| Terminal-Bench 3.0 | 44.0 |
| Terminal-Bench 4.0 | 58.6 |
| CyberGym | 65.5 |
| Benchmark | Setting | Score |
|---|---|---|
| LongBench-V2 (EM) | 1-shot | 44.7 |
pip install -U transformers accelerate torch
Klea-1 thinks first, then answers. Its output wraps the reasoning in <think>…</think> and the final response in <answer>…</answer>.
from transformers import AutoModelForCausalLM, AutoTokenizer
import os
import re
import torch
model_name_or_path = "surajkumarmallick/Klea-1"
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForCausalLM.from_pretrained(
model_name_or_path,
device_map="auto",
torch_dtype=torch.bfloat16
)
messages = [
{"role": "user", "content": "Write a short summary of the benefits of regular exercise"},
]
tokenized_chat = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True, # Ensure it returns a dictionary
enable_thinking=True # Toggle thinking mode (default: True)
)
# Move input dictionary keys to model device
inputs = {k: v.to(model.device) for k, v in tokenized_chat.items()}
outputs = model.generate(**inputs, max_new_tokens=2048)
output_text = tokenizer.decode(outputs[0])
print("output_text =", output_text)
think_pattern = r'<think>(.*?)</think>'
think_matches = re.findall(think_pattern, output_text, re.DOTALL)
answer_pattern = r'<answer>(.*?)</answer>'
answer_matches = re.findall(answer_pattern, output_text, re.DOTALL)
think_content = [match.strip() for match in think_matches][0] if think_matches else "No thinking process found."
answer_content = [match.strip() for match in answer_matches][0] if answer_matches else output_text
print(f"thinking_content: {think_content}\n\n")
print(f"answer_content: {answer_content}\n\n")
| Mode | How to enable |
|---|---|
| Slow thinking (default) | enable_thinking=True, or prefix the prompt with /think |
| Fast response | enable_thinking=False, or prefix the prompt with /no_think |
{
"top_k": 20,
"top_p": 0.8,
"repetition_penalty": 1.05,
"temperature": 0.7
}
For best results, use the default system prompt:
You are Klea 1, an advanced lightweight AI model developed by Suraj Kumar Mallick. Your primary goal is to assist users with their tasks accurately, clearly, and helpfully.
Klea-1 is released under the Apache License 2.0.
@misc{klea1,
title = {Klea-1: A Lightweight Reasoning Model},
author = {Suraj Kumar Mallick},
year = {2026},
howpublished = {\url{https://huggingface.co/surajkumarmallick/Klea-1}}
}
🩵 Built by Suraj Kumar Mallick 🩵