Skip to content

Weird memory management inside ranker.rerank #45

@chiaraatbolt

Description

@chiaraatbolt

Hi,

I am working a bit with Ranker.rerank() and I noticed the following problem. On this line, the original list of passages is saved as an attribute to the class, and on this line the same list is modified.

Due to the way Python lists are implemented, this means that each time we run rerank() we are actually modifying the original list in loco, and also that the output returned by rerank() is the same input list (at the same memory location). This can lead to multiple hidden behaviours, for instance: if I rerank the same passages on multiple queries sequentially and save the output somewhere, the output from each call is constantly being modified by subsequent calls, with the scores varying.

Is it possible to fix this?

Thanks a lot for your work :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions