Views
No views yet
model.py in this repo for the class definition)model.py's
generate()) -- ~36 generations/sec, ~920 tokens/sec at batch_size=32 on a consumer
CPU (fp32; int8 dynamic quantization was tested and found to not help once
KV-caching is used, at this model scale -- fp32 is the recommended path)<chat> -- short, high-volume, low-effort hype comments ("LMAOOO", "W stream", emote
spam), matching typical live chat cadence.<superchat> -- rarer, longer, more coherent messages: questions, personal questions,
playful roasts, jokes, and support messages, matching the style of paid
superchat/membership messages that streamers are expected to acknowledge.1import torch
2from tokenizers import Tokenizer
3from safetensors.torch import load_model
4from model import ChatGPTMini, ModelConfig # model.py included in this repo
5
6tokenizer = Tokenizer.from_file("tokenizer.json")
7cfg = ModelConfig(vocab_size=8000, pad_token_id=tokenizer.token_to_id("<pad>"))
8model = ChatGPTMini(cfg)
9load_model(model, "model.safetensors")
10model.eval()
11
12bos_id = tokenizer.token_to_id("<bos>")
13chat_id = tokenizer.token_to_id("<chat>")
14eos_id = tokenizer.token_to_id("<eos>")
15
16prompt = torch.tensor([[bos_id, chat_id]])
17out = model.generate(prompt, max_new_tokens=30, temperature=0.9, top_k=40, top_p=0.9, eos_token_id=eos_id)
18print(tokenizer.decode(out[0].tolist(), skip_special_tokens=True))example.py in this repo for a complete runnable script, including batched
generation (recommended for real usage -- throughput scales far better than looping
one generation at a time).lparkourer10/twitch_chat
dataset (CC-BY-SA-4.0, usernames stripped), supplemented with a small amount of
synthetic hype-phrase data.