it could be a number of things but could be air related and very simlar to a problem i had once and it was the idle speed control valve that had developed a mind if its own.
a quick check just to isolate the problem is to simply disconnect the iscv plug when the engine is acting up. if nothing happens then give the valve a few taps. if the revs drop off then you know where to start.