Skip to content

Commit 5907159

Browse files
author
Daniel Lorch
committed
chore: add class names and description for classification task, fix paths
1 parent 87fc504 commit 5907159

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ classes:
9696
"cc": null,
9797
"reference_number": "TNJB 0008497"
9898
imagePath: >-
99-
config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter1.jpg
99+
config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter1.jpg
100100
- classPrompt: This is an example of the class 'letter'
101101
name: Letter2
102102
attributesPrompt: |-
@@ -112,7 +112,7 @@ classes:
112112
"cc": null,
113113
"reference_number": null
114114
imagePath: >-
115-
config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter2.png
115+
config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter2.png
116116
- $schema: https://json-schema.org/draft/2020-12/schema
117117
$id: form
118118
x-aws-idp-document-type: form
@@ -587,7 +587,7 @@ classes:
587587
"thread_id": null,
588588
"message_id": null
589589
imagePath: >-
590-
config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/email1.jpg
590+
config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/email1.jpg
591591
- $schema: https://json-schema.org/draft/2020-12/schema
592592
$id: questionnaire
593593
x-aws-idp-document-type: questionnaire
@@ -805,7 +805,7 @@ classes:
805805
"account_number": ["003525801543","352580154336"],
806806
"transactions": [{"Date": "2/6/2020", "Description": "Food Purchase - AnyCompany Restaurant - 1194989245", "Amount": "-171"}]
807807
imagePath: >-
808-
config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/bank-statement-pages/
808+
config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/bank-statement-pages/
809809
810810
classification:
811811
maxPagesForClassification: "ALL"
@@ -822,9 +822,9 @@ classification:
822822
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.
823823
824824
<variables>
825-
DOCUMENT_TEXT: OCR-extracted text content from the document page that provides textual information for classification
826-
DOCUMENT_IMAGE: Visual representation of the document page that provides layout, formatting, and visual structure information
827-
CLASS_NAMES_AND_DESCRIPTIONS: List of valid document types with their descriptions that the document must be classified into
825+
<document-ocr-data>: OCR-extracted text content from the document page that provides textual information for classification
826+
<document-image>: Visual representation of the document page that provides layout, formatting, and visual structure information
827+
<document-types>: List of valid document types with their descriptions that the document must be classified into
828828
</variables>
829829
task_prompt: >-
830830
<reasoning-guidelines>
@@ -836,6 +836,10 @@ classification:
836836
- Provide specific evidence from both visual and textual analysis
837837
</reasoning-guidelines>
838838
839+
<document-types>
840+
{CLASS_NAMES_AND_DESCRIPTIONS}
841+
</document-types>
842+
839843
<output-format>
840844
Return your classification as valid JSON following this exact structure:
841845
{
@@ -892,6 +896,11 @@ extraction:
892896
893897
</task>
894898
899+
<few-shot-examples>
900+
901+
{FEW_SHOT_EXAMPLES}
902+
903+
</few-shot-examples>
895904
896905
<extraction-guidelines>
897906

notebooks/misc/test_few_shot_extraction.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"os.environ['ROOT_DIR'] = f\"{ROOTDIR}/\"\n",
2828
"\n",
2929
"# Add the idp_common package to the path\n",
30-
"sys.path.insert(0, '{ROOTDIR}/lib/idp_common_pkg')\n",
30+
"sys.path.insert(0, f'{ROOTDIR}/lib/idp_common_pkg')\n",
3131
"\n",
3232
"from idp_common.extraction.service import ExtractionService"
3333
]
@@ -56,7 +56,7 @@
5656
],
5757
"source": [
5858
"# Load the few-shot configuration\n",
59-
"config_path = f'{ROOTDIR}/config_library/pattern-2/few_shot_example_with_multimodal_page_classification/config.yaml'\n",
59+
"config_path = f'{ROOTDIR}/config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/config.yaml'\n",
6060
"with open(config_path, 'r') as f:\n",
6161
" config = yaml.safe_load(f)\n",
6262
"\n",
@@ -215,16 +215,16 @@
215215
" Attributes Prompt: expected attributes are:\n",
216216
" \"sender_name\": \"Will E. Clark\",\n",
217217
" \"sender_address\": \"206 Maple Street...\n",
218-
" Image Path: config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter1.jpg\n",
219-
" S3 URI: config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter1.jpg\n",
218+
" Image Path: config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter1.jpg\n",
219+
" S3 URI: config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter1.jpg\n",
220220
" Example 2:\n",
221221
" Name: Letter2\n",
222222
" Class Prompt: This is an example of the class 'letter'\n",
223223
" Attributes Prompt: expected attributes are:\n",
224224
" \"sender_name\": \"William H. W. Anderson\",\n",
225225
" \"sender_address\": \"P O. BO...\n",
226-
" Image Path: config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter2.png\n",
227-
" S3 URI: config_library/pattern-2/few_shot_example_with_multimodal_page_classification/example-images/letter2.png\n",
226+
" Image Path: config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter2.png\n",
227+
" S3 URI: config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/example-images/letter2.png\n",
228228
"\n",
229229
"Class: form\n",
230230
"Number of examples: 0\n",

0 commit comments

Comments
 (0)