Views
No views yet
anonymouscla/physground.adapter_config.json (base_model_name_or_path); the inference script
reads it automatically.| File | Purpose |
|---|---|
adapter_config.json | PEFT/LoRA config (records base model id) |
adapter_model.safetensors | LoRA weights (~167 MB) |
additional_config.json | ms-swift extras (lora_dtype / lr ratios) |
training_args.json | sanitized training hyperparameters |
subq+human.yaml | prompt template used at training and inference time |
infer.py | standalone end-to-end inference script |
1pip install "transformers>=4.49" peft accelerate pyyaml \
2 "qwen-vl-utils[decord]" huggingface_hubinfer.py accepts either a local folder or a HF Hub repo id via
--adapter-dir; the default value already points at this repo, so the
following commands work without cloning anything.1# General axes (1–5 each): SA / PTV / persistence
2python infer.py \
3 --video /path/to/video.mp4 \
4 --caption "A ball rolls down a ramp and knocks over a block." \
5 --metric SA
6
7# Physical-law axes (1–5 each): one of the 13 laws below
8python infer.py \
9 --video /path/to/video.mp4 \
10 --caption "A ball rolls down a ramp and knocks over a block." \
11 --law gravityinfer.py will:--adapter-dir to a local directory (huggingface_hub.snapshot_download
if it is a Hub id).adapter_config.json to find the base model and load it via
transformers.subq+human.yaml, plus the relevant
sub-questions / per-law criterion (constants embedded in infer.py).--max-new-tokens 64 (matches training).{"key": "gravity", "score": 4, "raw": "{\"gravity\": 4}"}--metric choices: SA, PTV, persistence.
--law choices: gravity, inertia, momentum, impenetrability,
collision, material, buoyancy, displacement, flow_dynamics,
boundary_interaction, fluid_continuity, reflection, shadow.--print-prompt to inspect the exact rendered system + user prompt
before generation.1from pathlib import Path
2import torch
3
4from infer import (
5 build_messages,
6 build_prompt,
7 decode_generated,
8 load_model,
9 load_yaml,
10 parse_score,
11 prepare_inputs,
12)
13
14processor, model, adapter_dir = load_model(
15 "anonymouscla/physground-judger9B",
16 dtype=torch.bfloat16,
17 device_map="auto",
18)
19cfg = load_yaml(adapter_dir / "subq+human.yaml")
20
21system, user, key = build_prompt(
22 cfg,
23 caption="A ball rolls down a ramp and knocks over a block.",
24 law="gravity",
25)
26messages = build_messages(system, user, Path("video.mp4"))
27inputs = prepare_inputs(
28 processor,
29 messages,
30 next(model.parameters()).device,
31 fps=2.0,
32 max_pixels=360 * 640,
33)
34
35with torch.inference_mode():
36 out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
37
38raw = decode_generated(processor, inputs, out)
39print({"key": key, "score": parse_score(raw, key), "raw": raw})subq+human.yaml — system prompt, the SA / PTV / persistence templates
for the general axes, and the physical_template shared by all 13
physical-law axes (with {prompt}, {law}, {criteria},
{questions_block} placeholders). Use --print-prompt to dump the
fully rendered system + user prompt.infer.py — the per-axis sub-question lists (GENERAL_SUB_QUESTIONS,
PHYSICAL_SUB_QUESTIONS) and per-law criteria (PHYSICAL_CRITERIA)
that are spliced into the YAML templates. Override any criterion at
inference time with --criteria "..." instead of editing the source.subq+human split
(automatically derived sub-question judgements + human-rated samples).
Full hyperparameters in training_args.json and additional_config.json;
exact LoRA target regex and rank in adapter_config.json. Framework:
ms-swift 4.1.2, PEFT 0.19.1, DeepSpeed ZeRO-2.anonymouscla/physground
for prompts, physical-law tags, and example videos.