Text Generation
Safetensors
English
llama
bitnet
1.58-bit
code
falcon
ternary
conversational
anthonylee991 commited on
Commit
9279a4d
·
verified ·
1 Parent(s): c17d8e1

Add model card with usage instructions and license

Browse files
Files changed (1) hide show
  1. README.md +160 -0
README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: tiiuae/Falcon-E-3B-Instruct
4
+ tags:
5
+ - bitnet
6
+ - 1.58-bit
7
+ - code
8
+ - text-generation
9
+ - falcon
10
+ - ternary
11
+ datasets:
12
+ - m-a-p/CodeFeedback-Filtered-Instruction
13
+ - ise-uiuc/Magicoder-OSS-Instruct-75K
14
+ - ise-uiuc/Magicoder-Evol-Instruct-110K
15
+ language:
16
+ - en
17
+ ---
18
+
19
+ # Falcon-Coder-3B (1.58-bit / TQ1_0)
20
+
21
+ A fine-tuned 1.58-bit ternary quantization of [Falcon-E-3B-Instruct](https://huggingface.co/tiiuae/Falcon-E-3B-Instruct), optimized for **CPU inference** via vanilla [llama.cpp](https://github.com/ggerganov/llama.cpp).
22
+
23
+ This model produces code (Python, TypeScript, etc.) at ~24 tokens/sec on a typical laptop CPU with a 710 MB on-disk footprint.
24
+
25
+ ## Model Details
26
+
27
+ | Property | Value |
28
+ |----------|-------|
29
+ | Base model | tiiuae/Falcon-E-3B-Instruct |
30
+ | Training method | 1.58-bit full fine-tune via [onebitllms](https://github.com/tiiuae/onebitllms) |
31
+ | Training data | 365k coding instruction examples (Magicoder + CodeFeedback) |
32
+ | Training duration | ~92 hours on RTX 4090 (24 GB) |
33
+ | Final loss | 0.5008 (started at 0.91) |
34
+ | Effective batch size | 32 (per_device=1 × grad_accum=32) |
35
+ | Optimizer | paged_adamw_8bit |
36
+ | Learning rate | 1e-4 (cosine schedule, 3% warmup) |
37
+ | Sequence length | 1024 |
38
+ | Epochs | 2 |
39
+ | Stored precision | BF16 (5.7 GB) |
40
+ | **Inference precision** | **TQ1_0 ternary (1.69 bpw, ~710 MB)** |
41
+ | **Inference engine** | **vanilla llama.cpp** (TQ1_0 quant) |
42
+ | Inference speed | ~24 tok/s on laptop CPU |
43
+
44
+ ## What's in the repo
45
+
46
+ This is the **training-time BF16 checkpoint**. To use it on CPU, you must convert it to a 1.58-bit ternary GGUF. See "Usage" below.
47
+
48
+ ## Usage
49
+
50
+ ### Inference on CPU (recommended)
51
+
52
+ This BF16 model is too large for fast CPU inference. **Convert to a 1.58-bit ternary GGUF first:**
53
+
54
+ ```powershell
55
+ # 1. Download the BF16 model
56
+ hf download anthonylee991/falcon-coder-3b --local-dir falcon-coder-3b-bf16
57
+
58
+ # 2. Convert to F16 GGUF
59
+ python llama.cpp/convert_hf_to_gguf.py falcon-coder-3b-bf16 `
60
+ --outfile falcon-coder-3b.gguf --outtype f16
61
+
62
+ # 3. Quantize to TQ1_0 (1.58-bit ternary, ~710 MB)
63
+ llama.cpp/build/bin/Release/llama-quantize.exe falcon-coder-3b.gguf `
64
+ falcon-coder-3b-tq1.gguf TQ1_0 8
65
+
66
+ # 4. Run inference
67
+ llama.cpp/build/bin/Release/llama-cli.exe `
68
+ -m falcon-coder-3b-tq1.gguf `
69
+ -p "def fibonacci(n):" -n 100 --threads 8
70
+ ```
71
+
72
+ ### Inference on GPU (BF16)
73
+
74
+ ```python
75
+ from transformers import AutoModelForCausalLM, AutoTokenizer
76
+ import torch
77
+
78
+ model = AutoModelForCausalLM.from_pretrained(
79
+ "anthonylee991/falcon-coder-3b",
80
+ torch_dtype=torch.bfloat16,
81
+ device_map="cuda",
82
+ )
83
+ tokenizer = AutoTokenizer.from_pretrained("anthonylee991/falcon-coder-3b")
84
+
85
+ prompt = "def quicksort(arr):"
86
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
87
+ output = model.generate(**inputs, max_new_tokens=200, do_sample=False)
88
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
89
+ ```
90
+
91
+ ## Intended Use
92
+
93
+ This model is a **code generation assistant**. Verified strong performance on:
94
+
95
+ - ✅ Pure algorithms (binary search, sort, recursive functions)
96
+ - ✅ Type definitions (TypeScript interfaces, Pydantic models)
97
+ - ✅ Test scaffolding (pytest, Jest)
98
+ - ✅ Mechanical refactors (if/elif → dict dispatch)
99
+ - ✅ Docstrings (Google-style with examples)
100
+
101
+ Verified **weak** performance on:
102
+
103
+ - ⚠️ PowerShell (uses deprecated cmdlets like `Get-WmiObject`)
104
+ - ⚠️ Complex business logic with multiple interacting rules
105
+ - ⚠️ Anything requiring framework-specific knowledge not in training data
106
+
107
+ For a detailed 10-test evaluation, see [the project repository](https://huggingface.co/anthonylee991/falcon-coder-3b) or the companion HOW-TO guide.
108
+
109
+ ## Training Data
110
+
111
+ Combined and deduplicated from:
112
+
113
+ | Dataset | Rows | Purpose |
114
+ |---------|------|---------|
115
+ | [m-a-p/CodeFeedback-Filtered-Instruction](https://huggingface.co/datasets/m-a-p/CodeFeedback-Filtered-Instruction) | ~156k | High-quality code instructions with feedback |
116
+ | [ise-uiuc/Magicoder-OSS-Instruct-75K](https://huggingface.co/datasets/ise-uiuc/Magicoder-OSS-Instruct-75K) | ~75k | Magicoder-style OSS examples |
117
+ | [ise-uiuc/Magicoder-Evol-Instruct-110K](https://huggingface.co/datasets/ise-uiuc/Magicoder-Evol-Instruct-110K) | ~110k | Evolved instructions |
118
+ | Various smaller PowerShell/TypeScript corpuses | ~30k | Multi-language coverage |
119
+
120
+ After deduplication via MinHash LSH @ 0.85: **365,251 train rows + 2,000 eval rows**.
121
+
122
+ The training data is generic Python code. **PowerShell, FastAPI, and TypeScript quality is limited** compared to Python. See the V2 plan in the project docs for how to address this.
123
+
124
+ ## Limitations
125
+
126
+ - **PowerShell quality is poor** — the model defaults to deprecated cmdlets. Use a more recent code model for PowerShell or fine-tune on PS-specific data.
127
+ - **Framework-specific code** (FastAPI deps, SQLAlchemy patterns, React state management) is hit-or-miss.
128
+ - **No held-out domain eval** — the eval split was drawn from the same training distribution.
129
+ - **Small model (3B)** — complex reasoning across multiple files is out of scope.
130
+ - **Output may include explanatory prose** — extract code blocks from the response, don't paste the whole output into your code.
131
+
132
+ ## Training Infrastructure
133
+
134
+ - Cloud GPU: Hivenet GPU-optimized container, single RTX 4090 (24 GB VRAM)
135
+ - 92 hours wall time, $40 approximate cost
136
+ - BF16 + 8-bit AdamW + gradient checkpointing to fit in 24 GB
137
+
138
+ ## License
139
+
140
+ This model is released under the **Apache 2.0 license**, consistent with the base [Falcon-E-3B-Instruct](https://huggingface.co/tiiuae/Falcon-E-3B-Instruct) license.
141
+
142
+ ## Citation
143
+
144
+ If you use this model, please cite the base model and the BitNet approach:
145
+
146
+ ```bibtex
147
+ @misc{falcon-e-3b-instruct,
148
+ title={Falcon-E: A Family of Universal, Pre-trained 1.58-bit Models},
149
+ author={TII Falcon Team},
150
+ year={2025},
151
+ url={https://huggingface.co/tiiuae/Falcon-E-3B-Instruct}
152
+ }
153
+
154
+ @misc{bitnet2025,
155
+ title={bitnet.cpp: Efficient Edge Inference for Ternary LLMs},
156
+ author={Jinheng Wang and others},
157
+ year={2025},
158
+ url={https://github.com/microsoft/BitNet}
159
+ }
160
+ ```