Skip to content

Question Answering application with Large Language Models (LLMs) and Amazon Postgresql using pgvector

License

Notifications You must be signed in to change notification settings

aws-samples/rag-with-amazon-postgresql-using-pgvector-and-sagemaker

QA with LLM and RAG (Retrieval Augmented Generation)

This project is a Question Answering application with Large Language Models (LLMs) and Amazon Aurora Postgresql using pgvector. An application using the RAG(Retrieval Augmented Generation) approach retrieves information most relevant to the user’s request from the enterprise knowledge base or content, bundles it as context along with the user’s request as a prompt, and then sends it to the LLM to get a GenAI response.

LLMs have limitations around the maximum word count for the input prompt, therefore choosing the right passages among thousands or millions of documents in the enterprise, has a direct impact on the LLM’s accuracy.

In this project, Amazon Aurora Postgresql with pgvector is used for knowledge base.

The overall architecture is like this:

rag_with_pgvector_arch

Overall Workflow

  1. Deploy the cdk stacks (For more information, see here).
    • A SageMaker Studio in a private VPC.
    • A SageMaker Endpoint for text generation.
    • A SageMaker Endpoint for generating embeddings.
    • An Amazon Aurora Postgresql cluster for storing embeddings.
    • Aurora Postgresql cluster's access credentials (username and password) stored in AWS Secrets Mananger as a name such as RAGPgVectorStackAuroraPostg-xxxxxxxxxxxx.
  2. Open JupyterLab in SageMaker Studio and then open a new terminal.
  3. Run the following commands on the terminal to clone the code repository for this project:
    git clone --depth=1 https://github.com/aws-samples/rag-with-amazon-postgresql-using-pgvector.git
    
  4. Open data_ingestion_to_pgvector.ipynb notebook and Run it. (For more information, see here)
  5. Run Streamlit application. (For more information, see here)

References

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

Question Answering application with Large Language Models (LLMs) and Amazon Postgresql using pgvector

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •