Skip to content

Commit

Permalink
Merge pull request #16 from CambioML/dev
Browse files Browse the repository at this point in the history
Update notebook with latset interface change from CDK information + Bump up version to 0.0.5.
  • Loading branch information
Cambio ML authored Apr 11, 2024
2 parents 61e79dc + b6fd97e commit 35c8f2b
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 123 deletions.
72 changes: 23 additions & 49 deletions examples/prompt_to_extract_table_from_pdf_to_json.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -76,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 26,
"metadata": {},
"outputs": [
{
Expand All @@ -99,43 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'result': [{\"Employee's social security number\": '758-58-5787',\n",
" 'Employer identification number (EIN)': '78-8778788',\n",
" \"Employer's name, address, and ZIP code\": 'DesignNext\\nKatham Dorbosto, Kashiani, Gopalganj\\nGopalganj, AK 8133',\n",
" 'Control number': '9',\n",
" \"Employee's first name and initial\": 'Jesan',\n",
" 'Last name': 'Rahaman',\n",
" \"State, Employer's state ID number\": 'AL',\n",
" 'Wages, tips, etc.': '80000.00',\n",
" 'Federal income tax withheld': '10368.00',\n",
" 'Social security tax withheld': '4960.00',\n",
" 'Medicare wages and tips': '80000.00',\n",
" 'Medicare tax withheld': '1160.00'}],\n",
" 'log': {'instruction': \"Return table in a JSON format with each box's key and value.\",\n",
" 'source': '',\n",
" 'usage': {'input_tokens': 1752, 'output_tokens': 226},\n",
" 'source_log': None},\n",
" 'page_num': 0}]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qa_result"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 27,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -184,12 +148,12 @@
" <td>Jesan</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Last name</th>\n",
" <th>Employee's last name</th>\n",
" <td>Rahaman</td>\n",
" </tr>\n",
" <tr>\n",
" <th>State, Employer's state ID number</th>\n",
" <td>AL</td>\n",
" <td>AL 877878878</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wages, tips, etc.</th>\n",
Expand All @@ -211,6 +175,14 @@
" <th>Medicare tax withheld</th>\n",
" <td>1160.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>State wages, tips, etc.</th>\n",
" <td>80000.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>State income tax</th>\n",
" <td>3835.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
Expand All @@ -222,22 +194,24 @@
"Employer's name, address, and ZIP code DesignNext\\nKatham Dorbosto, Kashiani, Gopalga...\n",
"Control number 9\n",
"Employee's first name and initial Jesan\n",
"Last name Rahaman\n",
"State, Employer's state ID number AL\n",
"Employee's last name Rahaman\n",
"State, Employer's state ID number AL 877878878\n",
"Wages, tips, etc. 80000.00\n",
"Federal income tax withheld 10368.00\n",
"Social security tax withheld 4960.00\n",
"Medicare wages and tips 80000.00\n",
"Medicare tax withheld 1160.00"
"Medicare tax withheld 1160.00\n",
"State wages, tips, etc. 80000.00\n",
"State income tax 3835.00"
]
},
"execution_count": 8,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = qa_result[0]['result']\n",
"data = qa_result[0]\n",
"keys = [list(item.keys()) for item in data][0]\n",
"values = [list(item.values()) for item in data][0]\n",
"\n",
Expand Down Expand Up @@ -277,7 +251,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
136 changes: 65 additions & 71 deletions examples/prompt_to_extract_table_from_pdf_to_json_advanced_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -76,7 +76,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand All @@ -99,52 +99,51 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{\"a Employee's social security number\": '758-58-5787',\n",
" 'b Employer identification number (EIN)': '78-8778788',\n",
" \"c Employer's name, address, and ZIP code\": 'DesignNext\\nKatham Dorbosto, Kashiani, Gopalganj\\nGopalganj, AK 8133',\n",
" 'd Control number': '9',\n",
" \"e Employee's first name and initial\": 'Jesan',\n",
" \"e Employee's last name\": 'Rahaman',\n",
" \"f Employee's address and ZIP code\": 'AL 877878878',\n",
" '1 Wages, tips, other compensation': '80000.00',\n",
" '2 Federal income tax withheld': '10368.00',\n",
" '3 Social security wages': '80000.00',\n",
" '4 Social security tax withheld': '4960.00',\n",
" '5 Medicare wages and tips': '80000.00',\n",
" '6 Medicare tax withheld': '1160.00',\n",
" '7 Social security tips': 'NA',\n",
" '8 Allocated tips': 'NA',\n",
" '10 Dependent care benefits': 'NA',\n",
" '11 Nonqualified plans': 'NA',\n",
" '13 Statutory Retroment employee plan': 'NA',\n",
" '13 Third-party sick pay': 'NA',\n",
" '14 Other': 'NA',\n",
" \"15 State Employer's state ID number\": 'AL',\n",
" '16 State wages, tips, etc.': '80000.00',\n",
" '17 State income tax': '3835.00',\n",
" '18 Local wages, tips, etc.': 'NA',\n",
" '19 Local income tax': 'NA',\n",
" '20 Locality name': 'NA'}]"
"[[{\"a Employee's social security number\": '758-58-5787',\n",
" 'b Employer identification number (EIN)': '78-8778788',\n",
" \"c Employer's name, address, and ZIP code\": 'DesignNext\\nKatham Dorbosto, Kashiani, Gopalganj\\nGopalganj, AK 8133',\n",
" 'd Control number': '9',\n",
" \"e Employee's first name and initial\": 'Jesan',\n",
" 'e Last name': 'Rahaman',\n",
" \"f Employee's address and ZIP code\": 'AL\\n877878878',\n",
" '1 Wages, tips, other compensation': '80000.00',\n",
" '2 Federal income tax withheld': '10368.00',\n",
" '3 Social security wages': '80000.00',\n",
" '4 Social security tax withheld': '4960.00',\n",
" '5 Medicare wages and tips': '80000.00',\n",
" '6 Medicare tax withheld': '1160.00',\n",
" '7 Social security tips': 'NA',\n",
" '8 Allocated tips': 'NA',\n",
" '10 Dependent care benefits': 'NA',\n",
" '11 Nonqualified plans': 'NA',\n",
" '13 Statutory Retroment employee Third-party sick pay plan': 'NA',\n",
" '14 Other': 'NA',\n",
" '15 State': 'AL',\n",
" '16 State wages, tips, etc.': '80000.00',\n",
" '17 State income tax': '3835.00',\n",
" '18 Local wages, tips, etc.': 'NA',\n",
" '19 Local income tax': 'NA',\n",
" '20 Locality name': 'NA'}]]"
]
},
"execution_count": 11,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qa_result[0]['result']"
"qa_result"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 27,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -193,12 +192,12 @@
" <td>Jesan</td>\n",
" </tr>\n",
" <tr>\n",
" <th>e Employee's last name</th>\n",
" <th>e Last name</th>\n",
" <td>Rahaman</td>\n",
" </tr>\n",
" <tr>\n",
" <th>f Employee's address and ZIP code</th>\n",
" <td>AL 877878878</td>\n",
" <td>AL\\n877878878</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1 Wages, tips, other compensation</th>\n",
Expand Down Expand Up @@ -241,19 +240,15 @@
" <td>NA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13 Statutory Retroment employee plan</th>\n",
" <td>NA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13 Third-party sick pay</th>\n",
" <th>13 Statutory Retroment employee Third-party sick pay plan</th>\n",
" <td>NA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14 Other</th>\n",
" <td>NA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15 State Employer's state ID number</th>\n",
" <th>15 State</th>\n",
" <td>AL</td>\n",
" </tr>\n",
" <tr>\n",
Expand Down Expand Up @@ -281,42 +276,41 @@
"</div>"
],
"text/plain": [
" Value\n",
"a Employee's social security number 758-58-5787\n",
"b Employer identification number (EIN) 78-8778788\n",
"c Employer's name, address, and ZIP code DesignNext\\nKatham Dorbosto, Kashiani, Gopalga...\n",
"d Control number 9\n",
"e Employee's first name and initial Jesan\n",
"e Employee's last name Rahaman\n",
"f Employee's address and ZIP code AL 877878878\n",
"1 Wages, tips, other compensation 80000.00\n",
"2 Federal income tax withheld 10368.00\n",
"3 Social security wages 80000.00\n",
"4 Social security tax withheld 4960.00\n",
"5 Medicare wages and tips 80000.00\n",
"6 Medicare tax withheld 1160.00\n",
"7 Social security tips NA\n",
"8 Allocated tips NA\n",
"10 Dependent care benefits NA\n",
"11 Nonqualified plans NA\n",
"13 Statutory Retroment employee plan NA\n",
"13 Third-party sick pay NA\n",
"14 Other NA\n",
"15 State Employer's state ID number AL\n",
"16 State wages, tips, etc. 80000.00\n",
"17 State income tax 3835.00\n",
"18 Local wages, tips, etc. NA\n",
"19 Local income tax NA\n",
"20 Locality name NA"
" Value\n",
"a Employee's social security number 758-58-5787\n",
"b Employer identification number (EIN) 78-8778788\n",
"c Employer's name, address, and ZIP code DesignNext\\nKatham Dorbosto, Kashiani, Gopalga...\n",
"d Control number 9\n",
"e Employee's first name and initial Jesan\n",
"e Last name Rahaman\n",
"f Employee's address and ZIP code AL\\n877878878\n",
"1 Wages, tips, other compensation 80000.00\n",
"2 Federal income tax withheld 10368.00\n",
"3 Social security wages 80000.00\n",
"4 Social security tax withheld 4960.00\n",
"5 Medicare wages and tips 80000.00\n",
"6 Medicare tax withheld 1160.00\n",
"7 Social security tips NA\n",
"8 Allocated tips NA\n",
"10 Dependent care benefits NA\n",
"11 Nonqualified plans NA\n",
"13 Statutory Retroment employee Third-party sic... NA\n",
"14 Other NA\n",
"15 State AL\n",
"16 State wages, tips, etc. 80000.00\n",
"17 State income tax 3835.00\n",
"18 Local wages, tips, etc. NA\n",
"19 Local income tax NA\n",
"20 Locality name NA"
]
},
"execution_count": 10,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = qa_result[0]['result']\n",
"data = qa_result[0]\n",
"keys = [list(item.keys()) for item in data][0]\n",
"values = [list(item.values()) for item in data][0]\n",
"\n",
Expand Down
Loading

0 comments on commit 35c8f2b

Please sign in to comment.