Mehdi commited on
Commit
f5c39d2
Β·
1 Parent(s): 5ad43b3

feat: retarget fine-tune pipeline to MiniCPM4.1-8B

Browse files

- train_modal.py: BASE_MODEL β†’ openbmb/MiniCPM4.1-8B
HUB_REPO β†’ build-small-hackathon/MiniCPM4.1-8B-PaperProf
enable_thinking=False in apply_chat_template
- convert_gguf_modal.py: SRC/GGUF repos updated to 4.1 names
- model/llm.py: DEFAULT_MODEL_ID and GGUF_REPO point to new fine-tune repos

finetune/convert_gguf_modal.py CHANGED
@@ -1,9 +1,9 @@
1
  """
2
  finetune/convert_gguf_modal.py β€” Convert the fine-tuned model to GGUF for llama.cpp.
3
 
4
- Pulls build-small-hackathon/MiniCPM4-8B-PaperProf, converts to GGUF f16 with
5
  llama.cpp's convert script, quantizes to Q4_K_M, and pushes both files to
6
- build-small-hackathon/MiniCPM4-8B-PaperProf-GGUF.
7
 
8
  Run (after the fine-tune has been pushed):
9
  modal run finetune/convert_gguf_modal.py
@@ -11,8 +11,8 @@ Run (after the fine-tune has been pushed):
11
 
12
  import modal
13
 
14
- SRC_REPO = "build-small-hackathon/MiniCPM4-8B-PaperProf"
15
- GGUF_REPO = "build-small-hackathon/MiniCPM4-8B-PaperProf-GGUF"
16
 
17
  app = modal.App("paperprof-gguf")
18
 
@@ -46,7 +46,7 @@ language:
46
  - en
47
  ---
48
 
49
- # MiniCPM4-8B-PaperProf-GGUF
50
 
51
  GGUF quantizations of [{SRC_REPO}](https://huggingface.co/{SRC_REPO}),
52
  the fine-tuned exam-question generator behind
@@ -54,8 +54,8 @@ the fine-tuned exam-question generator behind
54
 
55
  | File | Quant | Size | Use |
56
  |---|---|---|---|
57
- | `minicpm4-8b-paperprof-Q4_K_M.gguf` | Q4_K_M | ~4.9 GB | recommended, used by the Space |
58
- | `minicpm4-8b-paperprof-f16.gguf` | F16 | ~16 GB | full precision reference |
59
 
60
  ## Usage with llama.cpp
61
 
@@ -93,8 +93,8 @@ def convert():
93
  print(f"[pull] downloading {SRC_REPO}…")
94
  src = snapshot_download(SRC_REPO, token=token, local_dir="/tmp/src")
95
 
96
- f16 = "/tmp/minicpm4-8b-paperprof-f16.gguf"
97
- q4 = "/tmp/minicpm4-8b-paperprof-Q4_K_M.gguf"
98
 
99
  print("[convert] HF β†’ GGUF f16…")
100
  subprocess.run(
 
1
  """
2
  finetune/convert_gguf_modal.py β€” Convert the fine-tuned model to GGUF for llama.cpp.
3
 
4
+ Pulls build-small-hackathon/MiniCPM4.1-8B-PaperProf, converts to GGUF f16 with
5
  llama.cpp's convert script, quantizes to Q4_K_M, and pushes both files to
6
+ build-small-hackathon/MiniCPM4.1-8B-PaperProf-GGUF.
7
 
8
  Run (after the fine-tune has been pushed):
9
  modal run finetune/convert_gguf_modal.py
 
11
 
12
  import modal
13
 
14
+ SRC_REPO = "build-small-hackathon/MiniCPM4.1-8B-PaperProf"
15
+ GGUF_REPO = "build-small-hackathon/MiniCPM4.1-8B-PaperProf-GGUF"
16
 
17
  app = modal.App("paperprof-gguf")
18
 
 
46
  - en
47
  ---
48
 
49
+ # MiniCPM4.1-8B-PaperProf-GGUF
50
 
