I have chronic hamstring problems. It's a pretty common side effect of working at a desk all day, which tends to shorten your hammies. I stretch them a lot, but it never seems to be enough. The only thing that helps alleviate the problem at all for me is to ride easy to moderate for about the first 10-20 minutes of my ride at a high cadence to get nice and warm, and then stop and get off the bike and do some serious stretching. It helps a lot most days, but it's still an on-going battle.
If your bike is fit properly, the only thing I can think of is to look at your foot/pedal position. If you are pointing your toes too far down (or up), that could impact your hamstrings.
Finally, try to ride in a lower gear at a higher cadence to the extent that's practical. Mashing the gears is much harder on the hamstrings.