Model architecture and training