The new feature comes as a server-side update and you will be notified that it's here via a pop-up in the Android Messages app. Keep in mind that this is an opt-out feature that is enabled by default.
And in case you are worried about Google reading your messages, you can turn it off by pressing on the 3-dot icon in the Messages app, and then selecting the Advanced tab, where you will find the 'Spam protection' toggle.
Since this is Google and there is some data collection going on, naturally, you will want to know exactly what is Google collecting and how it's used. Here is an official statement that Google provided for TheVerge that explains this:
Interestingly, Google itself also explains that if you choose to manually report a spam message, then the contents of the message will also be sent to Google.
We are yet to see how well Google's new automatic spam filter works, but considering the growing amount of text message spam, it could be a very useful feature for many Android users.