How abaoxomtieu/rag-api-vietnamesepdf works
Main Components
• Data Ingestion & Preprocessing: This includes the PDF files placed in the data/ folder, and the processing scripts (app_transform_data.py, prepare_vector_db.py, remove_vector_store.py) that transform and ingest PDF content.
• Embedding and Vector Storage: The project uses models (located in the models/ directory) such as all-MiniLM-L6-v2-f16.gguf and vinallama-7b-chat_q5_0.gguf. The embeddings are stored in a vector database, with FAISS used for indexing (see vectorstores/db_faiss/).
• API and Q&A Engine: The API.py script leverages FastAPI to allow question-answering on the private PDF data.
• User Interface: The app.py script (using Streamlit) provides a GUI for users to interact with the system, primarily for initiating the transformation process and visualizing outputs.
• Utility Functions: Files such as utils.py (and similar in the "using_LLM&Embeedin_of_GEMINI" folder) support common functionalities across the system.
Relationships and Interactions
• The process starts with PDF file ingestion, where raw files (in the data/ folder) are processed by the transformation scripts. The outcome of this transformation is the generation of embedding vectors.
• The embedding vectors are then stored in the vector database (managed by FAISS), making them accessible for similarity queries.
• When a user submits a question (via the FastAPI endpoint or through the Streamlit UI), that question is matched against the stored embeddings.
• The retrieved context from the vector store is fed into a language model (using the provided GGUF models) which constructs the answer.
• Lastly, the answer is returned to the user through the API response or rendered via the Streamlit interface.
Architectural Patterns and Design Principles
• Separation of Concerns: Notice clear separation between data ingestion/preprocessing, storage (vector DB), and user interaction (API and UI). This helps in modularizing the components for easier maintenance and scaling.
• Layered Architecture: The system consists of distinct layers (Data Layer, Embedding/Processing Layer, Application Layer) that interact through well-defined interfaces.
• Extensibility: By having utility functions and clearly separated data processing scripts, the project is designed to allow future enhancements, such as integrating additional models, data sources, or different vector databases.
Relevant Technologies, Frameworks, and Libraries
• Langchain: For connecting language models and chaining actions.
• FastAPI: As the framework for the API.
• Streamlit: For building the interactive UI.
• FAISS: For creating and managing the vector database.
• CUDA / GPU Libraries: To leverage hardware acceleration for model inference.
• Python: As the primary programming language, with utilities and configurations defined in requirements.txt.