Make sure the tank breather isn't blocked, if you take the filler cap off and everything starts to work OK, it is blocked.
Change the plug.
Yams are noted for the inlet manifold leaking, you could be getting an air leak there.
If none of these cures it, you may have an electronics problem, the regulator, the coil, CDI or trigger coils going bad when warm. Check the voltage at the battery with the engine running, should be 13v to 14.5v any more and the regulator will be slow cooking the CDI.