build the framework for contextual model