musabc commited on
Commit
9c6ee46
·
verified ·
1 Parent(s): c55c554

Upload sft_03_train.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. sft_03_train.py +11 -4
sft_03_train.py CHANGED
@@ -179,8 +179,10 @@ def sample_test(model, tokenizer, prompt_text: str, max_new: int = 200):
179
  with torch.no_grad():
180
  with torch.amp.autocast(device_type="cuda", dtype=DTYPE):
181
  out = model.generate(x, max_new_tokens=max_new,
182
- temperature=0.7, top_k=50,
183
- repetition_penalty=1.1)
 
 
184
  text = tokenizer.decode(out[0].tolist())
185
  model.train()
186
  return text
@@ -406,9 +408,14 @@ def main():
406
  try:
407
  mdl = model._orig_mod if hasattr(model, "_orig_mod") else model
408
  prompts = [
409
- "### Kullanici:\n2 + 2 kac eder?\n### Asistan:\n",
 
 
410
  "### Kullanici:\nTurkiye'nin baskenti neresidir?\n### Asistan:\n",
411
- "### Kullanici:\nBir cocuga uzay neden onemli oldugunu anlat.\n### Asistan:\n",
 
 
 
412
  ]
413
  for p in prompts:
414
  out = sample_test(mdl, args.tokenizer, p, max_new=120)
 
179
  with torch.no_grad():
180
  with torch.amp.autocast(device_type="cuda", dtype=DTYPE):
181
  out = model.generate(x, max_new_tokens=max_new,
182
+ temperature=0.3, top_k=40,
183
+ repetition_penalty=1.0,
184
+ no_repeat_ngram_size=0,
185
+ eos_token_id=0) # <|endoftext|>
186
  text = tokenizer.decode(out[0].tolist())
187
  model.train()
188
  return text
 
408
  try:
409
  mdl = model._orig_mod if hasattr(model, "_orig_mod") else model
410
  prompts = [
411
+ # Tarif (training'de turkish_recipes 4K)
412
+ "### Kullanici:\nMercimek corbasi tarifi ver.\n### Asistan:\n",
413
+ # Factual short (turkish_exam, knowledge)
414
  "### Kullanici:\nTurkiye'nin baskenti neresidir?\n### Asistan:\n",
415
+ # Aciklayici (general)
416
+ "### Kullanici:\nBir e-mail nasil yazilir? Kisa anlat.\n### Asistan:\n",
417
+ # Simple math (gsm8k/metamath)
418
+ "### Kullanici:\nAhmet'in 5 elmasi var, 2 tane yer. Kac kaldi?\n### Asistan:\n",
419
  ]
420
  for p in prompts:
421
  out = sample_test(mdl, args.tokenizer, p, max_new=120)