llm-applications icon indicating copy to clipboard operation
llm-applications copied to clipboard

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

Open Wakings opened this issue 2 years ago • 0 comments

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

Wakings avatar Oct 02 '23 12:10 Wakings