The best performance of a Di2 rear derailleur is achieved through correct adjustment. The ST2S and the early ST5 use the XTR DI2 SHADOW PLUS RD-M9050 11-FACH model, the newer ST5 the Shimano XT Di2 11-Speed 11-42.
> Product info | FAQ
How Di2 rear derailleurs are adjusted does not differ between rear derailleurs. How to check and adjust the stops 'L' (=Lower Speed, largest sprocket) and 'H' (=Higher Speed, smallest sprocket), the wrap 'B' and the chainline is explained here using a Deore XT DM-8050 rear derailleur:
Video 1 | Video 2 | Excerpt from the dealer manual
The chainline is adjusted on the ST2S via the SC-M9051 display on the ST5 via the Di2 Cockpit Box EW-RS910 installed in the seat tube or, from summer 2019, in the right handlebar end. Alternatively, this can also be done via the E-Tube App from Shimano for mobile, tablet or PC.