Slayer1B-1.09-Instruct-26.11: weights, card, notes, training code, manifests and results (history squashed; training data not published)
6071ec5 Download training/code/convo_examples.py from SlayerLab/Slayer1B-1.09-Instruct-26.11: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/SlayerLab/Slayer1B-1.09-Instruct-26.11/resolve/main/training/code/convo_examples.py
- Command line
-
hf download hf://SlayerLab/Slayer1B-1.09-Instruct-26.11/training/code/convo_examples.py
-
curl -L -o convo_examples.py https://huggingface.co/SlayerLab/Slayer1B-1.09-Instruct-26.11/resolve/main/training/code/convo_examples.py
3.15 kB
| """Side-by-side conversation samples for the model card: the same everyday prompts and scripted multi-turn dialogues for | |
| several checkpoints (the model's own replies are fed back; the user turns are fixed). Greedy + repetition penalty 1.1. | |
| python convo_examples.py <label>=<ckpt> [<label>=<ckpt> ...] --out results/convo/<name>.json | |
| """ | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import torch | |
| from tokenizers import Tokenizer | |
| from chatfmt import Fmt | |
| from model_io import generate, load | |
| SINGLE = ["Cze艣膰! Co u ciebie s艂ycha膰?", "Nie mog臋 zasn膮膰, masz jaki艣 spos贸b?", "Polecisz mi jak膮艣 ksi膮偶k臋 na weekend?", | |
| "Jak ugotowa膰 dobr膮 jajecznic臋?", "Mam jutro rozmow臋 o prac臋 i troch臋 si臋 stresuj臋.", "Co warto zobaczy膰 w Krakowie w jeden dzie艅?", | |
| "Hi! What do you like to do on weekends?", "Can you explain what a black hole is, simply?", "I forgot my friend's birthday. What should I do?", | |
| "Give me a quick idea for a healthy dinner."] | |
| DIALOGUES = [["Hej, planuj臋 wycieczk臋 w g贸ry w pa藕dzierniku.", "A co powinienem zabra膰 ze sob膮?", "Dzi臋ki! A jak d艂ugo trwa wej艣cie na Giewont?"], | |
| ["Ucz臋 si臋 programowa膰 w Pythonie od tygodnia.", "Co to jest p臋tla for? Wyja艣nij pro艣ciej.", "Mo偶esz da膰 ma艂y przyk艂ad?"], | |
| ["I want to start running, but I get tired after two minutes.", "How often should I train in the first month?", "Thanks! Any tips for staying motivated?"], | |
| ["M贸j kot ci膮gle drapie kanap臋.", "Pr贸bowa艂em drapaka, ale go ignoruje.", "Dobra, spr贸buj臋. Dzi臋ki!"]] | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("models", nargs="+") | |
| ap.add_argument("--out", required=True) | |
| ap.add_argument("--max-new", type=int, default=300) | |
| a = ap.parse_args() | |
| f = Fmt(Tokenizer.from_file("/workspace/ckpt/tokenizer.json")) | |
| stop = {f.ime, f.bos, f.ims} | |
| res = {"settings": {"decoding": "greedy", "repetition_penalty": 1.1, "max_new_tokens": a.max_new}, "single": {}, "dialogues": {}} | |
| for spec in a.models: | |
| lab, ck = spec.split("=", 1) | |
| m, _, _ = load(ck, device="cuda", dtype=torch.bfloat16) | |
| m.eval() | |
| def say(msgs): | |
| o, why = generate(m, f.prompt_ids(msgs, None), stop_ids=stop, max_new_tokens=a.max_new, repetition_penalty=1.1, device="cuda") | |
| return f.tok.decode(o, skip_special_tokens=False).strip() + ("" if why == "stop" else " [鈥ut at token limit]") | |
| res["single"][lab] = [{"user": p, "assistant": say([{"role": "user", "content": p}])} for p in SINGLE] | |
| res["dialogues"][lab] = [] | |
| for d in DIALOGUES: | |
| msgs = [] | |
| for u in d: | |
| msgs.append({"role": "user", "content": u}) | |
| msgs.append({"role": "assistant", "content": say(msgs)}) | |
| res["dialogues"][lab].append(msgs) | |
| del m | |
| torch.cuda.empty_cache() | |
| print("done", lab, flush=True) | |
| Path(a.out).parent.mkdir(parents=True, exist_ok=True) | |
| Path(a.out).write_text(json.dumps(res, indent=1, ensure_ascii=False), encoding="utf-8") | |
| if __name__ == "__main__": | |
| main() | |