Ultimately, after large-scale technological innovation that leads to societal change like worker displacement (like happened after agricultural innovations displaced farm workers in the American South, or manufacturing innovations displaced American factory workers, or unemployment during the Great Depression) you end up with societal unrest (like organized protest and political action) that leads to increased societal safety nets and welfare benefits… temporarily and if the unrest is big enough.
But eventually, as markets adjust and other types of employment opportunities pop up or as the capital class gets annoyed at rising labor costs, the welfare roles contract to encourage people back into the workforce (in American society, I’m talking about. I’m not sure how other countries handle this.)
There’s a thorough and well-researched (though very dense) book called Regulating the Poor if you want to see more along those lines.
But job retraining tends not to have much of an effect.