astro_sky_image_vqa / SCHEMA.md
jnaiman
renaming
f61e5f9
|
Raw History Blame Contribute Delete
11.3 kB

Field reference

Field-by-field detail for every file type in this repo. The README is the overview; this is the part you read when writing a parser.


1. VQA_full/qa_jsons/vqa_NNNNNN_qa.json

Encoding gotcha: the file is a JSON-encoded string, so it needs two decodes — json.loads(json.load(f)). A single decode silently hands you a str, not a dict.

Top level: figure, plot0, VQA, vqa_id.

1.1 figure — render parameters

Field Type Notes
dpi int
base int base figure size before aspect scaling
aspect ratio float width / height
nrows, ncols int always 1 in this release
plot style str matplotlib style name, e.g. seaborn-v0_8-muted — ground truth for the plot style question
color map str e.g. rainbow_r — ground truth for colormap
title fontsize, xlabel fontsize, ylabel fontsize, xlabel ticks fontsize, ylabel ticks fontsize int
plot indexes list grid position of each panel, e.g. [[0, 0]]
pixel width, pixel height int rendered size; matches the JPEG
figsize [float, float] inches
facecolor [r, g, b, a] 0–1 floats
figure_params dict the fuller randomisation record: panel style, layout pads, tight_layout, flipped font/face colors, fontcolor
font_params dict per-element font sizes plus csfont (the chosen font family)

1.2 plot0 — the panel

Field Type Notes
type str contour or image of the sky
distribution str random / linear / gmm for contour; gmm or sky for sky images
data dict xs, ys, colors, data params — see below
data pixels dict the same data in pixel coordinates, under image and/or contour
data from plot dict values read back off the rendered artists; non-serialisable entries are the string "non serializable entry"
color bar dict bounding box xmin/ymin/xmax/ymax plus placement params
xticks, yticks, color bar ticks list of dict one per tick: data (the label as typeset, LaTeX included), its box, and anchor tx/ty
square dict bounding box of the plot area itself
title, xlabel, ylabel dict box plus words; title is absent when the figure has none

Coordinate convention: boxes are in pixels, origin bottom-left, matching the rendered JPEG's pixel width / pixel height. Flip y for image-library conventions with the origin at the top.

plot0.data.data params

For synthetic panels: the generating parameters.

For real sky panels (distribution == "sky") it additionally carries:

Field Notes
WCS "non serializable entry" — use the header strings instead
WCS header string FITS WCS of the panel as plotted
WCS header string (fetched) FITS WCS of the cutout as retrieved (before resampling)
sky image params full provenance — see below

sky image params (real sky panels only)

A dict — note it may be stored as its repr, in which case ast.literal_eval recovers it.

Field Notes
filename source FITS name; encodes bibcode, object, survey and cutout size
header the original FITS header, verbatim
survey header SkyView's survey descriptor
survey SkyView category, e.g. ['Optical:DSS class='] (a list)
object resolved object name, e.g. NAME Cas A, M 31 (SIMBAD spacing preserved)
telescope, instrument often None for optical plate surveys
bunit, btype physical units of the pixel values, e.g. MJY/SR, JY/BEAM, K
pdf ADS-style bibcode of the source paper, e.g. 1995ApJS___97__347G
original img size, fetched img size pixel dimensions before/after retrieval
resample transform how the cutout was resampled onto the panel grid

1.3 VQA — the questions

Addressed as VQA[level][kind][name], where level is Level 1 / Level 2 / Level 3 and kind is Figure-level questions or Plot-level questions.

The two kinds nest differently:

VQA['Level 1']['Figure-level questions']['plot style']           -> entry
VQA['Level 2']['Plot-level questions' ]['mean color']['plot0']   -> entry
                                                      ^^^^^^^^ panel key

Plot-level questions are keyed by panel underneath the question name. Every figure here is single-panel, so the extra level is easy to miss; code that omits it gets a dict where it expected a question. Detect by testing for the Q key rather than by assuming depth:

def question_entries(node):
    if 'Q' in node:
        yield None, node
    else:
        for panel, entry in node.items():
            yield panel, entry

A question entry:

Field Notes
Q the assembled prompt: persona + context + question + format
A ground truth. In the qa jsons this is always a one-key dict, e.g. {"plot style": "seaborn-v0_8-muted"}. (It is not always a dict in the run pickles — see §3.)
persona system framing
context scene-setting, and the multiple-choice list when one is offered
question the question alone, without persona/context/format
format the requested answer shape, e.g. {"plot style":""}

Parse format rather than hard-coding key names. It states the exact JSON key the model was asked to fill, so extraction can never drift from the prompt:

def expected_key(fmt):
    if not fmt or '{' not in fmt:
        return None
    inner = fmt.split('{', 1)[1].split('}', 1)[0]
    return inner.split(':', 1)[0].strip().strip('"\'') if ':' in inner else None

