Engineered by stripping the visual transformer from
Qwen/Qwen3.5-0.8B-Base down to
752M dense parameters, QaptaanLM achieves state-of-the-art computational and memory efficiency on consumer GPUs and edge accelerators. It couples linear-complexity recurrence layers with dense multi-head attention and was trained on
KapCode-1B (1-billion-token curated code, doc, and STEM corpus with 50% Fill-in-the-Middle infilling on Google TPU v5e-8).
1generation_config = {
2 "do_sample": False, # Greedy decoding for exact deterministic code completion
3 "temperature": 0.15, # Low temperature when sampling
4 "top_p": 0.90,
5 "top_k": 40,
6 "repetition_penalty": 1.10, # Prevents repetition loops
7 "eos_token_id": [248044, 248046],# <|endoftext|> and <|im_end|>
8 "pad_token_id": 248044
9}
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "kaptaan45/QaptaanLM-0.75B"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16,
10 device_map="auto",
11 trust_remote_code=True,
12)
13
14prompt = 'def binary_search(arr: list[int], target: int) -> int:\n """Return index of target in sorted arr, or -1 if not found."""\n '
15inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
16
17with torch.no_grad():
18 outputs = model.generate(
19 **inputs,
20 max_new_tokens=64,
21 do_sample=False,
22 repetition_penalty=1.10,
23 eos_token_id=[248044, 248046],
24 )
25
26print(tokenizer.decode(outputs[0], skip_special_tokens=True))
1prefix = "def calculate_circle_area(radius: float) -> float:\n \"\"\"Compute area of circle.\"\"\"\n if radius < 0:\n raise ValueError('Radius cannot be negative')\n"
2suffix = "\n return area\n"
3
4# Format: <|fim_prefix|> Prefix <|fim_suffix|> Suffix <|fim_middle|>
5fim_prompt = f"<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>"
6inputs = tokenizer(fim_prompt, return_tensors="pt").to(model.device)
7
8with torch.no_grad():
9 outputs = model.generate(
10 **inputs,
11 max_new_tokens=48,
12 do_sample=False,
13 eos_token_id=tokenizer.convert_tokens_to_ids("<|fim_middle|>"),
14 )
15
16infilled = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
17print("Infilled Code:\n", infilled)
Trained on
KapCode-1B (1,000,013,824 tokens) across 5 curated domains:
Released under the
Apache 2.0 License. Upstream base model weights and architecture adapted from
Qwen/Qwen3.5-0.8B-Base by the Qwen Team (Alibaba Cloud).