2 things to check.
1 if it is fuel it could be the float needle is sticking and not letting fuel to flow as easily as it should. But when the bike is off fuel still trickles down and eventually fills the bowl.
2 if it is electrical, it sounds like a bad condenser. They will run fine when cold but after a couple minutes they warm up and fail.
Check the float out first as it is easiest to get into. For the condenser you will need to purchase a flywheel puller tool to get to the stator plate with the condenser.