Question counts: 21 per contour figure, 25 per sky figure. The difference is the plot-level set — contour figures get x/y axis limits, colour statistics and two distribution questions; sky figures get RA/Dec limits and units, epoch, angular field size, colour statistics, provenance and pixel scale.


2. VQA_full/imgs/vqa_NNNNNN.jpeg

JPEG, RGB, one per record, filename matching the vqa_id. Dimensions vary per figure (roughly 2000–2700 px wide) and always equal figure['pixel width'] x figure['pixel height'].


3. LMM_outputs_n255*/MODEL/vqa_NNNNNN_qa.pickle

A 2-tuple: (qa_list, model_id).

  • qa_list — one dict per question asked of that figure, in ask order
  • model_id — the exact model string used, e.g. gpt-5.4-nano-2026-03-17

Entry fields, present for every model

Field Notes
Q, persona, context, question, format copied verbatim from the qa json
A ground truth, but reshaped: a dict for figure-level questions, unwrapped to a bare str or float for plot-level ones (see below)
Level, type which level and kind the question came from
reasoning the appended instruction asking for a separate explanation JSON
prompt the full text sent to the API, including the reasoning instruction
raw answer the model's response, verbatim — parse this
Response, Response String the same text after light handling

Ground-truth shape differs from the qa json

The qa json stores every A as a one-key dict. The runs unwrapped the plot-level ones when assembling prompts, so in the pickles:

Question kind A type Example
Figure-level (plot style, colormap, titles, labels, ticks, plot type) dict {'plot style': 'seaborn-v0_8-muted'}
Plot-level, categorical (epoch, finest unit, contour style, distribution) str 'gaussian mixture model'
Plot-level, numeric (axis limits, colour stats, field size, pixel scale) float -16.47

Two exceptions to keep in mind:

  • RA axis limits are str, not float — they are sexagesimal, e.g. '18h52m45.57s'. Dec limits are floats, in degrees. Do not assume the two coordinate axes parse the same way.
  • Tick-value answers are lists, and double-nested: A is {'xtick values': [[label, label, ...]]} — a list containing one list of tick labels, each a typeset string with LaTeX intact ('18$\\mathregular{^h}$52$\\mathregular{^m}$'). Unwrapping once gets you the inner list, which is the answer; these questions are not scalar-valued.

Each question is internally consistent in its type, so you can key the expected shape off the question — but do not assume dict:

def ground_truth(entry):
    a = entry.get('A')
    if isinstance(a, dict):
        a = next(iter(a.values()), None)
    return a[0] if isinstance(a, list) and a else a

Provider-specific extras

Field Present for
fac GPT — image downscale factor applied before sending
usage Claude, Gemini — token accounting
system prompt Claude, Gemini
Response (raw) Gemini — the untouched SDK payload

Unpickling without the vendor SDKs

The pickles embed the provider's own response object, so a plain pickle.load needs anthropic / google-genai importable. Every field listed above is a plain string, so unknown classes can be stubbed:

import pickle

class _Stub:
    def __init__(self, *a, **k): pass
    def __setstate__(self, s): self.__dict__.update(s if isinstance(s, dict) else {})

class TolerantUnpickler(pickle.Unpickler):
    def find_class(self, module, name):
        try:
            return super().find_class(module, name)
        except (ImportError, AttributeError):
            return type(name, (_Stub,), {})

with open(path, 'rb') as f:
    qa_list, model_id = TolerantUnpickler(f).load()

Parsing a response

Responses are two JSON objects back to back — the answer, then the explanation — and models are not reliable about it. Observed in these runs: the requested key renamed (plot_types for plot types), trailing commas, single quotes, unescaped LaTeX backslashes, mismatched braces, fenced code blocks, and answer and explanation merged into one object.

A robust reader should: strip code fences; extract balanced {...} objects; match the key from format up to spacing, underscores and case; treat the non-explanation value as the answer if the key is absent entirely; and distinguish "no answer recoverable" from "wrong answer". About 0.14% of responses (48 of 36,210) yield no answer at all.


4. LMM_outputs_n255_archive_light/archive_manifest.json

{vqa_id: recipe} for all 255 aged figures. The identical recipe is also written per figure as MODEL/vqa_NNNNNN_qa_archive.json.

Field Notes
preset "archive-light"
base_seed run-wide seed (20260914)
seed this figure's seed, derived from its id — the reason all three models saw the same aged image
effects effect names that fired, in order
effects_by_phase the same, split into ink, paper, post
grayscale whether this figure was converted to gray
gray_prob the probability used for that draw (0.6667)
page background RGB of the simulated paper

aged_imgs/vqa_NNNNNN.jpeg holds the resulting images — the exact bytes sent to the models. Re-running the aging is unnecessary.