Skip to content

About

This project builds a serverless Anti-Money Laundering (AML) assistant using Retrieval-Augmented Generation (RAG) and an agent-based workflow on AWS. It integrates AWS Bedrock foundation models with an AWS Knowledge Base to retrieve compliance policies and uploaded documents, ensuring responses are grounded in uploaded sources.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AML RAG Agent (AWS Bedrock + Lambda + Knowledge Base)

A serverless AML (Anti-Money Laundering) assistant that combines:

  • AWS Bedrock foundation models
  • AWS Knowledge Bases for Retrieval-Augmented Generation (RAG)
  • LangChain + LangGraph tool-based agent workflow
  • AWS Lambda (container image deployed via SAM)
  • Streamlit web interface

The system supports document retrieval, transaction risk assessment, sanctions checks, and compliance report generation.


Features

  • Retrieve AML policies from an AWS Knowledge Base
  • Tool-based transaction risk scoring
  • Simulated sanctions list screening
  • Generate structured AML compliance reports
  • Upload documents to S3 for Knowledge Base indexing
  • REST API exposed through API Gateway
  • Streamlit UI for document upload and chat

Picture

AML RAG Architecture


Simplified Layout

src/
  agent_handler.py        # Main Lambda agent with tools + workflow
  lambda_function.py      # Simpler RAG-only Lambda handler
  requirements.txt
  Dockerfile

streamlit_app.py          # Streamlit frontend

template.yaml             # AWS SAM deployment template

AWS Resources Used

This project expects:

  • An AWS Bedrock-enabled region
  • An existing AWS Knowledge Base ID
  • An S3 bucket used as the document source

Environment variables used by Lambda:

KB_ID=<knowledge-base-id>
S3_BUCKET=<bucket-id>

Deployment (AWS SAM)

Build the container:

sam build

Deploy:

sam deploy --guided

After deployment, SAM outputs the API endpoint:

https://<api-id>.execute-api.<region>.amazonaws.com/Prod/query

Use this endpoint in the Streamlit app configuration.


Lambda Container

Base image:

public.ecr.aws/lambda/python:3.10

Handler:

agent_handler.lambda_handler

Dependencies installed from:

requirements.txt

API Usage

Endpoint

POST /query

Request body

{
  "query": "Check a $15000 crypto transfer from IR"
}

Optional mode switch:

{
  "query": "...",
  "mode": "agent"
}

Modes:

  • "agent" → tool-enabled AML agent
  • "rag" → simple Knowledge Base retrieval

Example response

{
  "answer": "...",
  "mode": "agent",
  "tools_used": ["assess_transaction_risk"],
  "query": "..."
}

Streamlit UI (Optional)

Install minimal UI dependencies:

pip install streamlit boto3 requests

Run locally:

streamlit run streamlit_app.py

The UI allows:

  • Uploading AML documents to S3
  • Chatting with the assistant through the deployed API
  • Viewing uploaded document history

Document Upload Flow

Streamlit → S3 bucket (documents/) → Knowledge Base sync → Lambda retrieval

Knowledge Base indexing may take a short time before new documents become searchable.


Agent Tools Implemented

Tool Purpose
search_aml_knowledge_base Retrieve compliance documents
assess_transaction_risk Calculate AML risk score
check_sanctions_list Simulated sanctions screening
get_uploaded_documents List documents stored in S3
generate_compliance_report Produce structured AML report

The agent workflow instructs the model to rely on tool outputs for transaction analysis.


Notes

  • Sanctions screening logic is simplified for demonstration.
  • Risk scoring logic is rule-based and not regulatory-certified.
  • Knowledge Base syncing behavior depends on AWS indexing configuration.

About

This project builds a serverless Anti-Money Laundering (AML) assistant using Retrieval-Augmented Generation (RAG) and an agent-based workflow on AWS. It integrates AWS Bedrock foundation models with an AWS Knowledge Base to retrieve compliance policies and uploaded documents, ensuring responses are grounded in uploaded sources.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages