The social-media giant is aiming to cut around 8,000 employees in May as it continues to invest heavily in AI products.