Thinning the fruit definitely helps, but if the pears have been getting smaller for only the past two years, that's probably not the only issue. Over five years, a pear tree can actually deplete the soil, especially if it wasn't very rich to begin with. Check if maybe you're fertilizing "as usual" with some old habit, but the tree has grown and now needs more nutrients. Try adding a balanced mineral fertilizer in spring and nitrogen at the start of the season - pear trees especially love it.
But there's another thing to consider - the tree's age. From around five years old, pear trees start fruiting more actively, and if it sets too many fruits, there simply aren't enough nutrients to go around. That's when you need to thin the fruit set in June, while it's still small. Leave just one fruit per 15-20 centimeters of branch - that way each pear will get enough energy to develop properly.
Also pay attention to pruning. If you haven't thinned out the canopy in a while, it might be too dense, with leaves shading each other, and photosynthesis drops. The light conditions affect fruit size just as much as fertilizing does.