Reasoning with multiple levels of abstraction is a powerful method of controlling problem solving in complex domains. We consider the problem of simplifying a knowledge base by creating an abstraction that is tailored for a given set of queries. Our approach is based on associating formally an abstraction with some irrelevant detail that is removed from the knowledge base. We show how creating an abstraction and determining its utility amounts to automatically deciding which aspects of a representation are irrelevant to a query. As a result, we derive a general algorithm schema for automatically generating abstractions for a query. As an instance of the schema, we describe a novel algorithm for automatically abstracting a KB by projecting out relation arguments.