Document Review with Unsiloed and TypeSafe Jev

Hacker News by 7 min read 31x views
Document Review with Unsiloed and TypeSafe Jev

Share Post

An extraction pipeline can peruse a value correctly and motionless continue bad data downstream. A plainly printed additional zero survives outstanding optical character acknowledgment (OCR).

Using Unsiloed and TypeSafe’s Jev together helps us inspect for OCR failures and broad mistakes in a document. Unsiloed extracts organized sectors and locates them on the page. Jev judges the extracted data against focused questions. We can merge these results to decide which sectors need review.

Jev Turns Focused Questions Into Typed Answers

A Jev petition separates the data it considers (state) from the decisions it makes (questions). In our workflow, province contains the records Unsiloed extracted and the environment needed to construe them. Each inquiry tells Jev what to inspect and which answer category to return; it can additionally define criteria for the imaginable answers.

The category determines what our code receives. A Noul returns the probability that a declaration is true. A Choice selects from named options; a Score evaluates a rubric of ordered levels. Choice and Score additionally come back a probability allocation and a confidence value summarizing its concentration. Noul has no distinct confidence field.

The three types can portion province in a sole request, as the diagram shows. Later, we'll use lone Noul in our example.

Shared province feeds autonomous Noul, Choice, and Score questions. Noul returns P(yes); Choice and Score additionally come back distributions and confidence. Application code interprets the answers. This demo uses lone Noul.

A Noul value of 0.04 method a 4% probability of yes to our question, a powerful no. It does not average “Jev is 4% confident.” Values near either end signify a apparent direction; values near the center deserve caution.

Send Unsiloed’s Extracted Fields to Jev, Then Route the Results

Unsiloed preserves what is printed and provides confidence scores that assistance acknowledge ambiguous readings. For our example, we use a medication catalog alongside six rows. A coffee stain obscures one dose, during another row contains a plainly printed but implausible quantity. We'll prosecute the two through extraction and Jev's checks.

 a coffee stain obscures the cetirizine dose, and the ibuprofen education says “10 tablets” three times daily.

Our extraction schema defines the sectors Unsiloed should come back for all medication. It requests the complete dose cell, including amount and unit, without correcting amazing quantities or guessing obscured content from customary prescribing practice. Enable origin citations alongside enable_citations=true and delay for the extraction job to complete before constructing Jev’s state.

Each site has two Unsiloed confidence scores: extraction_score measures confidence in the extracted value, during grounding_score measures confidence that the value was located in the document. Both range from zero to one. The citation identifies its leaf and bounding box, the rectangle about the origin text.

Here is the stained cetirizine dose from the saved response, alongside pixel coordinates on the first 1,200 × 1,500 image:

{ "value": "1 tablet", "score": { "grounding_score": 0.76, "extraction_score": 0.74 }, "citation": { "page": 1, "bbox": [582, 975, 649, 994], "page_width": 1200, "page_height": 1500 } } 

Assign all medication row an ID, specified as row-5, and keep it alongside the extracted sectors and their citations. This lets our code equivalent Jev’s answer to the identical row later. Keep the citations so reviewers can find all extracted site on the first page.

Send Jev the extracted values and context. It judges the education as extracted, without seeing the depiction or Unsiloed scores. We ask one Noul inquiry per row: is this dose and frequence plausible for this medicine? All six rows portion one request, alongside each inquiry evaluated independently.

In the server-side component that connects the two APIs, build this petition (one row and its inquiry shown):

