更改

跳到导航 跳到搜索
添加4,994字节 、 2026年6月26日 (星期五)
第950行: 第950行:     
此外,基于PID的分析还揭示了LVLMs的多模态融合能力仅在视觉指令微调阶段习得的特点。
 
此外,基于PID的分析还揭示了LVLMs的多模态融合能力仅在视觉指令微调阶段习得的特点。
 +
===附录:信息原子的数值计算程序===
 +
 +
部分信息分解示例和dit库
 +
当涉及到信息理论概念时,dit是这些实验的绝佳工具。这是一个在你创建的自定义概率分布上进行测量的库(Https://Github.com/Dit/Dit)。
 +
首先我们有两个源变量<math>X_1</math>和<math>X_2</math>(它们都是二进制的)和一个目标变量Y,Y是关于这些源变量的布尔运算。所有测量部分信息的形式都将由Williams和Beer提供,但其他作者提出的其他形式也可以在dit中进行。
 +
 +
1.独特信息
 +
 +
在这个例子中,假设目标变量Y由下表给出。请注意,输出总是等于<math>X_1</math>,因此<math>X_2</math>完全无关紧要。
 +
{| class="wikitable"
 +
|-
 +
|<math>X_1</math>||<math>X_2</math>||<math>Y</math>
 +
|-
 +
|0||0||0
 +
|-
 +
|0||1||0
 +
|-
 +
|1||0||1
 +
|-
 +
|1||1||1
 +
|}
 +
因此,<math>X_1</math>和<math>X_2</math>提供的关于Y的信息完全集中在<math>X_1</math>中,我们可以说关于Y的信息是X_1独有的。
 +
 +
在dit库中,我们可以创建这个:
 +
 +
import dit                    # importing dit library
 +
 +
from dit.pid import PID_WB    # importing the PID measure we want to use
 +
 +
 +
# creating a probability distribution of copy gate
 +
 +
dist_unique = dit.Distribution(["000", "010", "101", "111"], [1/4, 1/4, 1/4, 1/4])
 +
 +
print(PID_WB(dist_unique))
 +
 +
 +
"""
 +
 +
Out:
 +
 +
+--------+--------+--------+
 +
 +
| I_min  |  I_r  |  pi  |
 +
 +
+--------+--------+--------+
 +
 +
| {0:1}  | 1.0000 | 0.0000 |
 +
 +
|  {0}  | 1.0000 | 1.0000 |
 +
 +
|  {1}  | 0.0000 | 0.0000 |
 +
 +
| {0}{1} | 0.0000 | 0.0000 |
 +
 +
+--------+--------+--------+
 +
 +
"""
 +
 +
dit对信息类型进行编码如下:
 +
 +
{0:1}:<math>X_1</math>和<math>X_2</math>之间的协同信息
 +
 +
{0}:<math>X_1</math>提供的唯一信息
 +
 +
{1}:<math>X_2</math>提供的唯一信息
 +
 +
{0}{1}:<math>X_1</math>和<math>X_2</math>提供的冗余信息
 +
 +
我们可以通过输出看到,提供的唯一部分信息(“pi”列)来自X_1。
 +
 +
2.冗余信息
 +
 +
下一个示例用于显示冗余信息。在这里,<math>X_1</math>、<math>X_2</math>和Y都相等,如下表所示,因此<math>X_1</math>和<math>X_2</math>提供的关于Y的冗余信息是最大的。
 +
{| class="wikitable"
 +
|-
 +
|<math>X_1</math>||<math>X_2</math>||<math>Y</math>
 +
|-
 +
|0||0||0
 +
|-
 +
|1||1||1
 +
|}
 +
 +
使用dit,代码如下:
 +
 +
import dit                    # importing dit library
 +
 +
from dit.pid import PID_WB    # importing the PID measure we want to use
 +
 +
 +
# creating a redundant probability distribution
 +
 +
dist_redundant = dit.Distribution(["000", "111"], [1/2, 1/2])
 +
 +
print(PID_WB(dist_redundant))
 +
 +
 +
"""
 +
 +
Out:
 +
 +
+--------+--------+--------+
 +
 +
| I_min  |  I_r  |  pi  |
 +
 +
+--------+--------+--------+
 +
 +
| {0:1}  | 1.0000 | 0.0000 |
 +
 +
|  {0}  | 1.0000 | 0.0000 |
 +
 +
|  {1}  | 1.0000 | 0.0000 |
 +
 +
| {0}{1} | 1.0000 | 1.0000 |
 +
 +
+--------+--------+--------+
 +
 +
"""
 +
 +
正如我们所看到的,X_1和X_2提供的关于Y的信息是冗余的,换句话说,两者都提供。
 +
 +
3.协同信息
 +
 +
协同信息的一个经典例子是XOR门,如下表所示。
 +
{| class="wikitable"
 +
|-
 +
|<math>X_1</math>||<math>X_2</math>||<math>Y</math>
 +
|-
 +
|0||0||0
 +
|-
 +
|0||1||1
 +
|-
 +
|1||0||1
 +
|-
 +
|1||1||0
 +
|}
 +
通过这个分布注意到,只有当我们同时知道<math>X_1</math>和<math>X_2</math>时,我们才能知道目标变量Y。没有<math>X_1</math>和<math>X_2</math>,就不可能知道Y。因为对于<math>X_1</math>的每个值,我们都有Y的两个值;<math>X_2</math>也是如此。
 +
 +
代码是:
 +
 +
import dit                    # importing dit library
 +
 +
from dit.pid import PID_WB    # importing the PID measure we want to use
 +
 +
 +
# creating a probability distribution of XOR gate
 +
 +
dist_syn = dit.Distribution(["000", "011", "101", "110"], [1/4]*4)
 +
 +
print(PID_WB(dist_syn))
 +
 +
 +
"""
 +
 +
Out:
 +
 +
+--------+--------+--------+
 +
 +
| I_min  |  I_r  |  pi  |
 +
 +
+--------+--------+--------+
 +
 +
| {0:1}  | 1.0000 | 1.0000 |
 +
 +
|  {0}  | 0.0000 | 0.0000 |
 +
 +
|  {1}  | 0.0000 | 0.0000 |
 +
 +
| {0}{1} | 0.0000 | 0.0000 |
 +
 +
+--------+--------+--------+
 +
 +
"""
 +
 +
<math>X_1</math>和<math>X_2</math>传达的关于Y的唯一信息是{0:1},这是协同信息。
 +
 +
下面介绍如何用dit库进行一次完整的部分信息分解实验:(以Williams & Beer为例,只需要更改调用的函数名称即可使用其他PID分解方法,详见https://dit.readthedocs.io/en/latest/measures/pid.html)
 +
 +
首先在python里导入dit.pit:In [1]: from dit.pid import *
 +
 +
随后给出一个分布:In [2]: d = dit.Distribution(['000', '011', '102', '113'], [1/4]*4)
 +
 +
 +
用给出的分布进行PID分解(更改“PID_"后面角标即可使用其他PID分解方法):In [3]: PID_WB(d)
 +
 +
输出结果:Out[13]:
 +
 +
+--------+--------+--------+
 +
 +
| I_min  |  I_r  |  pi  |
 +
 +
+--------+--------+--------+
 +
 +
| {0:1}  | 2.0000 | 1.0000 |
 +
 +
|  {0}  | 1.0000 | 0.0000 |
 +
 +
|  {1}  | 1.0000 | 0.0000 |
 +
 +
| {0}{1} | 1.0000 | 1.0000 |
 +
 +
+--------+--------+--------+
 +
 +
另外还有专门实现PID计算的pietromarchesi库:https://github.com/pietromarchesi/pidpy
    
== 参考文献列表 ==
 
== 参考文献列表 ==
175

个编辑

导航菜单