The multiyear pact gives Meta access to content for training and to retrieve information for users of its AI tools.