Code Monkey home page Code Monkey logo

langchain_faiss_vectorindex's Introduction

Document Retrieval with FAISS vectorstore, langchain and OpenAI

This is the repository to my tutorial on YouTube: https://youtu.be/N7TQgp18kA4 It will index your pdf documents from the data directory and store it in faiss_db.

You can then retrieve information from your documents, which will require an OpenAI api key. You can run the document_chat.py file to query your documents, or run the telegram_bot to query them on Telegram. This will require an API token, that you will get from the BotFather in Telegram.

You can add new documents to your index by placing new pdf files in the new_document directory and running the add_document.py file.

If you want to run everything on gpu, just install faiss-gpu (you must uninstall faiss-cpu then), and put the embeddings on the gpu by defining it in the config.yaml

Changes I made to the code you see in the video

I added a config.yaml file where you can define the huggingface embeddings you want to use, and on which device to run it (cpu or cuda). Also there is the save_path and index_name for FAISS vectorstore defined.

I added the functions load_db, save_db, load_embeddings and load_config in the utils file, to reduce repetetive code in the other .py files.

Running with cuda 12

It's difficult (or impossible) to install version 10 of the cuda sdk. To make it work with the current version (12), download a compatible torch build:

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.