feat: add non-interactive one-liner training commands
Browse filesFiles changed (3)
- README.md+12-1
- sage/cli.py+15
- sage_single.py+18
86 unmodified lines8788899091929386 unmodified lines## 👨🏫 Training SAGESAGE supports real-time training directly from the CLI.### /train [steps]Run pre-training using the `TinyStories` dataset (default).86 unmodified lines8788899091929394959697989910010110210310486 unmodified lines## 👨🏫 Training SAGESAGE supports real-time training either directly from the interactive REPL or via simple one-liner CLI commands (useful for background scripts).### Non-Interactive "One-Liner" CommandsIf you want to bypass the chat interface and just run a training job, pass the command as a CLI argument:```bashpython sage_single.py --train 100 # Pre-train for 100 stepspython sage_single.py --finetune 200 # Instruction-tune for 200 stepspython sage_single.py --quantize # Apply INT8 quantization```### Interactive REPL CommandsIf you are inside the chat interface, use the slash commands:### /train [steps]Run pre-training using the `TinyStories` dataset (default).
201 unmodified lines202203204205206207201 unmodified linesrag_manager = RAGManager(model, tokenizer, config.device)history = ConversationHistory(tokenizer, max_tokens=config.max_seq_len - 128)# ---------- REPL loop ----------while True:try:201 unmodified lines202203204205206207208209210211212213214215216217218219220221222201 unmodified linesrag_manager = RAGManager(model, tokenizer, config.device)history = ConversationHistory(tokenizer, max_tokens=config.max_seq_len - 128)# ---------- One-liner CLI arguments ----------if len(sys.argv) > 1:cmd = sys.argv[1].lower()args = sys.argv[2:]if cmd == "--train":handle_train(model, config, tokenizer, args)elif cmd == "--finetune":handle_finetune(model, config, tokenizer, args)elif cmd == "--quantize":handle_quantize(model)else:print(f" Unknown argument: {cmd}")print(" Usage: --train [steps] | --finetune [steps] | --quantize")return# ---------- REPL loop ----------while True:try:
673 unmodified lines674675676677678679673 unmodified linesrag = RAGManager(model, tok, config.device)hist = ConversationHistory(tok, config.max_seq_len - 128)while True:try: inp = input("You: ").strip()except (EOFError, KeyboardInterrupt): print("\n Goodbye!"); break673 unmodified lines674675676677678679680681682683684685686687688689690691692693694695696697673 unmodified linesrag = RAGManager(model, tok, config.device)hist = ConversationHistory(tok, config.max_seq_len - 128)if len(sys.argv) > 1:cmd = sys.argv[1].lower()args = sys.argv[2:]if cmd == "--train":s = int(args[0]) if args else 100train_model(model, config, s, tokenizer=tok)returnelif cmd == "--finetune":s = int(args[0]) if args else 200finetune(model, config, steps=s, tokenizer=tok)returnelif cmd == "--quantize":quantize_int8(model)returnelse:print(f" Unknown argument: {cmd}\n Usage: --train [steps] | --finetune [steps] | --quantize")returnwhile True:try: inp = input("You: ").strip()except (EOFError, KeyboardInterrupt): print("\n Goodbye!"); break
README.md+12-1
sage/cli.py+15
sage_single.py+18