1. A method of generating a context model to be used for context-based compression comprising: a. determining file categorization criteria for a file to be compressed; b. determining an initial context model including an initial value for a current number of contexts and an initial context set based on the file categorization criteria; c. determining, for the initial context model, empirical statistics of contexts and symbols; d. using the empirical statistics to reduce the current number of contexts to a predetermined number of contexts, said predetermined number being smaller than said initial value; and e. generating the context model for mapping data elements to a set of contexts of size equal to said predetermined number of contexts.