Encoding the models automatically