Video-Text-to-Text
Transformers
Safetensors
agent

Add library_name and paper link to model card

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +36 -180
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- license: bsd-3-clause
3
  base_model:
4
  - Qwen/Qwen2.5-Omni-7B
5
  - Qwen/Qwen2-VL-7B-Instruct
6
  - yeliudev/VideoMind-7B
 
7
  metrics:
8
  - accuracy
9
  pipeline_tag: video-text-to-text
 
10
  tags:
11
  - agent
12
  ---
@@ -20,7 +21,7 @@ tags:
20
  <a href="https://github.com/eeee-sys/MAOmni/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/badge/License-BSD--3--Clause-purple"></a>
21
  </div>
22
 
23
- **MODF-SIR** is a lightweight MLLM-based, distillation-augmented, multi-agent collaborative framework for social intelligence reasoning.
24
 
25
  ## 🔖 Model Details
26
 
@@ -28,225 +29,80 @@ tags:
28
  - **License:** BSD-3-Clause
29
 
30
  ## 👀 MODF-SIR Overview
31
- We propose a multi-agent collaborative framework built upon a lightweight Multimodal Large Language Model (MLLM), specifically designed for social intelligence reasoning. A key feature of our approach is that both the training and inference phases are augmented via knowledge distillation. Within this architecture, multi-modal data pertinent to social intelligence is precisely localized. Furthermore, relevant long-tail events are identified, extracted, and rendered as formatted, explicit text. This formatting strategy prevents critical long-tail information from being overshadowed by head events and environmental noise during the tokenization process. Specifically, we integrate Test-Time Adaptation (TTA) across the entire reasoning pipeline, encompassing the extraction and representation of long-tail events, Chain-of-Thought (CoT) prompting, and self-reflection. This TTA mechanism is also distillation-enhanced, utilizing Low-Rank Adaptation (LoRA) to fine-tune the foundation model exclusively for instance-level reasoning. Extensive evaluations against various open-source and proprietary AI models across multiple benchmarks demonstrate the effectiveness of the proposed framework.
32
 
33
  <p align="center">
34
  <img src="https://github.com/eeee-sys/MODF-SIR/blob/main/assets/method.png" width="100%" height="100%">
35
  </p>
36
 
37
  #### 🌟 Contributions in MODF-SIR
38
- 1. We propose MODF-SIR, a unified omni-modal reasoning framework that pioneers the application of multi-agent collaboration in the field of social intelligence reasoning. Our framework introduces dynamic strategy selection via a routing agent, enabling the model to adaptively determine whether to perform temporal grounding or direct reasoning based on input complexity.
39
 
40
- 2. We introduce GRPO Grounder and TTA Reviser. We train the video locator implemented by the autoregressive method using the GRPO algorithm and fine-tune the reasoning module during testing using the test-time adaption and REINFORCE with Baseline algorithms. This method enables our framework to have sample-level answering capabilities.
41
 
42
- 3. MODF-SIR achieves state-of-the-art results across three Benchmarks: IntentBench, Daily-Omni, WorldSense. Notably, our approach surpasses a host of commercial closed-source and open-source models, including GPT-4o, Gemini-2.5-Pro (think). Extensive ablations further confirm its effectiveness.
43
 
44
  ## 💻 Code Repository
45
 
