I showed document images (in Japanese) to Cloudflare's Clef and had it find errors in the OCR results
This page has been translated by machine translation. View original
Hello, I'm Keima.
Setups that use a VLM to read document images and perform OCR are on the rise, but how to verify that the extracted values truly match the image remains a challenge.
Jev from TypeSafe, known as a decision model specialized for judgment, accepts text input only, so it could not directly look at the original document image to check whether "the extraction result matches the image."
On the other hand, Cloudflare Workers AI's Clef is a decision model that supports image input.
You can pass it a document image together with the VLM's extraction result, have it directly judge whether each value is "exactly as printed in the image," and obtain a confidence score.
In the previous verification with English documents, when I passed Clef the document images and the OCR extraction results, it detected all 36 deliberately injected errors with zero false positives.
This time, I tested whether it can find errors in the same way in Japanese documents, which include registration numbers, reduced tax rates, amounts in formal kanji numerals, and a mix of full-width and half-width characters.
1. Test conditions
First, I had Claude Haiku 4.5 extract fields from Japanese invoices, quotes, and receipts (3 documents, 149 fields in total).
In the English test, Haiku extracted every field correctly, but with Japanese, 19 misreadings occurred naturally, so I included them as detection targets as well.
In addition, I deliberately injected four patterns of errors (36 in total) for testing.
-
Digit change (12): change just one digit of a number in an amount or ID (
51,750→51,790,MQ-2026-0918→MQ-2026-0916, etc.) -
Similar character substitution (9): swap in a similar-looking character (katakana "ka" → kanji "chikara (power)", kanji "kuchi (mouth)" → katakana "ro", the long-vowel mark → kanji "ichi (one)", etc.)
-
Full-width/half-width swap (3): "20 meals" written with full-width digits → the same with half-width digits, half-width
MN-2407→ its full-width version, etc. -
Replacement with a different value (12): replace with another value plausible for the document ("ordinary (savings)" → "current (checking)" for the account type, "Hikari Logistics Co., Ltd." → "Hikari Transport Co., Ltd.", etc.)
For each document, I prepared the following four extraction results.
-
Haiku's raw output: the result Haiku extracted (no additional errors injected; includes Haiku's own 19 misreadings)
-
With errors A / With errors B: Haiku's output with 6 deliberately injected errors each for testing
-
Ground truth (no errors): a version consisting only of correct values (control data to observe behavior when there are no errors at all)
The judgment and verification conditions are as follows.
-
Judgment method: pass one document image and the extraction result, and for each field ask with
noul(a question that returns the probability of yes) whether "this value is exactly as printed in the image." A probability below 0.5 is judged as an "error" -
Models:
clef(27B) andclef-flash(9B)
{
"model": "clef",
"images": ["data:image/png;base64,..."],
// state: The premise for the judgment (an OCR system read a Japanese invoice image and extracted keys and values)
"state": {
"task": "An OCR system read the attached Japanese invoice (請求書) image ...",
"extracted": { "issuer_name": "株式会社さくらフーズ" }
},
"questions": {
"field.issuer_name": {
"type": "noul", // A yes/no question. Returns the probability of yes
// instructions: The judgment instruction (Does the extracted value of issuer_name match the string printed in the document image exactly, character for character?)
"instructions": "Is the extracted value of \"issuer_name\" (\"株式会社さくらフーズ\") exactly what is printed in the document image, character for character?"
}
}
}

