xpol555 commited on
Commit
e8872d2
·
verified ·
1 Parent(s): 57228f0

Upload model README

Browse files
Files changed (1) hide show
  1. README.md +128 -3
README.md CHANGED
@@ -1,3 +1,128 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## sm_llm Workflow
2
+
3
+ This folder contains the end-to-end pipeline to fine-tune `Qwen/Qwen2.5-Coder-1.5B-Instruct`
4
+ on SuperMongo examples and export a quantized GGUF model for Ollama.
5
+
6
+ ### Files
7
+
8
+ - `1_dataset.jsonl`: ChatML training set
9
+ - `1b_alignment.jsonl`: targeted alignment examples (identity + anti-pseudo-syntax)
10
+ - `2_finetune_unsloth.py`: LoRA fine-tuning (Unsloth)
11
+ - `3_merge_weights.py`: merge LoRA into full model
12
+ - `4_convert_gguf.py`: HF -> GGUF + Q4_K_M quantization
13
+ - `5_build_mlc.py`: build MLC/WebLLM artifacts from merged model
14
+ - `6_publish_hf.py`: publish GGUF and/or MLC artifacts to Hugging Face
15
+ - `Modelfile.finetuned`: Ollama model definition
16
+
17
+ ### Prerequisites (WSL + NVIDIA)
18
+
19
+ Run training from Linux/WSL with CUDA available.
20
+
21
+ ```bash
22
+ nvidia-smi
23
+ python3 -c "import torch; print(torch.cuda.is_available())"
24
+ ```
25
+
26
+ ### Environment Setup
27
+
28
+ From `sm_llm/`:
29
+
30
+ ```bash
31
+ uv sync --extra train
32
+ ```
33
+
34
+ If you are using an already active venv, use `--active` in `uv run`.
35
+
36
+ ### Build llama.cpp (submodule)
37
+
38
+ The conversion script expects `llama.cpp` at `./llama.cpp` (submodule path).
39
+
40
+ ```bash
41
+ cd llama.cpp
42
+ cmake -B build
43
+ cmake --build build -j
44
+ cd ..
45
+ ```
46
+
47
+ ### Train + Export
48
+
49
+ ```bash
50
+ uv run --active --extra train python 2_finetune_unsloth.py
51
+ uv run --active --extra train python 3_merge_weights.py
52
+ uv run --active --extra train python 4_convert_gguf.py
53
+ ```
54
+
55
+ Generated artifacts:
56
+
57
+ - `lora_model/`
58
+ - `merged_model/`
59
+ - `gguf/sm-coder-1.5b-q4_k_m.gguf`
60
+
61
+ Note: `2_finetune_unsloth.py` loads both `1_dataset.jsonl` and `1b_alignment.jsonl` if present.
62
+
63
+ ### Ollama Test
64
+
65
+ ```bash
66
+ ollama create sm-coder -f Modelfile.finetuned
67
+ ollama run sm-coder
68
+ ```
69
+
70
+ ### Build MLC (WebLLM)
71
+
72
+ Install MLC CLI (inside WSL, in your active env).
73
+ The packages are hosted on a custom index and require platform-specific names.
74
+ For CUDA 13.0 (RTX 4080 / sm89):
75
+
76
+ ```bash
77
+ uv pip install --pre -U --find-links https://mlc.ai/wheels mlc-llm-nightly-cu130 mlc-ai-nightly-cu130
78
+ ```
79
+
80
+ > Note: `uv`-created venvs do not include `pip` by default, so use `uv pip` instead of `python -m pip`.
81
+ > For other CUDA versions replace `cu130` with e.g. `cu128` or `cpu`.
82
+
83
+ Build MLC artifacts from `merged_model/`:
84
+
85
+ ```bash
86
+ uv run --active python 5_build_mlc.py --model-id your-user/sm-coder-1.5b
87
+ ```
88
+
89
+ Output is written to:
90
+
91
+ - `mlc_dist/weights`
92
+ - `mlc_dist/lib/*.wasm`
93
+
94
+ ### Publish on Hugging Face
95
+
96
+ Install publish dependencies:
97
+
98
+ ```bash
99
+ uv sync --extra publish
100
+ ```
101
+
102
+ Login once:
103
+
104
+ ```bash
105
+ huggingface-cli login
106
+ ```
107
+
108
+ Publish only GGUF (the model used by Ollama):
109
+
110
+ ```bash
111
+ uv run --active --extra publish python 6_publish_hf.py \
112
+ --gguf-repo your-user/sm-coder-gguf
113
+ ```
114
+
115
+ Publish both GGUF and MLC artifacts:
116
+
117
+ ```bash
118
+ uv run --active --extra publish python 6_publish_hf.py \
119
+ --gguf-repo your-user/sm-coder-gguf \
120
+ --mlc-repo your-user/sm-coder-mlc
121
+ ```
122
+
123
+ Use `--private` if you want private repositories.
124
+
125
+ ### Notes
126
+
127
+ - On `/mnt/c` you may see UV hardlink warnings; they are harmless.
128
+ - You can silence them with: `export UV_LINK_MODE=copy`