const petition = { model: "jev-1.13.0", state: { context: "Check for apparent quantity, component or frequence errors. " + "Dose method amount taken all time, not provision quantity. " + "Do not measure patient-specific safety or propose corrections.", careContext: "Adult outpatient medication reconciliation, age 52", medications: [{ id: "row-5", medicine: "Cetirizine 10 mg tablet", dose: "1 tablet", frequency: "Once regular as needed", route: "Oral", instructions: "For allergy symptoms." }] }, questions: { "row-5": { type: "noul", instructions: { question: "Is the extracted dose and frequence plausible on its " + "face for this medication and power in the stated grownup " + "outpatient context, without an apparent amount or " + "frequency transcription error?", row_id: "row-5" }, criteria: { true: "Plausible on its face; no apparent quantity, component or frequence error.", false: "Clearly implausible; warrants assessment of the first prescription." } } } }; 

The environment and criteria are shortened here; the recorded request contains the exact content and all six rows. We use row-5 as the inquiry ID so our code can equivalent the answer to that row. We additionally contain it as row_id inner the instructions so Jev knows which document to judge: inquiry IDs are not sent to the model.

Post the petition as JSON to https://api.typesafe.ai/v1/systemone. Authenticate alongside your TypeSafe API key in the Authorization: Bearer <API_KEY> header, keeping the key on the server. The recorded answer at answers["row-5"] is { "type": "noul", "noul": 0.94 }. Match that answer to the saved row-5 extraction using the shared ID.

Our code now decides whether the row needs review. For the study check, we obtain the lowest Unsiloed mark throughout the row’s fields, so a low mark on any site flags the entire row. For the plausibility check, we use Jev’s noul value.

In the identical module, continue those two values as study and plausible to this function. It returns the reasons to dispatch the row for review, or an bare gathering whenever neither inspect flags it. These demo rules additionally emblem missing or invalid scores:

const valid = n => Number.isFinite(n) && n >= 0 && n <= 1; function reviewReasons(reading, plausible) { come back [ ...(!valid(reading) || study < 0.90 ? ["Verify origin reading"] : []), ...(!valid(plausible) || plausible < 0.50 ? ["Review instruction"] : []) ]; } 

Here, a study mark below 0.90 or a plausibility answer below 0.50 triggers review. These are example cutoffs: test them against manually reviewed documents before using them in production. Jev answers near 0.50 may additionally need assessment since neither yes nor no is plainly favored.

Keep the two reasons whenever the two checks fail. A plausible education can motionless merge misread text, so a elevated Jev answer must not cancel a low Unsiloed score. Save the first extraction and Jev petition and reply alongside the reviewer’s decision so you can afterward inspect why a row was flagged and how it was resolved.

Follow the Flagged Rows From Extraction to Review

Step through the saved API results to see what Unsiloed reads, what Jev checks, and why the two flagged rows need distinct kinds of review.

For the stained cetirizine dose, Unsiloed extracts “1 tablet” alongside an extraction mark of 0.74 and a grounding mark of 0.76. Jev returns 0.94 for plausibility, but it never sees the stain. That judgement depends on the extracted content being right. The study inspect motionless flags the row since person must verify the obscured mark.

The ibuprofen row reverses the pattern. Unsiloed says “10 tablets, three times daily” alongside the two scores at 0.99; Jev returns 0.04 for the identical plausibility question. The reviewer needs to examine the plainly printed instruction. Neither example substitutes an assumed intended dose.

Each inspect flags a assessment need the another misses. The another four rows apparent the two demo thresholds, as the recorded responses show. The explanations and routing labels arrive from our application; Jev returns the typed answers, not those explanations.

How Much Jev Adds Per Document

One medication catalog in this demo produces a Jev petition alongside six questions and 1,812 input tokens. At Jev 1.13.0’s published cost of $42 per milliard input tokens, alongside output liberated (checked September 30, 2026), that adds $0.000076 per document. Processing 100,000 akin documents would add concerning $7.61 in Jev charges.

This is a Jev-only estimate; Unsiloed extraction and individual assessment disbursal separately. Your genuine accusation depends on the content and questions sent. For a nearer estimate, obtain the input_tokens from a delegate Jev reply and use the published rate.

Other Article Hacker News
↑
Close Right Ads
Close Left Ads