Text Generation
Transformers
Safetensors
qwen2
code
c
linux-kernel
python
conversational
text-generation-inference
Instructions to use nethunter2023/kernel-coder-1.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nethunter2023/kernel-coder-1.5b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nethunter2023/kernel-coder-1.5b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nethunter2023/kernel-coder-1.5b") model = AutoModelForCausalLM.from_pretrained("nethunter2023/kernel-coder-1.5b", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nethunter2023/kernel-coder-1.5b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nethunter2023/kernel-coder-1.5b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nethunter2023/kernel-coder-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nethunter2023/kernel-coder-1.5b
- SGLang
How to use nethunter2023/kernel-coder-1.5b 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 "nethunter2023/kernel-coder-1.5b" \ --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": "nethunter2023/kernel-coder-1.5b", "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 "nethunter2023/kernel-coder-1.5b" \ --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": "nethunter2023/kernel-coder-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nethunter2023/kernel-coder-1.5b with Docker Model Runner:
docker model run hf.co/nethunter2023/kernel-coder-1.5b
Add code-model baselines, confidence intervals, and paired test
Browse files
README.md
CHANGED
|
@@ -12,11 +12,9 @@ pipeline_tag: text-generation
|
|
| 12 |
|
| 13 |
# kernel-coder-1.5b
|
| 14 |
|
| 15 |
-
A 1.5B code model
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
conventions enforced in kernel review: tab indentation, brace placement,
|
| 19 |
-
declarations before statements, `-ERRNO` returns, and `goto` label unwinding.
|
| 20 |
|
| 21 |
## Usage
|
| 22 |
|
|
@@ -41,23 +39,58 @@ print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))
|
|
| 41 |
Chat template ships with the tokenizer. Greedy decoding; the answer is the last
|
| 42 |
fenced code block.
|
| 43 |
|
| 44 |
-
## Results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|---|---|---|---|
|
| 51 |
-
| checkpatch defects / line β | 0.872 | **0.020** | 0.017 |
|
| 52 |
-
| checkpatch errors, mean β | 5.58 | **0.00** | 0.00 |
|
| 53 |
-
| style score β | 0.211 | **0.968** | 0.977 |
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
| |
|
| 58 |
|---|---|---|
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
The kernel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
Base model: [`Qwen/Qwen2.5-Coder-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
|
|
|
|
| 12 |
|
| 13 |
# kernel-coder-1.5b
|
| 14 |
|
| 15 |
+
A 1.5B code model that writes **C in Linux kernel style** β tab indentation,
|
| 16 |
+
brace placement, declarations before statements, `-ERRNO` returns, `goto` label
|
| 17 |
+
unwinding β while keeping the base model's Python ability.
|
|
|
|
|
|
|
| 18 |
|
| 19 |
## Usage
|
| 20 |
|
|
|
|
| 39 |
Chat template ships with the tokenizer. Greedy decoding; the answer is the last
|
| 40 |
fenced code block.
|
| 41 |
|
| 42 |
+
## Results β kernel C style
|
| 43 |
+
|
| 44 |
+
**N = 40** held-out kernel-doc tasks, greedy decoding, scored with the kernel's
|
| 45 |
+
own `scripts/checkpatch.pl --no-tree --file --strict`, reported as weighted
|
| 46 |
+
defects per line: `(2*errors + warnings + 0.5*checks) / lines`. All models were
|
| 47 |
+
given the identical prompts and scored by identical code.
|
| 48 |
+
|
| 49 |
+
| | params | defects / line β | 95% CI | checkpatch errors β | idiom β |
|
| 50 |
+
|---|---|---|---|---|---|
|
| 51 |
+
| deepseek-coder-1.3b-instruct | 1.3B | 0.679 | Β±0.196 | 4.43 | 0.738 |
|
| 52 |
+
| Qwen2.5-Coder-3B-Instruct | 3B | 0.750 | Β±0.182 | 4.78 | 0.755 |
|
| 53 |
+
| Qwen2.5-Coder-1.5B-Instruct *(base)* | 1.5B | 0.872 | Β±0.185 | 5.58 | 0.664 |
|
| 54 |
+
| **kernel-coder-1.5b** | **1.5B** | **0.020** | **Β±0.012** | **0.00** | **0.995** |
|
| 55 |
+
| *the kernel's own code* | β | *0.017* | β | *0.00* | *1.000* |
|
| 56 |
|
| 57 |
+
Against `Qwen2.5-Coder-3B-Instruct` β twice the parameters β the paired
|
| 58 |
+
difference is **β0.73 defects/line**, 95% CI [β0.91, β0.55], t = β7.87, lower on
|
| 59 |
+
**33 of 40** tasks. No general-purpose code model tested comes close, and this
|
| 60 |
+
model sits within noise of the kernel's own source.
|
| 61 |
|
| 62 |
+
## Results β Python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
MBPP `test`, 200 problems, greedy, executing the dataset's assertions.
|
| 65 |
|
| 66 |
+
| | params | pass@1 |
|
| 67 |
|---|---|---|
|
| 68 |
+
| deepseek-coder-1.3b-instruct | 1.3B | 0.250 |
|
| 69 |
+
| **kernel-coder-1.5b** | 1.5B | **0.420** |
|
| 70 |
+
| Qwen2.5-Coder-1.5B-Instruct *(base)* | 1.5B | 0.420 |
|
| 71 |
+
| Qwen2.5-Coder-3B-Instruct | 3B | 0.535 |
|
| 72 |
+
|
| 73 |
+
Python is unchanged from base β the kernel specialisation cost nothing, and
|
| 74 |
+
gained nothing, here. A 3B model is still better at general Python.
|
| 75 |
+
|
| 76 |
+
If you re-run MBPP, strip the trailing `print(...)` / `assert` / `__main__`
|
| 77 |
+
statements the model appends after the function before executing. They run at
|
| 78 |
+
import time and abort otherwise-correct solutions; leaving them in costs roughly
|
| 79 |
+
3 points.
|
| 80 |
+
|
| 81 |
+
## Limitations
|
| 82 |
|
| 83 |
+
- **The kernel gains are stylistic and structural, not functional.** Kernel code
|
| 84 |
+
cannot be executed in a sandbox, so nothing here measures semantic
|
| 85 |
+
correctness. A well-formatted stub and a working implementation score alike.
|
| 86 |
+
Review output before use.
|
| 87 |
+
- **A large share of the checkpatch improvement is indentation.** The base model
|
| 88 |
+
indents kernel C with spaces; this one uses tabs, and checkpatch flags every
|
| 89 |
+
space-indented line.
|
| 90 |
+
- **Roughly half of kernel completions** leave part of the body as placeholder
|
| 91 |
+
comments rather than a full implementation β a rate unchanged from base.
|
| 92 |
+
- **N = 40** on the kernel evaluation. The margin over the baselines is large
|
| 93 |
+
relative to that, but finer distinctions would need a bigger set.
|
| 94 |
+
- Training methodology is not published.
|
| 95 |
|
| 96 |
Base model: [`Qwen/Qwen2.5-Coder-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
|