Hi Sole,
It’s been a long time, but I remember helping with drafting the Tf-idf text in the documentation as part of a scikit-learn sprint at SciPy a looong time ago where I mentioned this difference (since it initially surprised me, because I couldn’t get it to match my from-scratch implementation). As far as I remember, the sklearn version addressed some instability issues for certain edge cases.
I am not sure if that helps, but I have briefly compared the textbook vs the sklearn tf-idf here:
https://github.com/rasbt/machine-learning-book/blob/main/ch08/ch08.ipynb
Best,
Sebastian