langchain-pgvector
langchain-pgvector copied to clipboard
Knowledge base Q&A program using LangChain for retrieval-augmented prompting and PGVector as vector store.
What is this?
This is a simple CLI Q&A tool that uses LangChain to generate document embeddings using HuggingFace embeddings, store them in a vector store (PGVector hosted on Supabase), retrieve them based on input similarity, and augment the LLM prompt with the knowledge base context.
The knowledge base documents are stored in the /documents directory.
How to run the program?
- Create a new virtual environment and launch it.
- Install dependencies with
pip install -r requirements.txt. - Create a vector database on Supabase by enabling the PGVector extension.
- Add your OpenAI API key and PGVector database information into an
.envfile (refer to.env.exampleas reference). - If running for the first time, set the
INITIALIZEvariable toTrue. - Run the program with
python qna.py.
How to 'fine-tune' it on my own documents?
Simply replace the .txt files in the /documents directory with your own documents and run the program.
I am encountering an error about token dimension mismatch (1536 vs 768)
Follow the recommendations from this GitHub Issue thread.