The social media giant is spending hundreds of billions of dollars in a bid to catch up in a fast-moving AI race