51
  GGUF quantizations of [{SRC_REPO}](https://huggingface.co/{SRC_REPO}),
52
  the fine-tuned exam-question generator behind
 
54
 
55
  | File | Quant | Size | Use |
56
  |---|---|---|---|
57
+ | `minicpm4-1-8b-paperprof-Q4_K_M.gguf` | Q4_K_M | ~4.9 GB | recommended, used by the Space |
58
+ | `minicpm4-1-8b-paperprof-f16.gguf` | F16 | ~16 GB | full precision reference |
59
 
60
  ## Usage with llama.cpp
61
 
 
93
  print(f"[pull] downloading {SRC_REPO}…")
94
  src = snapshot_download(SRC_REPO, token=token, local_dir="/tmp/src")
95
 
96
+ f16 = "/tmp/minicpm4-1-8b-paperprof-f16.gguf"
97
+ q4 = "/tmp/minicpm4-1-8b-paperprof-Q4_K_M.gguf"
98
 
99
  print("[convert] HF β†’ GGUF f16…")
100
  subprocess.run(
finetune/train_modal.py CHANGED
@@ -14,9 +14,9 @@ Output:
14
 
15
  import modal
16
 
17
- APP_NAME = "paperprof-finetune"
18
- BASE_MODEL = "openbmb/MiniCPM4-8B"
19
- HUB_REPO = "build-small-hackathon/MiniCPM4-8B-PaperProf"
20
  N_SAMPLES = 3000
21
  MAX_LEN = 1024
22
 
@@ -120,7 +120,7 @@ language:
120
  - en
121
  ---
122
 
123
- # MiniCPM4-8B-PaperProf
124
 
125
  Fine-tuned from [{BASE_MODEL}](https://huggingface.co/{BASE_MODEL}) for
126
  **exam-question generation** in [PaperProf](https://huggingface.co/spaces/build-small-hackathon/PaperProf),
@@ -326,7 +326,7 @@ def train():
326
  {"role": "user", "content": pair[0]},
327
  {"role": "assistant", "content": pair[1]},
328
  ]
329
- return tokenizer.apply_chat_template(messages, tokenize=False)
330
 
331
  texts = [to_text(p) for p in pairs]
332
 
 
14
 
15
  import modal
16
 
17
+ APP_NAME = "paperprof-finetune-41"
18
+ BASE_MODEL = "openbmb/MiniCPM4.1-8B"
19
+ HUB_REPO = "build-small-hackathon/MiniCPM4.1-8B-PaperProf"
20
  N_SAMPLES = 3000
21
  MAX_LEN = 1024
22
 
 
120
  - en
121
  ---
122
 
123
+ # MiniCPM4.1-8B-PaperProf
124
 
125
  Fine-tuned from [{BASE_MODEL}](https://huggingface.co/{BASE_MODEL}) for
126
  **exam-question generation** in [PaperProf](https://huggingface.co/spaces/build-small-hackathon/PaperProf),
 
326
  {"role": "user", "content": pair[0]},
327
  {"role": "assistant", "content": pair[1]},
328
  ]
329
+ return tokenizer.apply_chat_template(messages, tokenize=False, enable_thinking=False)
330
 
331
  texts = [to_text(p) for p in pairs]
332
 
model/llm.py CHANGED
@@ -7,8 +7,9 @@ Responsibility:
7
  about the underlying model loading or tokenisation details.
8
 
9
  Model choice:
10
- openbmb/MiniCPM4.1-8B β€” base model, thinking mode disabled for fast
11
- structured outputs. Requires transformers >= 4.56.
 
12
 
13
  Environment variables:
14
  PAPERPROF_MODEL Override the default model ID (e.g. "openbmb/MiniCPM3-4B"
@@ -30,7 +31,7 @@ import torch
30
  from functools import lru_cache
31
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
32
 
33
- DEFAULT_MODEL_ID = "openbmb/MiniCPM4.1-8B"
34
  DEFAULT_MAX_NEW_TOKENS = 512
35
 
36
  # Pre-load libnvJitLink.so.13 bundled with the nvidia-cu13 wheel so that
@@ -105,7 +106,7 @@ class LLM:
105
  return output[0]["generated_text"]
106
 
107
 
108
- DEFAULT_GGUF_REPO = "openbmb/MiniCPM4.1-8B-GGUF"
109
 
110
 
111
  class LlamaCppLLM:
 
7
  about the underlying model loading or tokenisation details.
8
 
9
  Model choice:
10
+ build-small-hackathon/MiniCPM4.1-8B-PaperProf β€” QLoRA fine-tune of
11
+ openbmb/MiniCPM4.1-8B on SQuAD/SciQ in PaperProf's production prompt
12
+ format. Thinking mode disabled. Requires transformers >= 4.56.
13
 
14
  Environment variables:
15
  PAPERPROF_MODEL Override the default model ID (e.g. "openbmb/MiniCPM3-4B"
 
31
  from functools import lru_cache
32
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
33
 
34
+ DEFAULT_MODEL_ID = "build-small-hackathon/MiniCPM4.1-8B-PaperProf"
35
  DEFAULT_MAX_NEW_TOKENS = 512
36
 
37
  # Pre-load libnvJitLink.so.13 bundled with the nvidia-cu13 wheel so that
 
106
  return output[0]["generated_text"]
107
 
108
 
109
+ DEFAULT_GGUF_REPO = "build-small-hackathon/MiniCPM4.1-8B-PaperProf-GGUF"
110
 
111
 
112
  class LlamaCppLLM: