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

Upload model README

Browse files
Files changed (1) hide show
  1. README.md +56 -103
README.md CHANGED
@@ -1,128 +1,81 @@
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`
 
 
1
+ # SM Coder 1.5B
2
 
3
+ SM Coder is a fine-tuned coding assistant focused on SuperMongo (SM) macro development for scientific plotting workflows.
 
4
 
5
+ This README is intended as the public model card for Hugging Face uploads.
6
 
7
+ ## Model Repositories
 
 
 
 
 
 
 
8
 
9
+ - GGUF (Ollama / llama.cpp): https://huggingface.co/xpol555/sm-coder-gguf
10
+ - MLC (WebLLM / browser deployment): https://huggingface.co/xpol555/sm-coder-mlc
11
 
12
+ ## What Is SuperMongo
13
 
14
+ SuperMongo is a plotting and data-analysis environment widely used in astronomy and scientific workflows.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ Reference:
17
+ - https://www.astro.princeton.edu/~rhl/sm/
18
 
19
+ ## Dataset and Scope
 
 
20
 
21
+ This model was developed on a curated dataset of SM macros and related examples collected and evolved over about 20 years of real usage.
22
 
23
+ The training data emphasizes:
24
+ - reusable plotting macros
25
+ - parameterized workflow helpers
26
+ - practical data visualization patterns used in long-running scientific analysis
27
 
28
+ ## Intended Use
 
 
 
 
 
29
 
30
+ - writing and refactoring SuperMongo macros
31
+ - translating plotting requests into SM macro skeletons
32
+ - helping document and modernize legacy macro collections
33
 
34
+ ## Not Intended As
 
 
35
 
36
+ - a general-purpose chatbot
37
+ - an authoritative source on non-SM domains
38
+ - a replacement for validation/testing of scientific plots
39
 
40
+ ## Example Prompts
41
 
42
+ - "Write an SM macro to draw concentric circles with configurable center and step."
43
+ - "Create an SM macro that computes min/max from two vectors and sets plotting limits."
44
+ - "Refactor this old SM macro into smaller parameterized helpers."
45
 
46
+ ## Example Macro Ideas
47
 
48
+ The model can propose macro structures like these (adapt names and details to your local SM setup):
 
49
 
50
+ ```sm
51
+ define draw_circle (xc,yc,r,npt) {
52
+ set _th = 2*3.14159265*indgen(npt)/npt
53
+ set _x = xc + r*cos(_th)
54
+ set _y = yc + r*sin(_th)
55
+ connect _x _y
56
+ }
57
 
58
+ define draw_concentric (xc,yc,r0,dr,nr,npt) {
59
+ do i = 0, nr-1 {
60
+ set _r = r0 + i*dr
61
+ draw_circle(xc,yc,_r,npt)
62
+ }
63
+ }
64
  ```
65
 
66
+ ```sm
67
+ define autoscale_xy (xv,yv,pad) {
68
+ set _xmin = min(xv)
69
+ set _xmax = max(xv)
70
+ set _ymin = min(yv)
71
+ set _ymax = max(yv)
72
+ limits (_xmin-pad) (_xmax+pad) (_ymin-pad) (_ymax+pad)
73
+ box
74
+ }
75
  ```
76
 
77
+ ## Notes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
+ - Validate generated macros against your SM version and local macro library.
80
+ - For browser usage, prefer the MLC repository.
81
+ - For local inference with Ollama/llama.cpp, prefer the GGUF repository.