llm-tools / embedJs

A NodeJS RAG framework to easily work with LLMs and embeddings
https://llm-tools.mintlify.app/get-started/introduction
Apache License 2.0
327 stars 39 forks source link

Rebuilding Embeddings #17

Closed converseKarl closed 6 months ago

converseKarl commented 6 months ago

If I want to clear out everything and rebuild all the embeddings what is the best approach?

For example a website may change over time and you may want to clear out the website embeddings or the entire thing and rebuild it weekly, monthly etc

adhityan commented 6 months ago

Hello, you can do that with the following methods available within RAGApplication

  1. deleteEmbeddingsFromLoader(uniqueLoaderId, true) - this can be used to remove the embeddings from a single loader
  2. deleteAllEmbeddings(true) - this will remove all the embeddings from all loaders

The parameter true is constant and is used to ensure you really mean to delete the embeddings. Not passing it or passing false would print a console warning without deleting the embeddings.

Hope this helps.

converseKarl commented 6 months ago

is there anyway to add a webload (url dynamically) incrementally whilst keeping existing loadings, and update the build? something along these lines?

    await ragApplication
        .setTemperature(0)
        .addLoader(new WebLoader({ url: url })) // Use the extracted URL
        .setVectorDb(new LanceDb({ path: './db' }))
        .build();
adhityan commented 6 months ago

Yes. Once you get an instance of ragapplcation, you can call the addLoader method on it at any time to add a new loader. In fact, I would recommend you add all loaders dynamically after build.