finnvoorhees commited on
Commit
de9221d
·
verified ·
1 Parent(s): a4264be

Training in progress, step 90

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,105 +1,58 @@
1
- # Tiny Coder Prompt Completion 0.5B
 
 
 
 
 
 
 
 
 
2
 
3
- A tiny model (~494M parameters, ~942MB weights) for **prompt autocomplete** in agentic coding editors like Claude Code, Codex CLI, aider, etc.
4
 
5
- ## What it does
 
6
 
7
- When you're typing a prompt to an AI coding agent, this model suggests how to **complete your thought**. For example:
8
-
9
- - `fix the bug in src/utils` → `.py where the auth token isn't refreshing`
10
- - `refactor the database` → `connection logic to use connection pooling`
11
- - `implement caching for the` → `user profile endpoint using Redis with a 5-minute TTL`
12
-
13
- ## Base Model
14
-
15
- This is a fine-tuned version of [Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct), which was purpose-built for code completion.
16
-
17
- ## On-Device Requirements
18
-
19
- - **RAM**: ~1GB for fp16 inference (easily fits in 16GB MacBooks)
20
- - **Disk**: ~1GB for model weights
21
- - **CPU/GPU**: Works great on CPU (M1/M2/M3 MacBooks), even better with GPU
22
-
23
- ## Quick Start
24
-
25
- ### Python (transformers)
26
 
27
  ```python
28
- from transformers import AutoTokenizer, AutoModelForCausalLM
29
- import torch
30
-
31
- model_id = "finnvoorhees/tiny-coder-prompt-completion-0.5B"
32
- tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
33
- model = AutoModelForCausalLM.from_pretrained(
34
- model_id,
35
- trust_remote_code=True,
36
- torch_dtype=torch.bfloat16,
37
- device_map="auto",
38
- )
39
-
40
- def complete_prompt(prompt: str) -> str:
41
- messages = [
42
- {"role": "system", "content": "You are a helpful coding assistant. Complete the user's partial prompt concisely."},
43
- {"role": "user", "content": prompt},
44
- ]
45
- inputs = tokenizer.apply_chat_template(
46
- messages,
47
- tokenize=True,
48
- return_tensors="pt",
49
- return_dict=True,
50
- add_generation_prompt=True,
51
- ).to(model.device)
52
-
53
- outputs = model.generate(
54
- **inputs,
55
- max_new_tokens=32,
56
- temperature=0.3,
57
- top_p=0.9,
58
- do_sample=True,
59
- )
60
-
61
- new_tokens = outputs[0][inputs["input_ids"].shape[1]:]
62
- return tokenizer.decode(new_tokens, skip_special_tokens=True).strip()
63
 
64
- print(complete_prompt("refactor the database"))
65
- # "connection logic to use connection pooling instead of creating new connections each time"
 
 
66
  ```
67
 
68
- ### Even smaller: GGUF / llama.cpp
69
 
70
- For ultra-fast CPU inference, convert to GGUF (Q4_K_M quantization → ~300MB):
71
 
72
- ```bash
73
- # Install llama.cpp
74
- brew install llama.cpp
75
 
76
- # Convert to GGUF (or download from the GGUF tag on this repo)
77
- python convert_hf_to_gguf.py finnvoorhees/tiny-coder-prompt-completion-0.5B --outfile tiny-coder-0.5b-Q4_K_M.gguf
78
 
79
- # Run inference
80
- llama-cli -m tiny-coder-0.5b-Q4_K_M.gguf -p "fix the bug in src/utils"
81
- ```
82
 
83
- ## Integration with Agentic Editors
84
 
85
- ### Claude Code
86
- Create a shell script that calls this model and pipe completions into your prompt:
 
 
 
87
 
88
- ```bash
89
- # ~/.claude-complete.sh
90
- python -c "from transformers import pipeline; print(pipeline('text-generation', model='finnvoorhees/tiny-coder-prompt-completion-0.5B')('$1'))"
91
- ```
92
 
