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

Can we update the another type instance database object by the map_batches of ray? #61

Open
Wakings opened this issue Oct 2, 2023 · 0 comments

Comments

@Wakings
Copy link

Wakings commented Oct 2, 2023

I want to use map_batches update the database obtained by langchain FAISS, but I can not get correct answer.
Is it because the distributed approach is not suitable for this kind of update ?

from langchain.vectorstores import FAISS
db = FAISS.from_texts(["start"],embedding_model)
def update_db(batch):
    global db
    db.add_texts(batch['text'])
    # log the db 
    print(len(db.docstore._dict)) # 2
    return {}

demo_data.map_batches(
    update_db,
    batch_size=10,
    compute=ActorPoolStrategy(size=1)).count()
print("-----")
print(len(db.docstore._dict)) # 1
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