OpenQlaw Fixes AI Microscopy Counting Errors With 100% Exact Results
A new agentic system fixes the hallucinated-count problem when vision-language models try to tally 2D material flakes in microscopy images.
Takeaways
- OpenQlaw pairs a vision-language orchestrator with the QuPAINT physics-aware expert for 2D material microscopy.
- Free-form candidate lists from multimodal models cause summary counts to drift away from the actual observations.
- State-Grounded OpenQlaw converts expert output into image-scoped records and runs deterministic count, select and measure tools.
- Raw and structured replay hit exact counts in only 40% and 42% of trials; the deterministic path is exact in 684/684.
- In-context counting collapses past roughly 15 observations; the record-based approach stays exact at every size.
- Follow-up OpenQlaw-v2 fuses the two models into one, cutting peak host memory from 44.44 GiB to 5.64 GiB.
The OpenQlaw preprint addresses a specific failure in multimodal scientific workflows: a vision-language system can localize monolayer flakes in an optical microscopy image, enumerate them correctly, and still report the wrong total. OpenQlaw stores those observations in a structured, image-scoped record and delegates counting, selection, rendering, and calibrated measurement to deterministic tools. This keeps numerical answers aligned with the stored evidence and makes each result reproducible.
Correct detections, wrong total
OpenQlaw’s perception component is QuPAINT, a physics-aware multimodal model for optical images of two-dimensional materials. QuPAINT uses optical contrast and substrate-relative color cues to identify candidate flakes, including monolayers that may be suitable for device fabrication.
QuPAINT returns detailed descriptions and coordinate arrays for review. When a language model processes that long numerical output in its context window, it can lose track of the number of observations. The resulting summary may disagree with the candidate list even when the underlying localization is correct. Reformatting the same observations as a cleaner structured list improves readability but does little to fix the counting error.
A record becomes the source of truth
OpenQlaw places a general vision-language orchestrator in front of QuPAINT using a lightweight agent framework. For a materials-related request, the orchestrator sends the uploaded image and a characterization prompt to a Material Domain Expert. QuPAINT is exposed to that expert through an API schema, leaving the orchestrator responsible for conversation and tool routing while the specialist model handles visual inference.
State-Grounded OpenQlaw parses the expert’s response into a record associated with the source image. The orchestrator accesses that state through four deterministic operations:
- Count returns the number of observations in the relevant record or selection.
- Select filters observations using attributes already present in the record.
- Measure combines stored geometry with a user-supplied spatial calibration.
- Render produces a visual representation of the stored observations.
Record identifiers are opaque, and record size is hidden from the language model, so the exact total must come from the count operation. Requests requiring fields absent from the record return a refusal. These constraints prevent the model from inventing unsupported attributes or deriving totals from a long sequence of coordinates.
684 exact counts, with a defined boundary
The evaluation includes a live pilot using 20 reviewed images of WSe2, or tungsten diselenide, plus a controlled replay that holds the expert observations fixed and changes how the orchestrator derives the total. The replay compares three strategies:
| Strategy | How the total is produced | Exact-match result |
|---|---|---|
| Raw replay | The model counts a free-form enumeration in its context. | 40% |
| Structured replay | The model counts the same observations in a structured list. | 42% |
| Deterministic delegation | The count tool reads the image-scoped record. | 100% (684/684) |
Exact-match performance for the two in-context methods drops sharply once records contain roughly 15 observations. State-Grounded OpenQlaw remains exact across every tested record-size group because the count comes from the record operation rather than language-model generation.
The primary metric measures consistency with the stored record. Image-level ground truth provides a narrower check on detector accuracy: among six cohort images whose selected-record size matched the reviewed image count, State-Grounded OpenQlaw returned the reviewed total in all six cases.
Calibration turns boxes into measurements
The same record supports spatial measurement. OpenQlaw parses QuPAINT’s localization output into coordinate arrays, converts bounding boxes to pixels using the source image dimensions, and applies a user-provided calibration to report area in square micrometres. The reported value is the area of the enclosing box, so its physical accuracy depends on localization quality, image scaling, and the supplied calibration.
Useful state, clear limits
For two-dimensional quantum-material fabrication, the system can scan microscopy images for monolayer candidates, measure a selected flake, and retain sample-preparation notes across sessions. Persistent context also stores physical scaling ratios for later calculations, allowing researchers to compare results without repeatedly entering the same metadata.
OpenQlaw guarantees deterministic operations only after QuPAINT’s output has been parsed into a record, leaving several sources of error outside that boundary:
- Missed or false detections remain in the perception layer.
- Parsing errors can create an incomplete or malformed record.
- QuPAINT retains the token-length constraints of current multimodal models.
- Measurements inherit errors from bounding boxes and spatial calibration.
- The reported evidence comes from a small pilot, including six qualifying images in the reviewed-count comparison.
The follow-up OpenQlaw-v2 combines the orchestrator and expert into a single adapted QuPAINT checkpoint while retaining the record-and-tool design. The paper reports a reduction in peak host memory from 44.44 GiB to 5.64 GiB.
For developers building scientific agents, the design creates a practical division of responsibility. The model interprets requests and produces candidate observations, typed state preserves those observations, and deterministic functions own aggregation and measurement. A lab can reproduce each total from the stored record and trace discrepancies to perception, parsing, or computation.