Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
base_model: Qwen/Qwen3-8B
|
| 5 |
+
base_model_relation: finetune
|
| 6 |
+
tags:
|
| 7 |
+
- multimodal
|
| 8 |
+
- vision-language-model
|
| 9 |
+
- smart-city
|
| 10 |
+
- traffic
|
| 11 |
+
- evidence-grounded-generation
|
| 12 |
+
- mixlora
|
| 13 |
+
- custom-code
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# TransCity-VLM StageC
|
| 18 |
+
|
| 19 |
+
This repository contains the **StageC-final SFT checkpoint** of TransCity-VLM, a custom multimodal model for evidence-grounded smart-city reasoning and prediction. It combines a Qwen3-8B decoder, a RoBERTa-large chunk encoder, a SigLIP vision encoder, multimodal projectors, and task-routed MixLoRA experts.
|
| 20 |
+
|
| 21 |
+
> This is a sharded checkpoint for the custom `SmartCityLLMForCausalLM` architecture. It is **not** directly loadable with `AutoModelForCausalLM.from_pretrained()`. Use it with the TransCity-VLM source code.
|
| 22 |
+
|
| 23 |
+
## Loading
|
| 24 |
+
|
| 25 |
+
Install the project dependencies and run the following from the TransCity-VLM source directory:
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from huggingface_hub import snapshot_download
|
| 29 |
+
from transformers import AutoTokenizer
|
| 30 |
+
|
| 31 |
+
from model.builder import build_smartcity_llm
|
| 32 |
+
|
| 33 |
+
MODEL_ID = "TransCity-VLM/Transcity-vlm-stageC"
|
| 34 |
+
checkpoint_dir = snapshot_download(MODEL_ID)
|
| 35 |
+
|
| 36 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 37 |
+
checkpoint_dir,
|
| 38 |
+
use_fast=True,
|
| 39 |
+
padding_side="left",
|
| 40 |
+
trust_remote_code=True,
|
| 41 |
+
)
|
| 42 |
+
if tokenizer.pad_token_id is None:
|
| 43 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 44 |
+
|
| 45 |
+
mixlora_config = {
|
| 46 |
+
"num_experts": 20,
|
| 47 |
+
"lora_r": 8,
|
| 48 |
+
"lora_alpha": 16.0,
|
| 49 |
+
"enable_attention": False,
|
| 50 |
+
"enable_ffn": True,
|
| 51 |
+
"share_router_for_wi": True,
|
| 52 |
+
"num_tasks": 3,
|
| 53 |
+
"ensure_nonzero_gating": False,
|
| 54 |
+
"num_universal": 4,
|
| 55 |
+
"num_pred": 8,
|
| 56 |
+
"num_reason": 8,
|
| 57 |
+
"rank_universal_mul": 2.0,
|
| 58 |
+
"target_modules_override": {
|
| 59 |
+
"atte": "self_attn",
|
| 60 |
+
"ffn": "mlp",
|
| 61 |
+
"q": [], "k": [], "v": [], "o": [],
|
| 62 |
+
"wi": ["mlp.gate_proj", "mlp.up_proj"],
|
| 63 |
+
"wo": ["mlp.down_proj"],
|
| 64 |
+
},
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
model = build_smartcity_llm(
|
| 68 |
+
decoder_name="Qwen/Qwen3-8B",
|
| 69 |
+
encoder_name="FacebookAI/roberta-large",
|
| 70 |
+
num_chunk_tokens=4,
|
| 71 |
+
adapter_heads=4,
|
| 72 |
+
encoder_max_length=512,
|
| 73 |
+
imagebind_variant="google/siglip-so400m-patch14-384",
|
| 74 |
+
num_image_tokens=32,
|
| 75 |
+
group_layers=2,
|
| 76 |
+
group_heads=8,
|
| 77 |
+
group_tau=1.0,
|
| 78 |
+
open_roberta=False,
|
| 79 |
+
open_vpma=False,
|
| 80 |
+
open_imagebind=False,
|
| 81 |
+
open_image_projector=False,
|
| 82 |
+
freeze_decoder=True,
|
| 83 |
+
use_mixlora=True,
|
| 84 |
+
mixlora_cfg_overrides=mixlora_config,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
model.load_full_state_dict(
|
| 88 |
+
checkpoint_dir,
|
| 89 |
+
cast_to_target_dtype=True,
|
| 90 |
+
verbose=True,
|
| 91 |
+
)
|
| 92 |
+
model.decoder.config.pad_token_id = tokenizer.pad_token_id
|
| 93 |
+
model.decoder.config.eos_token_id = tokenizer.eos_token_id
|
| 94 |
+
model.eval().to("cuda")
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
For preprocessing and generation, use the project `DataCollatorSmartCity` pipeline and `generate_with_modalities_cached()` implementation.
|
| 98 |
+
|
| 99 |
+
## Intended use and limitations
|
| 100 |
+
|
| 101 |
+
This checkpoint is intended for research on multimodal, evidence-grounded smart-city tasks. It expects the project-specific input format and preprocessing pipeline, and has not been validated for safety-critical or general-purpose deployment.
|
| 102 |
+
|
| 103 |
+
## License
|
| 104 |
+
|
| 105 |
+
The released checkpoint is available under **CC BY 4.0**. Upstream backbones and source-code dependencies retain their respective licenses.
|