Instructions to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kuantum-ai1/TinyCode1.2-164M-Python-Instruct") 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("Kuantum-ai1/TinyCode1.2-164M-Python-Instruct") model = AutoModelForCausalLM.from_pretrained("Kuantum-ai1/TinyCode1.2-164M-Python-Instruct", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
Use Docker
docker model run hf.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
- SGLang
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct 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 "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct" \ --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": "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct", "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 "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct" \ --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": "Kuantum-ai1/TinyCode1.2-164M-Python-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with Ollama:
ollama run hf.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with Docker Model Runner:
docker model run hf.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
- Lemonade
How to use Kuantum-ai1/TinyCode1.2-164M-Python-Instruct with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Kuantum-ai1/TinyCode1.2-164M-Python-Instruct:Q4_K_M
Run and chat with the model
lemonade run user.TinyCode1.2-164M-Python-Instruct-Q4_K_M
List all available models
lemonade list
- Atomic Chat
TinyCode1.2-164M-Python-Instruct
A small Python instruction-tuned model: Kuantum-ai1/TinyCode1.2-164M-Python fine-tuned on 30M tokens (2 epochs) of Python instruction pairs plus plain Python code. It answers a request with one fenced Python code block.
Prompt format
### Instruction:
{your request}
### Response:
```python
The model writes the code and a closing code fence, then stops (EOS). tokenizer.apply_chat_template produces this format. Pre-filling the opening code fence (see Usage) works best.
Training
- Base model:
Kuantum-ai1/TinyCode1.2-164M-Python - Data (30M tokens): 21.4M tokens of instruction pairs (response = the Python code block of the answer; loss only on the response) from
iamtarun/python_code_instructions_18k_alpaca,nickrosh/Evol-Instruct-Code-80k-v1,bigcode/self-oss-instruct-sc2-exec-filter-50kandise-uiuc/Magicoder-OSS-Instruct-75K, plus 8.6M tokens of plain Python fromjon-tow/starcoderdata-python-eduto keep completion ability. Several of these datasets are LLM-generated; check their licenses before commercial use. - Filtering: valid Python (
ast.parse), length and line-length limits, alphabetic-ratio check, exact deduplication, and removal of any sample that shares a normalized line (40+ chars, imports excluded) with HumanEval, any MBPP split or BigCodeBench, or contains an MBPP task description (1217 candidate samples removed). The packed data was re-scanned after tokenization as a final check. - Hardware: 2x NVIDIA T4 (DDP, fp16 mixed precision), sequence length 1024, batch 32k tokens, peak LR 2e-05, cosine schedule
Evaluation
Greedy decoding for pass@1 (%), identical harness for every row (max 200 new tokens). MBPP (500 test problems) is zero-shot with the task and the first test in the prompt; the "instruct template" row wraps the same prompt in the training format. MBPP pass@3 uses the unbiased estimator of Chen et al. (2021) from 5 sampled completions per problem (temperature 0.8, top_p 0.95). This is a lightweight harness (asserts run in a subprocess, 10 s timeout, only the libraries preinstalled on Kaggle, prompts longer than the 1024-token context count as failed).
| Model | Params | MBPP pass@1 | MBPP pass@3 |
|---|---|---|---|
| Kuantum-ai1/TinyCode1.2-164M-Python-Instruct (raw prompt) | 164M | 14.0 | 19.84 |
| Kuantum-ai1/TinyCode1.2-164M-Python-Instruct (instruct template) | 164M | 13.0 | 18.7 |
| Kuantum-ai1/TinyCode1.2-164M-Python (previous) | 164M | 8.8 | 13.56 |
| Base: bigcode/tiny_starcoder_py | 164M | 4.8 | - |
Instruct (template) vs the previous version: MBPP pass@1 +4.20, pass@3 +5.14 (absolute points).
The base row's MBPP pass@1 comes from an earlier run of the same harness; pass@3 was not measured for it.
MBPP+
MBPP+ (378 problems, EvalPlus extended tests), same prompts and decoding as the MBPP table above: pass@1 is greedy, pass@3 is the unbiased estimator from 5 samples (temperature 0.8, top_p 0.95), max 200 new tokens. A problem counts only if the code passes all extended tests (20 s timeout). This is a lightweight harness, not the official EvalPlus pipeline, so the numbers are not directly comparable with the EvalPlus leaderboard. The reference solutions pass 99.7% of the problems in this harness.
| Model | Params | MBPP+ pass@1 | MBPP+ pass@3 |
|---|---|---|---|
| Kuantum-ai1/TinyCode1.2-164M-Python-Instruct (raw prompt) | 164M | 19.31 | 21.67 |
| Kuantum-ai1/TinyCode1.2-164M-Python-Instruct (instruct template) | 164M | 16.93 | 23.12 |
| Kuantum-ai1/TinyCode1.2-164M-Python (previous) | 164M | 11.9 | 16.06 |
| Base: bigcode/tiny_starcoder_py | 164M | 7.94 | 8.68 |
Instruct (template) vs the previous version: MBPP+ pass@1 +5.03, pass@3 +7.06 (absolute points).
GGUF
TinyCode1.2-164M-Python-Instruct-Q4_0.gguf(126 MB)TinyCode1.2-164M-Python-Instruct-Q4_K_M.gguf(134 MB)TinyCode1.2-164M-Python-Instruct-Q4_K_S.gguf(127 MB)TinyCode1.2-164M-Python-Instruct-Q5_K_M.gguf(145 MB)TinyCode1.2-164M-Python-Instruct-Q6_K.gguf(157 MB)TinyCode1.2-164M-Python-Instruct-Q8_0.gguf(195 MB)
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Kuantum-ai1/TinyCode1.2-164M-Python-Instruct")
model = AutoModelForCausalLM.from_pretrained("Kuantum-ai1/TinyCode1.2-164M-Python-Instruct")
msgs = [{"role": "user", "content": "Write a function that returns the n-th Fibonacci number."}]
prompt = tok.apply_chat_template(msgs, tokenize=False) + "```python\n"
ids = tok(prompt, return_tensors="pt")
out = model.generate(**ids, max_new_tokens=200, do_sample=False)
print(tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True).split("\n```")[0])
Limitations
Small model: it makes frequent mistakes and should not be relied on for production code. It only answers with Python code (no explanations) and has a 1024-token context. Generated code must be reviewed before use.
License
bigcode-openrail-m
- Downloads last month
- -
Model tree for Kuantum-ai1/TinyCode1.2-164M-Python-Instruct
Base model
bigcode/tiny_starcoder_py