File size: 3,314 Bytes
147855a
 
 
 
 
 
 
 
 
 
 
 
 
 
364d30a
 
 
50f063a
147855a
 
b578034
 
50f063a
 
 
 
 
 
 
 
 
7f2a053
 
9f336b6
 
 
50f063a
d31fa75
 
50f063a
 
 
 
 
 
b578034
d5743c4
 
 
b578034
d5743c4
50f063a
d5743c4
 
b578034
50f063a
 
 
 
 
 
 
 
 
 
 
 
 
 
b578034
d5743c4
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
license: apache-2.0
language:
- en
pipeline_tag: text-generation
library_name: transformers
tags:
- code
- code-generation
- multimodal
- gguf
- llama
datasets:
- HuggingFaceH4/CodeAlpaca_20K
metrics:
- code_eval
- perplexity
version: 0.0.2
---

# Alfa Code - Multimodal Coding GGUF

Llama-based code models, trained on Kaggle T4. Ready-to-run GGUF weights below.

## Download (ready weights)

**GitHub release:** https://github.com/mrsandipmandal/alfa-code/releases/tag/v0.0.2
**HuggingFace:** https://huggingface.co/mrsandip/Alfa-Code/tree/main/gguf

| Model | Q8_0 (best) | Q4_0 (small) | Context |
|---|---|---|---|
| tiny-50M (56M) | [tiny-50M-q8.gguf](https://huggingface.co/mrsandip/Alfa-Code/resolve/main/gguf/tiny-50M-q8.gguf) (60 MB) | [tiny-50M-q4.gguf](https://huggingface.co/mrsandip/Alfa-Code/resolve/main/gguf/tiny-50M-q4.gguf) (32 MB) | 2048 |
| base-1B (1.1B) | [base-1B-q8.gguf](https://huggingface.co/mrsandip/Alfa-Code/resolve/main/gguf/base-1B-q8.gguf) (1.19 GB) | [base-1B-q4.gguf](https://huggingface.co/mrsandip/Alfa-Code/resolve/main/gguf/base-1B-q4.gguf) (632 MB) | 2048 |
| code-100k (1.39B) | ~~code-100k-Q8_0.gguf~~ | ~~code-100k-Q4_0.gguf~~ | — |

> code-100k files deprecated (broken tokenizer build, model dropped). Current line: tiny-50M + base-1B (fixed build: faithful HF-identical tokenization, embedded chat template). Next: `alfa-code-1.2` (this branch).

> code-100k is an early checkpoint (1 epoch, eval loss ~3.1) — loads and runs, but output quality is rough. More training coming.

```bash
llama-server -m base-1B-q4.gguf -c 2048
llama-server -m tiny-50M-q8.gguf -c 2048
```

Tokenizer (32k BPE): `tokenizers/alfa-32k.json` — also in the v0.0.2 release assets.

## 1. Data
`python scripts/download_data.py --dataset code_small_test --max-rows 500`
Output: `data/processed/train.jsonl` {modality,prompt,think,answer}

## 2. Tokenizer + Train
`python scripts/train_tokenizer.py` -> `tokenizers/alfa-32k.json` (32000 vocab, ~419KB)
`pip install torch --index-url https://download.pytorch.org/whl/cu121`
`python scripts/train.py` -> `outputs/tiny-50M`

Scale-up (Colab T4, ~2-4h): 5000+ rows, chat tuning, 3-5 epochs:
`python scripts/download_data.py --dataset multimodal_mix --max-rows 5000 --overwrite`
`python scripts/download_data.py --dataset chat_qa --max-rows 2000` (appends Q&A rows)
`python scripts/train_hf.py --data data/processed/train.jsonl --out /content/outputs/tiny-50M --epochs 3 --config configs/tiny-50M.yaml --max-seq-len 2048 --batch-size 1`

1B model (16GB+ GPU only, not RTX 3050 4GB): same commands with `--config configs/base-1B.yaml --out /content/outputs/base-1B` (1.12B params, ~2.2GB fp16).

## 3. GGUF (no llama.cpp clone needed)
`pip install gguf safetensors torch transformers`
`python scripts/convert_to_gguf.py --ckpt outputs/tiny-50M --quant Q8_0` (Q8_0 ~55MB, Q4_0 ~32MB, F16 ~105MB)
K-quants (Q4_K_M) need standard dims + `llama-quantize` binary — not offered (intermediate 1376).

Run local (RTX 3050 4GB):
`llama-server -m outputs/tiny-50M.gguf -c 2048` or Ollama Modelfile (`FROM ./outputs/tiny-50M.gguf`).

## 4. UI (reasoning live->collapsed + image/file/video)
`python app/ui.py` -> http://127.0.0.1:7860

## 5. Hub sync
`hf upload mrsandip/Alfa-Code . . --exclude __pycache__ --exclude .venv --commit-message "Update"`