LightMem icon indicating copy to clipboard operation
LightMem copied to clipboard

[Bug] It seems a bug when construct_update_queue_all_entries

Open OceanPresentChao opened this issue 8 months ago • 2 comments

In function construct_update_queue_all_entries in lightmem.py, we have

hits = self.embedding_retriever.search(
                query_vector=vec,
                limit=top_k,
                filters={"float_time_stamp": {"lte": ts}}
            )

According to paper, On this basis, we further impose the constraint that only entries with later timestamps are allowed to update earlier ones (tj ≥ ti), which is consistent with realistic temporal dynamics. Should we use operator gte to get all candidates that has later timestamps?

OceanPresentChao avatar Mar 17 '26 15:03 OceanPresentChao

Thank you for raising this, great question worth clarifying.

The current lte filter is intentional. Here, update_queue stores the targets that the current entry (as the updater) will push updates to, i.e., entries with earlier timestamps that should be revised in light of this newer one. This is consistent with the paper's constraint that "entries with later timestamps are allowed to update earlier ones (tj ≥ ti)": the current entry has the larger timestamp (tj), and the filtered candidates all satisfy ti ≤ tj. Using gte would invert the direction, collecting entries newer than the current one, but those haven't been written yet at construction time and would have no reason to be updated by an older entry.

Xubqpanda avatar Mar 18 '26 02:03 Xubqpanda

Thanks! I notice the code in lightmem.py

            candidate_sources = []
            for other in all_entries:
                update_queue = other["payload"].get("update_queue", [])
                for candidate in update_queue:
                    if candidate["id"] == eid and candidate["score"] >= score_threshold:
                        candidate_sources.append(other)
                        break

OceanPresentChao avatar Mar 18 '26 04:03 OceanPresentChao