llm.py- Main LLM implementation with training and chat functionalityllm_runner.py- Alternative runner with better error handlingchat.py- Lightweight chat interface for using pre-trained model
python llm.py --trainpython llm.py --chatpython llm.py --testpython chat.py- Transformer-based LLM with multi-head attention
- Memory-mapped file loading for large datasets
- Interactive chat interface for real-time conversations
- Error handling and input validation
- Cross-device compatibility (CPU/GPU/MPS)
- Python 3.8+
- torch
- pickle
- mmap
vocab.txt- Character vocabularyoutput/train_split.txt- Training dataoutput/val_split.txt- Validation data
- Ensure all required files exist
- Run training if model not already trained
- Start interactive chat to test the LLM
- Use the lightweight chat interface for quick conversations
The LLM is now ready to use! You can ask any question and it should provide coherent responses based on the training data.