I have been writing a few technical posts about how ML is used to show ads: https://satyagupte.github.io/posts/how-ads-work/