In this project, i use crawled documents from Thuvienphapluat to form a knowledge database in FAISS and build a retrieval-augmented generation application for these documents.
The documents are transformed to a vector database using RecursiveCharacterTextSplitter (the embedding model, chunk size, chunk overlap can be modified). I utilize FAISS for the vector database and Langchain for chunking. For the generator, i use Gemini models using API (in this code i use 1.5 Flash, which can be modified in main.py). The app is built using Flask as backend and a simple (i'm not humble, it's simple af) HTML frontend. I use ngrok to display the result.
You can run database\create_knowledge_database.ipynb to obtain the FAISS folder of the knowledge database. The embedding model, chunk size and chunk overlap size can be edited there.
The crawled documents and a database folder (using multilingual-e5-base as embedding model, a chunk size of 512 and chunk overlap size of 100) i ran can be found in this drive link. The FAISS database folder, Huggingface token and Gemini API key should be defined using OS variables.
Google Colab
Since my personal device does not have a powerful GPU, i run the app using Google Colab. You can upload the notebook main.ipynb on that environment and run the app.
Local If you're running on your PC, the app can be run using a virtual environment:
python -m venv venv
venv\Scripts\activateInstall the required libraries:
pip install -r requirements.txtRemember to set necessary OS variables.
Run the app:
python main.pyThen you click on the ngrok link displayed to use the app.
