implement top-freq style longterm memory training