Text Generation
Transformers
Safetensors
GGUF
English
gpt_bigcode
code
python
reasoning
conversational
text-generation-inference
Instructions to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Kuantum-ai1/TinyCode1.1-164M-Python-Thinking") 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.1-164M-Python-Thinking") model = AutoModelForCausalLM.from_pretrained("Kuantum-ai1/TinyCode1.1-164M-Python-Thinking", 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.1-164M-Python-Thinking 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.1-164M-Python-Thinking:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kuantum-ai1/TinyCode1.1-164M-Python-Thinking: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.1-164M-Python-Thinking:Q4_K_M # Run inference directly in the terminal: llama cli -hf Kuantum-ai1/TinyCode1.1-164M-Python-Thinking: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.1-164M-Python-Thinking:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
Use Docker
docker model run hf.co/Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Kuantum-ai1/TinyCode1.1-164M-Python-Thinking" # 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.1-164M-Python-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
- SGLang
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking 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.1-164M-Python-Thinking" \ --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.1-164M-Python-Thinking", "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.1-164M-Python-Thinking" \ --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.1-164M-Python-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with Ollama:
ollama run hf.co/Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with Docker Model Runner:
docker model run hf.co/Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
- Lemonade
How to use Kuantum-ai1/TinyCode1.1-164M-Python-Thinking with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Kuantum-ai1/TinyCode1.1-164M-Python-Thinking:Q4_K_M
Run and chat with the model
lemonade run user.TinyCode1.1-164M-Python-Thinking-Q4_K_M
List all available models
lemonade list
- Atomic Chat
TinyCode1.1-164M-Python-Thinking
Browse files- README.md +79 -0
- chat_template.jinja +5 -0
- config.json +42 -0
- generation_config.json +6 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +33 -0
README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: bigcode-openrail-m
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: Kuantum-ai1/TinyCode1.1-164M-Python-Instruct
|
| 8 |
+
tags:
|
| 9 |
+
- code
|
| 10 |
+
- python
|
| 11 |
+
- reasoning
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# TinyCode1.1-164M-Python-Thinking
|
| 15 |
+
|
| 16 |
+
A small Python model that writes a short reasoning block (`<think> ... </think>`, at most 1000 tokens in training) before its code. [`Kuantum-ai1/TinyCode1.1-164M-Python-Instruct`](https://huggingface.co/Kuantum-ai1/TinyCode1.1-164M-Python-Instruct) fine-tuned for 1 epochs on about 21M tokens.
|
| 17 |
+
|
| 18 |
+
## Prompt format
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
### Instruction:
|
| 22 |
+
{your request}
|
| 23 |
+
|
| 24 |
+
### Response:
|
| 25 |
+
<think>
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
Pre-fill `<think>\n`. The model writes its reasoning, `</think>`, one fenced Python block, then EOS.
|
| 29 |
+
|
| 30 |
+
## Training
|
| 31 |
+
|
| 32 |
+
- Base: `Kuantum-ai1/TinyCode1.1-164M-Python-Instruct`
|
| 33 |
+
- Thinking data (15.0M tokens): [`KodCode/KodCode-V1-SFT-R1`](https://huggingface.co/datasets/KodCode/KodCode-V1-SFT-R1) (`train` split), only samples whose reasoning is 10-1000 tokens, with a valid Python answer. KodCode is CC BY-NC 4.0: check the license before commercial use.
|
| 34 |
+
- Replay data (6.0M tokens, same sources as the Instruct model): python_code_instructions_18k_alpaca, Evol-Instruct-Code-80k, self-oss-instruct-sc2-exec-filter-50k, Magicoder-OSS-Instruct-75K (answer only, no reasoning) and plain Python from starcoderdata-python-edu.
|
| 35 |
+
- Filtering: `ast.parse`, length limits, and removal of any sample sharing a normalized 40+ char line with any MBPP split or containing an MBPP task description. Loss only on the response.
|
| 36 |
+
- Hardware: 2x T4 (DDP, fp16 mixed precision), sequence length 2048, batch 32k tokens, peak LR 2e-05, cosine schedule.
|
| 37 |
+
|
| 38 |
+
## Evaluation
|
| 39 |
+
|
| 40 |
+
MBPP (500 test problems), greedy decoding, pass@1 (%), zero-shot with the task and the first test in the prompt. The Thinking model is given `<think>\n` and up to 2048 new tokens (reasoning + code, capped by the 2048-token context); the others use up to 200 new tokens. Same unit-test harness for all rows; other rows come from earlier runs.
|
| 41 |
+
|
| 42 |
+
| Model | Params | MBPP |
|
| 43 |
+
|---|---|---|
|
| 44 |
+
| Kuantum-ai1/TinyCode1.1-164M-Python-Instruct (raw prompt) | 164M | 12.6 |
|
| 45 |
+
| Kuantum-ai1/TinyCode1.1-164M-Python-Instruct (instruct template) | 164M | 12.0 |
|
| 46 |
+
| Kuantum-ai1/TinyCode1.1-164M-Python (previous) | 164M | 9.8 |
|
| 47 |
+
| Base: bigcode/tiny_starcoder_py | 164M | 4.8 |
|
| 48 |
+
| Kuantum-ai1/TinyCode1.1-164M-Python-Thinking (thinking, prefilled `<think>`) | 164M | 4.6 |
|
| 49 |
+
|
| 50 |
+
## GGUF
|
| 51 |
+
|
| 52 |
+
- `TinyCode1.1-164M-Python-Thinking-Q8_0.gguf` (186 MB)
|
| 53 |
+
- `TinyCode1.1-164M-Python-Thinking-Q6_K.gguf` (149 MB)
|
| 54 |
+
- `TinyCode1.1-164M-Python-Thinking-Q5_K_M.gguf` (138 MB)
|
| 55 |
+
- `TinyCode1.1-164M-Python-Thinking-Q4_K_M.gguf` (127 MB)
|
| 56 |
+
- `TinyCode1.1-164M-Python-Thinking-Q4_K_S.gguf` (121 MB)
|
| 57 |
+
- `TinyCode1.1-164M-Python-Thinking-Q4_0.gguf` (120 MB)
|
| 58 |
+
|
| 59 |
+
## Usage
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 63 |
+
tok = AutoTokenizer.from_pretrained("Kuantum-ai1/TinyCode1.1-164M-Python-Thinking")
|
| 64 |
+
model = AutoModelForCausalLM.from_pretrained("Kuantum-ai1/TinyCode1.1-164M-Python-Thinking")
|
| 65 |
+
msgs = [{"role": "user", "content": "Write a function that returns the n-th Fibonacci number."}]
|
| 66 |
+
prompt = tok.apply_chat_template(msgs, tokenize=False) + "<think>\n"
|
| 67 |
+
ids = tok(prompt, return_tensors="pt")
|
| 68 |
+
out = model.generate(**ids, max_new_tokens=1500, do_sample=False)
|
| 69 |
+
text = tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 70 |
+
print(text.split("</think>")[-1].split("```python")[-1].split("\n```")[0])
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Limitations
|
| 74 |
+
|
| 75 |
+
Small model (2048-token context): frequent mistakes, and its short reasoning is not reliable. Review generated code before use.
|
| 76 |
+
|
| 77 |
+
## License
|
| 78 |
+
|
| 79 |
+
bigcode-openrail-m (see the KodCode note above).
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for m in messages %}{% if m['role'] == 'user' %}### Instruction:
|
| 2 |
+
{{ m['content'] }}
|
| 3 |
+
|
| 4 |
+
### Response:
|
| 5 |
+
{% elif m['role'] == 'assistant' %}{{ m['content'] }}{{ eos_token }}{% endif %}{% endfor %}
|
config.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_pytorch_tanh",
|
| 3 |
+
"add_cross_attention": false,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"GPTBigCodeForCausalLM"
|
| 6 |
+
],
|
| 7 |
+
"attention_softmax_in_fp32": true,
|
| 8 |
+
"attn_pdrop": 0.1,
|
| 9 |
+
"bos_token_id": 0,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"embd_pdrop": 0.1,
|
| 12 |
+
"eos_token_id": 0,
|
| 13 |
+
"inference_runner": 0,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"layer_norm_epsilon": 1e-05,
|
| 16 |
+
"max_batch_size": null,
|
| 17 |
+
"max_sequence_length": null,
|
| 18 |
+
"model_type": "gpt_bigcode",
|
| 19 |
+
"multi_query": true,
|
| 20 |
+
"n_embd": 768,
|
| 21 |
+
"n_head": 12,
|
| 22 |
+
"n_inner": 3072,
|
| 23 |
+
"n_layer": 20,
|
| 24 |
+
"n_positions": 8192,
|
| 25 |
+
"num_key_value_heads": 1,
|
| 26 |
+
"pad_key_length": true,
|
| 27 |
+
"pad_token_id": null,
|
| 28 |
+
"pre_allocate_kv_cache": false,
|
| 29 |
+
"resid_pdrop": 0.1,
|
| 30 |
+
"scale_attention_softmax_in_fp32": true,
|
| 31 |
+
"scale_attn_weights": true,
|
| 32 |
+
"summary_activation": null,
|
| 33 |
+
"summary_first_dropout": 0.1,
|
| 34 |
+
"summary_proj_to_labels": true,
|
| 35 |
+
"summary_type": "cls_index",
|
| 36 |
+
"summary_use_proj": true,
|
| 37 |
+
"tie_word_embeddings": true,
|
| 38 |
+
"transformers_version": "5.20.2",
|
| 39 |
+
"use_cache": false,
|
| 40 |
+
"validate_runner_input": true,
|
| 41 |
+
"vocab_size": 49152
|
| 42 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 0,
|
| 5 |
+
"transformers_version": "5.20.2"
|
| 6 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d55974b00355cd21fea86337bacd03669fad0be7343df9b83b01ea99abdc269c
|
| 3 |
+
size 656601304
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"extra_special_tokens": [
|
| 7 |
+
"<|endoftext|>",
|
| 8 |
+
"<fim_prefix>",
|
| 9 |
+
"<fim_middle>",
|
| 10 |
+
"<fim_suffix>",
|
| 11 |
+
"<fim_pad>",
|
| 12 |
+
"<filename>",
|
| 13 |
+
"<gh_stars>",
|
| 14 |
+
"<issue_start>",
|
| 15 |
+
"<issue_comment>",
|
| 16 |
+
"<issue_closed>",
|
| 17 |
+
"<jupyter_start>",
|
| 18 |
+
"<jupyter_text>",
|
| 19 |
+
"<jupyter_code>",
|
| 20 |
+
"<jupyter_output>",
|
| 21 |
+
"<empty_output>",
|
| 22 |
+
"<commit_before>",
|
| 23 |
+
"<commit_msg>",
|
| 24 |
+
"<commit_after>",
|
| 25 |
+
"<reponame>"
|
| 26 |
+
],
|
| 27 |
+
"is_local": true,
|
| 28 |
+
"local_files_only": false,
|
| 29 |
+
"model_max_length": 2048,
|
| 30 |
+
"tokenizer_class": "TokenizersBackend",
|
| 31 |
+
"unk_token": "<|endoftext|>",
|
| 32 |
+
"vocab_size": 49152
|
| 33 |
+
}
|