Spaces:
Sleeping
Sleeping
Upload 22 files
Browse files- .gitattributes +2 -0
- README.md +13 -7
- app.py +295 -0
- models/.DS_Store +0 -0
- models/qlora-adapter/README.md +62 -0
- models/qlora-adapter/adapter_config.json +47 -0
- models/qlora-adapter/adapter_model.safetensors +3 -0
- models/qlora-adapter/chat_template.jinja +6 -0
- models/qlora-adapter/checkpoint-19/README.md +209 -0
- models/qlora-adapter/checkpoint-19/adapter_config.json +47 -0
- models/qlora-adapter/checkpoint-19/adapter_model.safetensors +3 -0
- models/qlora-adapter/checkpoint-19/chat_template.jinja +6 -0
- models/qlora-adapter/checkpoint-19/optimizer.pt +3 -0
- models/qlora-adapter/checkpoint-19/rng_state.pth +3 -0
- models/qlora-adapter/checkpoint-19/scheduler.pt +3 -0
- models/qlora-adapter/checkpoint-19/tokenizer.json +3 -0
- models/qlora-adapter/checkpoint-19/tokenizer_config.json +19 -0
- models/qlora-adapter/checkpoint-19/trainer_state.json +33 -0
- models/qlora-adapter/checkpoint-19/training_args.bin +3 -0
- models/qlora-adapter/tokenizer.json +3 -0
- models/qlora-adapter/tokenizer_config.json +19 -0
- models/qlora-adapter/training_args.bin +3 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
models/qlora-adapter/checkpoint-19/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
models/qlora-adapter/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.12'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: PlainScript Medical Rewriter
|
| 3 |
+
emoji: 🩺
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# PlainScript — Patient-Friendly Medical Rewriter
|
| 14 |
+
|
| 15 |
+
Fine-tuned Qwen2-1.5B (QLoRA) that rewrites dense medical text into plain
|
| 16 |
+
language. Toggle shows base vs fine-tuned output side by side.
|
| 17 |
+
|
| 18 |
+
Trained on Cochrane plain-language summary pairs. Drafts for review only —
|
| 19 |
+
not medical advice.
|
app.py
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Patient-Friendly Medical Rewriter — Gradio web app.
|
| 3 |
+
|
| 4 |
+
Loads Qwen2-1.5B-Instruct with the trained LoRA adapter and exposes a
|
| 5 |
+
before/after comparison UI. The base ("before") and fine-tuned ("after")
|
| 6 |
+
outputs come from a single PeftModel by toggling the adapter on and off
|
| 7 |
+
with disable_adapter(), which keeps memory low enough for HF Spaces'
|
| 8 |
+
free CPU tier.
|
| 9 |
+
|
| 10 |
+
Entry point for Hugging Face Spaces (Gradio SDK looks for app.py).
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
|
| 15 |
+
import gradio as gr
|
| 16 |
+
import torch
|
| 17 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 18 |
+
from peft import PeftModel
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
MODEL_ID = "Qwen/Qwen2-1.5B-Instruct"
|
| 22 |
+
ADAPTER_DIR = os.environ.get("ADAPTER_DIR", "models/qlora-adapter")
|
| 23 |
+
|
| 24 |
+
SYSTEM_PROMPT = (
|
| 25 |
+
"You are a medical text simplifier. Rewrite the following medical text "
|
| 26 |
+
"into plain language that a patient with no medical background can "
|
| 27 |
+
"understand. Preserve all key findings and conclusions. Do not add "
|
| 28 |
+
"information not present in the original text."
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
EXAMPLES = [
|
| 32 |
+
"A meta-analysis of randomized controlled trials demonstrated a "
|
| 33 |
+
"statistically significant reduction in glycated hemoglobin (HbA1c) "
|
| 34 |
+
"levels (mean difference -0.5%, 95% CI -0.7 to -0.3, p<0.001) in "
|
| 35 |
+
"patients receiving the intervention compared to placebo.",
|
| 36 |
+
"The systematic review found moderate-certainty evidence that cognitive "
|
| 37 |
+
"behavioural therapy reduces the severity of chronic insomnia symptoms "
|
| 38 |
+
"compared with treatment as usual, measured by the Pittsburgh Sleep "
|
| 39 |
+
"Quality Index at 8 weeks post-intervention.",
|
| 40 |
+
"Prophylactic administration of low-molecular-weight heparin was "
|
| 41 |
+
"associated with reduced incidence of venous thromboembolism in "
|
| 42 |
+
"post-operative orthopaedic patients (RR 0.50, 95% CI 0.33 to 0.76), "
|
| 43 |
+
"though with a concomitant increase in minor bleeding events.",
|
| 44 |
+
]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _device() -> str:
|
| 48 |
+
"""Pick the best available device."""
|
| 49 |
+
if torch.cuda.is_available():
|
| 50 |
+
return "cuda"
|
| 51 |
+
if torch.backends.mps.is_available():
|
| 52 |
+
return "mps"
|
| 53 |
+
return "cpu"
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
print("Loading model (this can take a minute on first launch)...")
|
| 57 |
+
DEVICE = _device()
|
| 58 |
+
DTYPE = torch.float16 if DEVICE in ("cuda", "mps") else torch.float32
|
| 59 |
+
|
| 60 |
+
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_DIR, trust_remote_code=True)
|
| 61 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 62 |
+
|
| 63 |
+
_base = AutoModelForCausalLM.from_pretrained(
|
| 64 |
+
MODEL_ID, dtype=DTYPE, trust_remote_code=True
|
| 65 |
+
)
|
| 66 |
+
# Keep the adapter separate (not merged) so we can toggle it on/off.
|
| 67 |
+
model = PeftModel.from_pretrained(_base, ADAPTER_DIR)
|
| 68 |
+
model = model.to(DEVICE)
|
| 69 |
+
model.eval()
|
| 70 |
+
print(f"Model loaded on {DEVICE}.")
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _generate(text: str, max_new_tokens: int = 400) -> str:
|
| 74 |
+
"""Run one generation with the current adapter state."""
|
| 75 |
+
messages = [
|
| 76 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 77 |
+
{"role": "user", "content": text},
|
| 78 |
+
]
|
| 79 |
+
prompt = tokenizer.apply_chat_template(
|
| 80 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 81 |
+
)
|
| 82 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)
|
| 83 |
+
with torch.no_grad():
|
| 84 |
+
out = model.generate(
|
| 85 |
+
**inputs,
|
| 86 |
+
max_new_tokens=max_new_tokens,
|
| 87 |
+
do_sample=True,
|
| 88 |
+
temperature=0.7,
|
| 89 |
+
top_p=0.9,
|
| 90 |
+
repetition_penalty=1.1,
|
| 91 |
+
)
|
| 92 |
+
gen = out[0][inputs["input_ids"].shape[1]:]
|
| 93 |
+
return tokenizer.decode(gen, skip_special_tokens=True).strip()
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def rewrite(text: str):
|
| 97 |
+
"""
|
| 98 |
+
Produce base ('before') and fine-tuned ('after') rewrites.
|
| 99 |
+
|
| 100 |
+
The base output is generated with the adapter disabled; the fine-tuned
|
| 101 |
+
output with it enabled — same weights in memory, toggled per call.
|
| 102 |
+
"""
|
| 103 |
+
if not text or not text.strip():
|
| 104 |
+
return "", "Please paste some medical text above to see the rewrite."
|
| 105 |
+
|
| 106 |
+
with model.disable_adapter():
|
| 107 |
+
before = _generate(text)
|
| 108 |
+
after = _generate(text)
|
| 109 |
+
return before, after
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
# ---------------------------------------------------------------------------
|
| 113 |
+
# UI
|
| 114 |
+
# ---------------------------------------------------------------------------
|
| 115 |
+
|
| 116 |
+
CUSTOM_CSS = """
|
| 117 |
+
:root {
|
| 118 |
+
--teal: #0EA5A4;
|
| 119 |
+
--teal-deep: #0B7C7B;
|
| 120 |
+
--coral: #FB7185;
|
| 121 |
+
--ink: #0F172A;
|
| 122 |
+
--mint: #F0FDFA;
|
| 123 |
+
--card: rgba(255, 255, 255, 0.72);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.gradio-container {
|
| 127 |
+
background: linear-gradient(135deg, #F0FDFA 0%, #E0F2FE 50%, #FCE7F3 100%);
|
| 128 |
+
background-size: 400% 400%;
|
| 129 |
+
animation: bgshift 18s ease infinite;
|
| 130 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 131 |
+
max-width: 1100px !important;
|
| 132 |
+
margin: auto !important;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
@keyframes bgshift {
|
| 136 |
+
0% { background-position: 0% 50%; }
|
| 137 |
+
50% { background-position: 100% 50%; }
|
| 138 |
+
100% { background-position: 0% 50%; }
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/* floating medical stickers */
|
| 142 |
+
#sticker-layer {
|
| 143 |
+
position: fixed;
|
| 144 |
+
inset: 0;
|
| 145 |
+
pointer-events: none;
|
| 146 |
+
z-index: 0;
|
| 147 |
+
overflow: hidden;
|
| 148 |
+
}
|
| 149 |
+
.sticker {
|
| 150 |
+
position: absolute;
|
| 151 |
+
font-size: 2.4rem;
|
| 152 |
+
opacity: 0.14;
|
| 153 |
+
animation: float 14s ease-in-out infinite;
|
| 154 |
+
}
|
| 155 |
+
.sticker:nth-child(1) { left: 6%; top: 18%; animation-delay: 0s; }
|
| 156 |
+
.sticker:nth-child(2) { left: 84%; top: 12%; animation-delay: 2s; }
|
| 157 |
+
.sticker:nth-child(3) { left: 12%; top: 72%; animation-delay: 4s; }
|
| 158 |
+
.sticker:nth-child(4) { left: 78%; top: 68%; animation-delay: 1s; }
|
| 159 |
+
.sticker:nth-child(5) { left: 46%; top: 8%; animation-delay: 3s; }
|
| 160 |
+
.sticker:nth-child(6) { left: 90%; top: 44%; animation-delay: 5s; }
|
| 161 |
+
.sticker:nth-child(7) { left: 3%; top: 45%; animation-delay: 2.5s; }
|
| 162 |
+
|
| 163 |
+
@keyframes float {
|
| 164 |
+
0%, 100% { transform: translateY(0) rotate(-4deg); }
|
| 165 |
+
50% { transform: translateY(-26px) rotate(4deg); }
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.hero {
|
| 169 |
+
position: relative;
|
| 170 |
+
z-index: 1;
|
| 171 |
+
text-align: center;
|
| 172 |
+
padding: 26px 16px 6px;
|
| 173 |
+
}
|
| 174 |
+
.hero h1 {
|
| 175 |
+
font-size: 2.5rem;
|
| 176 |
+
font-weight: 800;
|
| 177 |
+
letter-spacing: -0.02em;
|
| 178 |
+
color: var(--ink);
|
| 179 |
+
margin: 0;
|
| 180 |
+
}
|
| 181 |
+
.hero h1 .accent { color: var(--teal-deep); }
|
| 182 |
+
.hero p {
|
| 183 |
+
color: #475569;
|
| 184 |
+
font-size: 1.05rem;
|
| 185 |
+
margin: 10px auto 0;
|
| 186 |
+
max-width: 620px;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
/* ECG signature line */
|
| 190 |
+
.ecg {
|
| 191 |
+
width: 220px; height: 40px; margin: 14px auto 0; display: block;
|
| 192 |
+
}
|
| 193 |
+
.ecg path {
|
| 194 |
+
fill: none; stroke: var(--coral); stroke-width: 2.5;
|
| 195 |
+
stroke-dasharray: 300; stroke-dashoffset: 300;
|
| 196 |
+
animation: trace 2.2s linear infinite;
|
| 197 |
+
}
|
| 198 |
+
@keyframes trace { to { stroke-dashoffset: -300; } }
|
| 199 |
+
|
| 200 |
+
.panel-card, .gr-box, .gr-panel { position: relative; z-index: 1; }
|
| 201 |
+
|
| 202 |
+
/* Output panels */
|
| 203 |
+
#before_box textarea {
|
| 204 |
+
background: rgba(255,255,255,0.6) !important;
|
| 205 |
+
border-left: 4px solid #94A3B8 !important;
|
| 206 |
+
}
|
| 207 |
+
#after_box textarea {
|
| 208 |
+
background: rgba(240,253,250,0.9) !important;
|
| 209 |
+
border-left: 4px solid var(--teal) !important;
|
| 210 |
+
font-weight: 500;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
button.primary, #go_btn {
|
| 214 |
+
background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%) !important;
|
| 215 |
+
border: none !important;
|
| 216 |
+
color: white !important;
|
| 217 |
+
font-weight: 600 !important;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.disclaimer {
|
| 221 |
+
text-align: center; color: #64748B; font-size: 0.82rem;
|
| 222 |
+
margin-top: 18px; position: relative; z-index: 1;
|
| 223 |
+
}
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
STICKERS_HTML = """
|
| 227 |
+
<div id="sticker-layer">
|
| 228 |
+
<div class="sticker">🩺</div>
|
| 229 |
+
<div class="sticker">💊</div>
|
| 230 |
+
<div class="sticker">❤️</div>
|
| 231 |
+
<div class="sticker">🩸</div>
|
| 232 |
+
<div class="sticker">💉</div>
|
| 233 |
+
<div class="sticker">🏥</div>
|
| 234 |
+
<div class="sticker">🪥</div>
|
| 235 |
+
</div>
|
| 236 |
+
"""
|
| 237 |
+
|
| 238 |
+
HERO_HTML = """
|
| 239 |
+
<div class="hero">
|
| 240 |
+
<h1>Plain<span class="accent">Script</span></h1>
|
| 241 |
+
<p>Paste a dense medical abstract and watch it turn into language a patient
|
| 242 |
+
can actually understand. See the model before and after fine-tuning.</p>
|
| 243 |
+
<svg class="ecg" viewBox="0 0 220 40">
|
| 244 |
+
<path d="M0,20 L60,20 L70,20 L78,4 L88,36 L98,20 L120,20 L128,12 L136,28 L146,20 L220,20"/>
|
| 245 |
+
</svg>
|
| 246 |
+
</div>
|
| 247 |
+
"""
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def build_app() -> gr.Blocks:
|
| 251 |
+
"""Construct the Gradio Blocks interface."""
|
| 252 |
+
with gr.Blocks(css=CUSTOM_CSS, title="PlainScript — Medical Rewriter") as app:
|
| 253 |
+
gr.HTML(STICKERS_HTML)
|
| 254 |
+
gr.HTML(HERO_HTML)
|
| 255 |
+
|
| 256 |
+
with gr.Row():
|
| 257 |
+
input_text = gr.Textbox(
|
| 258 |
+
label="Medical text",
|
| 259 |
+
placeholder="Paste a medical abstract or clinical summary here…",
|
| 260 |
+
lines=6,
|
| 261 |
+
elem_id="input_box",
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
go_btn = gr.Button("Rewrite it", variant="primary", elem_id="go_btn")
|
| 265 |
+
|
| 266 |
+
with gr.Row():
|
| 267 |
+
before_box = gr.Textbox(
|
| 268 |
+
label="Before · base Qwen2-1.5B",
|
| 269 |
+
lines=9,
|
| 270 |
+
interactive=False,
|
| 271 |
+
elem_id="before_box",
|
| 272 |
+
)
|
| 273 |
+
after_box = gr.Textbox(
|
| 274 |
+
label="After · fine-tuned on Cochrane",
|
| 275 |
+
lines=9,
|
| 276 |
+
interactive=False,
|
| 277 |
+
elem_id="after_box",
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
gr.Examples(examples=EXAMPLES, inputs=input_text, label="Try an example")
|
| 281 |
+
|
| 282 |
+
gr.HTML(
|
| 283 |
+
'<div class="disclaimer">Drafts for review only — not medical '
|
| 284 |
+
"advice. Outputs may contain errors and must be checked by a "
|
| 285 |
+
"qualified professional before any patient-facing use.</div>"
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
go_btn.click(fn=rewrite, inputs=input_text, outputs=[before_box, after_box])
|
| 289 |
+
|
| 290 |
+
return app
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
if __name__ == "__main__":
|
| 294 |
+
demo = build_app()
|
| 295 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
models/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
models/qlora-adapter/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen2-1.5B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
model_name: qlora-adapter
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen2-1.5B-Instruct
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
licence: license
|
| 12 |
+
pipeline_tag: text-generation
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Model Card for qlora-adapter
|
| 16 |
+
|
| 17 |
+
This model is a fine-tuned version of [Qwen/Qwen2-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct).
|
| 18 |
+
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 19 |
+
|
| 20 |
+
## Quick start
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from transformers import pipeline
|
| 24 |
+
|
| 25 |
+
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
|
| 26 |
+
generator = pipeline("text-generation", model="None", device="cuda")
|
| 27 |
+
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
|
| 28 |
+
print(output["generated_text"])
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## Training procedure
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
This model was trained with SFT.
|
| 38 |
+
|
| 39 |
+
### Framework versions
|
| 40 |
+
|
| 41 |
+
- PEFT 0.20.0
|
| 42 |
+
- TRL: 1.9.2
|
| 43 |
+
- Transformers: 5.14.1
|
| 44 |
+
- Pytorch: 2.11.0+cu128
|
| 45 |
+
- Datasets: 5.0.1
|
| 46 |
+
- Tokenizers: 0.22.2
|
| 47 |
+
|
| 48 |
+
## Citations
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
Cite TRL as:
|
| 53 |
+
|
| 54 |
+
```bibtex
|
| 55 |
+
@software{vonwerra2020trl,
|
| 56 |
+
title = {{TRL: Transformers Reinforcement Learning}},
|
| 57 |
+
author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
|
| 58 |
+
license = {Apache-2.0},
|
| 59 |
+
url = {https://github.com/huggingface/trl},
|
| 60 |
+
year = {2020}
|
| 61 |
+
}
|
| 62 |
+
```
|
models/qlora-adapter/adapter_config.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen2-1.5B-Instruct",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"monteclora_config": null,
|
| 27 |
+
"peft_type": "LORA",
|
| 28 |
+
"peft_version": "0.20.0",
|
| 29 |
+
"qalora_group_size": 16,
|
| 30 |
+
"r": 16,
|
| 31 |
+
"rank_pattern": {},
|
| 32 |
+
"revision": null,
|
| 33 |
+
"target_modules": [
|
| 34 |
+
"k_proj",
|
| 35 |
+
"o_proj",
|
| 36 |
+
"v_proj",
|
| 37 |
+
"q_proj"
|
| 38 |
+
],
|
| 39 |
+
"target_parameters": null,
|
| 40 |
+
"task_type": "CAUSAL_LM",
|
| 41 |
+
"trainable_token_indices": null,
|
| 42 |
+
"use_bdlora": null,
|
| 43 |
+
"use_dora": false,
|
| 44 |
+
"use_qalora": false,
|
| 45 |
+
"use_rslora": false,
|
| 46 |
+
"velora_config": null
|
| 47 |
+
}
|
models/qlora-adapter/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f0eee72a1dda2d7e14715bb53d63e8ac69604b71fcfe9a25e51f7498e1df35b0
|
| 3 |
+
size 8746152
|
models/qlora-adapter/chat_template.jinja
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
' }}{% endif %}{{'<|im_start|>' + message['role'] + '
|
| 4 |
+
' + message['content'] + '<|im_end|>' + '
|
| 5 |
+
'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
|
| 6 |
+
' }}{% endif %}
|
models/qlora-adapter/checkpoint-19/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen2-1.5B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen2-1.5B-Instruct
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Model Card for Model ID
|
| 14 |
+
|
| 15 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
### Model Description
|
| 22 |
+
|
| 23 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
- **Developed by:** [More Information Needed]
|
| 28 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
+
- **Model type:** [More Information Needed]
|
| 31 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
+
- **License:** [More Information Needed]
|
| 33 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
+
|
| 35 |
+
### Model Sources [optional]
|
| 36 |
+
|
| 37 |
+
<!-- Provide the basic links for the model. -->
|
| 38 |
+
|
| 39 |
+
- **Repository:** [More Information Needed]
|
| 40 |
+
- **Paper [optional]:** [More Information Needed]
|
| 41 |
+
- **Demo [optional]:** [More Information Needed]
|
| 42 |
+
|
| 43 |
+
## Uses
|
| 44 |
+
|
| 45 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 46 |
+
|
| 47 |
+
### Direct Use
|
| 48 |
+
|
| 49 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 50 |
+
|
| 51 |
+
[More Information Needed]
|
| 52 |
+
|
| 53 |
+
### Downstream Use [optional]
|
| 54 |
+
|
| 55 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 56 |
+
|
| 57 |
+
[More Information Needed]
|
| 58 |
+
|
| 59 |
+
### Out-of-Scope Use
|
| 60 |
+
|
| 61 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 62 |
+
|
| 63 |
+
[More Information Needed]
|
| 64 |
+
|
| 65 |
+
## Bias, Risks, and Limitations
|
| 66 |
+
|
| 67 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 68 |
+
|
| 69 |
+
[More Information Needed]
|
| 70 |
+
|
| 71 |
+
### Recommendations
|
| 72 |
+
|
| 73 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 74 |
+
|
| 75 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 76 |
+
|
| 77 |
+
## How to Get Started with the Model
|
| 78 |
+
|
| 79 |
+
Use the code below to get started with the model.
|
| 80 |
+
|
| 81 |
+
[More Information Needed]
|
| 82 |
+
|
| 83 |
+
## Training Details
|
| 84 |
+
|
| 85 |
+
### Training Data
|
| 86 |
+
|
| 87 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 88 |
+
|
| 89 |
+
[More Information Needed]
|
| 90 |
+
|
| 91 |
+
### Training Procedure
|
| 92 |
+
|
| 93 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 94 |
+
|
| 95 |
+
#### Preprocessing [optional]
|
| 96 |
+
|
| 97 |
+
[More Information Needed]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
#### Training Hyperparameters
|
| 101 |
+
|
| 102 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 103 |
+
|
| 104 |
+
#### Speeds, Sizes, Times [optional]
|
| 105 |
+
|
| 106 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 107 |
+
|
| 108 |
+
[More Information Needed]
|
| 109 |
+
|
| 110 |
+
## Evaluation
|
| 111 |
+
|
| 112 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 113 |
+
|
| 114 |
+
### Testing Data, Factors & Metrics
|
| 115 |
+
|
| 116 |
+
#### Testing Data
|
| 117 |
+
|
| 118 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
#### Factors
|
| 123 |
+
|
| 124 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
#### Metrics
|
| 129 |
+
|
| 130 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 131 |
+
|
| 132 |
+
[More Information Needed]
|
| 133 |
+
|
| 134 |
+
### Results
|
| 135 |
+
|
| 136 |
+
[More Information Needed]
|
| 137 |
+
|
| 138 |
+
#### Summary
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## Model Examination [optional]
|
| 143 |
+
|
| 144 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 145 |
+
|
| 146 |
+
[More Information Needed]
|
| 147 |
+
|
| 148 |
+
## Environmental Impact
|
| 149 |
+
|
| 150 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 151 |
+
|
| 152 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 153 |
+
|
| 154 |
+
- **Hardware Type:** [More Information Needed]
|
| 155 |
+
- **Hours used:** [More Information Needed]
|
| 156 |
+
- **Cloud Provider:** [More Information Needed]
|
| 157 |
+
- **Compute Region:** [More Information Needed]
|
| 158 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 159 |
+
|
| 160 |
+
## Technical Specifications [optional]
|
| 161 |
+
|
| 162 |
+
### Model Architecture and Objective
|
| 163 |
+
|
| 164 |
+
[More Information Needed]
|
| 165 |
+
|
| 166 |
+
### Compute Infrastructure
|
| 167 |
+
|
| 168 |
+
[More Information Needed]
|
| 169 |
+
|
| 170 |
+
#### Hardware
|
| 171 |
+
|
| 172 |
+
[More Information Needed]
|
| 173 |
+
|
| 174 |
+
#### Software
|
| 175 |
+
|
| 176 |
+
[More Information Needed]
|
| 177 |
+
|
| 178 |
+
## Citation [optional]
|
| 179 |
+
|
| 180 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 181 |
+
|
| 182 |
+
**BibTeX:**
|
| 183 |
+
|
| 184 |
+
[More Information Needed]
|
| 185 |
+
|
| 186 |
+
**APA:**
|
| 187 |
+
|
| 188 |
+
[More Information Needed]
|
| 189 |
+
|
| 190 |
+
## Glossary [optional]
|
| 191 |
+
|
| 192 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 193 |
+
|
| 194 |
+
[More Information Needed]
|
| 195 |
+
|
| 196 |
+
## More Information [optional]
|
| 197 |
+
|
| 198 |
+
[More Information Needed]
|
| 199 |
+
|
| 200 |
+
## Model Card Authors [optional]
|
| 201 |
+
|
| 202 |
+
[More Information Needed]
|
| 203 |
+
|
| 204 |
+
## Model Card Contact
|
| 205 |
+
|
| 206 |
+
[More Information Needed]
|
| 207 |
+
### Framework versions
|
| 208 |
+
|
| 209 |
+
- PEFT 0.20.0
|
models/qlora-adapter/checkpoint-19/adapter_config.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen2-1.5B-Instruct",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"monteclora_config": null,
|
| 27 |
+
"peft_type": "LORA",
|
| 28 |
+
"peft_version": "0.20.0",
|
| 29 |
+
"qalora_group_size": 16,
|
| 30 |
+
"r": 16,
|
| 31 |
+
"rank_pattern": {},
|
| 32 |
+
"revision": null,
|
| 33 |
+
"target_modules": [
|
| 34 |
+
"k_proj",
|
| 35 |
+
"o_proj",
|
| 36 |
+
"v_proj",
|
| 37 |
+
"q_proj"
|
| 38 |
+
],
|
| 39 |
+
"target_parameters": null,
|
| 40 |
+
"task_type": "CAUSAL_LM",
|
| 41 |
+
"trainable_token_indices": null,
|
| 42 |
+
"use_bdlora": null,
|
| 43 |
+
"use_dora": false,
|
| 44 |
+
"use_qalora": false,
|
| 45 |
+
"use_rslora": false,
|
| 46 |
+
"velora_config": null
|
| 47 |
+
}
|
models/qlora-adapter/checkpoint-19/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f0eee72a1dda2d7e14715bb53d63e8ac69604b71fcfe9a25e51f7498e1df35b0
|
| 3 |
+
size 8746152
|
models/qlora-adapter/checkpoint-19/chat_template.jinja
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
' }}{% endif %}{{'<|im_start|>' + message['role'] + '
|
| 4 |
+
' + message['content'] + '<|im_end|>' + '
|
| 5 |
+
'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
|
| 6 |
+
' }}{% endif %}
|
models/qlora-adapter/checkpoint-19/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:69be2bca19da23ec8f5095c89d0619bab7c6f2e66fd282bb9f498630b701f73c
|
| 3 |
+
size 17624139
|
models/qlora-adapter/checkpoint-19/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:83052e4995106c6cd2889c5d71cb82eeb5554622bfaf6c04ea5d2b42200522e1
|
| 3 |
+
size 14645
|
models/qlora-adapter/checkpoint-19/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e05c64baded779c44674cf60fea5d030392afceb752a7adf9b93c35bb717462d
|
| 3 |
+
size 1465
|
models/qlora-adapter/checkpoint-19/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:48f722bc04c884e2fe1525fdcd85a1293a8499b6e620c1ac7c083c49632305fb
|
| 3 |
+
size 11418262
|
models/qlora-adapter/checkpoint-19/tokenizer_config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": null,
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<|im_start|>",
|
| 10 |
+
"<|im_end|>"
|
| 11 |
+
],
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 32768,
|
| 15 |
+
"pad_token": "<|im_end|>",
|
| 16 |
+
"split_special_tokens": false,
|
| 17 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 18 |
+
"unk_token": null
|
| 19 |
+
}
|
models/qlora-adapter/checkpoint-19/trainer_state.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 1.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 19,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [],
|
| 12 |
+
"logging_steps": 25,
|
| 13 |
+
"max_steps": 19,
|
| 14 |
+
"num_input_tokens_seen": 0,
|
| 15 |
+
"num_train_epochs": 1,
|
| 16 |
+
"save_steps": 500,
|
| 17 |
+
"stateful_callbacks": {
|
| 18 |
+
"TrainerControl": {
|
| 19 |
+
"args": {
|
| 20 |
+
"should_epoch_stop": false,
|
| 21 |
+
"should_evaluate": false,
|
| 22 |
+
"should_log": false,
|
| 23 |
+
"should_save": true,
|
| 24 |
+
"should_training_stop": true
|
| 25 |
+
},
|
| 26 |
+
"attributes": {}
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"total_flos": 2987258504294400.0,
|
| 30 |
+
"train_batch_size": 4,
|
| 31 |
+
"trial_name": null,
|
| 32 |
+
"trial_params": null
|
| 33 |
+
}
|
models/qlora-adapter/checkpoint-19/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d74734ce9cb9bcc14d79fa44b836130442b41dc2e3dbb85c24097b9b0b9e291
|
| 3 |
+
size 5713
|
models/qlora-adapter/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:48f722bc04c884e2fe1525fdcd85a1293a8499b6e620c1ac7c083c49632305fb
|
| 3 |
+
size 11418262
|
models/qlora-adapter/tokenizer_config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": null,
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<|im_start|>",
|
| 10 |
+
"<|im_end|>"
|
| 11 |
+
],
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 32768,
|
| 15 |
+
"pad_token": "<|im_end|>",
|
| 16 |
+
"split_special_tokens": false,
|
| 17 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 18 |
+
"unk_token": null
|
| 19 |
+
}
|
models/qlora-adapter/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d74734ce9cb9bcc14d79fa44b836130442b41dc2e3dbb85c24097b9b0b9e291
|
| 3 |
+
size 5713
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.1.0
|
| 2 |
+
transformers>=4.40.0
|
| 3 |
+
peft>=0.10.0
|
| 4 |
+
accelerate>=0.30.0
|
| 5 |
+
gradio>=4.44.0
|