Per Apple: Photos is enabled by powerful machine learning to deliver unique features
like Memories, Search Suggestions, and For You. Photos analyzes every photo in a user’s photo library using on-device machine learning that delivers
a personalized experience for each user. And this analysis is designed from the ground up with privacy in mind, with all of the processing done on device—and the results of this analysis are not shared with anyone, not even Apple.
Use Memories in Photos on your iPhone, iPad, or iPod touch - Apple Support
The Photos app recognizes significant people, places, and events in your library, then presents them in curated collections called Memories. You can also create your own Memories, and share them with friends and family.
Photos for iOS and iPadOS - Apple
One of the best things about Photos is how it protects your privacy. iOS and iPadOS are designed to take advantage of the powerful processor built into every iPhone and iPad. So when you search your photos, for instance, all the face recognition and scene and object detection are done completely on your device. Which means your photos are yours and yours alone.
For more details, Apple has available a tech brief describing how this all works:
https://www.apple.com/ios/photos/pdf/Photos_Tech_Brief_Sept_2019.pdf
From that: People and pets identification
Identifies whether people, dogs, or cats are visible in a photo.
The machine learning algorithm is far from perfect, though. The algorithm used is convinced one of the cats I’ve photographed is a dog.