The invoice used in the test. A seal impression overlaps the issuer name and registration number
2. Results
2.1 Were the errors detected?
Clef returns, for each field, "the probability that the value matches the image."
Fields with a probability below 0.5 are judged as "errors," and I tallied the counts from the following three perspectives.
-
Detection of injected errors: of the 36 injected errors, the number correctly judged as "errors"
-
Detection of Haiku's errors: of Haiku's own 19 misreadings (the "Haiku's raw output" version), the number judged as "errors"
-
Correct values judged as errors: the number of values that were actually correct but were judged as "errors" (false positives)
| Condition | Injected errors detected (out of 36) | Haiku's errors detected (out of 19) | Correct values judged as errors (out of 503) |
|---|---|---|---|
| clef | 32 | 7 | 7 |
| clef-flash | 29 | 5 | 20 |
Clef detected most of the injected errors, but did not reach the full detection seen in the English test.
Also, it detected only 7 of Haiku's own 19 misreadings.
By error type, cases of overlooked full-width/half-width swaps and Haiku's own misreadings stood out.
| Type | clef | clef-flash |
|---|---|---|
| Injected error: digit | 10 / 12 | 9 / 12 |
| Injected error: similar character | 9 / 9 | 8 / 9 |
| Injected error: full-width/half-width | 1 / 3 | 1 / 3 |
| Injected error: replacement | 12 / 12 | 11 / 12 |
| Haiku misreading | 7 / 19 | 5 / 19 |
| Correct value judged as error (false positive) | 7 / 503 | 20 / 503 |
The items judged incorrectly numbered 23 for clef and 41 for clef-flash.
Note that "missed" here means an item that had an error but was given 0.5 or higher, and "false positive" means an item that was a correct value but was given below 0.5.
The 23 items clef judged incorrectly (click to expand)
| Error type | Category | Document | Extraction result | Field | Value passed | Correct value | Probability |
|---|---|---|---|---|---|---|---|
| Missed | Haiku misreading | Quote | No errors | issuer_name |
Techuark Co., Ltd. | Techno Ark Co., Ltd. | 0.76 |
| Missed | Haiku misreading | Quote | No errors | discount_name |
Shipment discount | Special courtesy discount | 0.87 |
| Missed | Haiku misreading | Quote | No errors | remarks |
The above prices apply only if you place an order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | The above prices apply only if you place a purchase order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | 0.63 |
| Missed | Haiku misreading | Invoice | No errors | issuer_registration_no |
T4010-0301-2345 | T4010403012345 | 0.73 |
| Missed | Haiku misreading | Invoice | No errors | issuer_tel |
TEL 045-312-7788 | 045-312-7788 | 0.90 |
| Missed | Haiku misreading | Invoice | No errors | reduced_rate_note |
Items marked with ※ are subject to the reduced tax rate (8%, written with a full-width percent sign) | Items marked with ※ are subject to the reduced tax rate (8%) | 0.78 |
| Missed | Haiku misreading | Invoice | No errors | account_holder |
Sakura Foods | Ka) Sakura Foods | 0.69 |
| Missed | Haiku misreading | Receipt | No errors | item1_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.89 |
| Missed | Haiku misreading | Receipt | No errors | item2_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.89 |
| Missed | Haiku misreading | Receipt | No errors | item3_qty |
1 lump-sum set (half-width digit) | 1 lump-sum set (full-width digit) | 0.87 |
| Missed | Haiku misreading | Receipt | No errors | recipient |
Aoha Planning Co., Ltd. | Aoba Planning Co., Ltd. | 0.91 |
| Missed | Haiku misreading | Receipt | No errors | stamp_duty |
200 yen (full-width digits) | 200 yen (half-width digits) | 0.61 |
| Missed | Full-width/half-width | Receipt | With errors A | issue_date |
October 2, 2026 (half-width digits) | October 2, 2026 (full-width digits) | 0.71 |
| Missed | Full-width/half-width | Receipt | With errors B | item4_qty |
20 meals (half-width digits) | 20 meals (full-width digits) | 0.54 |
| Missed | Digit | Quote | With errors B | subtotal |
1,788,800 | 1,786,800 | 0.56 |
| Missed | Digit | Invoice | With errors B | account_number |
4072579 | 4072519 | 0.75 |
| False positive | Correct value | Quote | Ground truth | discount_name |
Special courtesy discount | Special courtesy discount | 0.38 |
| False positive | Correct value | Invoice | With errors B | tax_total |
16,878 | 16,878 | 0.47 |
| False positive | Correct value | Invoice | Ground truth | account_holder |
Ka) Sakura Foods | Ka) Sakura Foods | 0.40 |
| False positive | Correct value | Receipt | With errors A | item4_qty |
20 meals (full-width digits) | 20 meals (full-width digits) | 0.39 |
| False positive | Correct value | Receipt | Ground truth | item1_qty |
3 days (full-width digit) | 3 days (full-width digit) | 0.34 |
| False positive | Correct value | Receipt | Ground truth | item2_qty |
3 days (full-width digit) | 3 days (full-width digit) | 0.28 |
| False positive | Correct value | Receipt | Ground truth | item3_qty |
1 lump-sum set (full-width digit) | 1 lump-sum set (full-width digit) | 0.32 |
The 41 items clef-flash judged incorrectly (click to expand)
| Error type | Category | Document | Extraction result | Field | Value passed | Correct value | Probability |
|---|---|---|---|---|---|---|---|
| Missed | Haiku misreading | Quote | No errors | issuer_name |
Techuark Co., Ltd. | Techno Ark Co., Ltd. | 0.83 |
| Missed | Haiku misreading | Quote | No errors | discount_name |
Shipment discount | Special courtesy discount | 0.64 |
| Missed | Haiku misreading | Quote | No errors | remarks |
The above prices apply only if you place an order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | The above prices apply only if you place a purchase order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | 0.91 |
| Missed | Haiku misreading | Invoice | No errors | issuer_registration_no |
T4010-0301-2345 | T4010403012345 | 0.76 |
| Missed | Haiku misreading | Invoice | No errors | issuer_tel |
TEL 045-312-7788 | 045-312-7788 | 0.93 |
| Missed | Haiku misreading | Invoice | No errors | reduced_rate_note |
Items marked with ※ are subject to the reduced tax rate (8%, written with a full-width percent sign) | Items marked with ※ are subject to the reduced tax rate (8%) | 0.91 |
| Missed | Haiku misreading | Invoice | No errors | account_holder |
Sakura Foods | Ka) Sakura Foods | 0.69 |
| Missed | Haiku misreading | Receipt | No errors | item1_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.88 |
| Missed | Haiku misreading | Receipt | No errors | item2_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.88 |
| Missed | Haiku misreading | Receipt | No errors | item3_qty |
1 lump-sum set (half-width digit) | 1 lump-sum set (full-width digit) | 0.84 |
| Missed | Haiku misreading | Receipt | No errors | recipient |
Aoha Planning Co., Ltd. | Aoba Planning Co., Ltd. | 0.64 |
| Missed | Haiku misreading | Receipt | No errors | stamp_duty |
200 yen (full-width digits) | 200 yen (half-width digits) | 0.89 |
| Missed | Haiku misreading | Receipt | No errors | proviso |
Received the above amount as the meeting room usage fee (for October, full-width digits). | As the meeting room usage fee (for October, full-width digits) | 0.77 |
| Missed | Haiku misreading | Receipt | No errors | issuer_address |
1-2-3 Sakuragaoka-cho, Shibuya-ku, Tokyo (full-width 1 and 3, half-width 2) | 1-2-3 Sakuragaoka-cho, Shibuya-ku, Tokyo (all half-width digits) | 0.73 |
| Missed | Similar character | Receipt | With errors B | issuer_name |
Midori Meeting Room Sāpisu Co., Ltd. | Midori Meeting Room Sābisu (Service) Co., Ltd. | 0.54 |
| Missed | Full-width/half-width | Receipt | With errors A | issue_date |
October 2, 2026 (half-width digits) | October 2, 2026 (full-width digits) | 0.96 |
| Missed | Full-width/half-width | Receipt | With errors B | item4_qty |
20 meals (half-width digits) | 20 meals (full-width digits) | 0.87 |
| Missed | Digit | Quote | With errors B | subtotal |
1,788,800 | 1,786,800 | 0.66 |
| Missed | Digit | Invoice | With errors A | item3_amount |
51,790 | 51,750 | 0.68 |
| Missed | Digit | Invoice | With errors B | tax_8 |
10,078 | 10,073 | 0.62 |
| Missed | Replacement | Receipt | With errors A | issuer_person |
Misaki Sato | Misaki Sasaki | 0.83 |
| False positive | Correct value | Quote | Ground truth | amount_kanji |
Yen 1,965,480 in formal kanji numerals, with the closing 'only' marker | Yen 1,965,480 in formal kanji numerals, with the closing 'only' marker | 0.33 |
| False positive | Correct value | Quote | Ground truth | item4_unit |
piece | piece | 0.43 |
| False positive | Correct value | Quote | Ground truth | item7_unit |
unit (counter for long objects) | unit (counter for long objects) | 0.49 |
| False positive | Correct value | Quote | Ground truth | item7_amount |
19,600 | 19,600 | 0.48 |
| False positive | Correct value | Quote | Ground truth | item8_unit |
lump-sum set | lump-sum set | 0.48 |
| False positive | Correct value | Quote | Ground truth | discount_name |
Special courtesy discount | Special courtesy discount | 0.40 |
| False positive | Correct value | Quote | Ground truth | discount_amount |
-50,000 | -50,000 | 0.43 |
| False positive | Correct value | Quote | Ground truth | subtotal |
1,786,800 | 1,786,800 | 0.39 |
| False positive | Correct value | Quote | Ground truth | tax |
178,680 | 178,680 | 0.39 |
| False positive | Correct value | Quote | Ground truth | total |
¥1,965,480 | ¥1,965,480 | 0.39 |
| False positive | Correct value | Invoice | Ground truth | item2_unit_price |
1,280 | 1,280 | 0.45 |
| False positive | Correct value | Invoice | Ground truth | item4_unit_price |
698 | 698 | 0.46 |
| False positive | Correct value | Invoice | Ground truth | item4_amount |
27,920 | 27,920 | 0.43 |
| False positive | Correct value | Invoice | Ground truth | item5_amount |
13,800 | 13,800 | 0.40 |
| False positive | Correct value | Invoice | Ground truth | subtotal_10 |
68,050 | 68,050 | 0.36 |
| False positive | Correct value | Invoice | Ground truth | tax_8 |
10,073 | 10,073 | 0.45 |
| False positive | Correct value | Invoice | Ground truth | account_holder |
Ka) Sakura Foods | Ka) Sakura Foods | 0.30 |
| False positive | Correct value | Receipt | No errors | receipt_no |
004127 | 004127 | 0.48 |
| False positive | Correct value | Receipt | Ground truth | item4_qty |
20 meals (full-width digits) | 20 meals (full-width digits) | 0.44 |
| False positive | Correct value | Receipt | Ground truth | receipt_no |
004127 | 004127 | 0.35 |
The 7 correct values that clef wrongly judged as errors are as follows.
| Document | Extraction result | Field | Value (correct) | clef probability |
|---|---|---|---|---|
| Invoice | With errors B | Total tax amount | 16,878 |
0.47 |
| Invoice | Ground truth | Account holder | Ka) Sakura Foods |
0.40 |
| Quote | Ground truth | Discount name | Special courtesy discount |
0.38 |
| Receipt | With errors A | Quantity of line item 4 | 20 meals (full-width digits) |
0.39 |
| Receipt | Ground truth | Quantity of line item 1 | 3 days (full-width digit) |
0.34 |
| Receipt | Ground truth | Quantity of line item 2 | 3 days (full-width digit) |
0.28 |
| Receipt | Ground truth | Quantity of line item 3 | 1 lump-sum set (full-width digit) |
0.32 |
Of these, 5 (the 5 in the ground truth) were the correct values of fields that Haiku had misread.
For example, for the quantity on the receipt, it gave 0.34 to the correct full-width "3 days" and 0.89 to Haiku's misread half-width "3 days," judging full-width and half-width the wrong way around.
It is more reliable not to leave the full-width/half-width distinction to Clef, and instead to normalize the strings before comparison to absorb the difference.
Match probabilities for the 36 injected errors (click to expand)
The probability is "the probability that the extracted value is correct per the image," so the lower it is, the more strongly the model suspects an error.
Values of 0.5 or higher (missed) are shown in bold.
| Document | Extraction result | Field | Correct value | Injected value | Pattern | clef | clef-flash |
|---|---|---|---|---|---|---|---|
| Invoice | A | invoice_no |
INV-202609-0417 | INV-202609-0411 | Digit | 0.12 | 0.17 |
| Invoice | A | item3_amount |
51,750 | 51,790 | Digit | 0.10 | 0.68 |
| Invoice | A | item1_name |
Niigata-grown Koshihikari rice 5kg | Niigata-grown Koshihi'chikara'ri rice 5kg (katakana 'ka' replaced with the kanji 'chikara (power)') | Similar character | 0.06 | 0.21 |
| Invoice | A | bank_branch |
Yokohama Nishiguchi (West Exit) Branch | Yokohama Nishi-'ro' Branch (kanji 'kuchi (mouth/exit)' replaced with katakana 'ro') | Similar character | 0.12 | 0.46 |
| Invoice | A | bill_to_name |
Minato Seiki Co., Ltd. | Minato Manufacturing Works Co., Ltd. | Replacement | 0.20 | 0.19 |
| Invoice | A | account_type |
Ordinary (savings) | Current (checking) | Replacement | 0.31 | 0.15 |
| Invoice | B | tax_8 |
10,073 | 10,078 | Digit | 0.30 | 0.62 |
| Invoice | B | account_number |
4072519 | 4072579 | Digit | 0.75 | 0.03 |
| Invoice | B | item2_name |
Organic green tea teabags, 50 pack | Organic green tea tea'ichi'bags, 50 pack (long-vowel mark replaced with the kanji 'ichi (one)') | Similar character | 0.26 | 0.17 |
| Invoice | B | item3_name |
Commercial kitchen paper towels | Commercial 'kitchiso' paper towels (katakana 'n' replaced with 'so') | Similar character | 0.10 | 0.15 |
| Invoice | B | subject |
Food ingredients and consumables for September | Beverages and consumables for September | Replacement | 0.11 | 0.14 |
| Invoice | B | item5_tax_rate |
10% | 8% | Replacement | 0.06 | 0.10 |
| Quote | A | item1_unit_price |
128,000 | 126,000 | Digit | 0.03 | 0.06 |
| Quote | A | quote_no |
MQ-2026-0918 | MQ-2026-0916 | Digit | 0.05 | 0.02 |
| Quote | A | item1_name |
14-inch laptop PC | 14-inch laptop 'pankon' (katakana 'so' replaced with 'n') | Similar character | 0.10 | 0.14 |
| Quote | A | item3_name |
USB-C docking station | USB-C docking 'stetsyon' (katakana 'shi' replaced with 'tsu') | Similar character | 0.17 | 0.07 |
| Quote | A | delivery_date |
About 3 weeks after order | About 2 months after order | Replacement | 0.03 | 0.02 |
| Quote | A | customer_name |
Hikari Logistics Co., Ltd. | Hikari Transport Co., Ltd. | Replacement | 0.12 | 0.30 |
| Quote | B | subtotal |
1,786,800 | 1,788,800 | Digit | 0.56 | 0.66 |
| Quote | B | item7_qty |
20 | 25 | Digit | 0.03 | 0.08 |
| Quote | B | item4_name |
Wireless keyboard | Wireless key'ichi'board (long-vowel mark replaced with the kanji 'ichi (one)') | Similar character | 0.18 | 0.25 |
| Quote | B | item2_code |
MN-2407 (half-width) | MN-2407 (full-width) | Full-width/half-width | 0.05 | 0.41 |
| Quote | B | subject |
Head office PC replacement, complete set | Branch office PC replacement, complete set | Replacement | 0.06 | 0.23 |
| Quote | B | item8_unit |
lump-sum set | unit (counter for machines) | Replacement | 0.15 | 0.14 |
| Receipt | A | amount |
¥165,000- | ¥185,000- | Digit | 0.02 | 0.02 |
| Receipt | A | issuer_tel |
03-5468-1234 | 03-5468-1284 | Digit | 0.08 | 0.08 |
| Receipt | A | item2_name |
Projector rental | Project'ichi' rental (long-vowel mark replaced with the kanji 'ichi (one)') | Similar character | 0.29 | 0.09 |
| Receipt | A | issue_date |
October 2, 2026 (full-width digits) | October 2, 2026 (half-width digits) | Full-width/half-width | 0.71 | 0.96 |
| Receipt | A | payment_method |
Bank transfer | Cash | Replacement | 0.02 | 0.01 |
| Receipt | A | issuer_person |
Misaki Sasaki | Misaki Sato | Replacement | 0.43 | 0.83 |
| Receipt | B | receipt_no |
004127 | 004121 | Digit | 0.03 | 0.07 |
| Receipt | B | item1_amount |
90,000 | 60,000 | Digit | 0.02 | 0.05 |
| Receipt | B | issuer_name |
Midori Meeting Room Sābisu (Service) Co., Ltd. | Midori Meeting Room Sāpisu Co., Ltd. (katakana 'bi' replaced with 'pi') | Similar character | 0.28 | 0.54 |
| Receipt | B | item4_qty |
20 meals (full-width digits) | 20 meals (half-width digits) | Full-width/half-width | 0.54 | 0.87 |
| Receipt | B | item3_name |
Audio equipment set | Lighting equipment set | Replacement | 0.05 | 0.09 |
| Receipt | B | item1_name |
Large meeting room A usage fee | Medium meeting room A usage fee | Replacement | 0.05 | 0.06 |
Haiku's 19 misreadings and their match probabilities (click to expand)
| Document | Field | Haiku's value | Correct value | clef | clef-flash |
|---|---|---|---|---|---|
| Invoice | issuer_name |
Sakura Seiki Co., Ltd. | Sakura Foods Co., Ltd. | 0.30 | 0.06 |
| Invoice | issuer_registration_no |
T4010-0301-2345 | T4010403012345 | 0.73 | 0.76 |
| Invoice | issuer_address |
Takashima 2-chome 8-ban-go-go, Nishi-ku, Yokohama, Kanagawa | Takashima 2-chome 8-ban 5-go, Nishi-ku, Yokohama, Kanagawa | 0.05 | 0.07 |
| Invoice | issuer_tel |
TEL 045-312-7788 | 045-312-7788 | 0.90 | 0.93 |
| Invoice | reduced_rate_note |
Items marked with ※ are subject to the reduced tax rate (8%, written with a full-width percent sign) | Items marked with ※ are subject to the reduced tax rate (8%) | 0.78 | 0.91 |
| Invoice | account_holder |
Sakura Foods | Ka) Sakura Foods | 0.69 | 0.69 |
| Quote | amount_kanji |
Yen 1,965,480 in kanji numerals (informal variants used for 5 and 80; no closing 'only' marker) | Yen 1,965,480 in formal kanji numerals, with the closing 'only' marker | 0.19 | 0.31 |
| Quote | issuer_name |
Techuark Co., Ltd. | Techno Ark Co., Ltd. | 0.76 | 0.83 |
| Quote | discount_name |
Shipment discount | Special courtesy discount | 0.87 | 0.64 |
| Quote | remarks |
The above prices apply only if you place an order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | The above prices apply only if you place a purchase order within the validity period of this quotation. The delivery date is an estimate after the order is confirmed and may vary depending on the parts procurement situation. Work at night or on holidays will be quoted separately. | 0.63 | 0.91 |
| Receipt | item1_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.89 | 0.88 |
| Receipt | item2_qty |
3 days (half-width digit) | 3 days (full-width digit) | 0.89 | 0.88 |
| Receipt | item3_qty |
1 lump-sum set (half-width digit) | 1 lump-sum set (full-width digit) | 0.87 | 0.84 |
| Receipt | item4_name |
Catering meal-meal (duplicated character) | Catering lunch | 0.10 | 0.19 |
| Receipt | recipient |
Aoha Planning Co., Ltd. | Aoba Planning Co., Ltd. | 0.91 | 0.64 |
| Receipt | stamp_duty |
200 yen (full-width digits) | 200 yen (half-width digits) | 0.61 | 0.89 |
| Receipt | proviso |
Received the above amount as the meeting room usage fee (for October, full-width digits). | As the meeting room usage fee (for October, full-width digits) | 0.12 | 0.77 |
| Receipt | issuer_address |
1-2-3 Sakuragaoka-cho, Shibuya-ku, Tokyo (full-width 1 and 3, half-width 2) | 1-2-3 Sakuragaoka-cho, Shibuya-ku, Tokyo (all half-width digits) | 0.44 | 0.73 |
| Receipt | issuer_building |
Sakuragaoka Sābiru 5F (full-width 5) | Sakuragaoka Daiichi Building 5F (full-width 5) | 0.32 | 0.28 |
2.2 How the probabilities were distributed
To determine where the threshold should be set, I summarized the spread of probabilities given to the injected errors (36), Haiku's misreadings (19), and the correct values (503).
The bottom 5% and top 5% are the values at the 5% and 95% positions when the probabilities are sorted from lowest to highest.
| Condition | Target | Min | Bottom 5% | Median | Top 5% | Max |
|---|---|---|---|---|---|---|
| clef | Injected errors | 0.022 | 0.025 | 0.107 | 0.594 | 0.748 |
| clef | Haiku's errors | 0.052 | 0.097 | 0.691 | 0.898 | 0.907 |
| clef | Correct values | 0.283 | 0.672 | 0.874 | 0.957 | 0.979 |
| clef-flash | Injected errors | 0.013 | 0.016 | 0.145 | 0.838 | 0.964 |
| clef-flash | Haiku's errors | 0.063 | 0.068 | 0.764 | 0.916 | 0.928 |
| clef-flash | Correct values | 0.302 | 0.541 | 0.857 | 0.959 | 0.977 |
Unlike in the English test, the probabilities for errors and correct values overlapped significantly.
In particular, the median for Haiku's misreadings was high at 0.691, making them hard to distinguish from the correct values (median 0.874).
The results when changing the threshold are as follows.
| Threshold | clef: injected errors | clef: Haiku's errors | clef: false positives | clef-flash: injected errors | clef-flash: Haiku's errors | clef-flash: false positives |
|---|---|---|---|---|---|---|
| 0.5 | 32/36 | 7/19 | 7/503 | 29/36 | 5/19 | 20/503 |
| 0.6 | 34/36 | 7/19 | 15/503 | 30/36 | 5/19 | 49/503 |
| 0.7 | 34/36 | 10/19 | 30/503 | 33/36 | 8/19 | 105/503 |
| 0.8 | 36/36 | 13/19 | 85/503 | 33/36 | 11/19 | 190/503 |
Raising clef's threshold to 0.8 catches all the injected errors, but about 17% of the correct values (85 items) also get sent to human review.
Even so, it catches only 13 of Haiku's 19 misreadings, so it was difficult to eliminate the misses by threshold tuning alone.
clef-flash detects fewer errors and produces more false positives than clef at every threshold, so clef still seems better suited to Japanese documents.
2.3 Time and cost
There is one request to Clef per document.
Each request sends one image together with questions about all fields in that document (30 to 63 questions).
With 3 documents × 4 extraction results, each model was called 12 times.
| Condition | Time per call (median) | Total time for 12 calls | Total cost for 12 calls |
|---|---|---|---|
| clef | 1.913 s (1,913 ms) | 21.60 s | $0.0207 (about ¥3.11) |
| clef-flash | 1.010 s (1,010 ms) | 11.30 s | $0.0078 (about ¥1.17) |
The times are measured values from calling the REST API from within Japan, and costs are converted at $1 = ¥150.
3. Summary
For Japanese documents, clef was generally able to detect errors that turn a value into something clearly different (digits, replacements, different words), but it tended to miss full-width/half-width differences and dropped single characters, and its accuracy was not as high as with English.
In particular, it caught only 7 of the 19 misreadings that the OCR (Haiku) actually made.
Support for image input and low cost are major strengths of Clef.
If you entrust it with checking at this point, its accuracy is by no means high enough to be trusted unconditionally, and it does not yet seem to reach a level where a threshold alone lets you say "this is definitely fine."
Still, compared with having humans check every item from the start, it seems worth trying for narrowing down suspicious items and reducing the cost of human review to some extent.
