To use st-vision-llm, you will need the following packages:
python>=3.10torch==2.4.1transformers==4.57.1accelerate==1.11.0ms-swift==3.10.1
pip install -r requirements.txt-
Split the Milan dataset and place the files in the structure below
data/raw/ Milan/ train/*.txt val/*.txt test/*.txt Trentino/ train/*.txt val/*.txt test/*.txt -
Dataset preprocessing
python dataset_prepare.py
- Each input directory produces one
.ptdata file saved todata/processed/<City>_<split>.pt. - The file contains:
tensors: dict whose keys are channels (sms_in,internet, etc.) and values are[T, H, W]float32 tensors.all_times: ISO timestamps in the Europe/Rome timezone.- Metadata such as
cache_version,created_time, etc.
- Each input directory produces one
-
Visualize the results
python dataset_prepare.py --check data/processed/Milan_train.pt
This command randomly samples a channel and previews all frames as an animation.
-
Generate training corpora
cd train_numtoken python num_encode_math.pyThis script automatically produces:
newtokens.txt: every<|FPm/e|>special token.stage1_train.jsonl: numeric alignment samples.stage2_train.jsonl/stage2_val.jsonl: numeric reasoning and basic arithmetic tasks.
-
Two-stage SFT
bash train_numtoken/train_sft.sh
- Stage 1 trains only
embed_tokensandlm_headto expand the vocabulary, saving totrain_numtoken/output_stage1. - Stage 2 automatically loads the latest Stage 1 checkpoint and continues full-parameter SFT on the
stage2_*data, outputting totrain_numtoken/output_stage2. - Change the
MODELvariable at the top oftrain_sft.shto swap the base model.
- Stage 1 trains only
-
Script entry point
bash train_sft/train_sft.sh \ <dataset_type> <ratio> <data_type> \ <input_len> <output_len> \ <x_start> <x_end> <y_start> <y_end> \ <base_model>
dataset_type:MilanorTrentino; the script maps this todata/processed/<City>_{train,val}.pt.ratio: sampling ratio for time slices in the training set.data_type: channel name insidetensors.input_len/output_len: number of historical frames vs. predicted frames.(x_start, x_end, y_start, y_end): spatial coordinate range.base_model: path or Hugging Face name of the NumToken-extended base model.
-
Example
bash train_sft/train_sft.sh \ Milan 0.02 internet \ 12 20 \ 45 55 45 55 \ Saves/qwenvl-7B-numtoken-math
-
Usage
bash train_grpo/train_grpo.sh \ <dataset_type> <ratio> <data_type> \ <input_len> <output_len> \ <x_start> <x_end> <y_start> <y_end> \ <base_model>
Parameters are identical to the SFT script.
-
Example
bash train_grpo/train_grpo.sh \ Milan 0.02 internet \ 12 20 \ 45 55 45 55 \ train_sft/sft/checkpoint-600