I can't remember the YouTube video that I used but the two below will give the idea. They say that it's important to keep the back straight, bend at the hips and let the knees naturally bend. A tip was to put a stick across the front of your hips and hold it there with your belly as you bend over. I tried to do essentially the same exercise by lying on the bed and bringing knees to chest but my right hip has been hurting too much.
The Science of Hamstring Flexibility โ Anatomy & Training Techniques - yogabody
Unlock Your Hamstrings Fast - Cathy Madeo Yoga