I’ve had this problem for a while, possibly since the start of iOS 12.
I have Show Star Ratings switches on and can access the star rating for songs in the Music app. I select Rate Song... from the action sheet, tap a star rating in the alert view, then tap the Done button. However the rating is not saved: if I open up the rating alert view again, it’s back to 0 stars.
This is happening both for music I’ve purchased from iTunes and other music I own.
Has anyone else experienced this? How can I fix it?