Text Generation
Transformers
Safetensors
GGUF
English
gpt_bigcode
code
python
instruct
conversational
text-generation-inference
Run this model with HF Jobs
Run Kuantum-ai1/TinyCode1.2-164M-Python-Instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Kuantum-ai1/TinyCode1.2-164M-Python-Instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
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
Upload folder using huggingface_hub
Browse filesFiles changed (14)
- .gitattributes+6
- README.mdAdded+83
- TinyCode1.2-164M-Python-Instruct-Q4_0.ggufAdded+3
- TinyCode1.2-164M-Python-Instruct-Q4_K_M.ggufAdded+3
- TinyCode1.2-164M-Python-Instruct-Q4_K_S.ggufAdded+3
- TinyCode1.2-164M-Python-Instruct-Q5_K_M.ggufAdded+3
- TinyCode1.2-164M-Python-Instruct-Q6_K.ggufAdded+3
- TinyCode1.2-164M-Python-Instruct-Q8_0.ggufAdded+3
- chat_template.jinjaAdded+5
- config.jsonAdded+42
- generation_config.jsonAdded+6
- model.safetensorsAdded+3
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+33
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines33343536373839404132 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q4_0.gguf filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q6_K.gguf filter=lfs diff=lfs merge=lfs -textTinyCode1.2-164M-Python-Instruct-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283---license: bigcode-openrail-mlanguage:- enlibrary_name: transformerspipeline_tag: text-generationbase_model: Kuantum-ai1/TinyCode1.2-164M-Pythontags:- code- python- instruct---
# TinyCode1.2-164M-Python-Instruct
A small Python instruction-tuned model: [`Kuantum-ai1/TinyCode1.2-164M-Python`](https://huggingface.co/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`](https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca), [`nickrosh/Evol-Instruct-Code-80k-v1`](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1), [`bigcode/self-oss-instruct-sc2-exec-filter-50k`](https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k) and [`ise-uiuc/Magicoder-OSS-Instruct-75K`](https://huggingface.co/datasets/ise-uiuc/Magicoder-OSS-Instruct-75K), plus 8.6M tokens of plain Python from [`jon-tow/starcoderdata-python-edu`](https://huggingface.co/datasets/jon-tow/starcoderdata-python-edu) to 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.
## 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
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizertok = 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-m123version https://git-lfs.github.com/spec/v1oid sha256:f24bf8cf7fe5c72b8a66f878f3d5faf7d4e0ffcb68829d3905f0057849dc9a3esize 126018144123version https://git-lfs.github.com/spec/v1oid sha256:38d6010388d56709cd3ccf9cd626b68357fc8e6bf5da9b2dafb98661fe4a4a20size 133874784123version https://git-lfs.github.com/spec/v1oid sha256:c43e31be66b489489d4ae1e663475d18dcb6c2a79b3456391f7e47fe642db16bsize 126952032123version https://git-lfs.github.com/spec/v1oid sha256:3a64a2e0f8a8c4339282067d8137bb3fbf855e415f6ea73486cdf8ee59aa5bcasize 145056864123version https://git-lfs.github.com/spec/v1oid sha256:0f4dee5f3f7329eaf2b420c2c965f159aa5ff44c34e7d51c23c2bfb810a55ad1size 156937824123version https://git-lfs.github.com/spec/v1oid sha256:782a66ef3392b22892639bef57a1d9a0e6428618e0c044a22b3559b77b891a77size 19512585612345{% for m in messages %}{% if m['role'] == 'user' %}### Instruction:{{ m['content'] }}
### Response:{% elif m['role'] == 'assistant' %}{{ m['content'] }}{{ eos_token }}{% endif %}{% endfor %}123456789101112131415161718192021222324252627282930313233343536373839404142{ "activation_function": "gelu_pytorch_tanh", "add_cross_attention": false, "architectures": [ "GPTBigCodeForCausalLM" ], "attention_softmax_in_fp32": true, "attn_pdrop": 0.1, "bos_token_id": 0, "dtype": "float32", "embd_pdrop": 0.1, "eos_token_id": 0, "inference_runner": 0, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "max_batch_size": null, "max_sequence_length": null, "model_type": "gpt_bigcode", "multi_query": true, "n_embd": 768, "n_head": 12, "n_inner": 3072, "n_layer": 20, "n_positions": 8192, "num_key_value_heads": 1, "pad_key_length": true, "pad_token_id": null, "pre_allocate_kv_cache": false, "resid_pdrop": 0.1, "scale_attention_softmax_in_fp32": true, "scale_attn_weights": true, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "tie_word_embeddings": true, "transformers_version": "5.20.2", "use_cache": true, "validate_runner_input": true, "vocab_size": 49152}123456{ "_from_model_config": true, "bos_token_id": 0, "eos_token_id": 0, "transformers_version": "5.20.2"}123version https://git-lfs.github.com/spec/v1oid sha256:e05d9ab32cec7a93013de0ddde7f15ca4182de8f578265a091b3972e3d27fb57size 656601304123456789101112131415161718192021222324252627282930313233{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "extra_special_tokens": [ "<|endoftext|>", "<fim_prefix>", "<fim_middle>", "<fim_suffix>", "<fim_pad>", "<filename>", "<gh_stars>", "<issue_start>", "<issue_comment>", "<issue_closed>", "<jupyter_start>", "<jupyter_text>", "<jupyter_code>", "<jupyter_output>", "<empty_output>", "<commit_before>", "<commit_msg>", "<commit_after>", "<reponame>" ], "is_local": false, "local_files_only": false, "model_max_length": 1000000000000000019884624838656, "tokenizer_class": "TokenizersBackend", "unk_token": "<|endoftext|>", "vocab_size": 49152}.gitattributes+6
README.mdAdded+83
TinyCode1.2-164M-Python-Instruct-Q4_0.ggufAdded+3
TinyCode1.2-164M-Python-Instruct-Q4_K_M.ggufAdded+3
TinyCode1.2-164M-Python-Instruct-Q4_K_S.ggufAdded+3
TinyCode1.2-164M-Python-Instruct-Q5_K_M.ggufAdded+3
TinyCode1.2-164M-Python-Instruct-Q6_K.ggufAdded+3
TinyCode1.2-164M-Python-Instruct-Q8_0.ggufAdded+3
chat_template.jinjaAdded+5
config.jsonAdded+42
generation_config.jsonAdded+6
model.safetensorsAdded+3
tokenizer.jsonAdded
tokenizer_config.jsonAdded+33