How can we prevent AI from being racist, sexist and offensive?

Artificial intelligences continue to exhibit the same biases and prejudices as humans because they are trained on what we create, but there are ways we can improve the situation