46
  The code for MAOmni, including training and evaluation scripts, can be found on GitHub: [https://github.com/eeee-sys/MODF-SIR](https://github.com/eeee-sys/MODF-SIR)
47
 
48
- ## 📈 Experimental Results
49
-
50
- #### 📍 Results
51
-
52
- <p align="center">
53
- <img src="assets/dailyomni.png" width="100%" height="100%">
54
- </p>
55
-
56
- <p align="center">
57
- <img src="assets/worldsense.png" width="100%" height="100%">
58
- </p>
59
-
60
- <p align="center">
61
- <img src="assets/intentbench.png" width="100%" height="100%">
62
- </p>
63
-
64
  ## 🚀 Quick Start
65
 
66
- ### Install the environment
67
-
68
- 1. Clone the repository from GitHub.
69
 
 
70
  ```shell
71
  git clone git@github.com:eeee-sys/MODF-SIR.git
72
  cd MODF-SIR
73
  ```
74
 
75
- 2. Initialize conda environment.
76
-
77
- ```shell
78
- conda create -n grpo_grounder python=3.11 -y
79
- conda activate grpo_grounder
80
- pip install -r src/requirements_grpo_grounder.txt
81
- ```
82
-
83
  ```shell
84
  conda create -n modfsir_main python=3.10 -y
85
  conda activate modfsir_main
86
  pip install -r src/requirements_main.txt
87
  ```
88
 
89
- ### Quick Inference Demo
90
 
91
- The script below showcases how to perform inference with MODF-SIR's different roles. Please refer to our [GitHub Repository](https://github.com/eeee-sys/MODF-SIR) for more details about this framework.
92
 
93
  ```python
94
  import torch
95
-
96
  from transformers import (
97
  Qwen2_5OmniForConditionalGeneration,
98
- Qwen2_5OmniThinkerForConditionalGeneration,
99
  Qwen2_5OmniProcessor,
100
  )
101
- from peft import LoraConfig, get_peft_model, PeftModel
102
-
103
- from qwen_omni_utils import process_mm_info
104
-
105
- # ============================================================
106
- # Main Process
107
- # ============================================================
108
- def main():
109
-
110
- # ---- Initialize Models ----
111
- print(f"\n[INIT] Loading Base Model ({args.base_model_path}) on {args.main_gpu}")
112
- base_model = Qwen2_5OmniForConditionalGeneration.from_pretrained(
113
- args.base_model_path, torch_dtype=torch.bfloat16, attn_implementation="flash_attention_2"
114
- ).to(args.main_gpu)
115
- base_processor = Qwen2_5OmniProcessor.from_pretrained(args.base_model_path)
116
-
117
- # Load Planner LoRA onto thinker submodule
118
- print(f"[INIT] Loading Planner LoRA onto base_model.thinker")
119
- base_model.thinker.load_adapter(args.planner_lora_path, adapter_name="planner")
120
- base_model.eval()
121
-
122
- print(f"[INIT] Loading HumanOmniV2 ({args.humanomni_path}) on {args.humanomni_gpu}")
123
- humanomni_model = Qwen2_5OmniThinkerForConditionalGeneration.from_pretrained(
124
- args.humanomni_path, torch_dtype=torch.bfloat16, attn_implementation="flash_attention_2"
125
- ).to(args.humanomni_gpu)
126
- humanomni_processor = Qwen2_5OmniProcessor.from_pretrained(args.humanomni_path)
127
-
128
- lora_config = LoraConfig(
129
- r=64, lora_alpha=128,
130
- target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
131
- lora_dropout=0.05, bias="none", task_type="CAUSAL_LM"
132
- )
133
- humanomni_model = get_peft_model(humanomni_model, lora_config, adapter_name="initial_dummy")
134
-
135
- humanomni_model.enable_input_require_grads()
136
-
137
- humanomni_model.gradient_checkpointing_enable()
138
- print(f"[INIT] Starting Grounder process on {args.grounder_gpu}...")
139
- grounder_script = os.path.join(SCRIPT_DIR, "grounder_worker_grpo.py")
140
- grounder_env = os.environ.copy()
141
- grounder_env["CUDA_VISIBLE_DEVICES"] = args.grounder_gpu.replace("cuda:", "")
142
- grounder_proc = subprocess.Popen([
143
- args.grounder_python, grounder_script,
144
- "--model_path", args.grounder_path,
145
- "--grpo_adapter_path", args.grpo_adapter_path,
146
- "--device", "cuda:0"
147
- ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, text=True, bufsize=1,
148
- env=grounder_env)
149
-
150
- ready_line = grounder_proc.stdout.readline().strip()
151
- if not ready_line or json.loads(ready_line).get("status") != "ready":
152
- print("[ERROR] Grounder worker failed to start.")
153
- sys.exit(1)
154
-
155
- print("[INIT] All models ready!")
156
- os.makedirs(args.lora_save_dir, exist_ok=True)
157
- tmp_dir = tempfile.mkdtemp(prefix="idea3_reviser7b_")
158
-
159
- # ---- 3. Loop through dataset ----
160
- for sample in samples_to_process:
161
- try:
162
- # ====== PLANNER STAGE ======
163
- # a) Collector Phase (LoRA disabled)
164
- base_model.thinker.set_adapter("planner") # Ensure adapter is active before disabling
165
- base_model.thinker.disable_adapters()
166
- collector_text = stage1_collector(base_model.thinker, base_processor, video_path, query, args.main_gpu)
167
- print(f"[Collector output] {collector_text}")
168
-
169
- # b) Planner Phase (LoRA enabled)
170
- base_model.thinker.enable_adapters()
171
- (use_grounder, gnd_query), planner_raw = stage2_planner(base_model.thinker, base_processor, video_path, query, collector_text, args.main_gpu)
172
- print(f"[Planner output] {planner_raw}")
173
- print(f"[Planner] Use Grounder: {use_grounder} | query: {gnd_query}")
174
-
175
- # ====== GROUNDER STAGE ======
176
- generation_video = video_path
177
- grounded_span = None
178
- if use_grounder:
179
- pred_spans, success = stage3_grounder(grounder_proc, video_path, gnd_query or query, duration)
180
- print(f"[Grounder output] {pred_spans}")
181
- grounded_span = pred_spans[0]
182
- trim_path = os.path.join(tmp_dir, f"trim_{dataset_id}.mp4")
183
- trim_video_ffmpeg(video_path, grounded_span[0], grounded_span[1], trim_path)
184
- generation_video = trim_path
185
- print(f"[Grounder] Grounded to {grounded_span[0]:.1f}s - {grounded_span[1]:.1f}s")
186
-
187
- # ====== HUMANOMNI & REINFORCE STAGE ======
188
- humanomni_query = build_humanomni_query(sample)
189
-
190
- adapter_name = f"sample_{dataset_id}".replace(".", "_")
191
- humanomni_model.add_adapter(adapter_name, lora_config)
192
- humanomni_model.set_adapter(adapter_name)
193
-
194
- # Ensure adapter parameters require gradients
195
- for n, p in humanomni_model.named_parameters():
196
- if adapter_name in n:
197
- p.requires_grad = True
198
-
199
- humanomni_model.train()
200
-
201
- trainable_params = [
202
- p for n, p in humanomni_model.named_parameters()
203
- if p.requires_grad and adapter_name in n
204
- ]
205
- optimizer = torch.optim.AdamW(trainable_params, lr=args.lr)
206
-
207
- b = args.b0
208
- best_score = -1
209
- best_answer = ""
210
- best_raw_resp = ""
211
- all_history = []
212
- early_stop = False
213
-
214
- for t in range(1, args.t_max + 1):
215
- gc.collect(); torch.cuda.empty_cache()
216
-
217
- humanomni_model.eval()
218
- inputs = get_humanomni_inputs(humanomni_processor, generation_video, humanomni_query, sample, args.humanomni_gpu)
219
-
220
- with torch.no_grad():
221
- output_ids = humanomni_model.generate(**inputs, max_new_tokens=1024, do_sample=True, temperature=0.85)
222
-
223
- generated_sequence = output_ids[0][inputs.input_ids.size(1):]
224
- y_t_text = humanomni_processor.decode(generated_sequence, skip_special_tokens=True)
225
- print(f" [Iter {t}/{args.t_max}] Answer = {y_t_text}")
226
-
227
- base_model.thinker.disable_adapters()
228
- score_t, reviser_raw = revise_answer(base_model.thinker, base_processor, video_path, query, y_t_text, args.main_gpu)
229
-
230
- all_history.append({"iter": t, "answer": y_t_text, "score": score_t, "reviser_raw": reviser_raw})
231
-
232
-
233
- # --- RL Update (REINFORCE) ---
234
- humanomni_model.train()
235
- optimizer.zero_grad()
236
 
237
- advantage = float(score_t - b)
238
- advantage_tensor = torch.tensor([advantage], device=args.humanomni_gpu, dtype=torch.bfloat16)
 
239
 
240
- outputs = humanomni_model(**forward_kwargs)
 
 
 
 
241
 
242
- nll_loss = outputs.loss
243
- final_loss = nll_loss * advantage_tensor.detach()
244
 
245
- final_loss.backward()
246
- optimizer.step()
 
 
247
 
248
- b = args.alpha * b + (1.0 - args.alpha) * score_t
249
 
 
250
 
 
 
 
251
 
 
 
 
252
 
 
 
 
 
1
  ---
 
2
  base_model:
3
  - Qwen/Qwen2.5-Omni-7B
4
  - Qwen/Qwen2-VL-7B-Instruct
5
  - yeliudev/VideoMind-7B
6
+ license: bsd-3-clause
7
  metrics:
8
  - accuracy
9
  pipeline_tag: video-text-to-text
10
+ library_name: transformers
11
  tags:
12
  - agent
13
  ---
 
21
  <a href="https://github.com/eeee-sys/MAOmni/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/badge/License-BSD--3--Clause-purple"></a>
22
  </div>
23
 
24
+ **MODF-SIR** is a lightweight MLLM-based, distillation-augmented, multi-agent collaborative framework for social intelligence reasoning. This model was introduced in the paper [MODF-SIR: A Multi-agent Omni-modal Distilled Framework for Social Intelligence Reasoning](https://huggingface.co/papers/2606.12018).
25
 
26
  ## 🔖 Model Details
27
 
 
29
  - **License:** BSD-3-Clause
30
 
31
  ## 👀 MODF-SIR Overview
32
+ We propose a multi-agent collaborative framework built upon a lightweight Multimodal Large Language Model (MLLM), specifically designed for social intelligence reasoning. A key feature of our approach is that both the training and inference phases are augmented via knowledge distillation. Within this architecture, multi-modal data pertinent to social intelligence is precisely localized. Furthermore, relevant long-tail events are identified, extracted, and rendered as formatted, explicit text. This formatting strategy prevents critical long-tail information from being overshadowed by head events and environmental noise during the tokenization process.
33
 
34
  <p align="center">
35
  <img src="https://github.com/eeee-sys/MODF-SIR/blob/main/assets/method.png" width="100%" height="100%">
36
  </p>
37
 
38
  #### 🌟 Contributions in MODF-SIR
39
+ 1. We propose MODF-SIR, a unified omni-modal reasoning framework that pioneers the application of multi-agent collaboration in the field of social intelligence reasoning.
40
 
41
+ 2. We introduce GRPO Grounder and TTA Reviser. This method enables our framework to have sample-level answering capabilities.
42
 
43
+ 3. MODF-SIR achieves state-of-the-art results across three Benchmarks: IntentBench, Daily-Omni, WorldSense.
44
 
45
  ## 💻 Code Repository
46
 
47
  The code for MAOmni, including training and evaluation scripts, can be found on GitHub: [https://github.com/eeee-sys/MODF-SIR](https://github.com/eeee-sys/MODF-SIR)
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ## 🚀 Quick Start
50
 
51
+ ### Installation
 
 
52
 
53
+ 1. Clone the repository from GitHub:
54
  ```shell
55
  git clone git@github.com:eeee-sys/MODF-SIR.git
56
  cd MODF-SIR
57
  ```
58
 
59
+ 2. Initialize conda environment:
 
 
 
 
 
 
 
60
  ```shell
61
  conda create -n modfsir_main python=3.10 -y
62
  conda activate modfsir_main
63
  pip install -r src/requirements_main.txt
64
  ```
65
 
66
+ ### Sample Usage
67
 
68
+ The snippet below showcases how to initialize the base model and load the planner LoRA using the `transformers` and `peft` libraries:
69
 
70
  ```python
71
  import torch
 
72
  from transformers import (
73
  Qwen2_5OmniForConditionalGeneration,
 
74
  Qwen2_5OmniProcessor,
75
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
+ # Initialize Models
78
+ model_id = "Harry-1234/MODF-SIR" # Replace with actual hub ID if different
79
+ device = "cuda" if torch.cuda.is_available() else "cpu"
80
 
81
+ base_model = Qwen2_5OmniForConditionalGeneration.from_pretrained(
82
+ model_id,
83
+ torch_dtype=torch.bfloat16,
84
+ attn_implementation="flash_attention_2"
85
+ ).to(device)
86
 
87
+ base_processor = Qwen2_5OmniProcessor.from_pretrained(model_id)
 
88
 
89
+ # Load Planner LoRA onto thinker submodule
90
+ base_model.thinker.load_adapter(model_id, adapter_name="planner")
91
+ base_model.eval()
92
+ ```
93
 
94
+ ## 📈 Experimental Results
95
 
96
+ #### 📍 Results
97
 
98
+ <p align="center">
99
+ <img src="https://raw.githubusercontent.com/eeee-sys/MODF-SIR/main/assets/dailyomni.png" width="100%" height="100%">
100
+ </p>
101
 
102
+ <p align="center">
103
+ <img src="https://raw.githubusercontent.com/eeee-sys/MODF-SIR/main/assets/worldsense.png" width="100%" height="100%">
104
+ </p>
105
 
106
+ <p align="center">
107
+ <img src="https://raw.githubusercontent.com/eeee-sys/MODF-SIR/main/assets/intentbench.png" width="100%" height="100%">
108
+ </p>