Skip to content

Commit 336ce24

Browse files
author
Bob Strahan
committed
Refactor pattern configurations and update default settings
1 parent 474b5a6 commit 336ce24

File tree

20 files changed

+87
-59
lines changed

20 files changed

+87
-59
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ SPDX-License-Identifier: MIT-0
3232
- Backward compatibility maintained - old parameter pattern still supported with deprecation warning
3333
- Updated all lambda functions and notebooks to use new simplified pattern
3434
- Removed fixed image target_height and target_width from default configurations, so images are processed in original resolution by default.
35+
- **Updated Default Configuration for Pattern1 and Pattern2**
36+
- Changed default configuration for new stacks from "default" to "lending-package-sample" for both Pattern1 and Pattern2
37+
- Maintains backward compatibility for stack updates by keeping the parameter value "default" mapped to the rvl-cdip-sample for pattern-2.
3538

3639

3740
### Fixed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.8-wip6
1+
0.3.8-alpha

config_library/pattern-1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ See the main [README.md](../README.md) for more detailed instructions on creatin
2727

2828
## Available Configurations
2929

30-
Currently, only the default configuration is available for Pattern 1. Contributions are welcome!
30+
Currently, only the default lending-package-sample configuration is available for Pattern 1. Contributions are welcome!

config_library/pattern-1/default/README.md renamed to config_library/pattern-1/lending-package-sample/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
SPDX-License-Identifier: MIT-0
33

4-
# Default Configuration
4+
# Default Configuration (lending-package-sample)
55

66
This directory contains the default configuration for the GenAI IDP Accelerator. This configuration serves as the baseline for all document processing tasks and can be used as a starting point for creating custom configurations.
77

File renamed without changes.

config_library/pattern-1/default/samples/lending_package.pdf renamed to config_library/pattern-1/lending-package-sample/samples/lending_package.pdf

File renamed without changes.

config_library/pattern-2/lending-package-sample/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
33

4-
notes: Default settings
4+
notes: Default settings for lending-package-sample configuration
55
ocr:
66
backend: "textract" # Default to Textract for backward compatibility
77
model_id: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
@@ -983,7 +983,7 @@ classification:
983983
DOCUMENT_IMAGE: Visual representation of the document page that provides layout, formatting, and visual structure information
984984
CLASS_NAMES_AND_DESCRIPTIONS: List of valid document types with their descriptions that the document must be classified into
985985
</variables>
986-
classificationMethod: textbasedHolisticClassification
986+
classificationMethod: multimodalPageLevelClassification
987987
extraction:
988988
image:
989989
target_width: '951'

config_library/pattern-2/few_shot_example_with_multimodal_page_classification/README.md renamed to config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/README.md

File renamed without changes.

config_library/pattern-2/few_shot_example_with_multimodal_page_classification/config.yaml renamed to config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/config.yaml

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
33

4-
notes: Default settings
4+
notes: Default settings for the rvl-cdip-sample-with-few-shot-examples config
55
ocr:
66
backend: "textract" # Default to Textract for backward compatibility
77
model_id: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
@@ -657,58 +657,49 @@ classification:
657657
top_k: '5'
658658
max_tokens: '4096'
659659
system_prompt: >-
660-
You are a document classification system that analyzes business documents,
661-
forms, and publications. Your sole task is to classify documents into
662-
categories based on their visual layout and textual content. You must:
660+
You are a multimodal document classification expert that analyzes business documents using both visual layout and textual content. Your task is to classify single-page documents into predefined categories based on their structural patterns, visual features, and text content. Your output must be valid JSON according to the requested format.
663661
664-
1. Output only a JSON object containing a single "class" field with the
665-
classification label
666-
667-
2. Use exactly one of the predefined categories, using the exact spelling
668-
and case provided
669-
670-
3. Never include explanations, reasoning, or additional text in your
671-
response
672-
673-
4. Respond with nothing but the JSON containing the classification
674-
675-
676-
Example correct response:
677-
678-
{"class": "letter"}
662+
<variables>
663+
DOCUMENT_TEXT: OCR-extracted text content from the document page that provides textual information for classification
664+
DOCUMENT_IMAGE: Visual representation of the document page that provides layout, formatting, and visual structure information
665+
CLASS_NAMES_AND_DESCRIPTIONS: List of valid document types with their descriptions that the document must be classified into
666+
</variables>
679667
task_prompt: >-
680-
Classify this document into exactly one of these categories:
681-
682-
683-
{CLASS_NAMES_AND_DESCRIPTIONS}
684-
685-
686-
<few_shot_example_with_multimodal_page_classifications>
687-
688-
{few_shot_example_with_multimodal_page_classificationS}
689-
690-
</few_shot_example_with_multimodal_page_classifications>
691-
668+
<reasoning-guidelines>
669+
When determining the document type:
670+
- First identify the document's primary purpose and function
671+
- Note specific visual elements (letterhead, forms, tables, signatures)
672+
- Identify key textual indicators (terminology, phrases, structure)
673+
- Consider the document's intended audience and use case
674+
- Provide specific evidence from both visual and textual analysis
675+
</reasoning-guidelines>
676+
677+
<output-format>
678+
Return your classification as valid JSON following this exact structure:
679+
{
680+
"classification_reason": "Detailed reasoning including specific visual and textual evidence that led to this classification",
681+
"class": "exact_document_type_from_list"
682+
}
683+
</output-format>
692684
693685
<<CACHEPOINT>>
694686
687+
<document-ocr-data>
688+
{DOCUMENT_TEXT}
689+
</document-ocr-data>
695690
696-
<document_ocr_data>
697-
698-
{DOCUMENT_TEXT}
699-
700-
</document_ocr_data>
701-
702-
703-
<document_image>
704-
705-
{DOCUMENT_IMAGE}
706-
707-
</document_image>
708-
691+
<document-image>
692+
{DOCUMENT_IMAGE}
693+
</document-image>
709694
710-
Respond only with a JSON object containing the class label. For example:
711-
{{"class": "letter"}}
695+
<final-instructions>
696+
Analyze the document above by:
697+
1. Applying the <classification-instructions> to examine both visual and textual features
698+
2. Following the <reasoning-guidelines> to build your classification rationale
699+
3. Selecting ONLY from document types in <document-types>
700+
4. Providing clear reasoning with specific evidence before the classification
701+
5. Outputting in the exact JSON format specified in <output-format>
702+
</final-instructions>
712703
extraction:
713704
image:
714705
target_height: ''

config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/bank-statement-pages/image1.jpg renamed to config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/bank-statement-pages/image1.jpg

File renamed without changes.

0 commit comments

Comments
 (0)