The Legal Document Summarizer is a Flask-based web application that uses AWS Bedrock and the Titan Text G1 - Lite model to summarize legal documents. It provides a structured JSON output with key details such as document type, key provisions, case background, court’s decision, legal implications, and a simplified summary.
- AI-Powered Summarization: Uses AWS Bedrock and the Titan Text G1 - Lite model to analyze and summarize legal documents.
- Structured JSON Output: Returns summaries in a well-structured JSON format.
- Easy Integration: Built with Flask for seamless integration with frontend applications.
- Scalable Deployment: Designed to be deployed on AWS Elastic Beanstalk for scalability and reliability.
-
AWS Bedrock:
- Used to access the Titan Text G1 - Lite model for AI-powered summarization.
- Handles the prompt engineering and model invocation.
-
AWS Elastic Beanstalk:
- Used to deploy and manage the Flask application.
- Provides automatic scaling, load balancing, and monitoring.
-
AWS IAM (Identity and Access Management):
- Used to manage permissions for accessing AWS Bedrock and other AWS services.
-
AWS EC2:
- Underlying compute service used by Elastic Beanstalk to host the Flask application.
-
AWS S3 (Optional):
- Can be used to store legal documents if the application is extended to handle file uploads.
Before deploying the application, ensure you have the following:
-
AWS Account:
- Sign up for an AWS account if you don’t have one.
-
AWS CLI:
- Install and configure the AWS CLI:
aws configure
- Install and configure the AWS CLI:
-
Python 3.9+:
- Ensure Python 3.9 or later is installed.
-
Dependencies:
- Install the required Python packages:
pip install Flask boto3
- Install the required Python packages:
Clone this repository to your local machine:
git clone https://github.com/your-username/legal-document-summarizer.git
cd legal-document-summarizerEnsure your AWS credentials are configured correctly:
aws configureEnable AWS Bedrock in your AWS account.
Ensure your IAM role has the necessary permissions to invoke the Bedrock model:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel"
],
"Resource": "*"
}
]
}Initialize Elastic Beanstalk:
eb init -p python-3.9 legal-summarizerCreate the Elastic Beanstalk Environment:
eb create legal-summarizer-envDeploy the Application:
eb deployAccess the Application:
Once deployed, Elastic Beanstalk will provide a URL for your application.
Example: http://legal-summarizer-env.eba-xxxxxxxx.us-east-1.elasticbeanstalk.com##Running Locally
Install Dependencies:
pip install -r requirements.txtRun the Flask Application:
python3 summarize.pyAccess the Application:
Open your browser and navigate to http://127.0.0.1:5000/.
Send a POST Request:
Use curl or Postman to send a POST request to the /summarize endpoint:
curl -X POST http://127.0.0.1:5000/summarize \
-H "Content-Type: application/json" \
-d '{"document": "IN THE SUPREME COURT OF INDIA..."}'
Example Response:
{
"Document Type": "Court Judgment",
"Key Provisions": "Interpretation of force majeure clause in commercial contracts.",
"Case Background": "Dispute between XYZ Corporation and ABC Ltd. regarding breach of a commercial contract for the supply of industrial machinery.",
"Court’s Decision": "The Supreme Court set aside the High Court's judgment and ruled in favor of the Appellant, holding the Respondent liable for breach of contract.",
"Legal Implications": "This judgment serves as a precedent for interpreting force majeure clauses in commercial contracts, especially in cases involving pandemics.",
"Simplified Summary": "The Supreme Court ruled that ABC Ltd. is liable for breaching a contract with XYZ Corporation due to delayed delivery of machinery. The Court clarified that the force majeure clause did not cover pandemic-related delays unless explicitly stated. ABC Ltd. was ordered to pay INR 10 crore in damages and bear litigation costs."
}