Update model files and add inference script
Browse filesFiles changed (2)
- README.md+10
- inference.pyAdded+51
76 unmodified lines7778798076 unmodified linesstate_dict = load_file("simbot.safetensors")model.load_state_dict(state_dict)model.eval()76 unmodified lines777879808182838485868788899076 unmodified linesstate_dict = load_file("simbot.safetensors")model.load_state_dict(state_dict)model.eval()```## Prompting the ModelThis model is a custom PyTorch implementation and does not support the Hugging Face inference widget.### Interactive Usage (Recommended)```bashpython inference.py
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import torchimport jsonfrom tokenizers import Tokenizerfrom safetensors.torch import load_filefrom model.simbot import SIMGPT
# -----------------------------# Load tokenizer & config# -----------------------------tokenizer = Tokenizer.from_file("tokenizer.json")
with open("config.json") as f: cfg = json.load(f)
# -----------------------------# Load model# -----------------------------model = SIMGPT( vocab_size=cfg["vocab_size"], block_size=cfg["block_size"], n_layers=cfg["n_layers"], n_heads=cfg["n_heads"], d_model=cfg["d_model"])
state_dict = load_file("simbot.safetensors")model.load_state_dict(state_dict)model.eval()
print("SimBot GPT ready. Type 'exit' to quit.\n")
# -----------------------------# Interactive loop# -----------------------------while True: user_input = input("User: ").strip() if user_input.lower() in {"exit", "quit"}: break
prompt = f"<bos>\nUser: {user_input}\nAssistant:" ids = tokenizer.encode(prompt).ids x = torch.tensor(ids).unsqueeze(0)
with torch.no_grad(): for _ in range(80): logits = model(x) next_id = torch.argmax(logits[:, -1, :], dim=-1).item() x = torch.cat([x, torch.tensor([[next_id]])], dim=1)
output = tokenizer.decode(x[0].tolist()) print("\nAssistant:", output.split("Assistant:")[-1].strip(), "\n")README.md+10
inference.pyAdded+51