I would check 1st all the vacuum hoses and connections. When it starts to die and you tap the gas to keep it going, if the rpm shoot up real easy but then wants to die right out when it idles down it could be a vacuum leak. A bad IAC on the throttle body would give a more erratic up and down idle speed.