Abstract
Motivation
- VLM에서 directly image 내에서의 reasoning task를 풀도록 하는 것은 잘 되지 않는다.
- LLM에서 reasoning 할 수 있도록 tool들을 활용하는 program을 만드는 경우도 있지만, generated program은 잘 동작하지 않아 여전히 expert model보다 잘 하지 못한다.
- VPD(Visual Program Distillation)에서는 cross modality reasoning capability를 VLM에 distill한다.
이는 다음 두 가지를 활용한다:- tool을 활용하는 visual program들의 advancement
- CoT reasoing을 통한 distillation 방법
Visual Program Distillation (VPD)
VPD는 다음 두 개의 step으로 구성된다:
- Program generation and verification
query $q$와 visual input $i$에 대해서 tool을 이용하여 query를 해결하는 program을 만든다. 그 후 이를 CoT $c$로 변환한다. - Distilling step-by-step
$i, q, c$가 VLM에 distillation된다.
Program Generation and Verification
- Program generation with LLM: $q$에 대해 $k$개의 candidate program list $π(q)={z_1,z_2,\dots,z_k}$를 만든다. 이때 $π$는 program generation function을 의미한다.
- Program execution with vision modules: 각 program $z_i$를 execution engine $φ$로 실행하여 result $φ(i,z_i)=\hat y_i$를 얻는다. 이때 execution trace $t_i$도 함께 저장한다. ${(z_1,\hat y_1, t_1), \dots, (z_k, \hat y_k, t_k)}$
-> execution trace는 program이 실행될 때 거치는 중간 operation들을 의미한다. 이때의 variable values, function call 등을 모두 포함하는 값이다.[2]
- Program filtering: $k$개의 candidate program 중에서 correct answer를 가진 하나의 tuple $(z,\hat y, t)$만 남긴다.
- Converting program execution traces into chain-of-thought rationales: LLM으로 $t$를 CoT $c$로 변환한다.
Program generation
PaLM-2로 candidate program을 generation했다. ViperGPT와 비슷하게 가능한 program 명세를 prompt로 제공하는 방식으로 generation하였다.
여기서 얻은 program 중 top-1 program을 뽑는 것보다 top-k program을 뽑는 것의 success rate가 더 좋았으므로, k개의 executable program을 LLM을 통해 얻는다. 이는 temperature T=0.5, k=5값으로 설정하여 수행되었다.
Program execution with vision modules
execution engine $φ$는 ViperGPT와 동일한 것을 사용하였다. 위에서 generate된 $z_i$는 Python program으로 $i$를 받아 $\hat y_i$를 return한다.
Program filtering
그러나 LLM에서 generation한 program은 일반적으로 잘 working하지 않는다. 그래서 filtering process를 거치는데, 여기서 k개의 program을 뽑고 실행되지 않는 것은 instantly discard된다. program output $\hat y_i$가 human label과 일치하는 경우의 program을 선택한다.
답이 ambiguous한 경우에는 LLM을 사용해서 확인했다.
정답이 없는 경우에는 점수가 가장 높은 것을 사용했고, rated sample은 fine-tuning stage에 사용되었다.
Converting program execution traces into chain-of-thought rationales
execution trace $t$는 VLM이 instruction tuning된 형태가 아니므로, LLM을 통해서 CoT $c$로 바꿨다.
실제로는 $(q,z,t)$가 CoT로 바뀌는 example을 20개 만들어 few-shot으로 사용했다.
Given an image and a question , I wrote the function execute_command using Python and the ImagePatch class (above), and the other functions above that could be executed to provide an answer to the query. As shown in the code, the code will print execution traces .
I need you to rewrite the execution trace into a natural language rationale that leads to the answer.
Consider the following guidelines :
− Use the bounding box information in the rationale .
− Referencing the execution trace , write a reasoning chain that leads to the most common human answer. Notice that the output should be the same as the human answer, not necessarily the program output .
Some examples:
Question: How many wheels does the plane have?
Program:
def execute_command(image):
image_patch = ImagePatch(image)
# Find the plane in the image
plane_patch = image_patch.find("plane")[0]
# Count the number of wheels on the plane num_wheels = 0
for wheel in plane_patch.find("wheel"):
num_wheels += 1
return formatting_answer( str (num_wheels))
Execution trace :
Calling find function . Detect plane
Detected plane at 153 25 647 972
Calling find function . Detect wheel
Detected wheel at 603 471 649 515
Detected wheel at 621 85 646 113
Detected wheel at 615 383 645 428
Program output : 3
Rationale : The plane at 153 25 647 972 has wheels at 603 471 649 515, 621 85 646 113, and 615 383 645 428.Thus, it has 3 wheels.
[Other demonstration examples]
Question: INSERT_QUESTION_HERE
INSERT_PROGRAM_HERE
Execution trace: INSERT_EXECUTION_TRACE_HERE
Rationale :
Distilling step-by-step
VLM을 위 data를 이용해서 fine-tune했다. 즉, VLM은 single end-to-end로 동작하고, VLM은 여러 task에 fine-tune된다.
즉, training dataset은 ${(i_j, q_j, \hat y_j, c_j, p_j)}^N_{j=1}$로 구성된다. 이는 각각 textual query, visual program ouput, gt label, CoT rationale, task-specific prompt를 의미한다.
optimization은 $\hat y_j$와 $c_j$에 대해서 수행했고 각각을 objective로 두었다. 즉,
$$\begin{align} \mathcal{L} &= \mathcal{L}{label} + \mathcal{L}{rationale} \ &= \sum^N_{j=1} \mathcal{l}(f(i_j,q_j,p_j)\hat_y_j)+\mathcal{l}(f(i_j,q_j,s_c),c_j)$$
이 되고, $\mathcal{l}$은 sequence length로 normalize된 cross entropy loss이다.
Experiments
PaLI-3(5B)와 PaLI-X(55B) 두 종류의 VLM을 이용해서 실험하였다.
PALI-3-Instruct와 PALI-X-Instruct는 CoT를 training에 포함하지 않고 instruction tuning한 경우이다.
Discussion
- 다른 filtering strategy를 통한 개선
- static program 대신 agent를 사용
- occlusion이나 many object scenario에서 성능 제한 → SAM등 dense labeling tool 도입
References
[1] Hu, Y., Stretcu, O., Lu, C. T., Viswanathan, K., Hata, K., Luo, E., ... & Fuxman, A. (2024). Visual program distillation: Distilling tools and programmatic reasoning into vision-language models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 9590-9601).
[2] https://www.ituonline.com/tech-definitions/what-is-an-execution-trace/
Footnotes
'DL·ML > Paper' 카테고리의 다른 글
PPO (Policy Proximal Optimization) (0) | 2024.08.20 |
---|---|
VoT (ICML oral, video understanding) (0) | 2024.08.06 |
InternVideo2 (VFM) (1) | 2024.07.25 |
ChatPose (CVPR 2024) (0) | 2024.07.17 |
OMG-LLaVA (1) | 2024.07.16 |