93
- ### Codex CLI / aider
94
- Set up a local API endpoint using `transformers` or `llama.cpp` server mode:
95
 
96
- ```bash
97
- # llama.cpp server (fast!)
98
- llama-server -m tiny-coder-0.5b-Q4_K_M.gguf --port 8080
99
 
100
- # Then use http://localhost:8080/v1/completions in your editor
101
- ```
102
-
103
- ## License
104
-
105
- Apache-2.0 (same as the base Qwen2.5-Coder-0.5B-Instruct model)
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-Coder-0.5B-Instruct
3
+ library_name: transformers
4
+ model_name: tiny-coder-prompt-completion-0.5B
5
+ tags:
6
+ - generated_from_trainer
7
+ - trl
8
+ - sft
9
+ licence: license
10
+ ---
11
 
12
+ # Model Card for tiny-coder-prompt-completion-0.5B
13
 
14
+ This model is a fine-tuned version of [Qwen/Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct).
15
+ It has been trained using [TRL](https://github.com/huggingface/trl).
16
 
17
+ ## Quick start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  ```python
20
+ from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
+ generator = pipeline("text-generation", model="finnvoorhees/tiny-coder-prompt-completion-0.5B", device="cuda")
24
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
+ print(output["generated_text"])
26
  ```
27
 
28
+ ## Training procedure
29
 
30
+
31
 
 
 
 
32
 
 
 
33
 
34
+ This model was trained with SFT.
 
 
35
 
36
+ ### Framework versions
37
 
38
+ - TRL: 1.2.0
39
+ - Transformers: 5.6.2
40
+ - Pytorch: 2.11.0
41
+ - Datasets: 4.8.4
42
+ - Tokenizers: 0.22.2
43
 
44
+ ## Citations
 
 
 
45
 
 
 
46
 
 
 
 
47
 
48
+ Cite TRL as:
49
+
50
+ ```bibtex
51
+ @software{vonwerra2020trl,
52
+ title = {{TRL: Transformers Reinforcement Learning}},
53
+ author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
54
+ license = {Apache-2.0},
55
+ url = {https://github.com/huggingface/trl},
56
+ year = {2020}
57
+ }
58
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": null,
7
+ "dtype": "bfloat16",
8
+ "eos_token_id": 151645,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 896,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 4864,
13
+ "layer_types": [
14
+ "full_attention",
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention"
38
+ ],
39
+ "max_position_embeddings": 32768,
40
+ "max_window_layers": 24,
41
+ "model_type": "qwen2",
42
+ "num_attention_heads": 14,
43
+ "num_hidden_layers": 24,
44
+ "num_key_value_heads": 2,
45
+ "pad_token_id": 151643,
46
+ "rms_norm_eps": 1e-06,
47
+ "rope_parameters": {
48
+ "rope_theta": 1000000.0,
49
+ "rope_type": "default"
50
+ },
51
+ "sliding_window": null,
52
+ "tie_word_embeddings": true,
53
+ "transformers_version": "5.6.2",
54
+ "use_cache": false,
55
+ "use_sliding_window": false,
56
+ "vocab_size": 151936
57
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_sample": true,
3
+ "eos_token_id": [
4
+ 151645,
5
+ 151643
6
+ ],
7
+ "pad_token_id": 151643,
8
+ "repetition_penalty": 1.05,
9
+ "temperature": 0.7,
10
+ "top_k": 20,
11
+ "top_p": 0.8,
12
+ "transformers_version": "5.6.2"
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81513daf667ea3ce13c2a16e0b4ed2631ae989f74efe875217d6422c66f0f20e
3
+ size 988097824
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
3
+ size 11421892
tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "local_files_only": false,
25
+ "model_max_length": 32768,
26
+ "pad_token": "<|endoftext|>",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null
30
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af1e287adb66fc7b18c7e1c19396bba4e849d9c353d7e3bf759308521994fa6d
3
+ size 5841