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
results, no methodology
Browse files
README.md
CHANGED
|
@@ -14,6 +14,12 @@ pipeline_tag: text-generation
|
|
| 14 |
|
| 15 |
A 1.5B code model for writing **C in Linux kernel style**, and Python.
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
```python
|
| 18 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 19 |
|
|
@@ -33,6 +39,25 @@ print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))
|
|
| 33 |
```
|
| 34 |
|
| 35 |
Chat template ships with the tokenizer. Greedy decoding; the answer is the last
|
| 36 |
-
fenced code block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
Base model: [`Qwen/Qwen2.5-Coder-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
|
|
|
|
| 14 |
|
| 15 |
A 1.5B code model for writing **C in Linux kernel style**, and Python.
|
| 16 |
|
| 17 |
+
Given a description and a signature it produces kernel C following the
|
| 18 |
+
conventions enforced in kernel review: tab indentation, brace placement,
|
| 19 |
+
declarations before statements, `-ERRNO` returns, and `goto` label unwinding.
|
| 20 |
+
|
| 21 |
+
## Usage
|
| 22 |
+
|
| 23 |
```python
|
| 24 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 25 |
|
|
|
|
| 39 |
```
|
| 40 |
|
| 41 |
Chat template ships with the tokenizer. Greedy decoding; the answer is the last
|
| 42 |
+
fenced code block.
|
| 43 |
+
|
| 44 |
+
## Results
|
| 45 |
+
|
| 46 |
+
Kernel C style, measured with the kernel's own `checkpatch.pl` on 40 held-out
|
| 47 |
+
tasks. `reference` is the kernel's own implementation of the same functions.
|
| 48 |
+
|
| 49 |
+
| | base | this model | reference |
|
| 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 |
+
Python, MBPP test (200 problems):
|
| 56 |
+
|
| 57 |
+
| | base | this model |
|
| 58 |
+
|---|---|---|
|
| 59 |
+
| pass@1 | 0.420 | 0.420 |
|
| 60 |
+
|
| 61 |
+
The kernel-side gains are stylistic; Python correctness is unchanged from base.
|
| 62 |
|
| 63 |
Base model: [`Qwen/Qwen2.5-Coder-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct)
|