Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ranker.compress_documents(query=query, documents=docs) changes the docs in the input #41

Open
tyu008 opened this issue May 17, 2024 · 0 comments

Comments

@tyu008
Copy link

tyu008 commented May 17, 2024

Now I have a series of two function calls.

(1) ranked_docs_1 = ranker.compress_documents(query=query1, documents=docs)

(2) ranked_docs_2 = ranker.compress_documents(query=query2, documents=docs)

The second call (2), will influence the content in ranked_docs_1. It brings me an issue when using it.

A workaround solution is to use deep copy in the input,
e.g.
ranker.compress_documents(query=query, documents=copy.deepcopy(docs))

Could we implement the deep-copy within the function "ranker.compress_documents"?

Below the testing codes leading to the above issues.

`from langchain.docstore.document import Document
from langchain_nvidia_ai_endpoints import NVIDIARerank
import os
os.environ["NVIDIA_API_KEY"]=""

ranker = NVIDIARerank()
docs = []
queries = []
for i in range(10):
docs.append(Document(page_content=str(i)))
queries.append(str(i) + "test")
IRs = []
for idx, query in enumerate(queries):
IRs.append(
ranker.compress_documents(query=query, documents=docs)
)
print(str(IRs[0]))`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant