Edit the GPTConfig in api.py to adjust model architecture:
python
1config = GPTConfig(2 vocab_size=vocab_size,3 n_embd=embedding_dim,4 n_layer=4,# Number of transformer layers5 n_head=4,# Number of attention heads6 max_seq_len=512,# Maximum sequence length7 dropout=0.1# Dropout rate8)
Server Settings
Change the port or host in api.py:
app.run(debug=True, host='0.0.0.0', port=5000)
🐛 Troubleshooting
Model Not Loading
Error:No such file or directory: 'gpt_embeddings_final.pt'
Solution: Make sure you have both:
gpt_embeddings_final.pt in the root directory
checkpoints/model_final.pt for the trained weights
Tokenizer Not Found
Error:No such file or directory: 'english_tokenizer.model'
Solution: Place your SentencePiece tokenizer file in the root directory
Port Already in Use
Error:Address already in use
Solution: Either:
Kill the process using port 5000
Change the port in api.py to a different number (e.g., 5001)
CORS Errors
If you're accessing from a different origin, CORS is already configured in api.py:
CORS(app) # Already enabled
💡 Tips
GPU Acceleration: If you have a CUDA-capable GPU, the model will automatically use it
Temperature: Start with 0.7-0.9 for balanced responses
Top-K: Lower values (20-40) for more focused responses, higher (60-100) for more variety
Max Length: Adjust based on your needs - shorter for quick responses, longer for detailed ones
🔒 Security Notes
This is a development server - not suitable for production
For production, use a WSGI server like Gunicorn or uWSGI
The server runs on all interfaces (0.0.0.0) - be cautious on public networks
📝 License
This project is open source and available for educational purposes.