Skip to content

Commit f78c0de

Browse files
authored
Merge pull request #224 from mrgiba/main
Enable support to Prompt Caching and Amazon Nova models
2 parents 829a332 + ae2908e commit f78c0de

File tree

104 files changed

+1253
-567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1253
-567
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
history

samples/contract-compliance-analysis/README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The project is powered by Large Language Models (LLM) available on Amazon Bedroc
88

99
## Architecture
1010

11-
The core of this solution is the contract analysis workflow, which leverages the Claude Large Language Models to perform advanced natural language tasks to evaluate clauses against predefined guidelines.
11+
The core of this solution is the contract analysis workflow, which leverages Large Language Models to perform advanced natural language tasks to evaluate clauses against predefined guidelines.
1212
Different storage components are used for the input, intermediate steps, analysis output, and the guidelines information. Additionally, there are components for the user interface, comprising web application hosting, authentication, and integration services.
1313

1414
![High Level Architecture](./images/high-level-architecture.png)
@@ -17,15 +17,58 @@ Zooming in to the contract analysis workflow:
1717

1818
![High Level Architecture](./images/contract-analysis-architecture.png)
1919

20+
## Cost Analysis and Pricing
21+
22+
This solution demonstrates significant cost savings by using Amazon Nova models compared to traditional Claude models. The following analysis is based on processing the **sample contract included with this solution** using the default guidelines.
23+
24+
### Model Cost Comparison
25+
26+
The following analysis shows token usage and costs for processing the included sample contract. Some of the scenarios have [Amazon Bedrock prompt caching](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html) enabled.
27+
28+
#### Claude 3.5 Haiku and Amazon Nova Lite
29+
| Model | Input Tokens | Output Tokens | Cache Read Tokens | Cache Write Tokens | **Total Cost** |
30+
|-------|-------------|---------------|-------------------|-------------------|---------------|
31+
| **Claude 3.5 Haiku** | 98,166<br>$0.08 | 40,570<br>$0.16 | 570,255<br>$0.05 | 16,293<br>$0.02 | **$0.30** |
32+
| **Amazon Nova Lite** | 89,140<br>$0.07 | 45,733<br>$0.11 | 534,275<br>$0.11 | 15,265<br>$0.00 | **$0.02** |
33+
| | | | | **Savings:** | **🟢 92%** |
34+
35+
#### Claude 3.5 Sonnet v2 and Amazon Nova Pro (without prompt caching)
36+
| Model | Input Tokens | Output Tokens | **Total Cost** |
37+
|-------|-------------|---------------|---------------|
38+
| **Claude 3.5 Sonnet v2** | 684,737<br>$2.05 | 65,927<br>$0.99 | **$3.04** |
39+
| **Amazon Nova Pro** | 625,677<br>$0.50 | 33,493<br>$0.11 | **$0.61** |
40+
| | | **Savings:** | **🟢 80%** |
41+
42+
#### Claude 3.7 Sonnet and Amazon Nova Premier
43+
| Model | Input Tokens | Output Tokens | Cache Read Tokens | Cache Write Tokens | **Total Cost** |
44+
|-------|-------------|---------------|-------------------|-------------------|---------------|
45+
| **Claude 3.7 Sonnet** | 98,189<br>$0.29 | 65,927<br>$0.99 | 586,548<br>$0.18 | 16,293<br>$0.06 | **$1.52** |
46+
| **Amazon Nova Premier** | 92,706<br>$0.23 | 53,539<br>$0.69 | 541,100<br>$0.34 | 15,460<br>$0.00 | **$1.26** |
47+
| | | | | **Savings:** | **🟢 17%** |
48+
49+
50+
### Cost Factors
51+
52+
Actual costs depend on several factors:
53+
- **Guidelines complexity**: More detailed guidelines require more tokens
54+
- **Contract size**: Larger contracts consume more input tokens
55+
- **Selected LLM**: Different models have different pricing structures
56+
57+
### Pricing Reference
58+
59+
For the most up-to-date pricing information, refer to the [Amazon Bedrock Pricing](https://aws.amazon.com/bedrock/pricing/) page.
60+
61+
> **Note**: The cost analysis above is based on processing the sample contract included with this solution using the default guidelines. Your actual costs may vary depending on your specific contract sizes, guidelines complexity, and usage patterns.
62+
2063
## Folder Structure
2164

2265
This sample application codebase is organized into these key folders:
2366

2467
```
2568
samples/contract-compliance-analysis
2669
27-
├── back-end # Back-end
28-
├── front-end # Front-end
70+
├── backend # Backend
71+
├── frontend # Frontend
2972
```
3073

3174
## Getting started
@@ -37,7 +80,7 @@ samples/contract-compliance-analysis
3780
3881
> You are also responsible for making your own independent assessment of the third-party GAI models that you use, including their outputs and how third-party GAI model providers use any data that might be transmitted to them based on your deployment configuration. AWS does not make any representations, warranties, or guarantees regarding the third-party GAI models, which are “Third-Party Content” under your agreement with AWS. This sample is offered to you as “AWS Content” under your agreement with AWS.
3982
40-
To deploy this project, follow the instructions available in the README files located at the **back-end** and **front-end** folders, in that sequence.
83+
To deploy this project, follow the instructions available in the README files located at the **backend** and **frontend** folders, in that sequence.
4184

4285

4386
# Content Security Legal Disclaimer
Binary file not shown.

samples/contract-compliance-analysis/back-end/scripts/utils/llm.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

samples/contract-compliance-analysis/back-end/stack/sfn/common-layer/llm.py

Lines changed: 0 additions & 118 deletions
This file was deleted.

samples/contract-compliance-analysis/back-end/stack/sfn/common-layer/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

samples/contract-compliance-analysis/back-end/stack/sfn/langchain-deps-layer/requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

samples/contract-compliance-analysis/back-end/.gitignore renamed to samples/contract-compliance-analysis/backend/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ __pycache__
77
~*.*
88
drafts
99
evaluation_questions.xlsx
10+
.DS_Store
1011

1112
# CDK asset staging directory
1213
.cdk.staging
1314
cdk.out
15+
/cdk.context.json
1416

1517
### JetBrains+all ###
1618
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
@@ -214,6 +216,7 @@ __pypackages__/
214216

215217

216218
### VisualStudioCode ###
219+
.vscode
217220
.vscode/*
218221
!.vscode/settings.json
219222
!.vscode/tasks.json
@@ -258,4 +261,4 @@ $RECYCLE.BIN/
258261
*.msp
259262

260263
# Windows shortcuts
261-
*.lnk
264+
*.lnk

0 commit comments

Comments
 (0)