ZHANGYUXUAN-zR commited on
Commit
51ec0a0
·
verified ·
1 Parent(s): 2d5af48

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +200 -0
  2. md/dev/0c2SbGJ3Lt/0c2SbGJ3Lt.md +432 -0
  3. md/dev/1wVvweK3oIb/1wVvweK3oIb.md +474 -0
  4. md/dev/2EDqbSCnmF/2EDqbSCnmF.md +376 -0
  5. md/dev/5zwnqUwphT/5zwnqUwphT.md +387 -0
  6. md/dev/AyajSjTAzmg/AyajSjTAzmg.md +306 -0
  7. md/dev/B9LUI0pZFGc/B9LUI0pZFGc.md +405 -0
  8. md/dev/BYLysbfdJOd/BYLysbfdJOd.md +437 -0
  9. md/dev/ETKGuby0hcs/ETKGuby0hcs.md +557 -0
  10. md/dev/G5RwHpBUv0/G5RwHpBUv0.md +211 -0
  11. md/dev/GLA4ablO3M/GLA4ablO3M.md +0 -0
  12. md/dev/K10zWxlEGI/K10zWxlEGI.md +532 -0
  13. md/dev/K48UYo0glaJ/K48UYo0glaJ.md +406 -0
  14. md/dev/M2sNIiCC6C/M2sNIiCC6C.md +564 -0
  15. md/dev/MeeQkFYVbzW/MeeQkFYVbzW.md +0 -0
  16. md/dev/MtGmCCPJD-/MtGmCCPJD-.md +454 -0
  17. md/dev/PlKWVd2yBkY/PlKWVd2yBkY.md +586 -0
  18. md/dev/PzcvxEMzvQC/PzcvxEMzvQC.md +489 -0
  19. md/dev/SrC-nwieGJ/SrC-nwieGJ.md +466 -0
  20. md/dev/TJUNtiZiTKE/TJUNtiZiTKE.md +304 -0
  21. md/dev/UPnJuDKqOfX/UPnJuDKqOfX.md +289 -0
  22. md/dev/aKXBrj0DHm/aKXBrj0DHm.md +310 -0
  23. md/dev/bMYU8_qD8PW/bMYU8_qD8PW.md +287 -0
  24. md/dev/cpDhcsEDC2/cpDhcsEDC2.md +395 -0
  25. md/dev/pkh8bwJbUbL/pkh8bwJbUbL.md +698 -0
  26. md/dev/s1FjXzJ0jy/s1FjXzJ0jy.md +621 -0
  27. md/dev/uLYc4L3C81A/uLYc4L3C81A.md +418 -0
  28. md/dev/ucNDIDRNjjv/ucNDIDRNjjv.md +237 -0
  29. md/dev/znNmsN_O7Sh/znNmsN_O7Sh.md +327 -0
  30. parse/train/0oabwyZbOu/0oabwyZbOu_layout.pdf +3 -0
  31. parse/train/0oabwyZbOu/0oabwyZbOu_origin.pdf +3 -0
  32. parse/train/0oabwyZbOu/0oabwyZbOu_span.pdf +3 -0
  33. parse/train/4AWko4A35ss/4AWko4A35ss_layout.pdf +3 -0
  34. parse/train/4AWko4A35ss/4AWko4A35ss_origin.pdf +3 -0
  35. parse/train/4AWko4A35ss/4AWko4A35ss_span.pdf +3 -0
  36. parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_layout.pdf +3 -0
  37. parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_origin.pdf +3 -0
  38. parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_span.pdf +3 -0
  39. parse/train/B1gabhRcYX/B1gabhRcYX_layout.pdf +3 -0
  40. parse/train/B1gabhRcYX/B1gabhRcYX_origin.pdf +3 -0
  41. parse/train/B1gabhRcYX/B1gabhRcYX_span.pdf +3 -0
  42. parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_layout.pdf +3 -0
  43. parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_origin.pdf +3 -0
  44. parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_span.pdf +3 -0
  45. parse/train/BJ8vJebC-/BJ8vJebC-_layout.pdf +3 -0
  46. parse/train/BJ8vJebC-/BJ8vJebC-_origin.pdf +3 -0
  47. parse/train/BJ8vJebC-/BJ8vJebC-_span.pdf +3 -0
  48. parse/train/BJC_jUqxe/BJC_jUqxe_layout.pdf +3 -0
  49. parse/train/BJC_jUqxe/BJC_jUqxe_origin.pdf +3 -0
  50. parse/train/BJC_jUqxe/BJC_jUqxe_span.pdf +3 -0
.gitattributes CHANGED
@@ -6019,3 +6019,203 @@ parse/train/lH2ukHnGDdq/lH2ukHnGDdq_origin.pdf filter=lfs diff=lfs merge=lfs -te
6019
  parse/train/B1TTpYKgx/B1TTpYKgx_origin.pdf filter=lfs diff=lfs merge=lfs -text
6020
  parse/train/B1TTpYKgx/B1TTpYKgx_layout.pdf filter=lfs diff=lfs merge=lfs -text
6021
  parse/train/B1TTpYKgx/B1TTpYKgx_span.pdf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6019
  parse/train/B1TTpYKgx/B1TTpYKgx_origin.pdf filter=lfs diff=lfs merge=lfs -text
6020
  parse/train/B1TTpYKgx/B1TTpYKgx_layout.pdf filter=lfs diff=lfs merge=lfs -text
6021
  parse/train/B1TTpYKgx/B1TTpYKgx_span.pdf filter=lfs diff=lfs merge=lfs -text
6022
+ parse/train/HJgpugrKPS/HJgpugrKPS_layout.pdf filter=lfs diff=lfs merge=lfs -text
6023
+ parse/train/HJgpugrKPS/HJgpugrKPS_span.pdf filter=lfs diff=lfs merge=lfs -text
6024
+ parse/train/HJgpugrKPS/HJgpugrKPS_origin.pdf filter=lfs diff=lfs merge=lfs -text
6025
+ parse/train/r1l73iRqKm/r1l73iRqKm_layout.pdf filter=lfs diff=lfs merge=lfs -text
6026
+ parse/train/r1l73iRqKm/r1l73iRqKm_span.pdf filter=lfs diff=lfs merge=lfs -text
6027
+ parse/train/r1l73iRqKm/r1l73iRqKm_origin.pdf filter=lfs diff=lfs merge=lfs -text
6028
+ parse/train/WEHSlH5mOk/WEHSlH5mOk_origin.pdf filter=lfs diff=lfs merge=lfs -text
6029
+ parse/train/WEHSlH5mOk/WEHSlH5mOk_layout.pdf filter=lfs diff=lfs merge=lfs -text
6030
+ parse/train/WEHSlH5mOk/WEHSlH5mOk_span.pdf filter=lfs diff=lfs merge=lfs -text
6031
+ parse/train/Hygxb2CqKm/Hygxb2CqKm_layout.pdf filter=lfs diff=lfs merge=lfs -text
6032
+ parse/train/Hygxb2CqKm/Hygxb2CqKm_span.pdf filter=lfs diff=lfs merge=lfs -text
6033
+ parse/train/Hygxb2CqKm/Hygxb2CqKm_origin.pdf filter=lfs diff=lfs merge=lfs -text
6034
+ parse/train/S1xiOjC9F7/S1xiOjC9F7_origin.pdf filter=lfs diff=lfs merge=lfs -text
6035
+ parse/train/S1xiOjC9F7/S1xiOjC9F7_span.pdf filter=lfs diff=lfs merge=lfs -text
6036
+ parse/train/S1xiOjC9F7/S1xiOjC9F7_layout.pdf filter=lfs diff=lfs merge=lfs -text
6037
+ parse/train/JzdYX8uzT4W/JzdYX8uzT4W_layout.pdf filter=lfs diff=lfs merge=lfs -text
6038
+ parse/train/JzdYX8uzT4W/JzdYX8uzT4W_span.pdf filter=lfs diff=lfs merge=lfs -text
6039
+ parse/train/JzdYX8uzT4W/JzdYX8uzT4W_origin.pdf filter=lfs diff=lfs merge=lfs -text
6040
+ parse/train/SyQq185lg/SyQq185lg_span.pdf filter=lfs diff=lfs merge=lfs -text
6041
+ parse/train/SyQq185lg/SyQq185lg_origin.pdf filter=lfs diff=lfs merge=lfs -text
6042
+ parse/train/SyQq185lg/SyQq185lg_layout.pdf filter=lfs diff=lfs merge=lfs -text
6043
+ parse/train/HkxlcnVFwB/HkxlcnVFwB_span.pdf filter=lfs diff=lfs merge=lfs -text
6044
+ parse/train/HkxlcnVFwB/HkxlcnVFwB_layout.pdf filter=lfs diff=lfs merge=lfs -text
6045
+ parse/train/HkxlcnVFwB/HkxlcnVFwB_origin.pdf filter=lfs diff=lfs merge=lfs -text
6046
+ parse/train/Syx7WyBtwB/Syx7WyBtwB_origin.pdf filter=lfs diff=lfs merge=lfs -text
6047
+ parse/train/Syx7WyBtwB/Syx7WyBtwB_span.pdf filter=lfs diff=lfs merge=lfs -text
6048
+ parse/train/Syx7WyBtwB/Syx7WyBtwB_layout.pdf filter=lfs diff=lfs merge=lfs -text
6049
+ parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_layout.pdf filter=lfs diff=lfs merge=lfs -text
6050
+ parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_origin.pdf filter=lfs diff=lfs merge=lfs -text
6051
+ parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_span.pdf filter=lfs diff=lfs merge=lfs -text
6052
+ parse/train/Hygm8jC9FQ/Hygm8jC9FQ_span.pdf filter=lfs diff=lfs merge=lfs -text
6053
+ parse/train/Hygm8jC9FQ/Hygm8jC9FQ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6054
+ parse/train/Hygm8jC9FQ/Hygm8jC9FQ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6055
+ parse/train/SJzvDjAcK7/SJzvDjAcK7_layout.pdf filter=lfs diff=lfs merge=lfs -text
6056
+ parse/train/SJzvDjAcK7/SJzvDjAcK7_origin.pdf filter=lfs diff=lfs merge=lfs -text
6057
+ parse/train/SJzvDjAcK7/SJzvDjAcK7_span.pdf filter=lfs diff=lfs merge=lfs -text
6058
+ parse/train/S19dR9x0b/S19dR9x0b_span.pdf filter=lfs diff=lfs merge=lfs -text
6059
+ parse/train/S19dR9x0b/S19dR9x0b_layout.pdf filter=lfs diff=lfs merge=lfs -text
6060
+ parse/train/S19dR9x0b/S19dR9x0b_origin.pdf filter=lfs diff=lfs merge=lfs -text
6061
+ parse/train/B1gabhRcYX/B1gabhRcYX_layout.pdf filter=lfs diff=lfs merge=lfs -text
6062
+ parse/train/B1gabhRcYX/B1gabhRcYX_origin.pdf filter=lfs diff=lfs merge=lfs -text
6063
+ parse/train/B1gabhRcYX/B1gabhRcYX_span.pdf filter=lfs diff=lfs merge=lfs -text
6064
+ parse/train/HyPpD0g0Z/HyPpD0g0Z_layout.pdf filter=lfs diff=lfs merge=lfs -text
6065
+ parse/train/HyPpD0g0Z/HyPpD0g0Z_span.pdf filter=lfs diff=lfs merge=lfs -text
6066
+ parse/train/HyPpD0g0Z/HyPpD0g0Z_origin.pdf filter=lfs diff=lfs merge=lfs -text
6067
+ parse/train/rJBiunlAW/rJBiunlAW_span.pdf filter=lfs diff=lfs merge=lfs -text
6068
+ parse/train/rJBiunlAW/rJBiunlAW_origin.pdf filter=lfs diff=lfs merge=lfs -text
6069
+ parse/train/rJBiunlAW/rJBiunlAW_layout.pdf filter=lfs diff=lfs merge=lfs -text
6070
+ parse/train/uY-XMIbyXec/uY-XMIbyXec_span.pdf filter=lfs diff=lfs merge=lfs -text
6071
+ parse/train/uY-XMIbyXec/uY-XMIbyXec_origin.pdf filter=lfs diff=lfs merge=lfs -text
6072
+ parse/train/uY-XMIbyXec/uY-XMIbyXec_layout.pdf filter=lfs diff=lfs merge=lfs -text
6073
+ parse/train/S1EwLkW0W/S1EwLkW0W_span.pdf filter=lfs diff=lfs merge=lfs -text
6074
+ parse/train/S1EwLkW0W/S1EwLkW0W_origin.pdf filter=lfs diff=lfs merge=lfs -text
6075
+ parse/train/S1EwLkW0W/S1EwLkW0W_layout.pdf filter=lfs diff=lfs merge=lfs -text
6076
+ parse/train/Bkeeca4Kvr/Bkeeca4Kvr_layout.pdf filter=lfs diff=lfs merge=lfs -text
6077
+ parse/train/Bkeeca4Kvr/Bkeeca4Kvr_origin.pdf filter=lfs diff=lfs merge=lfs -text
6078
+ parse/train/Bkeeca4Kvr/Bkeeca4Kvr_span.pdf filter=lfs diff=lfs merge=lfs -text
6079
+ parse/train/4AWko4A35ss/4AWko4A35ss_origin.pdf filter=lfs diff=lfs merge=lfs -text
6080
+ parse/train/4AWko4A35ss/4AWko4A35ss_span.pdf filter=lfs diff=lfs merge=lfs -text
6081
+ parse/train/4AWko4A35ss/4AWko4A35ss_layout.pdf filter=lfs diff=lfs merge=lfs -text
6082
+ parse/train/HJr4QJ26W/HJr4QJ26W_layout.pdf filter=lfs diff=lfs merge=lfs -text
6083
+ parse/train/HJr4QJ26W/HJr4QJ26W_span.pdf filter=lfs diff=lfs merge=lfs -text
6084
+ parse/train/HJr4QJ26W/HJr4QJ26W_origin.pdf filter=lfs diff=lfs merge=lfs -text
6085
+ parse/train/HkG3e205K7/HkG3e205K7_origin.pdf filter=lfs diff=lfs merge=lfs -text
6086
+ parse/train/HkG3e205K7/HkG3e205K7_layout.pdf filter=lfs diff=lfs merge=lfs -text
6087
+ parse/train/HkG3e205K7/HkG3e205K7_span.pdf filter=lfs diff=lfs merge=lfs -text
6088
+ parse/train/rkezdaEtvH/rkezdaEtvH_origin.pdf filter=lfs diff=lfs merge=lfs -text
6089
+ parse/train/rkezdaEtvH/rkezdaEtvH_layout.pdf filter=lfs diff=lfs merge=lfs -text
6090
+ parse/train/rkezdaEtvH/rkezdaEtvH_span.pdf filter=lfs diff=lfs merge=lfs -text
6091
+ parse/train/SkeK3s0qKQ/SkeK3s0qKQ_span.pdf filter=lfs diff=lfs merge=lfs -text
6092
+ parse/train/SkeK3s0qKQ/SkeK3s0qKQ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6093
+ parse/train/SkeK3s0qKQ/SkeK3s0qKQ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6094
+ parse/train/SnONpXZ_uQ_/SnONpXZ_uQ__span.pdf filter=lfs diff=lfs merge=lfs -text
6095
+ parse/train/SnONpXZ_uQ_/SnONpXZ_uQ__origin.pdf filter=lfs diff=lfs merge=lfs -text
6096
+ parse/train/SnONpXZ_uQ_/SnONpXZ_uQ__layout.pdf filter=lfs diff=lfs merge=lfs -text
6097
+ parse/train/FPpZrRfz6Ss/FPpZrRfz6Ss_layout.pdf filter=lfs diff=lfs merge=lfs -text
6098
+ parse/train/FPpZrRfz6Ss/FPpZrRfz6Ss_origin.pdf filter=lfs diff=lfs merge=lfs -text
6099
+ parse/train/FPpZrRfz6Ss/FPpZrRfz6Ss_span.pdf filter=lfs diff=lfs merge=lfs -text
6100
+ parse/train/sMEpviTLi1h/sMEpviTLi1h_layout.pdf filter=lfs diff=lfs merge=lfs -text
6101
+ parse/train/sMEpviTLi1h/sMEpviTLi1h_span.pdf filter=lfs diff=lfs merge=lfs -text
6102
+ parse/train/sMEpviTLi1h/sMEpviTLi1h_origin.pdf filter=lfs diff=lfs merge=lfs -text
6103
+ parse/train/ryHlUtqge/ryHlUtqge_layout.pdf filter=lfs diff=lfs merge=lfs -text
6104
+ parse/train/ryHlUtqge/ryHlUtqge_origin.pdf filter=lfs diff=lfs merge=lfs -text
6105
+ parse/train/ryHlUtqge/ryHlUtqge_span.pdf filter=lfs diff=lfs merge=lfs -text
6106
+ parse/train/MbM_gvIB3Y4/MbM_gvIB3Y4_layout.pdf filter=lfs diff=lfs merge=lfs -text
6107
+ parse/train/MbM_gvIB3Y4/MbM_gvIB3Y4_span.pdf filter=lfs diff=lfs merge=lfs -text
6108
+ parse/train/MbM_gvIB3Y4/MbM_gvIB3Y4_origin.pdf filter=lfs diff=lfs merge=lfs -text
6109
+ parse/train/rygunsAqYQ/rygunsAqYQ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6110
+ parse/train/rygunsAqYQ/rygunsAqYQ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6111
+ parse/train/rygunsAqYQ/rygunsAqYQ_span.pdf filter=lfs diff=lfs merge=lfs -text
6112
+ parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_origin.pdf filter=lfs diff=lfs merge=lfs -text
6113
+ parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_span.pdf filter=lfs diff=lfs merge=lfs -text
6114
+ parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_layout.pdf filter=lfs diff=lfs merge=lfs -text
6115
+ parse/train/np96ge7gz0j/np96ge7gz0j_span.pdf filter=lfs diff=lfs merge=lfs -text
6116
+ parse/train/np96ge7gz0j/np96ge7gz0j_layout.pdf filter=lfs diff=lfs merge=lfs -text
6117
+ parse/train/np96ge7gz0j/np96ge7gz0j_origin.pdf filter=lfs diff=lfs merge=lfs -text
6118
+ parse/train/HJy_5Mcll/HJy_5Mcll_origin.pdf filter=lfs diff=lfs merge=lfs -text
6119
+ parse/train/HJy_5Mcll/HJy_5Mcll_layout.pdf filter=lfs diff=lfs merge=lfs -text
6120
+ parse/train/HJy_5Mcll/HJy_5Mcll_span.pdf filter=lfs diff=lfs merge=lfs -text
6121
+ parse/train/BkwHObbRZ/BkwHObbRZ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6122
+ parse/train/BkwHObbRZ/BkwHObbRZ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6123
+ parse/train/BkwHObbRZ/BkwHObbRZ_span.pdf filter=lfs diff=lfs merge=lfs -text
6124
+ parse/train/BJC_jUqxe/BJC_jUqxe_span.pdf filter=lfs diff=lfs merge=lfs -text
6125
+ parse/train/BJC_jUqxe/BJC_jUqxe_layout.pdf filter=lfs diff=lfs merge=lfs -text
6126
+ parse/train/BJC_jUqxe/BJC_jUqxe_origin.pdf filter=lfs diff=lfs merge=lfs -text
6127
+ parse/train/Syee1pVtDS/Syee1pVtDS_layout.pdf filter=lfs diff=lfs merge=lfs -text
6128
+ parse/train/Syee1pVtDS/Syee1pVtDS_origin.pdf filter=lfs diff=lfs merge=lfs -text
6129
+ parse/train/Syee1pVtDS/Syee1pVtDS_span.pdf filter=lfs diff=lfs merge=lfs -text
6130
+ parse/train/r1ledo0ctX/r1ledo0ctX_layout.pdf filter=lfs diff=lfs merge=lfs -text
6131
+ parse/train/r1ledo0ctX/r1ledo0ctX_origin.pdf filter=lfs diff=lfs merge=lfs -text
6132
+ parse/train/r1ledo0ctX/r1ledo0ctX_span.pdf filter=lfs diff=lfs merge=lfs -text
6133
+ parse/train/_0kaDkv3dVf/_0kaDkv3dVf_layout.pdf filter=lfs diff=lfs merge=lfs -text
6134
+ parse/train/_0kaDkv3dVf/_0kaDkv3dVf_span.pdf filter=lfs diff=lfs merge=lfs -text
6135
+ parse/train/_0kaDkv3dVf/_0kaDkv3dVf_origin.pdf filter=lfs diff=lfs merge=lfs -text
6136
+ parse/train/0oabwyZbOu/0oabwyZbOu_layout.pdf filter=lfs diff=lfs merge=lfs -text
6137
+ parse/train/0oabwyZbOu/0oabwyZbOu_origin.pdf filter=lfs diff=lfs merge=lfs -text
6138
+ parse/train/0oabwyZbOu/0oabwyZbOu_span.pdf filter=lfs diff=lfs merge=lfs -text
6139
+ parse/train/MJIve1zgR_/MJIve1zgR__origin.pdf filter=lfs diff=lfs merge=lfs -text
6140
+ parse/train/MJIve1zgR_/MJIve1zgR__layout.pdf filter=lfs diff=lfs merge=lfs -text
6141
+ parse/train/MJIve1zgR_/MJIve1zgR__span.pdf filter=lfs diff=lfs merge=lfs -text
6142
+ parse/train/r1TA9ZbA-/r1TA9ZbA-_span.pdf filter=lfs diff=lfs merge=lfs -text
6143
+ parse/train/r1TA9ZbA-/r1TA9ZbA-_origin.pdf filter=lfs diff=lfs merge=lfs -text
6144
+ parse/train/r1TA9ZbA-/r1TA9ZbA-_layout.pdf filter=lfs diff=lfs merge=lfs -text
6145
+ parse/train/ZD7Ll4pAw7C/ZD7Ll4pAw7C_layout.pdf filter=lfs diff=lfs merge=lfs -text
6146
+ parse/train/ZD7Ll4pAw7C/ZD7Ll4pAw7C_origin.pdf filter=lfs diff=lfs merge=lfs -text
6147
+ parse/train/ZD7Ll4pAw7C/ZD7Ll4pAw7C_span.pdf filter=lfs diff=lfs merge=lfs -text
6148
+ parse/train/zQvxc8ul2rR/zQvxc8ul2rR_layout.pdf filter=lfs diff=lfs merge=lfs -text
6149
+ parse/train/zQvxc8ul2rR/zQvxc8ul2rR_span.pdf filter=lfs diff=lfs merge=lfs -text
6150
+ parse/train/zQvxc8ul2rR/zQvxc8ul2rR_origin.pdf filter=lfs diff=lfs merge=lfs -text
6151
+ parse/train/SyZipzbCb/SyZipzbCb_origin.pdf filter=lfs diff=lfs merge=lfs -text
6152
+ parse/train/SyZipzbCb/SyZipzbCb_span.pdf filter=lfs diff=lfs merge=lfs -text
6153
+ parse/train/SyZipzbCb/SyZipzbCb_layout.pdf filter=lfs diff=lfs merge=lfs -text
6154
+ parse/train/NzTU59SYbNq/NzTU59SYbNq_span.pdf filter=lfs diff=lfs merge=lfs -text
6155
+ parse/train/NzTU59SYbNq/NzTU59SYbNq_origin.pdf filter=lfs diff=lfs merge=lfs -text
6156
+ parse/train/NzTU59SYbNq/NzTU59SYbNq_layout.pdf filter=lfs diff=lfs merge=lfs -text
6157
+ parse/train/HJfwJ2A5KX/HJfwJ2A5KX_layout.pdf filter=lfs diff=lfs merge=lfs -text
6158
+ parse/train/HJfwJ2A5KX/HJfwJ2A5KX_span.pdf filter=lfs diff=lfs merge=lfs -text
6159
+ parse/train/HJfwJ2A5KX/HJfwJ2A5KX_origin.pdf filter=lfs diff=lfs merge=lfs -text
6160
+ parse/train/HJPmdP9le/HJPmdP9le_span.pdf filter=lfs diff=lfs merge=lfs -text
6161
+ parse/train/HJPmdP9le/HJPmdP9le_origin.pdf filter=lfs diff=lfs merge=lfs -text
6162
+ parse/train/HJPmdP9le/HJPmdP9le_layout.pdf filter=lfs diff=lfs merge=lfs -text
6163
+ parse/train/rkTBjG-AZ/rkTBjG-AZ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6164
+ parse/train/rkTBjG-AZ/rkTBjG-AZ_span.pdf filter=lfs diff=lfs merge=lfs -text
6165
+ parse/train/rkTBjG-AZ/rkTBjG-AZ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6166
+ parse/train/H1g8p1BYvS/H1g8p1BYvS_origin.pdf filter=lfs diff=lfs merge=lfs -text
6167
+ parse/train/H1g8p1BYvS/H1g8p1BYvS_span.pdf filter=lfs diff=lfs merge=lfs -text
6168
+ parse/train/H1g8p1BYvS/H1g8p1BYvS_layout.pdf filter=lfs diff=lfs merge=lfs -text
6169
+ parse/train/vllRjSTWcLs/vllRjSTWcLs_span.pdf filter=lfs diff=lfs merge=lfs -text
6170
+ parse/train/vllRjSTWcLs/vllRjSTWcLs_layout.pdf filter=lfs diff=lfs merge=lfs -text
6171
+ parse/train/vllRjSTWcLs/vllRjSTWcLs_origin.pdf filter=lfs diff=lfs merge=lfs -text
6172
+ parse/train/yT7-k6Q6gda/yT7-k6Q6gda_layout.pdf filter=lfs diff=lfs merge=lfs -text
6173
+ parse/train/yT7-k6Q6gda/yT7-k6Q6gda_origin.pdf filter=lfs diff=lfs merge=lfs -text
6174
+ parse/train/yT7-k6Q6gda/yT7-k6Q6gda_span.pdf filter=lfs diff=lfs merge=lfs -text
6175
+ parse/train/rk5UYassf/rk5UYassf_layout.pdf filter=lfs diff=lfs merge=lfs -text
6176
+ parse/train/rk5UYassf/rk5UYassf_origin.pdf filter=lfs diff=lfs merge=lfs -text
6177
+ parse/train/rk5UYassf/rk5UYassf_span.pdf filter=lfs diff=lfs merge=lfs -text
6178
+ parse/train/BJ8vJebC-/BJ8vJebC-_span.pdf filter=lfs diff=lfs merge=lfs -text
6179
+ parse/train/BJ8vJebC-/BJ8vJebC-_layout.pdf filter=lfs diff=lfs merge=lfs -text
6180
+ parse/train/BJ8vJebC-/BJ8vJebC-_origin.pdf filter=lfs diff=lfs merge=lfs -text
6181
+ parse/train/rk5upnsxe/rk5upnsxe_span.pdf filter=lfs diff=lfs merge=lfs -text
6182
+ parse/train/rk5upnsxe/rk5upnsxe_origin.pdf filter=lfs diff=lfs merge=lfs -text
6183
+ parse/train/rk5upnsxe/rk5upnsxe_layout.pdf filter=lfs diff=lfs merge=lfs -text
6184
+ parse/train/HkYhZDqxg/HkYhZDqxg_span.pdf filter=lfs diff=lfs merge=lfs -text
6185
+ parse/train/HkYhZDqxg/HkYhZDqxg_layout.pdf filter=lfs diff=lfs merge=lfs -text
6186
+ parse/train/HkYhZDqxg/HkYhZDqxg_origin.pdf filter=lfs diff=lfs merge=lfs -text
6187
+ parse/train/SyfIfnC5Ym/SyfIfnC5Ym_span.pdf filter=lfs diff=lfs merge=lfs -text
6188
+ parse/train/SyfIfnC5Ym/SyfIfnC5Ym_layout.pdf filter=lfs diff=lfs merge=lfs -text
6189
+ parse/train/SyfIfnC5Ym/SyfIfnC5Ym_origin.pdf filter=lfs diff=lfs merge=lfs -text
6190
+ parse/train/VzuIzbRDrum/VzuIzbRDrum_layout.pdf filter=lfs diff=lfs merge=lfs -text
6191
+ parse/train/VzuIzbRDrum/VzuIzbRDrum_origin.pdf filter=lfs diff=lfs merge=lfs -text
6192
+ parse/train/VzuIzbRDrum/VzuIzbRDrum_span.pdf filter=lfs diff=lfs merge=lfs -text
6193
+ parse/train/kgVJBBThdSZ/kgVJBBThdSZ_span.pdf filter=lfs diff=lfs merge=lfs -text
6194
+ parse/train/kgVJBBThdSZ/kgVJBBThdSZ_layout.pdf filter=lfs diff=lfs merge=lfs -text
6195
+ parse/train/kgVJBBThdSZ/kgVJBBThdSZ_origin.pdf filter=lfs diff=lfs merge=lfs -text
6196
+ parse/train/HyEl3o05Fm/HyEl3o05Fm_span.pdf filter=lfs diff=lfs merge=lfs -text
6197
+ parse/train/HyEl3o05Fm/HyEl3o05Fm_origin.pdf filter=lfs diff=lfs merge=lfs -text
6198
+ parse/train/HyEl3o05Fm/HyEl3o05Fm_layout.pdf filter=lfs diff=lfs merge=lfs -text
6199
+ parse/train/rkesVkHtDr/rkesVkHtDr_origin.pdf filter=lfs diff=lfs merge=lfs -text
6200
+ parse/train/rkesVkHtDr/rkesVkHtDr_span.pdf filter=lfs diff=lfs merge=lfs -text
6201
+ parse/train/rkesVkHtDr/rkesVkHtDr_layout.pdf filter=lfs diff=lfs merge=lfs -text
6202
+ parse/train/KYPz4YsCPj/KYPz4YsCPj_origin.pdf filter=lfs diff=lfs merge=lfs -text
6203
+ parse/train/KYPz4YsCPj/KYPz4YsCPj_span.pdf filter=lfs diff=lfs merge=lfs -text
6204
+ parse/train/KYPz4YsCPj/KYPz4YsCPj_layout.pdf filter=lfs diff=lfs merge=lfs -text
6205
+ parse/train/HklUCCVKDB/HklUCCVKDB_span.pdf filter=lfs diff=lfs merge=lfs -text
6206
+ parse/train/HklUCCVKDB/HklUCCVKDB_origin.pdf filter=lfs diff=lfs merge=lfs -text
6207
+ parse/train/HklUCCVKDB/HklUCCVKDB_layout.pdf filter=lfs diff=lfs merge=lfs -text
6208
+ parse/train/Db4yerZTYkz/Db4yerZTYkz_origin.pdf filter=lfs diff=lfs merge=lfs -text
6209
+ parse/train/Db4yerZTYkz/Db4yerZTYkz_layout.pdf filter=lfs diff=lfs merge=lfs -text
6210
+ parse/train/Db4yerZTYkz/Db4yerZTYkz_span.pdf filter=lfs diff=lfs merge=lfs -text
6211
+ parse/train/P5MtdcVdFZ4/P5MtdcVdFZ4_layout.pdf filter=lfs diff=lfs merge=lfs -text
6212
+ parse/train/P5MtdcVdFZ4/P5MtdcVdFZ4_span.pdf filter=lfs diff=lfs merge=lfs -text
6213
+ parse/train/P5MtdcVdFZ4/P5MtdcVdFZ4_origin.pdf filter=lfs diff=lfs merge=lfs -text
6214
+ parse/train/_mQp5cr_iNy/_mQp5cr_iNy_span.pdf filter=lfs diff=lfs merge=lfs -text
6215
+ parse/train/_mQp5cr_iNy/_mQp5cr_iNy_layout.pdf filter=lfs diff=lfs merge=lfs -text
6216
+ parse/train/_mQp5cr_iNy/_mQp5cr_iNy_origin.pdf filter=lfs diff=lfs merge=lfs -text
6217
+ parse/train/r1f78iAcFm/r1f78iAcFm_origin.pdf filter=lfs diff=lfs merge=lfs -text
6218
+ parse/train/r1f78iAcFm/r1f78iAcFm_span.pdf filter=lfs diff=lfs merge=lfs -text
6219
+ parse/train/r1f78iAcFm/r1f78iAcFm_layout.pdf filter=lfs diff=lfs merge=lfs -text
6220
+ parse/train/HJMHpjC9Ym/HJMHpjC9Ym_span.pdf filter=lfs diff=lfs merge=lfs -text
6221
+ parse/train/HJMHpjC9Ym/HJMHpjC9Ym_layout.pdf filter=lfs diff=lfs merge=lfs -text
md/dev/0c2SbGJ3Lt/0c2SbGJ3Lt.md ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TEXTLESS PHRASE STRUCTURE INDUCTION FROM VISUALLY-GROUNDED SPEECH
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We study phrase structure induction from visually-grounded speech without intermediate text or text pre-trained models. The core idea is to first segment the speech waveform into sequences of word segments, then induce phrase structure based on the inferred segment-level continuous representations. To this end, we present the Audio-Visual Neural Syntax Learner (AV-NSL) that learns non-trivial phrase structure by listening to audio and looking at images, without ever reading text. Experiments on SpokenCOCO, the spoken version of MSCOCO with paired images and spoken captions, show that AV-NSL infers meaningful phrase structures similar to those learned from naturally-supervised text parsing, quantitatively and qualitatively. The findings in this paper extend prior work in unsupervised language acquisition from speech and grounded grammar induction, and manifest one possibility of bridging the gap between the two fields.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Toddlers learn their first language through listening, talking, and interacting with the world through multi-sensory inputs. Different levels of early language acquisition happen without supervisory feedback (Dupoux, 2018): phonetics, phonology, morphology, syntax, semantics, pragmatics. It is therefore crucial to think about learning language, from identifying lower-level phones or words to inducing high-level linguistic structure like grammar, in natural settings.1 To this end, there have been two ongoing efforts in parallel:
12
+
13
+ • Zero-resource speech processing, where speech models are constructed without any textual intermediates, with the goal of mimicking how children learn to speak before learning to read or write. The modeling tasks are constrained to unsupervised learning of subphones, phones, and words (Jansen et al., 2013). • Grammar induction, which aims to learn latent syntactic structures, including constituency trees and dependency trees, with no annotation of syntactic structures as supervision.
14
+
15
+ Notably in recent years, multi-modal induction has emerged as a promising and effective objective for both efforts. In speech, Harwath (2018) proposed to leverage parallel image-speech data to acquire associated words (Harwath & Glass, 2017) and phones (Harwath et al., 2020) from raw waveforms. In syntax induction, Shi et al. (2019) proposed to induce phrase-structure grammar from parallel image-text data. The above observations motivated us to build a computational model that leverages the visual modality to acquire low-level words up to high-level phrase-structure from raw speech waveforms, without any intermediate textual forms or any direct supervision.2
16
+
17
+ In this paper, we present the Audio-Visual Neural Syntax Learner (AV-NSL), an approach toward learning phrase structure from raw speech waveforms without relying on any kind of intermediate textual form or text pre-trained models (Figure 1). In a nutshell, AV-NSL trains a visually-grounded syntax learner directly on a sequence of continuous speech representations given by an audio-visual word segmentation model. We also introduce a self-training process and an unsupervised decoding method to improve the final output of in AV-NSL. To measure the effectiveness of AV-NSL, we compare it to text-based syntax learner VG-NSL (Shi et al., 2019) and further introduce a novel evaluation metric, SAIOU, that accounts for structure differences when the number of tree nodes are mismatched. To validate our design choice of AV-NSL, we construct several baselines and introduce alternative modeling choices, including acoustic compound-PCFG (Kim et al., 2019a). Qualitatively, we provide constituency recall analyses and the visualizations of the inferred word segmentation and tree structures.
18
+
19
+ ![](images/f0d70eacb042ff33533595a02ebee55672bac6319f24de2f807d7ec9aa263d95.jpg)
20
+ Figure 1: We study the process of inducing phrase structure, in the form of constituency parse tree, on unsupervised inferred word segments from raw speech waveform. No intermediate text tokens or ASR is needed. For illustration purpose, here we show the gold parse tree from the given text caption.
21
+
22
+ In summary, we present the first study on inducing phrase structure from visually-grounded speech without relying on text, introducing the AV-NSL model (§3) with comprehensive experiments (§4) and analysis (§5). As a by product, we improve over the previous state of the art in unsupervised word segmentation (§4.4).
23
+
24
+ # 2 RELATED WORK
25
+
26
+ # 2.1 UNSUPERVISED AND DISTANTLY SUPERVISED GRAMMAR INDUCTION
27
+
28
+ Much work has been proposed to induce grammar from different sources of distant supervision, including language modeling (Shen et al., 2018; 2019; Kim et al., 2019a;b), masked language modeling (Drozdov et al., 2019), natural language inference (Li et al., 2019), and, more recently, visual grounding via image-caption matching (Shi et al., 2019; Zhao & Titov, 2020; Hong et al., 2021; Wan et al., 2022, inter alia). There has also been extensive study directly targeting unsupervised constituency parsing (Klein & Manning, 2002; 2004; Bod, 2006; Spitkovsky et al., 2013, inter alia). To the best of our knowledge, existing work on grammar induction from distant supervision has been based almost exclusively on text input. The most relevant work to ours is MMC-PCFG (Zhang et al., 2021), where speech features are treated as an auxiliary input for video-text grammar induction. However, text data and an off-the-shelf automatic speech recognition (ASR) model are required. In contrast to them, AV-NSL induces constituency parse trees from raw speech bypassing text, with distant supervision from parallel audio-visual data.
29
+
30
+ # 2.2 UNSUPERVISED LANGUAGE ACQUISITION FROM SPEECH
31
+
32
+ The earliest work (de Sa, 1994; De Marcken, 1996; Roy & Pentland, 2002) on language acquisition from speech required phonetic lexicon/labels in the process. The idea of spoken term discovery, i.e., discovering repetitive patterns or keywords from unannotated speech, was first addressed by Park & Glass (2007). Thereafter, subsequent work improved upon the original (Zhang & Glass, 2009; Jansen & Van Durme, 2011; McInnes & Goldwater, 2011; Zhang, 2013, inter alia). Other related work has considered tasks like unsupervised word segmentation and unsupervised ASR, sometimes jointly with spoken term discovery (Lee & Glass, 2012; Lee et al., 2015; Kamper et al., 2015; 2017; Kamper & van Niekerk, 2021; Chorowski et al., 2021; Bhati et al., 2021; Kamper, 2022; Algayres et al., 2022) The discovery of lexical units was applied to text-free language modeling (Nguyen et al., 2020; Peng & Harwath, 2022a) and speech generation (Lakhotia et al., 2021; Polyak et al., 2021; Kharitonov et al., 2022). The ZeroSpeech challenges (Versteegh et al., 2015; Dunbar et al., 2017; 2019; 2020; Nguyen et al., 2020) have been a major driving force in the field.
33
+
34
+ Harwath (2018) opened up a new direction in visually grounded language acquisition, showing word-like (Harwath & Glass, 2017) and phone-like (Harwath et al., 2020) units are acquired from speech by analyzing audio-visual retrieval models. Numerous works have studied the characteristics of the linguistic information acquired in visually grounded speech models (Havard et al., 2019; Khorrami & Ras¨ anen, 2021; Olaleye & Kamper, 2021; Wang & Hasegawa-Johnson, 2021; ¨ Mitja Nikolaus, 2022). Peng & Harwath (2022b) shows that clear word segmentation and identification naturally emerge from a visually grounded, self-supervised speech model named VG-HuBERT, by analyzing the model’s self-attention heads. Unlike the above, AV-NSL acquires phrase structure, in the form of constituency parsing on top of unsupervised word segments.
35
+
36
+ # 2.3 SPEECH PARSING AND ITS APPLICATIONS
37
+
38
+ Early work on speech parsing can be traced back to the SParseval toolkit (Roark et al., 2006), for evaluating text parsers given (errorful) ASR output. Tran et al. (2018; 2019); Tran & Ostendorf (2021) explored the use of acoustic-prosodic features for text parsing with auxiliary speech input. Lou et al. (2019) trained a text parser (Kitaev & Klein, 2018) to detect speech disfluencies. In the past, syntax has also been studied in the context of speech prosody (Wagner & Watson, 2010; Kohn ¨ et al., 2018). The most relevant work to ours is Pupier et al. (2022), where a text dependency parser is trained from speech jointly with an ASR model. Moreover, text syntax parsing has been applied to prosody modeling in end-to-end text-to-speech (TTS; Guo et al., 2019; Tyagi et al., 2020; Kaiki et al., 2021). This work builds on top of pre-existing text parsing algorithms or pre-existing phrase structures from text, whereas we study phrase structure acquisition in the absence of text.
39
+
40
+ # 3 METHOD
41
+
42
+ ![](images/1022ab95dbbcbbc5e4f5d65c9b2b1a42eaaa69555b3c232f911b502e0c1cc2d5.jpg)
43
+ Figure 2: Illustration of AV-NSL, which extends VG-NSL (Shi et al., 2019) to audio-visual inputs.
44
+
45
+ Given a set of paired spoken captions and images, the Audio-Visual Neural Syntax Learner (AVNSL) infers phrase structures from subsequences of raw speech segments without relying on text. The basis of AV-NSL is the Visually-Grounded Neural Syntax Learner (VG-NSL) (Shi et al., 2019). VG-NSL learns constituency parse trees by guiding a sequential tree sampling process with textimage matching. To extend VG-NSL to audio-visual inputs, the central challenge is extracting semantically-meaningful word segments from unannotated speech. We break down the problem into a two-step process: (1) obtaining sequences of word segments, and (2) extracting segment-level self-supervised representations. With these simple modifications, AV-NSL learns non-trivial phrase structure without ever reading text, instead by listening to speech and looking at images.
46
+
47
+ # 3.1 BACKGROUND: VISUALLY-GROUNDED NEURAL SYNTAX LEARNER
48
+
49
+ VG-NSL (Shi et al., 2019) is composed of a bottom-up text parser and a text-image embedding matching module. The parser consists of an embedding similarity scoring function score and an embedding cembeddings sively scorin ${ \cal { W } } = \{ w _ { i } ^ { 0 } \} _ { i = 1 } ^ { N }$ nction comof length g adjacent $N$ ne. Given a text caption, den, the parser synthesizes a consmbeddings at each step. At step ed by a sequence of wordtuency parse tree by recur-, VG-NSL (1) evaluates all $t$
50
+
51
+ consecutive pairs of embeddings $\langle w _ { i } ^ { t } , w _ { i + 1 } ^ { t } \rangle$ and assigns a scalar score to each with score, (2) selects a pair $\langle w _ { i ^ { \prime } } ^ { t } , w _ { i ^ { \prime } + 1 } ^ { t } \rangle$ based on the corresponding scores,3 and (3) combines the selected pair of embeddings via combine to form a new phrase embedding for the next step, copying the remaining ones to the next step. In VG-NSL, score is parameterized by a 2-layer ReLU-activated MLP, and combine is defined by the L2-normalized sum of the input embeddings. The resulting tree is inherently binary and there are $N - 1$ combining steps in total, as the tree parser must combine two nodes in each step.
52
+
53
+ The text-image embedding matching module of VG-NSL is based on the standard hinge-based triplet loss (Kiros et al., 2014), where the sentence-based loss is modified to a phrase-based one. Additionally, the loss function is adapted to estimate the visual concreteness of a text span: intuitively, the smaller the loss related to a candidate constituent $c$ , the larger the concreteness of $c$ , and vice versa. The concreteness of a constituent $c$ is defined as
54
+
55
+ $$
56
+ \mathbf { \nabla } \cdot e \left( \mathbf { c } ; \mathbf { i } \right) = \sum _ { \mathbf { c } ^ { \prime } } \left[ \cos \left( \mathbf { i } , \mathbf { c } \right) - \cos \left( \mathbf { i } , \mathbf { c } ^ { \prime } \right) - \delta \right] _ { + } + \sum _ { \mathbf { i } ^ { \prime } } \left[ \cos \left( \mathbf { i } ^ { \prime } , \mathbf { c } \right) - \cos \left( \mathbf { i } ^ { \prime } , \mathbf { c } \right) - \delta \right] _ { + } ,
57
+ $$
58
+
59
+ where c is the vector representation of $c$ ; i is the corresponding vector of the parallel image of $c ; \mathbf { c } ^ { \prime }$ is a candidate constituent from a sentence that is not in parallel with i; $\mathbf { i } ^ { \prime }$ is an image that is not in parallel with $c ; \delta$ is a constant margin. Here, $[ \cdot ] _ { + } : = \operatorname* { m a x } ( \cdot , 0 )$ . Finally, the estimated concreteness scores are passed back to the parser as rewards to the constituents. VG-NSL jointly optimizes the visual-semantic embedding loss, and trains the parser with REINFORCE (Williams, 1992).
60
+
61
+ # 3.2 AUDIO-VISUAL NEURAL SYNTAX LEARNER
62
+
63
+ AV-NSL extends VG-NSL by: (1) incorporating an audio-visual word segmentation model for obtaining sequences of word segments from unannotated speech, (2) jointly optimizing segment-level embeddings along with phrase structure induction, and (3) employing deeper score and combine function parameterization in the parsing module. We empirically found (3) necessary, mainly because speech embeddings are inherently richer, less clean, and semantically more ambiguous than word embeddings. In AV-NSL, score is parameterized by a 4-layer MLP with GELU nonlinearities (Hendrycks & Gimpel, 2016), and combine is a 5-layer MLP with GELUs. On the other hand, such parameterization may cause the text-based sampling procedure to favor sampling the visually-salient words (Shi et al., 2019; Kojima et al., 2020). We describe (1) and (2) in detail as follows.
64
+
65
+ ![](images/6556f77930feb888985877de3fee66012f8b8c7a64af3426d7862217fe5324ef.jpg)
66
+ Figure 3: Example of word segmentation from VG-HuBERT (top). We use the midpoints of adjacent attention boundaries (vertical blue dashed lines) as the word boundaries. We observe that function words are ignored by VG-HuBERT; to account for this, we introduce segment insertion (bottom): short segments are placed in long enough gaps between existing segments, such that function words are recovered. Inserted segments are marked with $\cdot _ { + } \cdot$ . Best viewed in color.
67
+
68
+ Audio-visual word segmentation: AV-NSL leverages VG-HuBERT Peng & Harwath (2022b) for word segmentation (Figure 2; bottom). VG-HuBERT is trained to associate spoken captions with natural images via retrieval training, without any textual supervision. After training, spoken word segmentation emerges via magnitude thresholding the self-attention heads of the model’s audio encoder: at layer $l$ , we threshold each CLS token attention weights over each temporal speech frame token to only show top $p \%$ of the magnitude. In Figure 3, we visualize the attention weights that each speech frame receives from the CLS token. Weights from different attention heads are plotted in different colors, and color transparency represents the magnitude of the attention weights.
69
+
70
+ However, an issue we observed with VG-HuBERT is that they tend to ignore function words such as $\mathbf { \ddot { a } } ^ { , , }$ , “the”, and “of”. While this is less of an issue for word segmentation and identification, it is problematic for our purpose, as the function words are critical for phrase induction. Therefore, we devise a simple heuristic to pick up function words’ segments – segment insertion. We insert a short word segment whenever there is a sufficiently long enough gap of $s$ seconds, and VGHuBERT fails to place an attention segment. See bottom of Figure 3. Since this could introduce false positives (inserting segments where there is no word spoken), we apply unsupervised voice activity detection (Tan et al., 2020) to further restrict segment insertion only in voiced regions. The length of the insertion gap $s$ , the VG-HuBERT segmentation layer $l$ , attention magnitude threshold $p \%$ , and model training snapshots over different random seeds and training steps, are all determined in an unsupervised fashion with minimal Bayes’ risk decoding, introduced in Section 3.4.
71
+
72
+ Speech segment representations: Given the word segments from the audio-visual segmentation model, segment representations are extracted as inputs for the tree sampling module. Ideally, these segments should be semantically-meaningful and mimic word embeddings method is speech discretization that converts the inputs into sequences of d $\mathbf { \bar { \mathit { W } } } = \{ w _ { i } ^ { 0 } \} _ { i = 1 } ^ { N }$ . A naive(Lakhotia et al., 2021). Yet, we are targeting word-level phrase structures, while speech discretization, namely acoustic unit discovery, are sub-phone level, which does not fit into our setup. Different from it, AVNSL is based on continuous segment-level self-supervised representations. Let’s denote the framelevel representation sequence as $R = \{ r _ { j } \} _ { j = 1 } ^ { T }$ , where $T$ is the speech sequence length. Audio-visual word segmentation returns an alignment $\bar { \boldsymbol { A } } ( i ) = \boldsymbol { r } _ { p : q }$ that maps the ith word segment to the $p$ th to $q$ th acoustic frames. The segment-level continuous representation for the ith word is simply,
73
+
74
+ $$
75
+ w _ { i } ^ { 0 } = \sum _ { t \in A ( i ) } \stackrel { } { a _ { i t } } r _ { i t }
76
+ $$
77
+
78
+ where $a _ { i t }$ is the attention weights over the segments specified by $A ( i )$ . By default in AV-NSL, $R$ is the layer representation from VG-HuBERT, and $a _ { i t }$ is the CLS token attention weights over frames within each segment. In some cases, visual grounding is not available in AV-NSL’s word segmentation, e.g. VG-HuBERT is not available. We instead take $R$ as the layer representation from a vanilla HuBERT (Hsu et al., 2021a), and $a _ { i t }$ is parameterized by a hidden layer that is jointly optimized with the tree sampling module. Despite its simplicity, AV-NSL learns meaningful phrase structures on these segment representation sequences.
79
+
80
+ # 3.3 SELF-TRAINING
81
+
82
+ A self-training procedure is introduced for AV-NSL to further improve its parsing capability. Previously, it has been shown that self-training consistently improves the performance of text-based unsupervised constituency parsing. In Shi et al. (2020), the self-training model was based on Benepar (Kitaev & Klein, 2018), a supervised neural constituency parser, which (1) takes a sentence as the input, (2) maps it to word representations, and (3) predicts a score for any constituency parse tree. In the inference stage, the model evaluates all possible tree structures and outputs the highest-scoring one using the CKY algorithm (Kasami, 1966; Younger, 1967; Cocke, 1969).
83
+
84
+ In this work, we introduce s-Benepar, which is based on the original Benepar, except the model input is the segment-level continuous HuBERT representations mean-pooled over unsupervised word segmentation from VG-HuBERT with segment insertion, and model output is AV-NSL’s inferred constituency parse from Section 3.2. We also removed part-of-speech tag prediction as in Benepar, as there is no textual supervision in our setting. To summarize, with paired speech $D _ { A }$ and image $D _ { V }$ data, the training scheme for AV-NSL with self-training is as follows:
85
+
86
+ 1. Train an AV-NSL from audio-visual data $( D _ { A } , D _ { V } )$ and obtain the trained model $M _ { a v }$ .
87
+ 2. Generate parse tree $T _ { 0 }$ with $M _ { a v }$ for $D _ { A }$ . Obtain audio-tree pairs $( D _ { A } , T _ { 0 } )$ . Set $T = T _ { 0 }$ .
88
+ 3. Train an s-Benepar from $( D _ { A } , T )$ and obtain the trained model $M _ { s } ^ { i }$ .
89
+ 4. Generate parse tree $T _ { i }$ with $M _ { s } ^ { i }$ for $D _ { A }$ . Obtain audio-tree pairs $( D _ { A } , T _ { i } )$ . Set $T = T _ { i }$ .
90
+ 5. Go to Step 3 if we have not reached the desirable number of iterations; return $T$ otherwise.
91
+
92
+ We find it helpful to iterate s-Benepar training twice $( i = 2$ ), but the results plateau afterwards.
93
+
94
+ # 3.4 UNSUPERVISED DECODING
95
+
96
+ One key ingredient of AV-NSL is applying minimum Bayes risk (MBR) decoding (Bickel & Li, 1977) as the selection criterion for fully-unsupervised spoken word segmentation and phrasestructure induction.4 Specifically, this is in contrast to all prior unsupervised word segmentation work, in which ground truth word segments from a development set are required for decoding.
97
+
98
+ At a high level, given a loss function $\ell _ { M B R } ( O _ { 1 } , O _ { 2 } )$ between two outputs $O _ { 1 }$ and $O _ { 2 }$ , and a set of $k$ outputs $\mathcal { O } = \{ O _ { 1 } , \ldots , O _ { k } \}$ , we select the optimal output
99
+
100
+ $$
101
+ \hat { O } = \arg \operatorname* { m i n } _ { O ^ { \prime } \in { \mathcal O } } \sum _ { O ^ { \prime \prime } \in { \mathcal O } } \ell _ { M B R } ( O ^ { \prime } , O ^ { \prime \prime } ) .
102
+ $$
103
+
104
+ For word segmentation, we define the loss between two segmentation proposals $ { \boldsymbol { S } } _ { 1 }$ and $S _ { 2 }$ by $\ell _ { M B R } ( S _ { 1 } , S _ { 2 } ) ^ { - } = - \mathrm { M I O U } ( S _ { 1 } , S _ { 2 } )$ , where $\mathrm { { M I O U } } ( \cdot , \cdot )$ denotes the mean intersection over union ratio across all matched pairs of predicted word spans from $S _ { 1 }$ and $S _ { 2 }$ . We match the predicted word spans using the maximum weight matching algorithm (Galil, 1986), where word spans correspond to vertices, and we define edge weights by the temporal overlap between the corresponding spans.
105
+
106
+ For phrase structure induction, we define the loss function between two parse trees $\mathcal { T } _ { 1 }$ and $\mathcal { T } _ { 2 }$ by $\ell _ { M B R } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } ) = 1 - F _ { 1 } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } )$ , where $F _ { 1 } ( \cdot , \cdot )$ denotes the $F _ { 1 }$ score between two trees.
107
+
108
+ # 4 EXPERIMENTS
109
+
110
+ # 4.1 SETTING
111
+
112
+ Dataset: All models are evaluated on SpokenCOCO, the spoken version of MSCOCO (Lin et al., 2014) where the text captions are read out by MTurk users (Hsu et al., 2021b). It contains $8 3 \mathrm { k } / 5 \mathrm { k } / 5 \mathrm { k }$ images for training, validation, and test: each image has 5 corresponding spoken captions. SpokenCOCO totals 740h of read speech from $2 . 3 \mathrm { k }$ speakers, with an average utterance duration of about 4 seconds, covering 29K different word types.
113
+
114
+ Preprocessing: For oracle word segmentation, we ran an off-the-shelf English ASR from Montreal Force Aligner (McAuliffe et al., 2017) that was pre-trained on Librispeech and adapted to SpokenCOCO. We removed a few utterances that have mismatches in their ASR transcripts and their text captions. Following Shi et al. (2019), we included trivial spans in tree evaluation. Additionally, we ran an off-the-shelf English parser (Kitaev & Klein, 2018) on the ASR transcript (normalized text with punctuation removed) to generate the oracle trees for SpokenCOCO.
115
+
116
+ # 4.2 BASELINES AND TOPLINES
117
+
118
+ AV-NSL segments speech waveforms into word segments, then learns phrase structures on top of the learned segments. Both segmentation and structure induction are fully-unsupervised and visuallygrounded. To help us examine the role of each component in AV-NSL, we therefore further construct the following baselines and toplines. Their full descriptions are in Appendix A.1.
119
+
120
+ Trivial tree structures: Following (Shi et al., 2019), we include baselines without linguistic information: random binary trees, left-branching binary trees, and right-branching binary trees.
121
+
122
+ AV-cPCFG: We train compound probabilistic context free grammar (cPCFG) (Kim et al., 2019a) on word-level discrete speech tokens. Similar to AV-NSL, word segments and segment representations are based on VG-HuBERT. Different from AV-NSL, the segment representations are discretized via kmeans to obtain word-level discrete indices. In short, AV-cPCFG leverages visual cues only for segmentation and segment representations, but not for phrase structure induction.
123
+
124
+ DPDP-cPCFG: Instead of training cPCFG on audio-visual word segments and audio-visual segment representations, DPDP-cPCFG does not rely on any visual grounding throughout. Instead, DPDP (Kamper, 2022) and vanilla HuBERT representations are used. As in AV-cPCFG, kmeans is used for word-level discretization.
125
+
126
+ Oracle AV-NSL: To remove the uncertainty of unsupervised word segmentation, we directly train AV-NSL on top of oracle word segmentation via force alignment.
127
+
128
+ # 4.3 EVALUATION METRIC
129
+
130
+ Word segmentation. We use the standard word boundary prediction metrics (precision, recall and F1), which are calculated by comparing the temporal position between inferred word boundaries and force aligned word boundaries. In particular, following Peng & Harwath (2022b), when an inferred boundary is located within $\pm 2 0 m s$ of a force aligned boundary, we declare a successful prediction.
131
+
132
+ Parsing. For parsing with oracle word segmentation, we use EVALB to calculate the $F _ { 1 }$ score between the predicted and ground-truth parse trees.5 For parsing with inferred word segmentation, due to the mismatch in the number of nodes between the predicted and ground-truth parse trees, we introduce the structured average intersection-over-union ratio (SAIOU) as an additional metric.
133
+
134
+ SAIOU takes both word segmentation quality and temporal overlap between induced constituents into consutterance $\mathcal { T } _ { 1 } = \{ c _ { 1 , i } = ( \ell _ { 1 , i } , \dot { r } _ { 1 , i } ) \} _ { i = 1 } ^ { n _ { 1 } }$ pa t id $\mathcal { T } _ { 2 } = \{ c _ { 2 , j } = ( \ell _ { 2 , j } , r _ { 2 , j } ) \} _ { j = 1 } ^ { n _ { 2 } }$ s over the same speech, represented by a set of constituency tempthe constituents in l boand d, $\ell$ $r$ ignmen, where $\mathcal { T } _ { 1 }$ $\mathcal { T } _ { 2 }$ $\begin{array} { r } { \hat { \mathcal { A } } = \arg \operatorname* { m a x } _ { \nu a l i d \mathcal { A } } \sum _ { i = 1 } ^ { n _ { 1 } } \sum _ { j = 1 } ^ { n _ { 2 } } \mathcal { A } _ { i , j } \mathrm { I o U } ( c _ { 1 , i } , c _ { 2 , j } ) } \end{array}$ $A _ { i , j } = 1$ denotes $c _ { 1 , i }$ aligns with $c _ { 2 , j }$ , and $A _ { i , j } = 0$ otherwise; $\operatorname { I o U } ( \cdot , \cdot )$ denotes the intersection-over-union ratio between two spans. A valid alignment $\mathcal { A }$ is one that satisfies the following conditions:
135
+
136
+ 1. Any constituent may be aligned with up to 1 constituent in the other tree;
137
+
138
+ 2. For any pair of $i$ and $j$ where $A _ { i , j } = 1$ ,
139
+
140
+ • Any descendant of $c _ { 1 , i } , c _ { 1 , k }$ , may either align to a descendant of $c _ { 2 , j }$ or be left unaligned;
141
+ • Any ancestor of $c _ { 1 , i } , c _ { 1 , k ^ { \prime } }$ , may either align to a ancestor of $c _ { 2 , j }$ or be left unaligned;
142
+ • Any descendant of $c _ { 2 , j } , c _ { 2 , p }$ , may either align to a descendant of $c _ { 1 , i }$ or be left unaligned;
143
+ • Any ancestor of $c _ { 2 , j } , c _ { 2 , p ^ { \prime } }$ , may either align to a ancestor of $c _ { 1 , i }$ or be left unaligned.
144
+
145
+ Given the optimal alignment $\hat { A }$ , we calculate the structured average IOU between $\mathcal { T } _ { 1 }$ and $\mathcal { T } _ { 2 }$ by
146
+
147
+ $$
148
+ \operatorname { S A I o U } ( \mathcal { T } _ { 1 } , \mathcal { T } _ { 2 } ) = \frac { 2 } { n _ { 1 } + n _ { 2 } } \left( \sum _ { i = 1 } ^ { n _ { 1 } } \sum _ { j = 1 } ^ { n _ { 2 } } \hat { A } _ { i , j } \mathrm { I o U } ( c _ { 1 , i } , c _ { 2 , j } ) \right) .
149
+ $$
150
+
151
+ # 4.4 UNSUPERVISED WORD SEGMENTATION
152
+
153
+ We validate our decision of adopting VG-HuBERT to extract word-like units from raw speech waveforms for later phrase structure parsing. In particular, we investigate two questions: (1) How does segment insertion affect word segmentation performance? (2) how does MBR-based VG-HuBERT compare to supervised selected VG-HuBERT?
154
+
155
+ In Table 1, in addition to VG-HuBERT, we also list a speech-only word segmentation algorithm DPDP (Kamper, 2022). Note that audio-visual model VG-HuBERT significantly outperform DPDP. For question (1), by comparing the third row and the fourth row, as expected we see that performing segment insertion improves recall and hurts precision, and slightly improves F1. For question (2), by comparing the fourth row and the fifth row (second to last row), we see that MBR selection actually leads to better performance than supervised selection. The final MBR selection we adopted is based on the last row, where we first performed MBR selection on SpokenCOCO val set on all 405 candidates, and subsequently chose the 10 most selected combinations to perform another round of MBR decoding. Getting the top 10 most selected combinations does not require knowing the performance on segmentation, and therefore this process is still completely unsupervised. The reason for doing 2 iterations of MBR is because performing MBR on 405 candidates on SpokenCOCO training set is estimated to take 2 months, and MBR on 10 candidates can be done in 5 days. Comparing the last two rows, we observe that two iterations of MBR does not lead to worse results.
156
+
157
+ # 4.5 UNSUPERVISED PHRASE STRUCTURE INDUCTION
158
+
159
+ We quantitatively show that AV-NSL learns meaningful phrase structure given word segments. First, Table 2 is the main result of the fully-unsupervised AV-NSL on SpokenCOCO, evaluated with SAIOU. The best performing AV-NSL is based on our improved VG-HuBERT with MBR top 10 selection for word segmentation, attention-weighted mean-pool over VG-HuBERT layers as the segment representations, and another MBR decoding over all phrase structure induction hyperparameters. Comparing AV-NSL against AV-cPCFG and AV-cPCFG against DPDP-cPCFG, we empirically show the necessity of training AV-NSL on continuous segment representation instead of discretized speech tokens, and the effectiveness of visual-grounding in our overall model design.
160
+
161
+ Table 1: Word Segmentation Performance on SpokenCOCO validation set. Out. Sel. denotes output selection methods, and #Sel. Cand. denotes the number of candidate models to be selected. MBR (2iter) means we first run MBR on all 405 candidates, and then run MBR again on the $1 0 \ \mathrm { m o s t }$ selected candidates. Our improved VG-HuBERT with MBR achieves the best boundary $F _ { 1 }$ .
162
+
163
+ <table><tr><td>Method</td><td>Insertion</td><td>Out. Sel.</td><td>#Sel. Cand.</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>DPDP (Kamper,2022)</td><td></td><td>supervised</td><td></td><td>17.37</td><td>9.00</td><td>11.85</td></tr><tr><td>VG-HuBERT (Peng &amp; Harwath,2022b)</td><td></td><td>supervised</td><td></td><td>36.19</td><td>27.22</td><td>31.07</td></tr><tr><td rowspan="3">Improved VG-HuBERT (Ours)</td><td></td><td>supervised</td><td></td><td>34.34</td><td>29.85</td><td>31.94</td></tr><tr><td></td><td>MBR</td><td>405</td><td>33.83</td><td>34.37</td><td>34.10</td></tr><tr><td>√</td><td>MBR (2iter)</td><td>405→10</td><td>33.31</td><td>34.90</td><td>34.09</td></tr></table>
164
+
165
+ Table 2: Fully-unsupervised phrase structure induction results on SpokenCOCO. The best overall number and the best number produced by neural models are in boldface. Full table in Appendix 7.
166
+
167
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation (continuous/discrete)</td></tr><tr><td>Right-Branching</td><td>VG-HuBERT+MBR10</td><td></td><td></td><td>0.546</td></tr><tr><td>Right-Branching</td><td>DPDP</td><td></td><td></td><td>0.478</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o (continuous)</td><td>MBR</td><td>0.516</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT10,11,12 (continuous)</td><td>MBR</td><td>0.521</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.499</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.481</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+2k km (discrete)</td><td>last ckpt.</td><td>0.465</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.426</td></tr></table>
168
+
169
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Segmentation</td><td rowspan="2">Seg. Representation</td><td colspan="3">tree target</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>train</td><td>val</td><td>test</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT6</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2,4,6.8,10,12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>MBR</td><td>0.536</td></tr></table>
170
+
171
+ Table 3: Single round self-training in Section 3.3 improves the best AV-NSL from Table 2. We train s-Benepar on the trees from fully-unsupervised AV-NSL. Full table in Appendix 8.
172
+
173
+ Secondly, Table 3 shows that our proposed self-training with s-Benepar complements AV-NSL. Generally, a single round of self-training improves the SAIOU, and our best s-Benepar improves the best AV-NSL from 0.521 to 0.538. Thirdly, Table 4 isolates phrase structure induction from word segmentation quality with oracle AV-NSL. Different from Table 2, since there is no mismatch in the number of tree nodes, we can adopt $F _ { 1 }$ evaluation. With proper segment-level representations, unsupervised oracle AV-NSL matches or out-performs text-based VG-NSL. Similar to Tabel 3, selftraining with s-Benepar on oracle AV-NSL trees further improves the syntax induction results, almost matching that of right-branching tree. Last but not least, perhaps surprisingly, right-branching trees (RBT) on the given word segmentation reach the best SAIOU and $F _ { 1 }$ scores. We note that the rightbranching approach highly aligns with the head-initial property of English (Baker, 2001), especially in our setting where all punctuation marks were removed; thus, it is nontrivial for AV-NSL to reach the performance on par with RBT without inductive biases favoring any specific type of trees.
174
+
175
+ # 5 ANALYSES
176
+
177
+ Unsupervised Constituent Recall: Following Shi et al. (2019), we show the recall of specific types of constituents (Table 5). While VG-NSL benefits from the head-initial (HI) bias, where abstract words are encouraged to appear in the beginning of a constituent, it is worth noting that AV-NSL outperforms all variations of VG-NSL, without inductive biases favoring any specific types of trees.
178
+
179
+ Table 4: Phrase structure induction with oracle segmentation given. Full table in Appendix 9.
180
+
181
+ <table><tr><td colspan="2">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Seg.Representation</td></tr><tr><td>Random</td><td></td><td></td><td>32.77</td></tr><tr><td>Left-Branching</td><td></td><td></td><td>24.56</td></tr><tr><td>Right-Branching VG-NSL</td><td></td><td>Supervised</td><td>57.39 53.11</td></tr><tr><td></td><td>word embeddings</td><td></td><td></td></tr><tr><td>oracle AV-NSL</td><td>log-Mel spectrogram</td><td>Supervised</td><td>42.01</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>Supervised</td><td>55.51</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>MBR</td><td>54.99</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2,4,6,8,10,12,24</td><td>MBR</td><td>55.96</td></tr><tr><td>oracle AV-NSL →s-Benepar</td><td>HuBERT2</td><td>MBR</td><td>57.24</td></tr><tr><td>oracle AV-NSL →s-Benepar</td><td>HuBERT12</td><td>MBR</td><td>57.33</td></tr></table>
182
+
183
+ Ablation Study: We present two ablations to examine the effectiveness of high-quality word segmentation and visual representation (Table 6). We train AV-NSL with the following modifications:
184
+
185
+ 1. Fix the visual representations, but replace oracle segmentation with naive uniform word segmentation, where the number of words in each caption is given (uniform AV-NSL).
186
+ 2. Fix the oracle word segmentation, but replace visual embeddings with random images, where each pixel is independently sampled from a uniform distribution.
187
+
188
+ We observe that there are significant performance drops in both settings, comparing to the AV-NSL trained with oracle segmentation and high-quality visual representation. This set of results complement Table 2, stressing that precise word segmentation and high-quality visual representations are both necessary for phrase structure induction from speech. Furthermore, we provide tree structure and word segmentation visualizations for qualitative analysis in the Appendix.
189
+
190
+ Table 6: Top rows: performance of AV-NSL with word segmentation in various quality and high-quality visual embeddings. Bottom rows: performance of AV-NSL with visual embeddings in various quality and highquality word segmentation. DINO: a selfsupervised model that produces high-quality visual representations (Caron et al., 2021).
191
+
192
+ Table 5: Recall of specific typed phrases, including noun phrases (NP), verb phrases (VP), prepositional phrases (PP) and adjective phrases (ADJP), and overall $F _ { 1 }$ score, evaluated on the SpokenCOCO test split. The VG-NSL numbers are taken from (Shi et al., 2019). AV-NSL here are trained on oracle segmentation with vanilla HuBERT as the layer representations.
193
+
194
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">F1</td><td colspan="4">Constituent Recall</td></tr><tr><td>NP</td><td>VP</td><td>PP</td><td>ADJP</td></tr><tr><td>VG-NSL (Shi et al.,2019)</td><td>50.4</td><td>79.6</td><td>26.2</td><td>42.0</td><td>22.0</td></tr><tr><td>VG-NSL + HI</td><td>53.3</td><td>74.6</td><td>32.5</td><td>66.5</td><td>21.7</td></tr><tr><td>VG-NSL + HI+ FastText</td><td>54.4</td><td>78.8</td><td>24.4</td><td>65.6</td><td>22.0</td></tr><tr><td>oracle AV-NSL</td><td>55.6</td><td>55.5</td><td>68.1</td><td>66.6</td><td>22.1</td></tr></table>
195
+
196
+ <table><tr><td colspan="2">Model</td><td rowspan="2">Visual</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Seg.Repre.</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT10</td><td>ResNet101</td><td>50.50</td></tr><tr><td>uniform AV-NSL</td><td>HuBERT10</td><td>ResNet101</td><td>36.62</td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td></td><td>55.71</td></tr><tr><td></td><td></td><td>DINO</td><td></td></tr><tr><td>oracle AV-NSL</td><td>HuBERT2</td><td>random</td><td>31.23</td></tr></table>
197
+
198
+ # 6 CONCLUSION
199
+
200
+ In recent years, there have been fruitful progresses in multi-modal induction for zero-resource speech processing and grammar induction respectively. The idea of leveraging the visual modality to learn language competence, either lexicon units from speech or syntactic structure from text, is an attractive approach for modeling human language acquisition. Our study contributes to both lines of research, by presenting an unifying framework that learns phrase structure from visually-grounded speech, without any text. We show that our proposed model, AV-NSL, infers meaningful constituency parse trees on top of continuous word segment representations, both quantitatively and qualitatively. To justify our modeling design choices, we construct several baselines and introduce a novel evaluation metric. We envision our research as the first of many in textless structure learning.
201
+
202
+ # ETHICS STATEMENT
203
+
204
+ This work is scientific at its core, as the goal is to study the process of grammar induction from speech with visual grounding. The data used in this work is also publicly available. One potential concern is that the data and experiments are based on English, which does not represent the global human population. However, we believe that our proposed method is general enough to be applied to other spoken languages when the data is available, because we do not use any language specific speech processing techniques, and we do not have any built-in bias within the models.
205
+
206
+ # REPRODUCIBILITY STATEMENT
207
+
208
+ AV-NSL code, s-Benepar code, and SAIOU evaluation code will be made publicly available. AVNSL code is based on the VG-NSL codebase. s-Benepar code is based on the Benepar codebase. SpokenCOCO is publicly available to download. All models are trained on a single GPU. We also included as many experimental details as we can in the main content of the paper and in Appendix A.2.
209
+
210
+ # REFERENCES
211
+
212
+ Robin Algayres, Tristan Ricoul, Julien Karadayi, Hugo Laurenc¸on, Salah Zaiem, Abdelrahman Mohamed, Benoˆıt Sagot, and Emmanuel Dupoux. Dp-parse: Finding word boundaries from raw speech with an instance lexicon. arXiv preprint arXiv:2206.11332, 2022.
213
+
214
+ Mark C Baker. The atoms of language. Basic Books, 2001.
215
+
216
+ Saurabhchand Bhati, Jesus Villalba, Piotr ´ Zelasko, Laureano Moro-Velazquez, and Najim Dehak. ˙ Segmental contrastive predictive coding for unsupervised word segmentation. Interspeech, 2021.
217
+
218
+ Peter J Bickel and Bo Li. Mathematical statistics. In Test. Citeseer, 1977.
219
+
220
+ Rens Bod. An all-subtrees approach to unsupervised parsing. COLING-ACL, 2006.
221
+
222
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9650–9660, 2021.
223
+
224
+ Jan Chorowski, Grzegorz Ciesielski, Jarosław Dzikowski, Adrian Łancucki, Ricard Marxer, Ma- ´ teusz Opala, Piotr Pusz, Paweł Rychlikowski, and Michał Stypułkowski. Aligned contrastive predictive coding. Interspeech, 2021.
225
+
226
+ John Cocke. Programming languages and their compilers: Preliminary notes. New York University, 1969.
227
+
228
+ Carl De Marcken. Unsupervised language acquisition. PhD thesis, Massachusetts Institute of Technology, 1996.
229
+
230
+ Virginia R de Sa. Learning classification with unlabeled data. NeurIPS, 1994.
231
+
232
+ Andrew Drozdov, Pat Verga, Mohit Yadav, Mohit Iyyer, and Andrew McCallum. Unsupervised latent tree induction with deep inside-outside recursive autoencoders. NAACL-HLT, 2019.
233
+
234
+ Ewan Dunbar, Xuan Nga Cao, Juan Benjumea, Julien Karadayi, Mathieu Bernard, Laurent Besacier, Xavier Anguera, and Emmanuel Dupoux. The zero resource speech challenge 2017. ASRU, 2017.
235
+
236
+ Ewan Dunbar, Robin Algayres, Julien Karadayi, Mathieu Bernard, Juan Benjumea, Xuan-Nga Cao, Lucie Miskic, Charlotte Dugrain, Lucas Ondel, Alan W Black, et al. The zero resource speech challenge 2019: Tts without t. Interspeech, 2019.
237
+
238
+ Ewan Dunbar, Julien Karadayi, Mathieu Bernard, Xuan-Nga Cao, Robin Algayres, Lucas Ondel, Laurent Besacier, Sakriani Sakti, and Emmanuel Dupoux. The zero resource speech challenge 2020: Discovering discrete subword and word units. Interspeech, 2020.
239
+
240
+ Emmanuel Dupoux. Cognitive science in the era of artificial intelligence: A roadmap for reverseengineering the infant language-learner. Cognition, 173:43–59, 2018.
241
+
242
+ Zvi Galil. Efficient algorithms for finding maximum matching in graphs. ACM Comput. Surv., 18 (1):23–38, mar 1986. ISSN 0360-0300. doi: 10.1145/6462.6502. URL https://doi.org/ 10.1145/6462.6502.
243
+
244
+ Haohan Guo, Frank K Soong, Lei He, and Lei Xie. Exploiting syntactic features in a parsed tree to improve end-to-end tts. Interspeech, 2019.
245
+
246
+ David Harwath and James R Glass. Learning word-like units from joint audio-visual analysis. ACL, 2017.
247
+
248
+ David Harwath, Wei-Ning Hsu, and James Glass. Learning hierarchical discrete linguistic units from visually-grounded speech. ICLR, 2020.
249
+
250
+ David Frank Harwath. Learning spoken language through vision. PhD thesis, Massachusetts Institute of Technology, 2018.
251
+
252
+ William N. Havard, Jean-Pierre Chevrot, and Laurent Besacier. Word recognition, competition, and activation in a model of visually grounded speech. In CoNLL, 2019.
253
+
254
+ Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
255
+
256
+ Yining Hong, Qing Li, Song-Chun Zhu, and Siyuan Huang. Vlgrammar: Grounded grammar induction of vision and language. ICCV, 2021.
257
+
258
+ Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460, 2021a.
259
+
260
+ Wei-Ning Hsu, David Harwath, Christopher Song, and James Glass. Text-free image-to-speech synthesis using learned segmental units. ACL, 2021b.
261
+
262
+ Aren Jansen and Benjamin Van Durme. Efficient spoken term discovery using randomized algorithms. ASRU, 2011.
263
+
264
+ Aren Jansen, Emmanuel Dupoux, Sharon Goldwater, Mark Johnson, Sanjeev Khudanpur, Kenneth Church, Naomi Feldman, Hynek Hermansky, Florian Metze, Richard Rose, et al. A summary of the 2012 jhu clsp workshop on zero resource speech technologies and models of early language acquisition. ICASSP, 2013.
265
+
266
+ Nobuyoshi Kaiki, Sakriani Sakti, and Satoshi Nakamura. Using local phrase dependency structure information in neural sequence-to-sequence speech synthesis. In 2021 24th Conference of the Oriental COCOSDA International Committee for the Co-ordination and Standardisation of Speech Databases and Assessment Techniques (O-COCOSDA), pp. 206–211. IEEE, 2021.
267
+
268
+ Herman Kamper. Word segmentation on discovered phone units with dynamic programming and self-supervised scoring. arXiv preprint arXiv:2202.11929, 2022.
269
+
270
+ Herman Kamper and Benjamin van Niekerk. Towards unsupervised phone and word segmentation using self-supervised vector-quantized neural networks. Interspeech, 2021.
271
+
272
+ Herman Kamper, Aren Jansen, and Sharon Goldwater. Fully unsupervised small-vocabulary speech recognition using a segmental bayesian model. In Sixteenth Annual Conference of the International Speech Communication Association, 2015.
273
+
274
+ Herman Kamper, Aren Jansen, and Sharon Goldwater. A segmental framework for fullyunsupervised large-vocabulary speech recognition. Computer Speech & Language, 46:154–174, 2017.
275
+
276
+ Tadao Kasami. An efficient recognition and syntax-analysis algorithm for context-free languages. Coordinated Science Laboratory Report no. R-257, 1966.
277
+
278
+ Eugene Kharitonov, Ann Lee, Adam Polyak, Yossi Adi, Jade Copet, Kushal Lakhotia, Tu-Anh Nguyen, Morgane Riviere, Abdelrahman Mohamed, Emmanuel Dupoux, et al. Text-free prosody- \` aware generative spoken language modeling. ACL, 2022.
279
+
280
+ Khazar Khorrami and Okko Johannes Ras¨ anen. Can phones, syllables, and words emerge as ¨ side-products of cross-situational audiovisual learning? - a computational investigation. ArXiv, abs/2109.14200, 2021.
281
+
282
+ Yoon Kim, Chris Dyer, and Alexander M Rush. Compound probabilistic context-free grammars for grammar induction. ACL, 2019a.
283
+
284
+ Yoon Kim, Alexander M Rush, Lei Yu, Adhiguna Kuncoro, Chris Dyer, and Gabor Melis. Unsuper- ´ vised recurrent neural network grammars. NAACL-HLT, 2019b.
285
+
286
+ Ryan Kiros, Ruslan Salakhutdinov, and Richard S Zemel. Unifying visual-semantic embeddings with multimodal neural language models. arXiv preprint arXiv:1411.2539, 2014.
287
+
288
+ Nikita Kitaev and Dan Klein. Constituency parsing with a self-attentive encoder. In ACL, 2018.
289
+
290
+ Dan Klein and Christopher D Manning. A generative constituent-context model for improved grammar induction. ACL, 2002.
291
+
292
+ Dan Klein and Christopher D Manning. Corpus-based induction of syntactic structure: Models of dependency and constituency. ACL, 2004.
293
+
294
+ Arne Kohn, Timo Baumann, and Oskar D ¨ orfler. An empirical analysis of the correlation of syntax ¨ and prosody. Interspeech, 2018.
295
+
296
+ Noriyuki Kojima, Hadar Averbuch-Elor, Alexander M Rush, and Yoav Artzi. What is learned in visually grounded neural syntax acquisition. ACL, 2020.
297
+
298
+ Shankar Kumar and William Byrne. Minimum Bayes-risk decoding for statistical machine translation. In Proceedings of the Human Language Technology Conference of the North American Chapter of the Association for Computational Linguistics: HLT-NAACL 2004, pp. 169–176, Boston, Massachusetts, USA, May 2 - May 7 2004. Association for Computational Linguistics. URL https://aclanthology.org/N04-1022.
299
+
300
+ Kushal Lakhotia, Eugene Kharitonov, Wei-Ning Hsu, Yossi Adi, Adam Polyak, Benjamin Bolte, Tu-Anh Nguyen, Jade Copet, Alexei Baevski, Abdelrahman Mohamed, et al. On generative spoken language modeling from raw audio. Transactions of the Association for Computational Linguistics, 9:1336–1354, 2021.
301
+
302
+ Chia-ying Lee and James Glass. A nonparametric bayesian approach to acoustic model discovery. ACL, 2012.
303
+
304
+ Chia-ying Lee, Timothy J O’donnell, and James Glass. Unsupervised lexicon discovery from acoustic input. Transactions of the Association for Computational Linguistics, 3:389–403, 2015.
305
+
306
+ Bowen Li, Lili Mou, and Frank Keller. An imitation learning approach to unsupervised parsing. ACL, 2019.
307
+
308
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ European conference on computer vision, pp. 740–755. Springer, 2014.
309
+
310
+ Paria Jamshid Lou, Yufei Wang, and Mark Johnson. Neural constituency parsing of speech transcripts. NAACL-HLT, 2019.
311
+
312
+ Jana M Mason. When do children begin to read: An exploration of four year old children’s letter and word reading competencies. Reading Research Quarterly, pp. 203–227, 1980.
313
+
314
+ Michael McAuliffe, Michaela Socolof, Sarah Mihuc, Michael Wagner, and Morgan Sonderegger. Montreal forced aligner: Trainable text-speech alignment using kaldi. Interspeech, 2017.
315
+
316
+ Fergus McInnes and Sharon Goldwater. Unsupervised extraction of recurring words from infantdirected speech. In Proceedings of the Annual Meeting of the Cognitive Science Society, volume 33, 2011.
317
+
318
+ Grzegorz Chrupała Mitja Nikolaus, Afra Alishahi. Learning english with peppa pig. TACL, 2022.
319
+
320
+ Letitia Naigles. Children use syntax to learn verb meanings. Journal of child language, 17(2): 357–374, 1990.
321
+
322
+ Tu Nguyen, Maureen de Seyssel, Patricia Roz’e, Morgane Riviere, Evgeny Kharitonov, Alexei \` Baevski, Ewan Dunbar, and Emmanuel Dupoux. The zero resource speech benchmark 2021: Metrics and baselines for unsupervised spoken language modeling. Self-Supervised Learning for Speech and Audio Processing NeurIPS Workshop, 2020.
323
+
324
+ Kayode Olaleye and Herman Kamper. Attention-based keyword localisation in speech using visual grounding. In Interspeech, 2021.
325
+
326
+ Alex S Park and James R Glass. Unsupervised pattern discovery in speech. IEEE Transactions on Audio, Speech, and Language Processing, 16(1):186–197, 2007.
327
+
328
+ Puyuan Peng and David Harwath. Self-supervised representation learning for speech using visual grounding and masked language modeling. Self-Supervised Learning for Speech and Audio Processing Workshop at AAAI, 2022a.
329
+
330
+ Puyuan Peng and David Harwath. Word discovery in visually grounded, self-supervised speech models. Interspeech, 2022b.
331
+
332
+ Adam Polyak, Yossi Adi, Jade Copet, Eugene Kharitonov, Kushal Lakhotia, Wei-Ning Hsu, Abdelrahman Mohamed, and Emmanuel Dupoux. Speech resynthesis from discrete disentangled self-supervised representations. Interspeech, 2021.
333
+
334
+ Adrien Pupier, Maximin Coavoux, Benjamin Lecouteux, and Jer´ ome Goulian. End-to-end depen- ˆ dency parsing of spoken french. In Interspeech, 2022.
335
+
336
+ Brian Roark, Mary Harper, Eugene Charniak, Bonnie Dorr, Mark Johnson, Jeremy G Kahn, Yang Liu, Mari Ostendorf, John Hale, Anna Krasnyanskaya, et al. Sparseval: Evaluation metrics for parsing speech. LREC, 2006.
337
+
338
+ Deb K Roy and Alex P Pentland. Learning words from sights and sounds: A computational model. Cognitive science, 26(1):113–146, 2002.
339
+
340
+ Yikang Shen, Zhouhan Lin, Chin-Wei Huang, and Aaron Courville. Neural language modeling by jointly learning syntax and lexicon. ICLR, 2018.
341
+
342
+ Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. ICLR, 2019.
343
+
344
+ Freda Shi, Daniel Fried, Marjan Ghazvininejad, Luke Zettlemoyer, and Sida I Wang. Natural language to code translation with execution. arXiv preprint arXiv:2204.11454, 2022.
345
+
346
+ Haoyue Shi, Jiayuan Mao, Kevin Gimpel, and Karen Livescu. Visually grounded neural syntax acquisition. ACL, 2019.
347
+
348
+ Haoyue Shi, Karen Livescu, and Kevin Gimpel. On the role of supervision in unsupervised constituency parsing. In EMNLP. Association for Computational Linguistics, 2020.
349
+
350
+ Valentin I. Spitkovsky, Hiyan Alshawi, and Daniel Jurafsky. Breaking out of local optima with count transforms and model recombination: A study in grammar induction. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 1983–1995, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. URL https: //aclanthology.org/D13-1204.
351
+
352
+ Zheng-Hua Tan, Najim Dehak, et al. rvad: An unsupervised segment-based robust voice activity detection method. Computer speech & language, 59:1–21, 2020.
353
+
354
+ Trang Tran and Mari Ostendorf. Assessing the use of prosody in constituency parsing of imperfect transcripts. Interspeech, 2021.
355
+
356
+ Trang Tran, Shubham Toshniwal, Mohit Bansal, Kevin Gimpel, Karen Livescu, and Mari Ostendorf. Parsing speech: a neural approach to integrating lexical and acoustic-prosodic information. NAACL-HLT, 2018.
357
+
358
+ Trang Tran, Jiahong Yuan, Yang Liu, and Mari Ostendorf. On the role of style in parsing speech with neural models. Interspeech, 2019.
359
+
360
+ Shubhi Tyagi, Marco Nicolis, Jonas Rohnke, Thomas Drugman, and Jaime Lorenzo-Trueba. Dynamic prosody generation for speech synthesis using linguistics-driven acoustic embedding selection. Interspeech, 2020.
361
+
362
+ Maarten Versteegh, Roland Thiolliere, Thomas Schatz, Xuan Nga Cao, Xavier Anguera, Aren Jansen, and Emmanuel Dupoux. The zero resource speech challenge 2015. ISCA, 2015.
363
+
364
+ Michael Wagner and Duane G Watson. Experimental and theoretical advances in prosody: A review. Language and cognitive processes, 25(7-9):905–945, 2010.
365
+
366
+ Bo Wan, Wenjuan Han, Zilong Zheng, and Tinne Tuytelaars. Unsupervised vision-language grammar induction with shared structure modeling. ICLR, 2022.
367
+
368
+ Liming Wang and Mark Hasegawa-Johnson. A translation framework for visually grounded spoken unit discovery. In ACSSC, 2021.
369
+
370
+ Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3-4):229–256, 1992. URL https://link.springer.com/ content/pdf/10.1007/BF00992696.pdf.
371
+
372
+ Daniel H Younger. Recognition and parsing of context-free languages in time n3. Information and control, 10(2):189–208, 1967.
373
+
374
+ Hao Zhang and Daniel Gildea. Efficient multi-pass decoding for synchronous context free grammars. In Proceedings of ACL-08: HLT, pp. 209–217, Columbus, Ohio, June 2008. Association for Computational Linguistics. URL https://aclanthology.org/P08-1025.
375
+
376
+ Songyang Zhang, Linfeng Song, Lifeng Jin, Kun Xu, Dong Yu, and Jiebo Luo. Video-aided unsupervised grammar induction. NAACL-HLT, 2021.
377
+
378
+ Yaodong Zhang. Unsupervised speech processing with applications to query-by-example spoken term detection. PhD thesis, Massachusetts Institute of Technology, 2013.
379
+
380
+ Yaodong Zhang and James R Glass. Unsupervised spoken keyword spotting via segmental dtw on gaussian posteriorgrams. ASRU, 2009.
381
+
382
+ Yanpeng Zhao and Ivan Titov. Visually grounded compound pcfgs. EMNLP, 2020.
383
+
384
+ # A APPENDIX
385
+
386
+ A.1 BASELINES
387
+
388
+ AV-cPCFG: We train compound probabilistic context free grammar (cPCFG) (Kim et al., 2019a) on word-level discrete speech tokens. Similar to AV-NSL, word segments are obtained from VGHuBERT with segment insertion, and segment representations are extracted from VG-Hubert layer 10 with CLS attention weighted mean-pool. Different from AV-NSL, the segment representations are discretized via kmeans to obtain word-level discrete indices. Because the discretization is wordlevel instead of phone-level, we swept the number of kmeans cluster over $\left\{ 1 \mathrm { k } , 2 \mathrm { k } , 4 \mathrm { k } , 8 \mathrm { k } , 1 2 \mathrm { k } , 1 6 \mathrm { k } , \right.$ , $2 0 \mathrm { k } \}$ , which corresponds to the dictionary size in cPCFG. In summary, AV-cPCFG leverages visual cues only for segmentation and segment representations, but not for phrase structure induction.
389
+
390
+ DPDP-cPCFG: Instead of training cPCFG on audio-visual word segments and audio-visual segment representations, DPDP-cPCFG does not rely on any visual grounding throughout. Instead, DPDP (Kamper, 2022), a recent speech-only word segmentation algorithm, and vanilla HuBERT representations mean-pooled over DPDP segments are used. We swept through HuBERT layer {2, 4, 6, 8, 10, 12}. As in AV-cPCFG, kmeans is used for word-level discretization.
391
+
392
+ oracle AV-NSL: To remove the uncertainty of unsupervised word segmentation, we directly train AV-NSL on top of oracle word segmentation via force alignment. The segment representations are based on learnable attention pooling over vanilla HuBERT layer $\{ 2 , 4 , 6 , 8 , 1 0 , 1 2 \}$ representations. We also tried log Mel spectrograms and HuBERT-L 300M to examine the effectiveness of different input representations. One note is that simpler score and combine parametrization suffices here6.
393
+
394
+ # A.2 HYPERPARAMETERS
395
+
396
+ For VG-HuBERT, we run MBR selection on the combination of insertion gap $\{ 0 . 1 , 0 . 2 , 0 . 3 \}$ seconds, segmentation layer $\{ 9 , 1 0 , 1 1 \}$ , attention magnitude threshold at top $\{ 3 0 \% , 2 0 \% , 1 0 \% \}$ , three training random seeds, and model snapshots at training step 20k, 30k, 40k, 50k, 60k. This gives 405 combinations in total.
397
+
398
+ # A.3 FULL RESULTS TABLE
399
+
400
+ # A.4 WORD SEGMENTATION VIZ
401
+
402
+ We show more examples of word segmentation generated by our improved VG-HuBERT in Figure 4. Segments marked with $" + "$ are inserted segments, and vertical blue dotted lines are inferred word boundaries.
403
+
404
+ # A.5 VISUALIZATION OF INDUCED TREES
405
+
406
+ We visualize the induced trees in Figure 5.
407
+
408
+ Table 7: Fully-unsupervised phrase structure induction results evaluated with SAIOU.
409
+
410
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation (continuous/discrete)</td></tr><tr><td>Right-Branching</td><td>VG-HuBERT+MBR10</td><td></td><td></td><td>0.546</td></tr><tr><td>Right-Branching</td><td>DPDP</td><td></td><td></td><td>0.478</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o (continuous)</td><td>MBR</td><td>0.516</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT11 (continuous)</td><td>MBR</td><td>0.498</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT12 (continuous)</td><td>MBR</td><td>0.492</td></tr><tr><td>AV-NSL</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT10,11,12 (continuous)</td><td>MBR</td><td>0.521</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+1k km (discrete)</td><td>last ckpt.</td><td>0.454</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.444</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.499</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.481</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+12k km (discrete)</td><td>last ckpt.</td><td>0.473</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+16k km (discrete)</td><td>last ckpt.</td><td>0.471</td></tr><tr><td>AV-cPCFG</td><td>VG-HuBERT+MBR10</td><td>VG-HuBERT1o+20k km (discrete)</td><td>last ckpt.</td><td>0.454</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+1k km (discrete)</td><td>last ckpt.</td><td>0.434</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+2k km (discrete)</td><td>last ckpt.</td><td>0.465</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+4k km (discrete)</td><td>last ckpt.</td><td>0.444</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+8k km (discrete)</td><td>last ckpt.</td><td>0.387</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+12k km (discrete)</td><td>last ckpt.</td><td>0.447</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT2+16k km (discrete)</td><td>last ckpt.</td><td>0.360</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+1k km (discrete)</td><td>last ckpt.</td><td>0.403</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+2k km (discrete)</td><td>last ckpt.</td><td>0.426</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+4k km (discrete)</td><td>last ckpt.</td><td>0.415</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+8k km (discrete)</td><td>last ckpt.</td><td>0.367</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+12k km (discrete)</td><td>last ckpt.</td><td>0.415</td></tr><tr><td>DPDP-cPCFG</td><td>DPDP</td><td>HuBERT1o+16k km (discrete)</td><td>last ckpt.</td><td>0.414</td></tr></table>
411
+
412
+ Table 8: Self-training results evaluated with SAIOU.
413
+
414
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Segmentation</td><td rowspan="2">Seg.Representation</td><td colspan="3">tree target</td><td rowspan="2">Output Selection</td><td rowspan="2">SAIoU</td></tr><tr><td>train</td><td>val</td><td>test</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT4</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.536</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT6</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.538</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT8</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.532</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT10</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.537</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>last ckpt.</td><td>0.536</td></tr><tr><td>s-Benepar</td><td>VG-HuBERT+MBR10</td><td>HuBERT2,4,6,8,10,12</td><td>AV-NSL</td><td>AV-NSL</td><td>oracle</td><td>MBR</td><td>0.536</td></tr></table>
415
+
416
+ Table 9: Phrase structure induction with oracle segmentation given results evaluated with $F _ { 1 }$ .
417
+
418
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Output Selection</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation</td></tr><tr><td>Random</td><td>oracle</td><td></td><td></td><td>32.77</td></tr><tr><td>Left-Branching</td><td>oracle</td><td></td><td></td><td>24.56</td></tr><tr><td>Right-Branching</td><td>oracle</td><td></td><td></td><td>57.39</td></tr><tr><td>VG-NSL</td><td></td><td>word embeddings</td><td>Supervised</td><td>53.11</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>log-Mel spectrogram</td><td>Supervised</td><td>42.01</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>Supervised</td><td>55.51</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT-L24</td><td></td><td>54.63</td></tr><tr><td></td><td></td><td></td><td>Supervised</td><td></td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>MBR</td><td>54.99</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT4</td><td>MBR</td><td>53.25</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT6</td><td>MBR</td><td>53.46</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT8</td><td>MBR</td><td>53.14</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT10</td><td>MBR</td><td>36.67</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT12</td><td>MBR</td><td>48.51</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT-L24</td><td>MBR</td><td>54.39</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2,4,6,8,10,12</td><td>MBR</td><td>55.56</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2,4,6,8,10,12,24</td><td>MBR</td><td>55.96</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT2</td><td>MBR</td><td>57.24</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT4</td><td>MBR</td><td>57.08</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT6</td><td>MBR</td><td>56.81</td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT8</td><td>MBR</td><td>56.94</td></tr><tr><td>AV-NSL→s-Benepar</td><td>oracle</td><td>HuBERT10</td><td>MBR</td><td>57.16</td></tr><tr><td>AV-NSL →s-Benepar</td><td>oracle</td><td>HuBERT12</td><td>MBR</td><td>57.33</td></tr></table>
419
+
420
+ Table 10: Recall of specific typed phrases, and overall $F _ { 1 }$ score, evaluated on the SpokenCOCO test split. VG-NSL numbers are taken directly from (Shi et al., 2019). AV-NSL here are trained on oracle segmentation with vanilla HuBERT as the layer representations.
421
+
422
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">F1</td><td colspan="4">Constituent Recall</td></tr><tr><td>NP</td><td>VP</td><td>PP</td><td>ADJP</td></tr><tr><td>VG-NSL (Shi et al.,2019)</td><td>50.4</td><td>79.6</td><td>26.2</td><td>42.0</td><td>22.0</td></tr><tr><td>VG-NSL + HI</td><td>53.3</td><td>74.6</td><td>32.5</td><td>66.5</td><td>21.7</td></tr><tr><td>VG-NSL +HI+FastText</td><td>54.4</td><td>78.8</td><td>24.4</td><td>65.6</td><td>22.0</td></tr><tr><td>AV-NSL (oracle seg.+ HuBERT2)</td><td>55.6</td><td>55.5</td><td>68.1</td><td>66.6</td><td>22.1</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT4)</td><td>53.7</td><td>57.4</td><td>56.8</td><td>61.3</td><td>21.3</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT6)</td><td>53.9</td><td>59.4</td><td>55.4</td><td>59.3</td><td>21.2</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT8)</td><td>53.9</td><td>56.0</td><td>58.0</td><td>64.9</td><td>22.5</td></tr><tr><td>AV-NSL (oracle seg.+HuBERT10)</td><td>50.6</td><td>55.8</td><td>48.1</td><td>57.0</td><td>20.5</td></tr><tr><td>AV-NSL (oracle seg. + HuBERT12)</td><td>49.0</td><td>62.5</td><td>34.4</td><td>45.0</td><td>17.4</td></tr></table>
423
+
424
+ Table 11: Top rows: Impact of segmentation quality for AV-NSL with number of words segments known in advance. Bottom rows: Impact of visual embedding for AV-NSL
425
+
426
+ <table><tr><td colspan="3">Model</td><td rowspan="2">Visual Embedding</td><td rowspan="2">F1</td></tr><tr><td>Syntax Induction</td><td>Segmentation</td><td>Seg.Representation</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>ResNet101</td><td>55.51</td></tr><tr><td>AV-NSL</td><td>uniform</td><td>HuBERT2</td><td>ResNet101</td><td>48.97</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT10</td><td>ResNet101</td><td>50.50</td></tr><tr><td>AV-NSL</td><td>uniform</td><td>HuBERT10</td><td>ResNet101</td><td>36.62</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>DINO</td><td>55.71</td></tr><tr><td>AV-NSL</td><td>oracle</td><td>HuBERT2</td><td>random</td><td>31.23</td></tr></table>
427
+
428
+ ![](images/6eafec723763f1955cfa3db3f2fc4b4dc5b5264e53948ae6cd47f58566a414d3.jpg)
429
+ Figure 4: Examples of attention segments generated by VG-HuBERT. Inserted segments are marked with $" + "$ . Vertical blue dotted lines are inferred word boundaries.
430
+
431
+ ![](images/b9ba5c7f7252344a82826fa03c2de12600f34bc8ecb7e8a39029ac2f4d17e2ae.jpg)
432
+ Figure 5: Visualization of an example produced by AV-NSL (best viewed in color). Top (red and green): the ground-truth parse tree; bottom (blue and yellow): the generated parse tree. In each tree, a parent segment adjacently covers its two children segments.
md/dev/1wVvweK3oIb/1wVvweK3oIb.md ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SIMPLE GNN REGULARISATION FOR 3D MOLECULARPROPERTY PREDICTION & BEYOND
2
+
3
+ Jonathan Godwin, Michael Schaarschmidt, Alexander Gaunt, Alvaro Sanchez-Gonzales, Yulia Rubanova, Petar Velickovi ˇ c,´ James Kirkpatrick & Peter Battaglia
4
+
5
+ DeepMind, London {jonathangodwin}@deepmind.com
6
+
7
+ # ABSTRACT
8
+
9
+ In this paper we show that simple noisy regularisation can be an effective way to address oversmoothing. We argue that regularisers addressing oversmoothing should both penalise node latent similarity and encourage meaningful node representations. From this observation we derive “Noisy Nodes”, a simple technique in which we corrupt the input graph with noise, and add a noise correcting node-level loss. The diverse node level loss encourages latent node diversity, and the denoising objective encourages graph manifold learning. Our regulariser applies well-studied methods in simple, straightforward ways which allow even generic architectures to overcome oversmoothing and achieve state of the art results on quantum chemistry tasks, and improve results significantly on Open Graph Benchmark (OGB) datasets. Our results suggest Noisy Nodes can serve as a complementary building block in the GNN toolkit.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Graph Neural Networks (GNNs) are a family of neural networks that operate on graph structured data by iteratively passing learned messages over the graph’s structure (Scarselli et al., 2009; Bronstein et al., 2017; Gilmer et al., 2017; Battaglia et al., 2018; Shlomi et al., 2021). While Graph Neural Networks have demonstrated success in a wide variety of tasks (Zhou et al., 2020a; Wu et al., 2020; Bapst et al., 2020; Schütt et al., 2017; Klicpera et al., 2020a), it has been proposed that in practice “oversmoothing” limits their ability to benefit from overparametrization.
14
+
15
+ Oversmoothing is a phenomenon where a GNN’s latent node representations become increasing indistinguishable over successive steps of message passing (Chen et al., 2019). Once these representations are oversmoothed, the relational structure of the representation is lost, and further message-passing cannot improve expressive capacity. We argue that the challenges of overcoming oversmoothing are two fold. First, finding a way to encourage node latent diversity; second, to encourage the diverse node latents to encode meaningful graph representations. Here we propose a simple noise regulariser, Noisy Nodes, and demonstrate how it overcomes these challenges across a range of datasets and architectures, achieving top results on OC20 IS2RS & IS2RE direct, QM9 and OGBG-PCQM4Mv1.
16
+
17
+ Our “Noisy Nodes” method is a simple technique for regularising GNNs and associated training procedures. During training, our noise regularisation approach corrupts the input graph’s attributes with noise, and adds a per-node noise correction term. We posit that our Noisy Nodes approach is effective because the model is rewarded for maintaining and refining distinct node representations through message passing to the final output, which causes it to resist oversmoothing. Like denoising autoencoders, it encourages the model to explicitly learn the manifold on which the uncorrupted input graph’s features lie, analogous to a form of representation learning. When applied to 3D molecular prediction tasks, it encourages the model to distinguish between low and high energy states. We find that applying Noisy Nodes reduces oversmoothing for shallower networks, and allows us to see improvements with added depth, even on tasks for which depth was assumed to be unhelpful.
18
+
19
+ This study’s approach is to investigate the combination of Noisy Nodes with generic, popular baseline GNN architectures. For 3D Molecular prediction we use a standard architecture working on 3D point clouds developed for particle fluid simulations, the Graph Net Simulator (GNS) (Sanchez-Gonzalez\* et al., 2020), which has also been used for molecular property prediction (Hu et al., 2021b). Without using Noisy Nodes the GNS is not a competitive model, but using Noisy Nodes allows the GNS to achieve top performance on three 3D molecular property prediction tasks: the OC20 IS2RE direct task by $43 \%$ over previous work, $12 \%$ on OC20 IS2RS direct, and top results on 3 out of 12 of the QM9 tasks. For non-spatial GNN benchmarks we test a MPNN (Gilmer et al., 2017) on OGBG-MOLPCBA and OGBG-PCQM4M (Hu et al., 2021a) and again see significant improvements. Finally, we applied Noisy Nodes to a GCN (Kipf & Welling, 2016), arguably the most popular and simple GNN, trained on OGBN-Arxiv and see similar results. These results suggest Noisy Nodes can serve as a complementary GNN building block.
20
+
21
+ # 2 PRELIMINARIES: GRAPH PREDICTION PROBLEM
22
+
23
+ Let $G = ( V , E , g )$ be an input graph. The nodes are $V = \{ v _ { 1 } , \ldots , v _ { | V | } \}$ , where $v _ { i } \in \mathbb { R } ^ { d _ { v } }$ . The directed, attributed edges are $E = \left\{ e _ { 1 } , \dots , e _ { | E | } \right\}$ : each edge includes a sender node index, receiver node index, and edge attribute, $\boldsymbol { e } _ { k } = \left( \boldsymbol { s } _ { k } , r _ { k } , \boldsymbol { e } _ { k } \right)$ , respectively, where $s _ { k } , r _ { k } \in \{ 1 , \dots , | V | \}$ and $e _ { k } \in \mathbb { R } ^ { d _ { e } }$ . The graph-level property is $g \in \mathbb { R } ^ { d _ { g } }$ .
24
+
25
+ The goal is to predict a target graph, $G ^ { \prime }$ , with the same structure as $G$ , but different node, edge, and/or graph-level attributes. We denote $\hat { G } ^ { \prime }$ as a model’s prediction of $G ^ { \prime }$ . Some error metric defines quality of $\hat { G } ^ { \prime }$ with respect to the target $G ^ { \prime }$ , $\mathrm { E r r o r } ( \hat { G } ^ { \prime } , G ^ { \prime } )$ , which the training loss terms are defined to optimize. In this paper the phrase “message passing steps” is synonymous with “GNN layers”.
26
+
27
+ # 3 OVERSMOOTHING
28
+
29
+ “Oversmoothing” is when the node latent vectors of a GNN become very similar after successive layers of message passing. Once nodes are identical there is no relational information contained in the nodes, and no higher-order latent graph representations can be learned. It is easiest to see this effect with the update function of a Graph Convolutional Network with no adjacency normalization $\begin{array} { r } { v _ { i } ^ { k } = \sum _ { j } W v _ { j } ^ { k - 1 } } \end{array}$ with $j \in N e i g h b o r h o o d _ { v _ { i } }$ , $W \in \mathbb { R } ^ { d _ { g } \times d _ { g } }$ and $k$ the layer index. As the number of applications increases, the averaging effect of the summation forces the nodes to become almost identical. However, as soon as residual connections are added we can construct a network that need not suffer from oversmoothing by setting the residual updates to zero at a similarity threshold. Similarly, multi-head attention Vaswani et al. (2017); Velickovi ˇ c et al. (2018) and GNNs with edge ´ updates (Battaglia et al., 2018; Gilmer et al., 2017) can modulate node updates. As such for modern GNNs oversmoothing is primarily a “training” problem - i.e. how to choose model architectures and regularisers to encourage and preserve meaningful latent relational representations.
30
+
31
+ We can discern two desiderata for a regulariser or loss that addresses oversmoothing. First, it should penalise identical node latents. Second, it should encourage meaningful latent representations of the data. One such example may be the auto-regressive loss of transformer based language models (Brown et al. (2020)). In this case, each word (equivalent to node) prediction must be distinct, and the auto-regressive loss encourages relational dependence upon prior words. We can take inspiration from this observation to derive auxiliary losses that both have diverse node targets and encourage relational representation learning. In the following section we derive one such regulariser, Noisy Nodes.
32
+
33
+ # 4 NOISY NODES
34
+
35
+ Noisy Nodes tackles the oversmoothing problem by adding a diverse noise correction target, modifying the original graph prediction problem definition in several ways. It introduces a graph corrupted by noise, $\bar { \tilde { G } } = \tilde { ( V , E , g ) }$ , where $\tilde { v } _ { i } \in \tilde { V }$ is constructed by adding noise, $\sigma _ { i }$ , to the input nodes, $\tilde { v } _ { i } = v _ { i } + \sigma _ { i }$ . The edges, $\tilde { E }$ , and graph-level attribute, $\tilde { g }$ , can either be uncorrupted by noise (i.e., $\tilde { E } = E , \tilde { g } = g )$ , calculated from the noisy nodes (for example in a nearest neighbors graph), or corrupted independent of the nodes—these are minor choices that can be informed by the specific problem setting.
36
+
37
+ $$
38
+ \begin{array} { c } { { \displaystyle \binom { \zeta _ { i } } { \upsilon _ { i } } { \cdots } _ { { \bf \bar { \Phi } } _ { i } } ; } } \\ { { + \Delta _ { i } \left[ \begin{array} { c } { { { \bf \bar { \Phi } } _ { \bar { i } } } } \\ { { { \bf \bar { \Phi } } _ { \bar { i } } } } \end{array} \right] ^ { \prime } { \bf \bar { \Phi } } _ { \bar { { { + } } } \Delta _ { i } } - \sigma _ { i } } } \\ { { \displaystyle \binom { \bf \bar { \bf \Phi } _ { \bar { i } } } { \bf \bar { \Phi } } ^ { \prime } { \bf \bar { \Phi } } ^ { \prime } { \bf \bar { \Phi } } _ { \bar { { { + } } } \Delta _ { i } } } } \end{array}
39
+ $$
40
+
41
+ ![](images/9092527f228fe1aca776680174ed12f46f8bd5366238138d84754289aa2e0519.jpg)
42
+ Figure 2: Per layer node latent diversity, measured by MAD on a 16 layer MPNN trained on OGBGMOLPCBA. Noisy Nodes maintains a higher level of diversity throughout the network than competing methods.
43
+
44
+ Figure 1: Noisy Node mechanics during training. Input positions are corrupted with noise $\sigma$ , and the training objective is the node-level difference between target positions and the noisy inputs.
45
+
46
+ Our method requires a noise correction target to prevent oversmoothing by enforcing diversity in the last layers of the GNN, which can be achieved with an auxiliary denoising autoencoder loss. For example, where the Error is defined with respect to graph-level predictions (e.g., predict the minimum energy value of some molecular system), a second output head can be added to the GNN architecture which requires denoising the inputs as targets. Alternatively, if the inputs and targets are in the same real domain as is the case for physical simulations we can adjust the target for the noise. Figure 1 demonstrates this Noisy Nodes set up. The auxiliary loss is weighted by a constant coefficient $\lambda \in \mathbb { R }$
47
+
48
+ In Figure 2 we illustrate the impact of Noisy Nodes on oversmoothing by plotting the Mean Absolute Distance (MAD) (Chen et al., 2020) of the residual updates of each layer of an MPNN trained on the QM9 (Ramakrishnan et al., 2014) dataset, and compare it to alternative methods DropEdge (Rong et al., 2019) and DropNode (Do et al., 2021). MAD is a measure of the diversity of graph node features, often used to quantify oversmoothing, the higher the number the more diverse the node features, the lower the number the less diverse. In this plot we can see that for Noisy Nodes the node updates remain diverse for all of the layers, whereas without Noisy Nodes diversity is lost. Further analysis of MAD across seeds and with sorted layers can be seen in Appendix Figures 7 and 6 for models applied to 3D point clouds.
49
+
50
+ The Graph Manifold Learning Perspective. By using an implicit mapping from corrupted data to clean data, the Noisy Nodes objective encourages the model to learn the manifold on which the clean data lies— we speculate that the GNN learns to go from low probability graphs to high probability graphs. In the autoencoder case the GNN learns the manifold of the input data. When node targets are provided, the GNN learns the manifold of the target data (e.g. the manifold of atoms at equilibrium). We speculate that such a manifold may include commonly repeated substructures that are useful for downstream prediction tasks. A similar motivation can be found for denoising in (Vincent et al., 2010; Song & Ermon, 2019).
51
+
52
+ The Energy Perspective for Molecular Property Prediction. Local, random distortions of the geometry of a molecule at a local energy minimum are almost certainly higher energy configurations. As such, a task that maps from a noised molecule to a local energy minimum is learning a mapping from high energy to low energy. Data such as QM9 contains molecules at local minima.
53
+
54
+ Some problems have input data that is already high energy, and targets that are at equilibrium. For these datasets we can generate new high energy states by adding noise to the inputs but keeping the equilibrium target the same, Figure 1 demonstrates this approach. To preserve translation invariance we use displacements between input and target $\Delta$ , the corrected target after noise is $\Delta - \sigma$ .
55
+
56
+ # 5 RELATED WORK
57
+
58
+ Oversmoothing. Recent work has aimed to understand why it is challenging to realise the benefits of training deeper GNNs (Wu et al., 2020). Since first being noted in ((Li et al., 2018)) oversmoothing has been studied extensively and regularisation techniques have been suggested to overcome it (Chen et al., 2019; Cai & Wang, 2020; Rong et al., 2019; Zhou et al., 2020b; Yang et al., 2020; Do et al., 2021; Zhao & Akoglu, 2020). A recent paper, (Li et al., 2021), finds, as in previous work, (Li et al., 2019; 2020), the optimal depth for some datasets they evaluate on to be far lower (5 for OGBN-Arxiv from the Open Graph Benchmark (Hu et al., 2020a), for example) than the 1000 layers possible.
59
+
60
+ Denoising & Noise Models. Training neural networks with noise has a long history (Sietsma & Dow, 1991; Bishop, 1995). Of particular relevance are Denoising Autoencoders (Vincent et al., 2008) in which an autoencoder is trained to map corrupted inputs $\tilde { \mathbf { x } }$ to uncorrupted inputs $\mathbf { X }$ . Denoising Autoencoders have found particular success as a form of pre-training for representation learning (Vincent et al., 2010). More recently, in research applying GNNs to simulation (Sanchez-Gonzalez et al., 2018; Sanchez-Gonzalez\* et al., 2020; Pfaff et al., 2020) Gaussian noise is added during training to input positions of a ground truth simulator to mimic the distribution of errors of the learned simulator. Pre-training methods (Devlin et al., 2019; You et al., 2020; Thakoor et al., 2021) are another similar approach; most similarly to our method Hu et al. (2020b) apply a reconstruction loss to graphs with masked nodes to generate graph embeddings for use in downstream tasks. FLAG (Kong et al., 2020) adds adversarial noise during training to input node features as a form of data augmentation for GNNs that demonstrates improved performance for many tasks. It does not add an additional auxiliary loss, which we find is essential for addressing oversmoothing. In other related GNN work, (Sato et al., 2021) use random input features to improve generalisation of graph neaural networks. Adding noise to help input node disambiguation has also been covered in (Dasoulas et al., 2019; Loukas, 2020; Vignac et al., 2020; Murphy et al., 2019), but there is no auxiliary loss.
61
+
62
+ Finally, we take inspiration from (Vincent et al., 2008; 2010; Vincent, 2011; Song & Ermon, 2019) which use the observation that noised data lies off the data manifold for representation learning and generative modelling.
63
+
64
+ Machine Learning for 3D Molecular Property Prediction. One application of GNNs is to speed up quantum chemistry calculations which operate on 3D positions of a molecule (Duvenaud et al., 2015; Gilmer et al., 2017; Schütt et al., 2017; Hu et al., 2021b). Common goals are the prediction of molecular properties (Ramakrishnan et al., 2014), forces (Chmiela et al., 2017), energies (Chanussot\* et al., 2020) and charges (Unke & Meuwly, 2019).
65
+
66
+ A common approach to embed physical symmetries is to design a network that predicts a rotation and translation invariant energy (Schütt et al., 2017; Klicpera et al., 2020a; Liu et al., 2021). The input features of such models include distances (Schütt et al., 2017), angles (Klicpera et al., 2020b;a) or torsions and higher order terms (Liu et al., 2021). An alternative approach to embedding symmetries is to design a rotation equivariant neural network that use equivariant representations (Thomas et al., 2018; Köhler et al., 2019; Kondor et al., 2018; Fuchs et al., 2020; Batzner et al., 2021; Anderson et al., 2019; Satorras et al., 2021).
67
+
68
+ Machine Learning for Bond and Atom Molecular Graphs. Predicting properties from molecular graphs without 3D points, such as graphs of bonds and atoms, is studied separately and often used to benchmark generic graph property prediction models such as GCNs (Hu et al., 2020a) or GATs (Velickovi ˇ c et al., 2018). Models developed for 3D molecular property prediction cannot be applied ´ to bond and atom graphs. Common datasets that contain such data are OGBG-MOLPCBA and OGBG-MOLHIV.
69
+
70
+ # 6 3D MOLECULAR PROPERTY PREDICTION EXPERIMENTS AND RESULTS
71
+
72
+ In this section we evaluate how a popular, simple model, the GNS (Sanchez-Gonzalez\* et al., 2020) performs on 3D molecular prediction tasks when combined with Noisy Nodes. The GNS was originally developed for particle fluid simulations, but has recently been adapted for molecular property prediction (Hu et al., 2021b). We find that Without Noisy Nodes the GNS architecture is not competitive, but by using Noisy Nodes we see improved performance comparable to the use of specialised architectures.
73
+
74
+ We made minor changes to the GNS architecture. We featurise the distance input features using radial basis functions. We group layer weights, similar to grouped layers used in Jumper et al. (2021) for reduced parameter counts; for a group size of $n$ the first $n$ layer weights are repeated, i.e. the first layer with a group size of 10 has the same weights as the $1 1 ^ { t h }$ , $2 1 ^ { s t }$ , $3 1 ^ { s t }$ layers and so on. $n$ contiguous blocks of layers are considered a single group. Finally we find that decoding the intermediate latents and adding a loss after each group aids training stability. The decoder is shared across groups.
75
+
76
+ ![](images/5efaa6e41a8dc4e467e193db6b0773e8c0e5b0fe814b747533de08946897ae36.jpg)
77
+ Figure 3: Validation curves, OC20 IS2RE ID. A) Without any node targets our model has poor performance and realises no benefit from depth. B) After adding a position node loss, performance improves as depth increases. C) As we add Noisy Nodes and parameters the model achieves SOTA, even with 3 layers, and stops overfitting. D) Adding Noisy Nodes allows a model with even fully shared weights to achieve SOTA.
78
+
79
+ We tested this architecture on three challenging molecular property prediction benchmarks: OC20 (Chanussot\* et al., 2020) IS2RS & IS2RE, and QM9 (Ramakrishnan et al., 2014). These benchmarks are detailed below, but as general distinctions, OC20 tasks use graphs $2 \mathrm { - } 2 0 \mathrm { x }$ larger than QM9. While QM9 always requires graph-level prediction, one of OC20’s two tasks (IS2RS) requires node-level predictions while the other (IS2RE) requires graph-level predictions. All training details may be found in the Appendix.
80
+
81
+ # 6.1 OPEN CATALYST 2020
82
+
83
+ Dataset. The OC20 dataset (Chanussot\* et al., 2020) (CC Attribution 4.0) describes the interaction of a small molecule (the adsorbate) and a large slab (the catalyst), with total systems consisting of 20-200 atoms simulated until equilibrium is reached.
84
+
85
+ We focus on two tasks; the Initial Structure to Resulting Energy (IS2RE) task which takes the initial structure of the simulation and predicts the final energy, and the Initial Structure to Resulting Structure (IS2RS) which takes the initial structure and predicts the relaxed structure. Note that we train the more common “direct” prediction task that map directly from initial positions to target in a single forward pass, and compare against other models trained for direct prediction.
86
+
87
+ Models are evaluated on 4 held out test sets. Four canonical validation datasets are also provided. Test sets are evaluated on a remote server hosted by the dataset authors with a very limited number of submissions per team.
88
+
89
+ Noisy Nodes in this case consists of a random jump between the initial position and relaxed position. During training we first sample uniformly from a point in the relaxation trajectory or interpolate uniformly between the initial and final positions $( v _ { i } - \tilde { v } _ { i } ) \gamma , \gamma \sim \mathrm { U } ( 0 , 1 )$ , and then add I.I.D Gaussian noise with mean zero and $\sigma = 0 . 3$ . The Noisy Node target is the relaxed structure.
90
+
91
+ Table 1: OC20 ISRE Validation, eV MAE, ↓. “GNS-Shared” indicates shared weights. “GNS-10” indicates a group size of 10.
92
+
93
+ <table><tr><td>Model</td><td>Layers</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>GNS</td><td>50</td><td>0.59 ±0.01</td><td>0.65 ±0.01</td><td>0.55 ±0.00</td><td>0.54 ±0.00</td></tr><tr><td>GNS-Shared + Noisy Nodes</td><td>50</td><td>0.49 ±0.00</td><td>0.54 ±0.00</td><td>0.51 ±0.01</td><td>0.51 ±0.01</td></tr><tr><td>GNS + Noisy Nodes</td><td>50</td><td>0.48 ±0.00</td><td>0.53 ±0.00</td><td>0.49 ±0.01</td><td>0.48 ±0.00</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>100</td><td>0.46±0.00</td><td>0.51 ±0.00</td><td>0.48 ±0.00</td><td>0.47 ±0.00</td></tr></table>
94
+
95
+ Table 2: Results OC20 IS2RE Test
96
+
97
+ <table><tr><td colspan="6">eV MAE↓</td></tr><tr><td></td><td>SchNet</td><td>DimeNet++</td><td>SpinConv</td><td>SphereNet</td><td>GNS + Noisy Nodes</td></tr><tr><td>OOD Both</td><td>0.704</td><td>0.661</td><td>0.674</td><td>0.638</td><td>0.465 (-24.0%)</td></tr><tr><td>OOD Adsorbate</td><td>0.734</td><td>0.725</td><td>0.723</td><td>0.703</td><td>0.565 (-22.8%)</td></tr><tr><td>OOD Catalyst</td><td>0.662</td><td>0.576</td><td>0.569</td><td>0.571</td><td>0.437 (-17.2%)</td></tr><tr><td>ID</td><td>0.639</td><td>0.562</td><td>0.558</td><td>0.563</td><td>0.422 (-18.8%)</td></tr><tr><td colspan="6">Average Energy within Threshold (AEwT) ↑</td></tr><tr><td></td><td>SchNet</td><td>DimeNet++</td><td>SpinConv</td><td>SphereNet</td><td>GNS + Noisy Nodes</td></tr><tr><td>OOD Both</td><td>0.0221</td><td>0.0241</td><td>0.0233</td><td>0.0241</td><td>0.047 (+95.8%)</td></tr><tr><td>OOD Adsorbate</td><td>0.0233</td><td>0.0207</td><td>0.026</td><td>0.0229</td><td>0.035 (+89.5%)</td></tr><tr><td>OOD Catalyst</td><td>0.0294</td><td>0.0410</td><td>0.0382</td><td>0.0409</td><td>0.080 (+95.1%)</td></tr><tr><td>ID</td><td>0.0296</td><td>0.0425</td><td>0.0408</td><td>0.0447</td><td>0.091 (+102.0%)</td></tr></table>
98
+
99
+ We first convert to fractional coordinates (i.e. use the periodic unit cell as the basis) which render the predictions of our model invariant to rotations, and append the following rotation and translation invariant vector $( \alpha \beta ^ { T } , \beta \gamma ^ { T } , \alpha \gamma ^ { T } , | \alpha | , | \beta | , | \gamma | ) \in \mathbb { R } ^ { 6 }$ to the edge features where $\alpha , \beta , \gamma$ are vectors of the unit cell. This additional vector provides rotation invariant angular and extent information to the GNN.
100
+
101
+ IS2RE Results. In Figure 3 we show how using Noisy Nodes allows the GNS to achieve state of the art performance. Figure $_ { 3 \mathrm { ~ A ~ } }$ shows that without any auxiliary node target, an IS2RE GNS achieves poor performance even with increased depth. The fact that increased depth does not result in improvement supports the hypothesis that GNS suffers from oversmoothing. As we add a node level position target in B) we see better performance, and improvement as depth increases, validating our hypothesis that node level targets are key to addressing oversmoothing. In C) we add noisy nodes and parameters, and see that the increased diversity of the node level predictions leads to very significant improvements and SOTA, even for a shallow 3 layer network. D) demonstrates this effect is not just due to increased parameters - SOTA can still be achieve with shared layer weights .
102
+
103
+ In Table 1 we conduct an ablation on our hyperparameters, and again demonstrate the improved performance of using Noisy Nodes. Results were averaged over 3 seeds and standard errors on the best obtained checkpoint show little sensitivity to initialisation. All results in the table are reported using sampling states from trajectories. We conducted an ablation on ID comparing sampling from a relaxation trajectory and interpolating between initial & final positions which found that interpolation improved our score from 0.47 to 0.45.
104
+
105
+ Our best hyperparameter setting was 100 layers which achieved a $9 5 . 6 \%$ relative performance improvement against SOTA results (Table 2) on the AEwT benchmark. Due to limited permitted test submissions, results presented here were from one test upload of our best performing validation seed.
106
+
107
+ IS2RS Results. In Table 4 we see that GNS $^ +$ Noisy Nodes is significantly better than the only other reported IS2RS direct result, ForceNet, itself a GNS variant.
108
+
109
+ Table 3: OC20 IS2RS Validation, ADwT, ↑
110
+
111
+ <table><tr><td>Model</td><td>Layers</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>GNS</td><td>50</td><td>43.0%±0.0</td><td>38.0%±0.0</td><td>37.5% 0.0</td><td>40.0%±0.0</td></tr><tr><td>GNS + Noisy Nodes</td><td>50</td><td>50.1%±0.0</td><td>44.3%±0.0</td><td>44.1%±0.0</td><td>46.1% ±0.0</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>50</td><td>52.0%±0.0</td><td>46.2%±0.0</td><td>46.1% ±0.0</td><td>48.3% ±0.0</td></tr><tr><td>GNS-10 + Noisy Nodes + Pos only</td><td>100</td><td>54.3%±0.0</td><td>48.3%±0.0</td><td>48.2% ±0.0</td><td>50.0% ±0.0</td></tr></table>
112
+
113
+ Table 4: OC20 IS2RS Test, ADwT, ↑
114
+
115
+ <table><tr><td>Model</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>ForceNet</td><td>46.9%</td><td>37.7%</td><td>43.7%</td><td>44.9%</td></tr><tr><td>GNS + Noisy Nodes</td><td> 52.7%</td><td>43.9%</td><td>48.4%</td><td> 50.9%</td></tr><tr><td>Relative Improvement</td><td>+12.4%</td><td>+16.4%</td><td>+10.7%</td><td>+13.3%</td></tr></table>
116
+
117
+ # 6.2 QM9
118
+
119
+ Dataset. The QM9 benchmark (Ramakrishnan et al., 2014) contains $1 3 4 \mathrm { k }$ molecules in equilibrium with up to 9 heavy C, O, N and F atoms, targeting 12 associated chemical properties (License: CCBY 4.0). We use 114k molecules for training, 10k for validation and 10k for test. All results are on the test set. We subtract a fixed per atom energy from the target values computed from linear regression to reduce variance. We perform training in $\mathbf { e V }$ units for energetic targets, and evaluate using MAE. We summarise the results across the targets using mean standardised MAE (std. MAE) in which MAEs are normalised by their standard deviation, and mean standardised logMAE. Std. MAE is dominated by targets with high relative error such as $\Delta \epsilon$ , whereas logMAE is sensitive to outliers such as $\left. R ^ { 2 } \right.$ . As is standard for this dataset, a model is trained separately for each target.
120
+
121
+ For this dataset we add I.I.D Gaussian noise with mean zero and $\sigma = 0 . 0 2$ to the input atom positions.
122
+ A denoising autoencoder loss is used.
123
+
124
+ Results In Table 6 we can see that adding Noisy Nodes significantly improves results by $2 3 . 1 \%$ relative for GNS, making it competitive with specialised architectures. To understand the effect of adding a denoising loss, we tried just adding noise and found no where near the same improvement (Table 6).
125
+
126
+ A GNS- $1 0 +$ Noisy Nodes with 30 layers achieves top results on 3 of the 12 targets and comparable performance on the remainder (Table 6). On the std. MAE aggregate metric $\mathrm { G N S + }$ Noisy Nodes performs better than all other reported results, showing that Noisy Nodes can make even a generic model competitive with models hand-crafted for molecular property prediction. The same trend is repeated for an rotation invariant version of this network that uses the principle axes of inertia ordered by eigenvalue as the co-ordinate frame (Table 5).
127
+
128
+ $\left. R ^ { 2 } \right.$ , the electronic spatial extent, is an outlier for GNS + Noisy Nodes. Interestingly, we found that without noise GNS- $^ { 1 0 + }$ Noisy Nodes achieves 0.33 for this target. We speculate that this target is particularly sensitive to noise, and the best noise value for this target would be significantly lower than for the dataset as a whole.
129
+
130
+ Table 5: QM9, Impact of Noisy Nodes on GNS architecture.
131
+
132
+ <table><tr><td></td><td>Layers</td><td>std. MAE</td><td>% Change</td><td>logMAE</td></tr><tr><td>GNS</td><td>10</td><td>1.17</td><td>=</td><td>-5.39</td></tr><tr><td>GNS + Noise But No Node Target</td><td>10</td><td>1.16</td><td>-0.9%</td><td>-5.32</td></tr><tr><td>GNS + Noisy Nodes</td><td>10</td><td>0.90</td><td>-23.1%</td><td>-5.58</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>20</td><td>0.89</td><td>-23.9%</td><td>-5.59</td></tr><tr><td>GNS-1O + Noisy Nodes + Invariance</td><td>30</td><td>0.92</td><td>-21.4%</td><td>-5.57</td></tr><tr><td>GNS-10 + Noisy Nodes</td><td>30</td><td>0.88</td><td>-24.8%</td><td>-5.60</td></tr></table>
133
+
134
+ Table 6: QM9, Test MAE, Mean & Standard Deviation of 3 Seeds Reported.
135
+
136
+ <table><tr><td>Target</td><td>Unit</td><td>SchNet</td><td>E(n)GNN</td><td>DimeNet++</td><td>SphereNet</td><td>PaiNN</td><td>GNS + Noisy Nodes</td></tr><tr><td>μ</td><td>D</td><td>0.033</td><td>0.029</td><td>0.030</td><td>0.027</td><td>0.012</td><td>0.025 ±0.01</td></tr><tr><td>α</td><td>a03</td><td>0.235</td><td>0.071</td><td>0.043</td><td>0.047</td><td>0.045</td><td>0.052 ±0.00</td></tr><tr><td>EHOMO</td><td>meV</td><td>41</td><td>29.0</td><td>24.6</td><td>23.6</td><td>27.6</td><td>20.4 ±0.2</td></tr><tr><td>ELUMO</td><td>meV</td><td>34</td><td>25.0</td><td>19.5</td><td>18.9</td><td>20.4</td><td>18.6 ±0.4</td></tr><tr><td>△</td><td>meV</td><td>63</td><td>48.0</td><td>32.6</td><td>32.3</td><td>45.7</td><td>28.6 ±0.1</td></tr><tr><td>(R²&gt;</td><td>a02</td><td>0.07</td><td>0.11</td><td>0.33</td><td>0.29</td><td>0.07</td><td>0.70 ±0.01</td></tr><tr><td>ZPVE</td><td>meV</td><td>1.7</td><td>1.55</td><td>1.21</td><td>1.12</td><td>1.28</td><td>1.16 ±0.01</td></tr><tr><td>Uo</td><td>meV</td><td>14.00</td><td>11.00</td><td>6.32</td><td>6.26</td><td>5.85</td><td>7.30 ±0.12</td></tr><tr><td>U</td><td>meV</td><td>19.00</td><td>12.00</td><td>6.28</td><td>7.33</td><td>5.83</td><td>7.57 ±0.03</td></tr><tr><td>H</td><td>meV</td><td>14.00</td><td>12.00</td><td>6.53</td><td>6.40</td><td>5.98</td><td>7.43±0.06</td></tr><tr><td>G</td><td>meV cal</td><td>14.00</td><td>12.00</td><td>7.56</td><td>8.0</td><td>7.35</td><td>8.30 ±0.14</td></tr><tr><td>Cv</td><td>molK</td><td>0.033</td><td>0.031</td><td>0.023</td><td>0.022</td><td>0.024</td><td>0.025 ±0.00</td></tr><tr><td>std. MAE</td><td>%</td><td>1.76</td><td>1.22</td><td>0.98</td><td>0.94</td><td>1.00</td><td>0.88</td></tr><tr><td>logMAE</td><td></td><td>-5.17</td><td>-5.43</td><td>-5.67</td><td>-5.68</td><td>-5.85</td><td>-5.60</td></tr></table>
137
+
138
+ Table 7: OGBG-PCQM4M Results
139
+
140
+ <table><tr><td>Model</td><td>Number of Layers</td><td>Using I Noisy Nodes</td><td>MAE</td></tr><tr><td>MPNN + Virtual Node</td><td>16</td><td>Yes</td><td>0.1249 ± 0.0003</td></tr><tr><td>MPNN+Virtual Node</td><td>50</td><td>No</td><td>0.1236 ± 0.0001</td></tr><tr><td>Graphormer (Ying et al., 2021)</td><td>1</td><td>1</td><td>0.1234</td></tr><tr><td>MPNN + Virtual Node</td><td>50</td><td>Yes</td><td>0.1218 ± 0.0001</td></tr></table>
141
+
142
+ # 7 NON-SPATIAL TASKS
143
+
144
+ The previous experiments use the 3D geometries of atoms, and models that operate on 3D points. However, the recipe of adding a denoising auxiliary loss can be applied to other graphs with different types of features. In this section we apply Noisy Nodes to additional datasets with no 3D points, using different GNNs, and show analagous effects to the 3D case. Details of the hyperparameters, models and training details can be found in the appendix.
145
+
146
+ # 7.1 OGBG-PCQM4M
147
+
148
+ This dataset from the OGB benchmarks consists of molecular graphs which consist of bonds and atom types, and no 3D or 2D coordinates. To adapt Noisy Nodes to this setting, we randomly flip node and edge features at a rate of $5 \%$ and add a reconstruction loss. We evaluate Noisy Nodes using an MPNN $^ +$ Virtual Node (Gilmer et al., 2017). The test set is not currently available for this dataset.
149
+
150
+ In Table 7 we see that for this task Noisy Nodes enables a 50 layer MPNN to reach state of the art results. Before adding Noisy Nodes, adding capacity beyond 16 layers did not improve results.
151
+
152
+ # 7.2 OGBG-MOLPCBA
153
+
154
+ The OGBG-MOLPCBA dataset contains molecular graphs with no 3D points, with the goal of classifying 128 biological activities. On the OGBG-MOLPCBA dataset we again use an $\mathbf { M P N N + }$ Virtual Node and random flipping noise. In Figure 4 we see that adding Noisy Nodes improves the performance of the base model, accentuated for deeper networks. Our 16 layer MPNN improved from $2 7 . 6 \% \pm 0 . 0 0 4$ to $2 8 . 1 \% \pm 0 . 0 0 2$ Mean Average Precision (“Mean AP”). Figure 5 demonstrates how Noisy Nodes improves performance during training. Of the reported results, our MPNN is most similar to $\mathrm { G C N ^ { 1 } \Sigma + }$ Virtual Node and $\mathrm { G I N } +$ Virtual Node (Xu et al., 2018) which report results of $2 4 . 2 \% \pm 0 . 0 0 3$ and $2 7 . 0 3 \% \pm 0 . 0 0 3$ respectively. We evaluate alternative methods for oversmoothing, DropNode and DropEdge in Figure 2 and find that Noisy Nodes is more effective at address oversmoothing, although all 3 methods can be combined favourably (results in appendix).
155
+
156
+ ![](images/57ba876e022cd007dd51858c1a902699202bbf32b42279871e90436d20b8f8ca.jpg)
157
+ Figure 4: Adding Noisy Nodes with random flipping of input categories improves the performance of MPNNs, and the effect is accentuated with depth.
158
+
159
+ ![](images/7bfe2ea3e2eda99fc6bd566bd30c775ccfd387055396f4da3a1e2401fb68e4f8.jpg)
160
+ Figure 5: Validation curve comparing with and without noisy nodes. Using Noisy Nodes leads to a consistent improvement.
161
+
162
+ # 7.3 OGBN-ARXIV
163
+
164
+ The above results use models with explicit edge updates, and are reported for graph prediction. To test the effectiveness with Noisy Nodes with GCNs, arguably the simplest and most popular GNN, we use OGBN-ARXIV, a citation network with the goal of predicting the arxiv category of each paper. Adding Noisy Nodes, with noise as input dropout of 0.1, to 4 layer GCN with residual connections improves from $7 2 . 3 9 \% \pm 0 . 0 0 2$ accuracy to $7 2 . 5 2 \% \pm 0 . 0 0 3$ accuracy. A baseline 4 layer GCN on this dataset reports $7 1 . 7 1 \% \pm 0 . 0 0 2$ . The SOTA for this dataset is $7 4 . 3 1 \%$ (Sun & Wu, 2020).
165
+
166
+ # 7.4 LIMITATIONS
167
+
168
+ We have not demonstrated the effectiveness of Noisy Nodes in small data regimes, which may be important for learning from experimental data. The representation learning perspective requires access to a local minimum configuration, which is not the case for all quantum modeling datasets. We have also not demonstrated the combination of Noisy Nodes with more sophisticated 3D molecular property prediction models such as DimeNet++(Klicpera et al., 2020a), such models may require an alternative reconstruction loss to position change, such as pairwise interatomic distances. We leave this to future work.
169
+
170
+ Noisy Nodes requires careful selection of the form of noise, and a balance between the auxiliary and primary losses. This can require hyper parameter tuning, and models can be sensitive to the choice of these parameters. Noisy Nodes has a particular effect for deep GNNs, but depth is not always an advantage. There are situations, for example molecular dynamics, which place a premium on very fast inference time. However even at 3 layers (a comparable depth to alternative architectures) the GNS architecture achieves state of the art validation OC20 IS2RE predictions (Figure 3). Finally, returns diminish as depth increases indicating depth is not the only answer (Table 1).
171
+
172
+ # 8 CONCLUSIONS
173
+
174
+ In this work we present Noisy Nodes, a novel regularisation technique for GNNs with particular focus on 3D molecular property prediction. Noisy nodes helps address common challenges around oversmoothed node representations, shows benefits for GNNs of all depths, but in particular improves performance for deeper GNNs. We demonstrate results on challenging 3D molecular property prediction tasks, and some generic GNN benchmark datasets. We believe these results demonstrate Noisy Nodes could be a useful building block for GNNs for molecular property prediction and beyond.
175
+
176
+ # 9 REPRODUCIBILITY STATEMENT
177
+
178
+ Code for reproducing OGB-PCQM4M results using Noisy Nodes is available on github, and was prepared as part of a leaderboard submission. https://github.com/deepmind/ deepmind-research/tree/master/ogb_lsc/pcq.
179
+
180
+ We provide detailed hyper parameter settings for all our experiments in the appendix, in addition to formulae for computing the encoder and decoder stages of the GNS.
181
+
182
+ # 10 ETHICS STATEMENT
183
+
184
+ Who may benefit from this work? Molecular property prediction with GNNs is a fast-growing area with applications across domains such as drug design, catalyst discovery, synthetic biology, and chemical engineering. Noisy Nodes could aid models applied to these domains. We also demonstrate on OC20 that our direct state prediction approach is nearly as accurate as learned relaxed approaches at a small fraction of the computational cost, which may support material design which requires many predictions.
185
+
186
+ Finally, Noisy Nodes could be adapted and applied to many areas in which GNNs are used—for example, knowledge base completion, physical simulation or traffic prediction.
187
+
188
+ Potential negative impact and reflection. Noisy Nodes sees improved performance from depth, but the training of very deep GNNs could contribute to global warming. Care should be taken when utilising depth, and we note that Noisy Nodes settings can be calibrated at shallow depth.
189
+
190
+ # REFERENCES
191
+
192
+ Brandon M. Anderson, T. Hy, and R. Kondor. Cormorant: Covariant molecular neural networks. In NeurIPS, 2019.
193
+
194
+ Igor Babuschkin, Kate Baumli, Alison Bell, Surya Bhupatiraju, Jake Bruce, Peter Buchlovsky, David Budden, Trevor Cai, Aidan Clark, Ivo Danihelka, Claudio Fantacci, Jonathan Godwin, Chris Jones, Tom Hennigan, Matteo Hessel, Steven Kapturowski, Thomas Keck, Iurii Kemaev, Michael King, Lena Martens, Vladimir Mikulik, Tamara Norman, John Quan, George Papamakarios, Roman Ring, Francisco Ruiz, Alvaro Sanchez, Rosalia Schneider, Eren Sezener, Stephen Spencer, Srivatsan Srinivasan, Wojciech Stokowiec, and Fabio Viola. The DeepMind JAX Ecosystem, 2020. URL http://github.com/deepmind.
195
+
196
+ V. Bapst, T. Keck, Agnieszka Grabska-Barwinska, C. Donner, E. D. Cubuk, S. Schoenholz, A. Obika, Alexander W. R. Nelson, T. Back, D. Hassabis, and P. Kohli. Unveiling the predictive power of static structure in glassy systems. Nature Physics, 16:448–454, 2020.
197
+
198
+ P. Battaglia, Jessica B. Hamrick, V. Bapst, A. Sanchez-Gonzalez, V. Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, A. Santoro, R. Faulkner, Çaglar Gülçehre, H. Song, A. J. Ballard, J. Gilmer, George E. Dahl, Ashish Vaswani, Kelsey R. Allen, Charlie Nash, Victoria Langston, Chris Dyer, N. Heess, Daan Wierstra, P. Kohli, M. Botvinick, Oriol Vinyals, Y. Li, and Razvan Pascanu. Relational inductive biases, deep learning, and graph networks. ArXiv, abs/1806.01261, 2018.
199
+
200
+ Simon Batzner, T. Smidt, L. Sun, J. Mailoa, M. Kornbluth, N. Molinari, and B. Kozinsky. Se(3)- equivariant graph neural networks for data-efficient and accurate interatomic potentials. ArXiv, abs/2101.03164, 2021.
201
+
202
+ Charles M. Bishop. Training with noise is equivalent to tikhonov regularization. Neural Computation, 7:108–116, 1995.
203
+
204
+ James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
205
+
206
+ Michael M Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond euclidean data. IEEE Signal Processing Magazine, 34(4):18–42, 2017.
207
+
208
+ T. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, J. Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, T. Henighan, R. Child, A. Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, J. Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. ArXiv, abs/2005.14165, 2020.
209
+
210
+ Chen Cai and Yusu Wang. A note on over-smoothing for graph neural networks. CoRR, abs/2006.13318, 2020. URL https://arxiv.org/abs/2006.13318.
211
+
212
+ Lowik Chanussot\*, Abhishek Das\*, Siddharth Goyal\*, Thibaut Lavril\*, Muhammed Shuaibi\*, Morgane Riviere, Kevin Tran, Javier Heras-Domingo, Caleb Ho, Weihua Hu, Aini Palizhati, Anuroop Sriram, Brandon Wood, Junwoong Yoon, Devi Parikh, C. Lawrence Zitnick, and Zachary Ulissi. Open catalyst 2020 (oc20) dataset and community challenges. ACS Catalysis, 0(0): 6059–6072, 2020. doi: 10.1021/acscatal.0c04525. URL https://doi.org/10.1021/ acscatal.0c04525.
213
+
214
+ Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. CoRR, abs/1909.03211, 2019. URL http://arxiv.org/abs/1909.03211.
215
+
216
+ Deli Chen, Yankai Lin, W. Li, Peng Li, J. Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In AAAI, 2020.
217
+
218
+ Stefan Chmiela, A. Tkatchenko, H. E. Sauceda, I. Poltavsky, Kristof T. Schütt, and K. Müller. Machine learning of accurate energy-conserving molecular force fields. Science Advances, 3, 2017.
219
+
220
+ George Dasoulas, Ludovic Dos Santos, Kevin Scaman, and Aladin Virmaux. Coloring graph neural networks for node disambiguation. ArXiv, abs/1912.06058, 2019.
221
+
222
+ J. Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
223
+
224
+ Tien Huu Do, Duc Minh Nguyen, Giannis Bekoulis, Adrian Munteanu, and N. Deligiannis. Graph convolutional neural networks with node transition probability-based message passing and dropnode regularization. Expert Syst. Appl., 174:114711, 2021.
225
+
226
+ David Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, Rafael Gómez-Bombarelli, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P. Adams. Convolutional networks on graphs for learning molecular fingerprints. In Proceedings of the 28th International Conference on Neural Information Processing Systems - Volume 2, NIPS’15, pp. 2224–2232, Cambridge, MA, USA, 2015. MIT Press.
227
+
228
+ F. Fuchs, Daniel E. Worrall, Volker Fischer, and M. Welling. Se(3)-transformers: 3d roto-translation equivariant attention networks. ArXiv, abs/2006.10503, 2020.
229
+
230
+ J. Gilmer, S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. ArXiv, abs/1704.01212, 2017.
231
+
232
+ Jonathan Godwin\*, Thomas Keck\*, Peter Battaglia, Victor Bapst, Thomas Kipf, Yujia Li, Kimberly Stachenfeld, Petar Velickovi ˇ c, and Alvaro Sanchez-Gonzalez. Jraph: A library for graph neural ´ networks in jax., 2020. URL http://github.com/deepmind/jraph.
233
+
234
+ Tom Hennigan, Trevor Cai, Tamara Norman, and Igor Babuschkin. Haiku: Sonnet for JAX, 2020. URL http://github.com/deepmind/dm-haiku.
235
+
236
+ Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. ArXiv, abs/2005.00687, 2020a.
237
+
238
+ Weihua Hu, Bowen Liu, Joseph Gomes, M. Zitnik, Percy Liang, V. Pande, and J. Leskovec. Strategies for pre-training graph neural networks. arXiv: Learning, 2020b.
239
+
240
+ Weihua Hu, Matthias Fey, Hongyu Ren, Maho Nakata, Yuxiao Dong, and Jure Leskovec. Ogb-lsc: A large-scale challenge for machine learning on graphs. arXiv preprint arXiv:2103.09430, 2021a.
241
+
242
+ Weihua Hu, Muhammed Shuaibi, Abhishek Das, Siddharth Goyal, Anuroop Sriram, J. Leskovec, Devi Parikh, and C. L. Zitnick. Forcenet: A graph neural network for large-scale quantum calculations. ArXiv, abs/2103.01436, 2021b.
243
+
244
+ John M. Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Zídek, Anna Potapenko, Alex Bridgland, Clemens Meyer, Simon A A Kohl, Andy Ballard, Andrew Cowie, Bernardino RomeraParedes, Stanislav Nikolov, Rishub Jain, Jonas Adler, Trevor Back, Stig Petersen, David A. Reiman, Ellen Clancy, Michal Zielinski, Martin Steinegger, Michalina Pacholska, Tamas Berghammer, Sebastian Bodenstein, David Silver, Oriol Vinyals, Andrew W. Senior, Koray Kavukcuoglu, Pushmeet Kohli, and Demis Hassabis. Highly accurate protein structure prediction with alphafold. Nature, 596:583 – 589, 2021.
245
+
246
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015.
247
+
248
+ Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. CoRR, abs/1609.02907, 2016. URL http://arxiv.org/abs/1609.02907.
249
+
250
+ Johannes Klicpera, Shankari Giri, Johannes T. Margraf, and Stephan Günnemann. Fast and uncertainty-aware directional message passing for non-equilibrium molecules. CoRR, abs/2011.14115, 2020a. URL https://arxiv.org/abs/2011.14115.
251
+
252
+ Johannes Klicpera, Janek Groß, and Stephan Günnemann. Directional message passing for molecular graphs. ArXiv, abs/2003.03123, 2020b.
253
+
254
+ Risi Kondor, Hy Truong Son, Horace Pan, Brandon M. Anderson, and Shubhendu Trivedi. Covariant compositional networks for learning graphs. CoRR, abs/1801.02144, 2018. URL http:// arxiv.org/abs/1801.02144.
255
+
256
+ Kezhi Kong, Guohao Li, Mucong Ding, Zuxuan Wu, Chen Zhu, Bernard Ghanem, G. Taylor, and T. Goldstein. Flag: Adversarial data augmentation for graph neural networks. ArXiv, abs/2010.09891, 2020.
257
+
258
+ Jonas Köhler, Leon Klein, and Frank Noé. Equivariant flows: sampling configurations for multi-body systems with symmetric energies, 2019.
259
+
260
+ G. Li, M. Müller, Ali K. Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 9266–9275, 2019.
261
+
262
+ Guohao Li, C. Xiong, Ali K. Thabet, and Bernard Ghanem. Deepergcn: All you need to train deeper gcns. ArXiv, abs/2006.07739, 2020.
263
+
264
+ Guohao Li, Matthias Müller, Bernard Ghanem, and Vladlen Koltun. Training graph neural networks with 1000 layers. CoRR, abs/2106.07476, 2021. URL https://arxiv.org/abs/2106. 07476.
265
+
266
+ Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
267
+
268
+ Yi Liu, Limei Wang, Meng Liu, Xuan Zhang, Bora Oztekin, and Shuiwang Ji. Spherical message passing for 3d graph networks. arXiv preprint arXiv:2102.05013, 2021.
269
+
270
+ Andreas Loukas. How hard is to distinguish graphs with graph neural networks? arXiv: Learning, 2020.
271
+
272
+ Ryan L. Murphy, Balasubramaniam Srinivasan, Vinayak A. Rao, and Bruno Ribeiro. Relational pooling for graph representations. In ICML, 2019.
273
+ T. Pfaff, Meire Fortunato, Alvaro Sanchez-Gonzalez, and P. Battaglia. Learning mesh-based simulation with graph networks. ArXiv, abs/2010.03409, 2020.
274
+ R. Ramakrishnan, Pavlo O. Dral, M. Rupp, and O. A. von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific Data, 1, 2014.
275
+ Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. The truly deep graph convolutional networks for node classification. CoRR, abs/1907.10903, 2019. URL http://arxiv.org/ abs/1907.10903.
276
+ Alvaro Sanchez-Gonzalez, N. Heess, Jost Tobias Springenberg, J. Merel, Martin A. Riedmiller, R. Hadsell, and P. Battaglia. Graph networks as learnable physics engines for inference and control. ArXiv, abs/1806.01242, 2018.
277
+ Alvaro Sanchez-Gonzalez\*, Jonathan Godwin\*, Tobias Pfaff\*, Rex Ying\*, Jure Leskovec, and Peter Battaglia. Learning to simulate complex physics with graph networks. In Hal Daumé III and Aarti Singh (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 8459–8468. PMLR, 13–18 Jul 2020. URL http://proceedings.mlr.press/v119/sanchez-gonzalez20a.html.
278
+ R. Sato, Makoto Yamada, and Hisashi Kashima. Random features strengthen graph neural networks. In SDM, 2021.
279
+ Victor Garcia Satorras, Emiel Hoogeboom, and Max Welling. E(n) equivariant graph neural networks, 2021.
280
+ Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80, 2009. doi: 10.1109/TNN.2008.2005605.
281
+ Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, A. Tkatchenko, and K. Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In NIPS, 2017.
282
+ Jonathan Shlomi, Peter Battaglia, and Jean-Roch Vlimant. Graph neural networks in particle physics. Machine Learning: Science and Technology, 2(2):021001, Jan 2021. ISSN 2632-2153. doi: 10.1088/2632-2153/abbf9a. URL http://dx.doi.org/10.1088/2632-2153/abbf9a.
283
+ J. Sietsma and Robert J. F. Dow. Creating artificial neural networks that generalize. Neural Networks, 4:67–79, 1991.
284
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. ArXiv, abs/1907.05600, 2019.
285
+ Chuxiong Sun and Guoshi Wu. Adaptive graph diffusion networks with hop-wise attention. ArXiv, abs/2012.15024, 2020.
286
+ Shantanu Thakoor, C. Tallec, M. G. Azar, R. Munos, Petar Velivckovi’c, and Michal Valko. Bootstrapped representation learning on graphs. ArXiv, abs/2102.06514, 2021.
287
+ Nathaniel Thomas, Tess Smidt, Steven M. Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation- and translation-equivariant neural networks for 3d point clouds. CoRR, abs/1802.08219, 2018. URL http://arxiv.org/abs/1802.08219.
288
+ Oliver T. Unke and Markus Meuwly. Physnet: A neural network for predicting energies, forces, dipole moments, and partial charges. Journal of Chemical Theory and Computation, 15(6):3678–3693, May 2019. ISSN 1549-9626. doi: 10.1021/acs.jctc.9b00181. URL http://dx.doi.org/10. 1021/acs.jctc.9b00181.
289
+ Ashish Vaswani, Noam M. Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. ArXiv, abs/1706.03762, 2017.
290
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua ´ Bengio. Graph attention networks, 2018.
291
+ Cl’ement Vignac, Andreas Loukas, and Pascal Frossard. Building powerful and equivariant graph neural networks with structural message-passing. arXiv: Learning, 2020.
292
+ Pascal Vincent. A connection between score matching and denoising autoencoders. Neural Computation, 23:1661–1674, 2011.
293
+ Pascal Vincent, H. Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In ICML ’08, 2008.
294
+ Pascal Vincent, H. Larochelle, Isabelle Lajoie, Yoshua Bengio, and Pierre-Antoine Manzagol. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. J. Mach. Learn. Res., 11:3371–3408, 2010.
295
+ Zonghan Wu, Shirui Pan, Fengwen Chen, Guodong Long, Chengqi Zhang, and S Yu Philip. A comprehensive survey on graph neural networks. IEEE transactions on neural networks and learning systems, 2020.
296
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? CoRR, abs/1810.00826, 2018. URL http://arxiv.org/abs/1810.00826.
297
+ Chaoqi Yang, Ruijie Wang, Shuochao Yao, Shengzhong Liu, and Tarek Abdelzaher. Revisiting" over-smoothing" in deep gcns. arXiv preprint arXiv:2003.13663, 2020.
298
+ Chengxuan Ying, Tianle Cai, Shengjie Luo, Shuxin Zheng, Guolin Ke, Di He, Yanming Shen, and Tie-Yan Liu. Do transformers really perform bad for graph representation? ArXiv, abs/2106.05234, 2021.
299
+ Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. ArXiv, abs/2010.13902, 2020.
300
+ L. Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. ArXiv, abs/1909.12223, 2020.
301
+ Jie Zhou, Ganqu Cui, Shengding Hu, Zhengyan Zhang, Cheng Yang, Zhiyuan Liu, Lifeng Wang, Changcheng Li, and Maosong Sun. Graph neural networks: A review of methods and applications. AI Open, 1:57–81, 2020a.
302
+ Kuangqi Zhou, Yanfei Dong, Wee Sun Lee, Bryan Hooi, Huan Xu, and Jiashi Feng. Effective training strategies for deep graph neural networks. CoRR, abs/2006.07107, 2020b. URL https: //arxiv.org/abs/2006.07107.
303
+
304
+ # A APPENDIX
305
+
306
+ The following sections include details on training setup, hyper-parameters, input processing, as well as additional experimental results.
307
+
308
+ # A.1 ADDITIONAL METRICS FOR OPEN CATALYST IS2RS TEST SET
309
+
310
+ Relaxation approaches to IS2RS minimise forces with respect to positions, with the expectation that forces at the minimum are close to zero. One metric of such a model’s success is to evaluate the forces at the converged structure using ground truth Density Functional Theory calculations and see how close they are to zero. Two metrics are provided by OC20 (Chanussot\* et al., 2020) on the IS2RS test set: Force below Threshold (FbT), which is the percentage of structures that have forces below 0.05 eV/Angstrom, and Average Force below Threshold (AFbT) which is FbT calculated at multiple thresholds.
311
+
312
+ The OC20 project computes test DFT calculations on the evaluation server and presents a summary result for all IS2RS position predictions. Such calculations take 10-12 hours and they are not available for the validation set. Thus, we are not able to analyse the results in Tables 8 and 9 in any further detail. Before application to catalyst screening further work may be needed for direct approaches to ensure forces do not explode from atoms being too close together.
313
+
314
+ Table 8: OC20 IS2RS Test, Average Force below Threshold $\%$ , ↑
315
+
316
+ <table><tr><td>Model</td><td>Method</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>Noisy Nodes</td><td>Direct</td><td>0.09%</td><td>0.00%</td><td>0.29%</td><td>0.54%</td></tr></table>
317
+
318
+ Table 9: OC20 IS2RS Test, Force below Threshold %, ↑
319
+
320
+ <table><tr><td>Model</td><td>Method</td><td>OOD Both</td><td>OOD Adsorbate</td><td>OOD Catalyst</td><td>ID</td></tr><tr><td>Noisy Nodes</td><td>Direct</td><td>0.0%</td><td>0.0%</td><td>0.0%</td><td>0.0%</td></tr></table>
321
+
322
+ A.2 MORE DETAILS ON GNS ADAPTATIONS FOR MOLECULAR PROPERTY PREDICTION.
323
+
324
+ # Encoder.
325
+
326
+ The node features are a learned embedding lookup of the atom type, and in the case of OC20 two additional binary features representing whether the atom is part of the adsorbate or catalyst and whether the atom remains fixed during the quantum chemistry simulation.
327
+
328
+ The edge features, $e _ { k }$ are the distances $| d |$ featurised using $c$ Radial Bessel basis functions, $\tilde { e } _ { R B F , c } =$ ${ \sqrt { \frac { 2 } { R } } } { \frac { \sin ( { \frac { c \pi } { R } } d ) } { d } }$ , and the edge vector displacements, $d$ , normalised by the edge distance:
329
+
330
+ $$
331
+ e _ { k } = { \mathrm { C o n c a t } } ( { \tilde { e } } _ { R B F , 1 } ( | d | ) , . . . , { \tilde { e } } _ { R B F , c } ( | d | ) , \frac { d } { | d | } )
332
+ $$
333
+
334
+ Our conversion to fractional coordinates only applied to the vector quantities, i.e. $\frac { d } { | d | }$
335
+
336
+ # Decoder
337
+
338
+ The decoder consists of two parts, a graph-level decoder which predicts a single output for the input graph, and a node-level decoder which predicts individual outputs for each node. The graph-level decoder implements the following equation:
339
+
340
+ $$
341
+ y = W ^ { \mathrm { P r o c } } \sum _ { i = 1 } ^ { | V | } \mathrm { M L P } _ { \mathrm { P r o c } } ( a _ { i } ^ { \mathrm { P r o c } } ) + b ^ { \mathrm { P r o c } } + W ^ { \mathrm { E n c } } \sum _ { i = 1 } ^ { | V | } \mathrm { M L P } _ { \mathrm { E n c } } ( a _ { i } ^ { \mathrm { E n c } } ) + b ^ { \mathrm { E n c } }
342
+ $$
343
+
344
+ Where $a _ { i } ^ { \mathrm { P r o c } }$ are node latents from the Processor, $a _ { i } ^ { \mathrm { E n c } }$ are node latents from the Encoder, $W ^ { \mathrm { E n c } }$ and $W ^ { \mathrm { P r o c } }$ are linear layers, $b ^ { \mathrm { E n c } }$ and $b ^ { \mathrm { P r o c } }$ are biases, and $| V |$ is the number of nodes. The node-level decoder is simply an MLP applied to each $a _ { i } ^ { \mathrm { P r o c } }$ which predicts $a _ { i } ^ { \Delta }$ .
345
+
346
+ # A.3 MORE DETAILS ON MPNN FOR OGBG-PCQM4M AND OGBG-MOLPCBA
347
+
348
+ Our MPNN follows the blueprint of Gilmer et al. (2017). We use $\vec { h } _ { v } ^ { ( t ) }$ to denote the latent vector of node $v$ at message passing step $t$ , and $\vec { m } _ { u v } ^ { ( t ) }$ to be the computed message vector for the edge between nodes $u$ and $v$ at message passing step $t$ . We define the update functions as:
349
+
350
+ $$
351
+ \begin{array} { l } { { \displaystyle { \vec { m } } _ { u v } ^ { ( t + 1 ) } = \psi _ { t + 1 } \left( { \vec { h } } _ { u } ^ { ( t ) } , { \vec { h } } _ { v } ^ { ( t ) } , { \vec { m } } _ { u v } ^ { ( t ) } + { \vec { m } } _ { u v } ^ { ( t - 1 ) } \right) } } \\ { { \displaystyle { \vec { h } } _ { u } ^ { ( t + 1 ) } = \phi _ { t + 1 } \left( \vec { h } _ { u } ^ { ( t ) } , \sum _ { u \in \mathcal { N } _ { v } } { \vec { m } } _ { v u } ^ { ( t + 1 ) } , \sum _ { v \in \mathcal { N } _ { u } } { \vec { m } } _ { u v } ^ { ( t + 1 ) } \right) + { \vec { h } } _ { u } ^ { t } } } \end{array}
352
+ $$
353
+
354
+ Where the message function $\psi _ { t + 1 }$ and the update function $\phi _ { t + 1 }$ are MLPs. We use a “Virtual Node” which is connected to all other nodes to enable long range communication. Out readout function is an MLP. No spatial features are used.
355
+
356
+ ![](images/c7eaa426764d4dbb01365e7083e172b81b885cc891f5b42cdc12a2b5286b2fcf.jpg)
357
+ Figure 6: GNS Unsorted MAD per Layer Averaged Over 3 Random Seeds. Evidence of oversmoothing is clear. Model trained on QM9.
358
+
359
+ ![](images/eef81f0e6873634d5070ad73ccea49c007d1978eea1981e9416189db3816b3be.jpg)
360
+ Figure 7: GNS Sorted MAD per Layer Averaged Over 3 Random Seeds. The trend is clearer when the MAD values have been sorted. Model trained on QM9.
361
+
362
+ # A.4 EXPERIMENT SETUP FOR 3D MOLECULAR MODELING
363
+
364
+ Open Catalyst. All training experiments were ran on a cluster of TPU devices. For the Open Catalyst experiments, each individual run (i.e. a single random seed) utilised 8 TPU devices on 2 hosts (4 per host) for training, and 4 V100 GPU devices for evaluation (1 per dataset).
365
+
366
+ Each Open Catalyst experiment was ran until convergence for up to 200 hours. Our best result, the large 100 layer model requires 7 days of training using the above setting. Each configuration was run at least 3 times in this hardware configuration, including all ablation settings.
367
+
368
+ We further note that making effective use of our regulariser requires sweeping noise values. These sweeps are dataset dependent and can be carried out using few message passing steps.
369
+
370
+ QM9. Experiments were also run on TPU devices. Each seed was run using 8 TPU devices on a single host for training, and 2 V100 GPU devices for evaluation. QM9 targets were trained between 12-24 hours per experiment.
371
+
372
+ Following Klicpera et al. (2020b) we define std. MAE as :
373
+
374
+ $$
375
+ \mathrm { s t d . ~ } \mathrm { M A E } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \left( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \frac { | f _ { \theta } ^ { ( m ) } ( X _ { i } , z _ { i } ) - \hat { t } _ { i } ^ { ( m ) } | } { \sigma _ { m } } \right)
376
+ $$
377
+
378
+ and logMAE as:
379
+
380
+ $$
381
+ \log \mathrm { M A E } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \log \left( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \frac { | f _ { \theta } ^ { ( m ) } ( X _ { i } , z _ { i } ) - \hat { t } _ { i } ^ { ( m ) } | } { \sigma _ { m } } \right)
382
+ $$
383
+
384
+ with target index $m$ , number of targets $M = 1 2$ , dataset size $N$ , ground truth values $\hat { t } ^ { ( m ) }$ , model $f _ { \theta } ^ { ( m ) }$ , inputs $X _ { i }$ and $z _ { i }$ , and standard deviation $\sigma _ { m }$ of $\hat { t } ^ { ( m ) }$ .
385
+
386
+ # A.5 OVER SMOOTHING ANALYSIS FOR GNS
387
+
388
+ In addition to Figure 2, we repeat the analysis with a mean MAD over 3 seeds 7. Furthermore we remove the sorting layer by MAD value and find the trend holds.
389
+
390
+ # A.6 NOISE ABLATIONS FOR OGBG-MOLPCBA
391
+
392
+ We conduct a noise ablation on the random flipping noise for OGBG-MOLPCBA with an 8 layer MPNN $^ +$ Virtual Node, and find that our model is not very sensitive to the noise value (Table 10), but degrades from 0.1.
393
+
394
+ Table 10: OGBG-MOLPCBA Noise Ablation
395
+
396
+ <table><tr><td>Flip Probability</td><td>Mean AP</td></tr><tr><td>0.01</td><td>27.8% +- 0.002</td></tr><tr><td>0.03</td><td>27.9% +- 0.003</td></tr><tr><td>0.05</td><td>28.1% +- 0.001</td></tr><tr><td>0.1</td><td>28.0% +- 0.003</td></tr><tr><td>0.2</td><td>27.7% +- 0.002</td></tr></table>
397
+
398
+ Table 11: OGBG-MOLPCBA DropEdge Ablation
399
+
400
+ <table><tr><td></td><td>Mean AP</td></tr><tr><td>MPNN Without DropEdge</td><td>27.4% ± 0.002</td></tr><tr><td>MPNN With DropEdge</td><td>27.5% ± 0.001</td></tr><tr><td>MPNN + DropEdge + Noisy Nodes</td><td>27.8% ± 0.002</td></tr></table>
401
+
402
+ A.7 DROPEDGE & DROPNODE ABLATIONS FOR OGBG-MOLPCBA
403
+
404
+ We conduct an ablation with our 16 layer MPNN using DropEdge at a rate of 0.1 as an alternative approach to improving oversmoothing and find it does not improve performance for ogbg-molpcba (Table 11), similarly we find DropNode (Table 12) does not improve performance. In addition, we find that these two methods can’t be combined well together, reaching a performance of $2 7 . 0 \% \pm$ 0.003. However, both methods can be combined advantageously with Noisy Nodes.
405
+
406
+ We also measure the MAD of the node latents for each layer and find the indeed Noisy Nodes is more effective at addressing oversmoothing in Figure 8.
407
+
408
+ A.8 TRAINING CURVES FOR OC20 NOISY NODES ABLATIONS DEMONSTRATING OVERFITTING
409
+
410
+ Figure 9
411
+
412
+ Table 12: OGBG-MOLPCBA DropNode Ablation
413
+
414
+ <table><tr><td>一</td><td>Mean AP</td></tr><tr><td>MPNN With DropNode</td><td>27.5% ± 0.001</td></tr><tr><td>MPNN Without DropNode</td><td>27.5% ± 0.004</td></tr><tr><td>MPNN + DropNode + Noisy Nodes</td><td>28.2% ±0.005</td></tr></table>
415
+
416
+ ![](images/0f0f48f21c0bc15b691e20d800d9179b61b0e2909b24b9c5cd2fcdafc6808e86.jpg)
417
+ Figure 8: Comparison of the effect of techniques to address oversmoothing on MPNNs. Whilst Some effect can be seen from DropEdge and DropNode, Noisy Nodes is significantly better at preserving per node diversity.
418
+
419
+ A.9 PSEUDOCODE FOR 3D MOLECULAR PREDICTION TRAINING STEP
420
+
421
+ <table><tr><td>Algorithm 1: Noisy Nodes Training Step</td></tr><tr><td>G=(V,E,g) // Input graph</td></tr><tr><td>G=G// Initialize noisy graph λ// Noisy Nodes Weight</td></tr><tr><td>if not_provided(V&#x27;) then</td></tr><tr><td>-V←V end</td></tr><tr><td>if predict_differences then</td></tr><tr><td> △={u&#x27;- vili ∈1,...,|Vl}</td></tr><tr><td>end for each i∈1,...,|V| do</td></tr><tr><td></td></tr><tr><td>Oi = sample_node_noise(shape_of(ui));</td></tr><tr><td>Vi=Ui+Oi;</td></tr><tr><td>if predict_differences then</td></tr><tr><td>△i=△i-Oi;</td></tr><tr><td>end</td></tr><tr><td>endfor</td></tr><tr><td></td></tr><tr><td>E = recompute_edges(V);</td></tr><tr><td>G&#x27; = GNN(G);</td></tr><tr><td></td></tr><tr><td>if predict_differences then</td></tr><tr><td>V&#x27;=△i;</td></tr><tr><td>end</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td>Loss = λ NoisyNodesLoss(G&#x27;, V&#x27;) + PrimaryLos(G&#x27;, V/&#x27;); Loss.minimise()</td></tr></table>
422
+
423
+ ![](images/8c69d25563ff26c9fdb7456b6c7e432192e7ec9d31f1d6f84b386ea31a771df0.jpg)
424
+ Figure 9: Training curves to accompany Figure 3. This demonstrates that even as the validation performance is getting worse, training loss is going down, indicating overfitting.
425
+
426
+ Table 13: Open Catalyst training parameters.
427
+
428
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>5e5</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>5e6</td></tr><tr><td>Loss type</td><td>Mean squared error</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>1024</td></tr><tr><td>Max edges in batch</td><td>12800</td></tr><tr><td>Max graphs in batch</td><td>10</td></tr><tr><td>MLP number of layers</td><td>3</td></tr><tr><td>MLP hidden sizes</td><td>512</td></tr><tr><td>Number Bessel Functions</td><td>512</td></tr><tr><td>Activation</td><td>shifted softplus</td></tr><tr><td>message passing layers</td><td>50</td></tr><tr><td>Group size</td><td>10</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Position noise</td><td>Gaussian (μ = O,σ = 0.3)</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.9999</td></tr><tr><td>Position Loss Co-efficient</td><td>1.0</td></tr></table>
429
+
430
+ # A.10 TRAINING DETAILS
431
+
432
+ Our code base is implemented in JAX using Haiku and Jraph for GNNs, and Optax for training (Bradbury et al., 2018; Babuschkin et al., 2020; Godwin\* et al., 2020; Hennigan et al., 2020). Model selection used early stopping.
433
+
434
+ All results reported as an average of 10 random seeds. OGBG-PCQM4M & OGBG-MOLPCBA were trained with 16 TPUs and evaluated with a single V100 GPU. OGBN-Arxiv was trained and evalated with a single TPU
435
+
436
+ # 3D Molecular Prediction
437
+
438
+ We minimise the mean squared error loss on mean and standard deviation normalised targets and use the Adam (Kingma & Ba, 2015) optimiser with warmup and cosine decay. For OC20 IS2RE energy prediction we subtract a learned reference energy, computed using an MLP with atom types as input.
439
+
440
+ For the GNS model the node and edge latents as well as MLP hidden layers were sized 512, with 3 layers per MLP and using shifted softplus activations throughout. OC20 & QM9 Models were trained on 8 TPU devices and evaluated on a single V100 GPUs. We provide the full set of hyper-parameters and computational resources used separately for each dataset in the Appendix. All noise levels were determined by sweeping a small range of values $( \approx 1 0 )$ ) informed by the noised feature covariance.
441
+
442
+ # Non Spatial Tasks
443
+
444
+ # A.11 HYPER-PARAMETERS
445
+
446
+ Open Catalyst. We list the hyper-parameters used to train the default Open Catalyst experiment. If not specified otherwise (e.g. in ablations of these parameters), experiments were ran with this configuration.
447
+
448
+ Table 14: QM9 training parameters.
449
+
450
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>1e4</td></tr><tr><td>Warm up start learning rate</td><td>3e-7</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>2e6</td></tr><tr><td>Loss type</td><td>Mean squared error</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>256</td></tr><tr><td>Max edges in batch</td><td>4096</td></tr><tr><td>Max graphs in batch</td><td>8</td></tr><tr><td>MLP number of layers</td><td>3</td></tr><tr><td>MLPhidden sizes</td><td>1024</td></tr><tr><td>Number Bessel Funtions</td><td>512</td></tr><tr><td>Activation</td><td>shifted softplus</td></tr><tr><td>message passing layers</td><td>10</td></tr><tr><td>Group Size</td><td>10</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Position noise</td><td>Gaussian (μ= O,σ = 0.02)</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.9999</td></tr><tr><td>Position Loss Coefficient</td><td>0.1</td></tr></table>
451
+
452
+ Dynamic batch sizes refers to constructing batches by specifying maximum node, edge and graph counts (as opposed to only graph counts) to better balance computational load. Batches are constructed until one of the limits is reached.
453
+
454
+ Parameter updates were smoothed using an EMA for the current training step with the current decay value computed through $d e c a y = m \bar { i } n ( d e c a y , ( 1 . 0 + s t e p ) / ( 1 0 . 0 + \bar { s t e p } )$ . As discussed in the evaluation, best results on Open Catalyst were obtained by utilising a 100 layer network with group size 10.
455
+
456
+ QM9 Table 14 lists QM9 hyper-parameters which primarily reflect the smaller dataset and geometries with fewer long range interactions. For $U _ { 0 }$ , $U$ , $H$ and $G$ we use a slightly larger number of graphs per batch - 16 - and a smaller position loss co-efficient of 0.01.
457
+
458
+ OGBG-PCQM4M Table 15 provides the hyper parameters for OGBG-PCQM4M.
459
+
460
+ OGBG-MOLPCBA Table 16 provides the hyper parameters for the OGBG-MOLPCBA experiments
461
+
462
+ OGBN-ARXIV Table 17 provides the hyper parameters for the OGBN-Arxiv experiments.
463
+
464
+ Table 15: OGBG-PCQM4M Training Parameters.
465
+
466
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β1</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>5e4</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>5e5</td></tr><tr><td>Loss type</td><td>Mean absolute error</td></tr><tr><td>Reconstruction type</td><td>Softmax Cross Entropy</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>20,480</td></tr><tr><td>Max edges in batch</td><td>8,192</td></tr><tr><td>Max graphs in batch</td><td>512</td></tr><tr><td>MLP number of layers</td><td>2</td></tr><tr><td>MLP hidden sizes</td><td>512</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Noisy Nodes Category Flip Fate</td><td>0.05</td></tr><tr><td>Parameter update</td><td>Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.999</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
467
+
468
+ Table 16: OGBG-MOLPCBA Training Parameters.
469
+
470
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser β</td><td>Adam with warm up and cosine cycling 0.9</td></tr><tr><td>β2</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>1e4</td></tr><tr><td></td><td></td></tr><tr><td>Warm up start learning rate</td><td>1e-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>le-4</td></tr><tr><td>Cosine cycle length</td><td>1e5</td></tr><tr><td>Loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Reconstruction loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Batch size</td><td>Dynamic to max edge/node/graph count</td></tr><tr><td>Max nodes in batch</td><td>20,480</td></tr><tr><td>Max edges in batch</td><td>8,192</td></tr><tr><td>Max graphs in batch</td><td>512</td></tr><tr><td></td><td>2</td></tr><tr><td>MLP number of layers MLP hidden sizes</td><td>512</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>BatchNormalization</td><td>Yes,after every hidden layer</td></tr><tr><td>Node/Edge latent vector sizes</td><td>512</td></tr><tr><td>Dropnode Rate</td><td></td></tr><tr><td></td><td>0.1 0.1</td></tr><tr><td>Dropout Rate</td><td></td></tr><tr><td>Noisy Nodes Category Flip Fate Parameter update</td><td>0.05 Exponentially moving average (EMA) smoothing</td></tr><tr><td>EMA decay</td><td>0.999</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
471
+
472
+ Table 17: OGBG-ARXIV Training Parameters.
473
+
474
+ <table><tr><td>Parameter</td><td>Value or description</td></tr><tr><td>Optimiser</td><td>Adam with warm up and cosine cycling</td></tr><tr><td>β</td><td>0.9</td></tr><tr><td>β</td><td>0.95</td></tr><tr><td>Warm up steps</td><td>50</td></tr><tr><td>Warm up start learning rate</td><td>le-5</td></tr><tr><td>Warm up/cosine max learning rate</td><td>1e-3</td></tr><tr><td>Cosine cycle length</td><td>12,000</td></tr><tr><td>Loss type</td><td>Softmax Cross Entropy</td></tr><tr><td>Reconstruction loss type</td><td>Mean Squared Error</td></tr><tr><td>Batch size</td><td>Full graph</td></tr><tr><td>MLP number of layers</td><td>1</td></tr><tr><td>Activation</td><td>relu</td></tr><tr><td>Batch Normalization</td><td>Yes,after every hidden layer</td></tr><tr><td>Node/Edge latent vector sizes</td><td>256</td></tr><tr><td>Dropout Rate</td><td>0.5</td></tr><tr><td>Noisy Nodes Input Dropout</td><td>0.05</td></tr><tr><td>Reconstruction Loss Coefficient</td><td>0.1</td></tr></table>
md/dev/2EDqbSCnmF/2EDqbSCnmF.md ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Any-to-Any Generation via Composable Diffusion
2
+
3
+ # Zineng Tang1∗
4
+
5
+ # Mohit Bansal1†
6
+
7
+ Ziyi Yang2† Chenguang ${ \bf Z } { \bf h } { \bf u } ^ { 2 \ddagger }$ Michael Zeng2 1University of North Carolina at Chapel Hill 2Microsoft Azure Cognitive Services Research https://codi-gen.github.io
8
+
9
+ # Abstract
10
+
11
+ We present Composable Diffusion (CoDi), a novel generative model capable of generating any combination of output modalities, such as language, image, video, or audio, from any combination of input modalities. Unlike existing generative AI systems, CoDi can generate multiple modalities in parallel and its input is not limited to a subset of modalities like text or image. Despite the absence of training datasets for many combinations of modalities, we propose to align modalities in both the input and output space. This allows CoDi to freely condition on any input combination and generate any group of modalities, even if they are not present in the training data. CoDi employs a novel composable generation strategy which involves building a shared multimodal space by bridging alignment in the diffusion process, enabling the synchronized generation of intertwined modalities, such as temporally aligned video and audio. Highly customizable and flexible, CoDi achieves strong joint-modality generation quality, and outperforms or is on par with the unimodal state-of-the-art for single-modality synthesis. The project page with demonstrations and code is at https://codi-gen.github.io/
12
+
13
+ ![](images/f6d7a60ecba1b89ddec9c2b8b8bfea37a1e8ff89e67fccf04a7b8dcb4427834d.jpg)
14
+ Figure 1: CoDi can generate various (joint) combinations of output modalities from diverse (joint) sets of inputs: video, image, audio, and text (example combinations depicted by the colored arrows).
15
+
16
+ # 1 Introduction
17
+
18
+ Recent years have seen the rise of powerful cross-modal models that can generate one modality from another, e.g. text-to-text [6, 37], text-to-image [13, 19, 22, 41, 44], or text-to-audio [23, 33]. However, these models are restricted in their real-world applicability where multiple modalities coexist and interact. While one can chain together modality-specific generative models in a multi-step generation setting, the generation power of each step remains inherently limited, and a serial, multistep process can be cumbersome and slow. Moreover, independently generated unimodal streams will not be consistent and aligned when stitched together in a post-processing way (e.g., synchronized video and audio). The development of a comprehensive and versatile model that can generate any combination of modalities from any set of input conditions has been eagerly anticipated, as it would more accurately capture the multimodal nature of the world and human comprehension, seamlessly consolidate information from a wide range of sources, and enable strong immersion in human-AI interactions (for example, by generating coherent video, audio, and text description at the same time).
19
+
20
+ In pursuit of this goal, we propose Composable Diffusion, or CoDi, the first model capable of simultaneously processing and generating arbitrary combinations of modalities as shown in Fig. 1. Training a model to take any mixture of input modalities and flexibly generate any mixture of outputs presents significant computational and data requirements, as the number of combinations for the input and output modalities scales exponentially. Also aligned training data for many groups of modalities is scarce or even non-existent, making it infeasible to train with all possible input-output combinations. To address this challenge, we propose to align multiple modalities in both the input conditioning (Section 3.2) and generation diffusion step (Section 3.4). Furthermore, a proposed “Bridging Alignment” strategy for contrastive learning (Section 3.2) allows us to efficiently model the exponential number of input-output combinations with a linear number of training objectives.
21
+
22
+ Building a model with any-to-any generation capacity with exceptional generation quality requires comprehensive model design and training on diverse data resources. Therefore, we build CoDi in an integrative way. First, we train a latent diffusion model (LDM) for each modality, e.g., text, image, video, and audio. These models can be trained in parallel independently, ensuring exceptional singlemodality generation quality using widely available modality-specific training data (i.e., data with one or more modalities as input and one modality as output). For conditional cross-modality generation, such as generating images using audio+language prompts, the input modalities are projected into a shared feature space (Section 3.2), and the output LDM attends to the combination of input features. This multimodal conditioning mechanism prepares the diffusion model to condition on any modality or combination of modalities without directly training for such settings.
23
+
24
+ The second stage of training enables the model to handle many-to-many generation strategies that involve simultaneously generating arbitrary combinations of output modalities. To the best of our knowledge, CoDi is the first AI model with this capability. This is achieved by adding a crossattention module to each diffuser, and an environment encoder $V$ to project the latent variable of different LDMs into a shared latent space (Section 3.4). Next, we freeze the parameters of the LDM, training only the cross-attention parameters and $V$ . Since the environment encoder of different modalities are aligned, an LDM can cross-attend with any group of co-generated modalities by interpolating the representation’s output by $V$ . This enables CoDi to seamlessly generate any group of modalities, without training on all possible generation combinations. This reduces the number of training objectives from exponential to linear.
25
+
26
+ We demonstrate the any-to-any generation capability of CoDi, including single-to-single modality generation, multi-condition generation, and the novel capacity of joint generation of multiple modalities. For example, generating synchronized video and audio given the text input prompt; or generating video given a prompt image and audio. We also provide a quantitative evaluation of CoDi using eight multimodal datasets. As the latest work from Project i-Code [55] towards Composable AI, CoDi exhibits exceptional generation quality across assorted scenarios, with synthesis quality on par or even better than single to single modality SOTA, e.g., audio generation and audio captioning.
27
+
28
+ # 2 Related Works
29
+
30
+ Diffusion models (DMs) learn the data distribution by denoising and recovering the original data. Deep Diffusion Process (DDP) [45] adopts a sequence of reversible diffusion steps to model image probability distribution. It uses a reversible encoder to map the input image to a latent space and a decoder to map the latent variables to an output image. Denoising diffusion probabilistic model (DDPM) [20] uses a cascade of diffusion processes to gradually increase the complexity of the probability density function model. At each step, the model adds noise to the input image and estimates the corresponding noise level using an autoregressive model. This allows the model to capture the dependencies between adjacent pixels and generate high-quality images. Score-based generative models (SOG) [46] use the score function to model the diffusion process. [40] generates high-fidelity images conditioned on CLIP representations of text prompts. Latent diffusion model (LDM) [41] uses a VAE to encode inputs into latent space to reduce modeling dimension and improves efficiency. The motivation is that image compression can be separated into semantic space by a diffusion model and perceptual space by an autoencoder. By incorporating temporal modeling modules and cascading model architectures, video diffusion models have been built upon image diffusers to generate temporally consistent and inherent frames[14, 19, 21, 44]. Diffusion models have also been applied to other domains, such as generating audio from text and vision prompts[23, 33].
31
+
32
+ ![](images/fd34f6f54041b6f9329e8b6d950176f23a2bd0ce1819fa8d9711a4b7d903ec66.jpg)
33
+ Figure 2: CoDi model architecture: (a) We first train individual diffusion model with aligned prompt encoder by “Bridging Alignment”; (b) Diffusion models learn to attend with each other via “Latent Alignment”; (c) CoDi achieves any-to-any generation with a linear number of training objectives.
34
+
35
+ Multimodal modeling has experienced rapid advancement recently, with researchers striving to build uniform representations of multiple modalities using a single model to achieve more comprehensive cross-modal understanding. Vision transformers [11], featuring diverse model architectures and training techniques, have been applied to various downstream tasks such as vision Q&A and image captioning. Multimodal encoders have also proven successful in vision-language [1, 8, 57], videoaudio [47] and video-speech-language [55, 56] domains. Aligning data from different modalities is an active research area [12, 38], with promising applications in cross-modality retrieval and building uniform multimodal representations [33, 35, 41].
36
+
37
+ # 3 Methodology
38
+
39
+ # 3.1 Preliminary: Latent Diffusion Model
40
+
41
+ Diffusion models (DM) represent a class of generative models that learn data distributions $p ( { \pmb x } )$ by simulating the diffusion of information over time. During training, random noise is iteratively added to $_ { \textbf { \em x } }$ , while the model learns to denoise the examples. For inference, the model denoises data points sampled from simple distributions such as Gaussian. Latent diffusion models (LDM) [41] learn the distribution of the latent variable $_ { z }$ corresponding to $_ { \textbf { \em x } }$ , significantly reducing computational cost by decreasing the data dimension.
42
+
43
+ In LDM, an autoencoder is first trained to reconstruct $_ { \textbf { \em x } }$ , i.e., $\hat { \pmb { x } } = D ( E ( \pmb { x } ) )$ , where $E$ and $D$ denote the encoder and decoder, respectively. The latent variable $z = E ( { \pmb x } )$ is iteratively diffused over time steps $t$ based on a variance schedule $\beta _ { 1 } , \ldots , \beta _ { T }$ , i.e., $q ( z _ { t } | z _ { t - 1 } ) = \mathcal { N } ( z _ { t } ; \sqrt { 1 - \beta _ { t } } z _ { t - 1 } , \beta _ { t } I )$ [20, 45].
44
+
45
+ The forward process allows the random sampling of ${ \boldsymbol { z } } _ { t }$ at any timestep in a closed form [20, 45]: $\boldsymbol { z } _ { t } = \alpha _ { t } \boldsymbol { z } + \sigma _ { t } \boldsymbol { \epsilon }$ , where $\epsilon \sim \mathcal { N } ( 0 , I )$ , $\alpha _ { t } : = 1 - \beta _ { t }$ and $\begin{array} { r } { \sigma _ { t } : = \dot { 1 } - \prod _ { s = 1 } ^ { t } \dot { \alpha } _ { s } } \end{array}$ . The diffuser learns how to denoise from $\left\{ { z } _ { t } \right\}$ to recover $_ z$ . Following the reparameterization method proposed in [20], the denoising training objective can be expressed as [41]:
46
+
47
+ $$
48
+ \begin{array} { r } { \mathcal { L } _ { D } = \mathbb { E } _ { z , \epsilon , t } \Vert \epsilon - \epsilon _ { \theta } ( z _ { t } , t , C ( \pmb { y } ) ) \Vert _ { 2 } ^ { 2 } . } \end{array}
49
+ $$
50
+
51
+ In data generation, the denoising process can be realized through reparameterized Gaussian sampling:
52
+
53
+ $$
54
+ p ( z _ { t - 1 } | z _ { t } ) = \mathcal { N } \left( z _ { t - 1 } ; \frac { 1 } { \sqrt { \alpha _ { t } } } \left( z _ { t } - \frac { \beta _ { t } } { \sqrt { \sigma _ { t } } } \epsilon _ { \theta } \right) , \beta _ { t } I \right) .
55
+ $$
56
+
57
+ In $\mathcal { L } _ { D }$ , the diffusion time step $t \sim \mathcal { U } [ 1 , T ]$ ; $\epsilon _ { \theta }$ is a denoising model with UNet backbone parameterized by $\theta ; { \boldsymbol { y } }$ represents the conditional variable that can be used to control generation; $C$ is the prompt encoder. The conditioning mechanism is implemented by first featurizing $\textbf { { y } }$ into $C ( \boldsymbol { y } )$ , then the UNet $\epsilon _ { \theta }$ conditions on $C ( \boldsymbol { y } )$ via cross-attention, as described in [41]. Distinct from previous works, our model can condition on any combinations of modalities of text, image, video and audio. Details are presented in the following section.
58
+
59
+ # 3.2 Composable Multimodal Conditioning
60
+
61
+ To enable our model to condition on any combination of input/prompt modalities, we align the prompt encoder of text, image, video and audio (denoted by $C _ { t }$ , $C _ { i }$ , $C _ { v }$ , and $C _ { a }$ , respectively) to project the input from any modality into the same space. Multimodal conditioning can then be conveniently achieved by interpolating the representations of each modality $m$ : $\begin{array} { r } { C ( x _ { t } , \bar { x _ { i } } , x _ { v } , x _ { a } ) = \sum _ { m } \alpha _ { m } C ( \bar { m } ) } \end{array}$ for $m \in \ b { x } _ { t } , \ b { x } _ { i } , \ b { x } _ { v } , \ b { x } _ { a }$ , with $\textstyle \sum _ { m } \alpha _ { m } = 1$ . Through simple weighted interpolation of aligned embeddings, we enable models trained with single-conditioning (i.e., with only one input) to perform zero-shot multi-conditioning (i.e., with multiple inputs). This process is illustrated in Fig. 2 (a)(2).
62
+
63
+ Optimizing all four prompt encoders simultaneously in a combinatorial manner is computationally heavy, with $\mathcal { O } ( n ^ { 2 } )$ pairs. Additionally, for certain dual modalities, well-aligned paired datasets are limited or unavailable e.g., image-audio pairs. To address this challenge, we propose a simple and effective technique called "Bridging Alignment" to efficiently align conditional encoders. As shown in Fig. 2 (a)(1), we choose the text modality as the "bridging" modality due to its ubiquitous presence in paired data, such as text-image, text-video, and text-audio pairs. We begin with a pretrained text-image paired encoder, i.e., CLIP [38]. We then train audio and video prompt encoders on audio-text and video-text paired datasets using contrastive learning, with text and image encoder weights frozen.
64
+
65
+ In this way, all four modalities are aligned in the feature space. As shown in Section 5.2, CoDi can effectively leverage and combine the complementary information present in any combination of modalities to generate more accurate and comprehensive outputs. The high generation quality remains unaffected with respect to the number of prompt modalities. As we will discuss in subsequent sections, we continue to apply Bridging Alignment to align the latent space of LDMs with different modalities to achieve joint multimodal generation.
66
+
67
+ # 3.3 Composable Diffusion
68
+
69
+ Training an end-to-end anything-to-anything model requires extensive learning on various data resources. The model also needs to maintain generation quality for all synthesis flows. To address these challenges, CoDi is designed to be composable and integrative, allowing individual modalityspecific models to be built independently and then smoothly integrated later. Specifically, we start by independently training image, video, audio, and text LDMs. These diffusion models then efficiently learn to attend across modalities for joint multimodal generation (Section 3.4) by a novel mechanism named “latent alignment”.
70
+
71
+ Image Diffusion Model. The image LDM follows the same structure as Stable Diffusion 1.5 [41] and is initialized with the same weights. Reusing the weights transfers the knowledge and exceptional generation fidelity of Stable Diffusion trained on large-scale high-quality image datasets to CoDi.
72
+
73
+ Video Diffusion Model. To model the temporal properties of videos and simultaneously maintain vision generation quality, we construct the video diffuser by extending the image diffuser with temporal modules. Specifically, we insert pseudo-temporal attention before the residual block [13]. However, we argue that pseudo-temporal attention only enables video frames to globally attend to each other by flattening the pixels (height, width dimension) to batch dimension, resulting in a lack of cross-frame interaction between local pixels. We argue that this results in the common temporal-inconsistency issue in video generation that locations, shapes, colors, etc. of objects can be inconsistent across generated frames. To address this problem, we propose adapting the latent shift method [2] that performs temporal-spatial shifts on latent features in accordance with temporal attention. We divide the video by the hidden dimension into $k = 8$ chunks, and for each chunk $i = 0$ to 7, we shift the temporal dimension forward by $i$ positions. Further details will be provided in the appendix.
74
+
75
+ Audio Diffusion Model. To enable flexible cross-modality attention in joint generation, the audio diffuser is designed to have a similar architecture to vision diffusers, where the mel-spectrogram can be naturally viewed as an image with 1 channel. We use a VAE encoder to encode the melspectrogram of audio to a compressed latent space. In audio synthesis, a VAE decoder maps the latent variable to the mel-spectrogram, and a vocoder generates the audio sample from the mel-spectrogram. We employ the audio VAE from [33] and the vocoder from [27].
76
+
77
+ Text Diffusion Model. The VAE of the text LDM is OPTIMUS [29], and its encoder and decoder are [9] and GPT-2 [39], respectively. For the denoising UNet, unlike the one in image diffusion, the 2D convolution in residual blocks is replaced with 1D convolution [53].
78
+
79
+ # 3.4 Joint Multimodal Generation by Latent Alignment
80
+
81
+ The final step is to enable cross-attention between diffusion flows in joint generation, i.e., generating two or more modalities simultaneously. This is achieved by adding cross-modal attention sublayers to the UNet $\epsilon _ { \theta }$ (Fig. 2 (b)(2)). Specifically, consider a diffusion model of modality $A$ that cross-attends with another modality $B$ . Let the latent variables of modalities $m _ { A }$ and $m _ { B }$ at diffusion step $t$ be denoted as $ { \boldsymbol { z } } _ { t } ^ { A }$ and $\hat { z _ { t } ^ { B } }$ , respectively. The proposed “Latent Alignment” technique is such that a modality-specific environment encoder $V _ { B }$ first projects $ { \boldsymbol { z } } _ { t } ^ { B }$ into a shared latent space for different modalities. Then, in each layer of the UNet for modality $A$ , a cross-attention sublayer attends to $V _ { B } \big ( z _ { t } ^ { B } \big )$ . For the diffusion model of modality $A$ , the training objective in Eq. (1) now becomes:
82
+
83
+ $$
84
+ \mathcal { L } _ { C r o s s } ^ { A } = \mathbb { E } _ { z , \epsilon , t } \Vert \epsilon - \epsilon _ { \theta _ { c } } ( z _ { t } ^ { A } , V _ { B } ( z _ { t } ^ { B } ) , t , C ( \pmb { y } ) ) \Vert _ { 2 } ^ { 2 } ,
85
+ $$
86
+
87
+ where $\theta _ { c }$ denotes the weights of cross-attention modules in the UNet.
88
+
89
+ The training objective of $A + B$ joint generation is $\mathcal { L } _ { C r o s s } ^ { A } + \mathcal { L } _ { C r o s s } ^ { B }$ . $V ( \cdot )$ of different modalities are trained to be aligned with contrastive learning. Since $z _ { t } ^ { A }$ and $z _ { t } ^ { B }$ at any time step can be sampled with closed form in the diffusion process Section 3.1, one can conveniently train the contrastive learning together with $\mathcal { L } _ { C r o s s }$ . The purpose of $V$ is to achieve the generation of any combination of modalities (in polynomial) by training on a linear number of joint-generation tasks. For example, if we have trained the joint generation of modalities $A , B$ , and $B$ , $C$ independently, then we have $V _ { A } ( z _ { t } ^ { A } )$ , $V _ { B } \big ( z _ { t } ^ { B } \big )$ , and $V _ { C } ( z _ { t } ^ { C } )$ aligned. Therefore, CoDi can seamlessly achieve joint generation of modalities $A$ and $C$ without any additional training. Moreover, such design automatically effortlessly enables joint generation of modalities $A$ , $B$ , and $C$ concurrently. Specifically, UNet of $A$ can cross-attend with the interpolation of $V _ { B } \big ( z _ { t } ^ { B } \big )$ , and $V _ { C } ( z _ { t } ^ { C } )$ , although CoDi has not been trained with such task.
90
+
91
+ As shown in Fig. 2(b)(3), we follow similar designs to the "Bridging Alignment" in training joint generation: (1) We first train the cross-attention weights in the image and text diffusers, as well as their environment encoders $V$ , on text-image paired data. (2) We freeze the weights of the text diffuser and train the environment encoder and cross-attention weights of the audio diffuser on text-audio paired data. (3) Finally we freeze the audio diffuser and its environment encoder, and train the joint generation of the video modality on audio-video paired data. As demonstrated in Section 5.3, although only trained on three paired joint generation tasks (i.e, Text $^ +$ Audio, Text+Image, and Video+Audio), CoDi is capable of generating assorted combinations of modalities simultaneously that are unseen in training, e.g., joint image-text-audio generation in Fig. 5.
92
+
93
+ Table 1: Training tasks (CT stands for “contrastive learning” to align prompt encoders) and datasets with corresponding statistics. \* denotes the number of accessible examples in the original datasets.
94
+
95
+ <table><tr><td>Categories</td><td>Tasks</td><td>Datasets</td><td># of samples</td><td>Domain</td></tr><tr><td>Image + Text</td><td>Image-→Text,Text-→Image Text-→Image+Text</td><td>Laion400M [42]</td><td>400M</td><td>Open</td></tr><tr><td>Audio + Text</td><td>Text→Audio,Audio-→Text, Text-→Audio+Text,Audio-Text CT</td><td>AudioSet [16] AudioCaps [24] Freesound 500K BBC Sound Effect</td><td>900K* 46K 2.5M 30K</td><td>YouTube YouTube Public audio samples Authentic natural sound</td></tr><tr><td>Audiovisual</td><td>Image→Audio,Image→Video+Audio</td><td>AudioSet SoundNet [3]</td><td>900K* 1.0M*</td><td>YouTube Flickr, natural sound</td></tr><tr><td>Video</td><td>Text-→Video,Image→Video, Video-Text CT</td><td>Webvid10M[4] HD-Villa-100M [54]</td><td>10.7M 100M</td><td>Short videos YouTube</td></tr></table>
96
+
97
+ ![](images/493f24169a89b5450efae4d85c3805ebc13a132fcf5e28a3a488cbd564530264.jpg)
98
+ Figure 3: Single-to-single modality generation. Clockwise from top left: text image, image text, image video, audio image.
99
+
100
+ # 4 Experiments
101
+
102
+ # 4.1 Training Objectives and Datasets
103
+
104
+ We list training tasks of CoDi in Table 1, including single modality synthesis, joint multimodal generation, and contrastive learning to align prompt encoders. Table 1 provides an overview of the datasets, tasks, number of samples, and domain. Datasets are from the following domains: image $^ +$ text (e.g. image with caption), audio $^ +$ text (e.g. audio with description), audio $^ +$ video (e.g. video with sound), and video $^ +$ text (e.g. video with description). As one may have noticed, the language modality appears in most datasets and domains. This echos the idea of using text as the bridge modality to be able to extrapolate and generate new unseen combinations such as audio and image bridged by text, as mentioned in Section 3.2 and Section 3.4. Due to space limit, more details on training datasets and can be found in Appendix C, model architecture details in Appendix Appendix A.1, and training details in Appendix B.
105
+
106
+ Image $^ +$ Text. We use a recently developed large-scale image caption dataset, Laion400M [42]. This image-text paired data allows us to train with tasks text image, image text, and the joint generation of image and text. For the joint generation task, we propose to train with text image+text, where the prompt text is the truncated image caption, and the output text is the original caption. Since the condition information is incomplete, the text and image diffuser will need to learn to attend with each other through the joint generation process.
107
+
108
+ Table 2: COCO-caption [32] FID scores for text-to-image generation.
109
+
110
+ <table><tr><td>Method</td><td>FID↓</td></tr><tr><td>CogView [10]</td><td>27.10</td></tr><tr><td>GLIDE [36]</td><td>12.24</td></tr><tr><td>Make-a-Scene [15]</td><td>11.84</td></tr><tr><td>LDM [41]</td><td>12.63</td></tr><tr><td>Stable Diffusion-1.4</td><td>11.21</td></tr><tr><td>Stable Diffusion-1.5</td><td>11.12</td></tr><tr><td>Versatile Diffusion [53]</td><td>11.10</td></tr><tr><td>CoDi (Ours)</td><td>11.26</td></tr></table>
111
+
112
+ Table 3: MSR-VTT text-to-video Table 4: UCF-101 text-to-video generation performance. generation performance.
113
+
114
+ <table><tr><td>Method</td><td>Zero-Shot</td><td>CLIPSIM ↑</td></tr><tr><td>GODIVA [50]</td><td>No</td><td>0.2402</td></tr><tr><td>NUWA [51]</td><td>No</td><td>0.2439</td></tr><tr><td>CogVideo [22]</td><td>Yes</td><td>0.2631</td></tr><tr><td>Make-A-Video [44]</td><td>Yes</td><td>0.3049</td></tr><tr><td>Video LDM[5]</td><td>Yes</td><td>0.2929</td></tr><tr><td>CoDi(Ours)</td><td>Yes</td><td>0.2890</td></tr></table>
115
+
116
+ <table><tr><td>Method</td><td>IS(1)</td><td>FVD (↑)</td></tr><tr><td>Cog Video (Chinese)</td><td>23.55</td><td>751.34</td></tr><tr><td>CogVideo (English)</td><td>25.27</td><td>701.59</td></tr><tr><td>Make-A-Video</td><td>33.00</td><td>367.23</td></tr><tr><td>Video LDM</td><td>33.45</td><td>550.61</td></tr><tr><td>CoDi(Ours)</td><td>32.88</td><td>596.34</td></tr></table>
117
+
118
+ Table 5: The comparison between our audio diffuser and baseline TTA generation models. Evaluation is conducted on AudioCaps test set. AS, AC, FSD, BBC, and SDN stand for AudioSet, AudioCaps, Freesound, BBC Sound Effect, and Soundnet.
119
+
120
+ <table><tr><td>Model</td><td>Datasets</td><td>FD↓</td><td>IS个</td><td>KL←</td><td>FAD↓</td><td>OVL ↑</td><td>REL个</td></tr><tr><td>Ground truth</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>83.61</td><td>80.11</td></tr><tr><td>DiffSound</td><td>AS+AC</td><td>47.68</td><td>4.01</td><td>2.52</td><td>7.75</td><td>45.00</td><td>43.83</td></tr><tr><td>AudioGen</td><td>AS +AC+8others</td><td>=</td><td>-</td><td>2.09</td><td>3.13</td><td>-</td><td>=</td></tr><tr><td>AudioLDM-L-Full</td><td>AS+AC+FSD+BBC</td><td>23.31</td><td>8.13</td><td>1.59</td><td>1.96</td><td>65.91</td><td>65.97</td></tr><tr><td>CoDi(Ours)</td><td>AS+AC+FSD+BBC+SDN</td><td>22.90</td><td>8.77</td><td>1.40</td><td>1.80</td><td>66.87</td><td>67.60</td></tr></table>
121
+
122
+ Table 6: COCO image captioning scores comparison.
123
+
124
+ <table><tr><td>Model</td><td>B@4</td><td>METEOR</td><td>CIDEr</td></tr><tr><td colspan="4">Autoregressive Model</td></tr><tr><td>Oscar [31]</td><td>36.58</td><td>30.4</td><td>124.12</td></tr><tr><td>ClipCap [35]</td><td>32.15</td><td>27.1</td><td>108.35</td></tr><tr><td>OFA [49]</td><td>44.9</td><td>32.5</td><td>154.9</td></tr><tr><td>BLIP2 [30]</td><td>43.7</td><td>-</td><td>145.8</td></tr><tr><td colspan="4">Diffusion Model</td></tr><tr><td>DDCap [59]</td><td>35.0</td><td>28.2</td><td>117.8</td></tr><tr><td>SCD-Net [34]</td><td>39.4</td><td>29.2</td><td>131.6</td></tr><tr><td>CoDi (Ours)</td><td>40.2</td><td>31.0</td><td>149.9</td></tr></table>
125
+
126
+ Table 7: AudioCaps audio captioning scores comparison.
127
+
128
+ <table><tr><td>Model</td><td>SPIDEr</td><td>CIDEr</td><td>SPICE</td></tr><tr><td>AudioCaps [24]</td><td>0.369</td><td>0.593</td><td>0.144</td></tr><tr><td>BART-Finetune [17]</td><td>0.465</td><td>0.753</td><td>0.176</td></tr><tr><td>VALOR[7]</td><td></td><td>0.741</td><td></td></tr><tr><td>AL-MixGen [25]</td><td>0.466</td><td>0.755</td><td>0.177</td></tr><tr><td>CoDi (Ours)</td><td>0.480</td><td>0.789</td><td>0.182</td></tr></table>
129
+
130
+ Table 8: MSRVTT video captioning scores comparison.
131
+
132
+ <table><tr><td>Model</td><td>B@4</td><td>METEOR</td><td>CIDEr</td></tr><tr><td>ORG-TRL[58]</td><td>43.6</td><td>28.8</td><td>50.9</td></tr><tr><td>MV-GPT[43]</td><td>48.9</td><td>38.7</td><td>60.0</td></tr><tr><td>GIT[48]</td><td>54.8</td><td>33.1</td><td>75.9</td></tr><tr><td>mPLUG-2 [52]</td><td>57.8</td><td>34.9</td><td>80.3</td></tr><tr><td>CoDi(Ours)</td><td>52.1</td><td>32.5</td><td>74.4</td></tr></table>
133
+
134
+ Audio $^ +$ Text. We curated a new dataset, Freesound 500K, by crawling 500K audio samples together with tags and descriptions from the Freesound website. We also use AudioSet [42] with 2 million human-labeled 10-second sound clips from YouTube videos and AudioCaps [24] with 46K audiotext pairs derived from the AudioSet dataset. Audio samples are clipped into 10-second segments for training purposes. The paired audio $^ +$ text data enables us to train text audio, audio text, text audio $^ +$ text generation, and audio-text contrastive learning. Similar to image $^ +$ text joint generation, in text audio $^ +$ text, text prompt is the truncated text, and the output is the original text.
135
+
136
+ Video. We use the following diverse and high-quality video datasets to train video generation and video prompt encoder. WebVid [4], a large-scale dataset of web videos together with descriptions; HD-Villa-100M [54] with high resolution YouTube videos of at least 720P. We perform text video and video-text contrastive learning task with WebVid. We use HD-Villa-100M for image video generation where the middle frame is the input image.
137
+
138
+ Audiovisual. Web videos are a natural aligned audio-video data resource. However, many existing datasets, e.g., ACAV100M [28], feature heavily on videos of human speech rather than natural sounds. Therefore, we leverage sound-oriented datasets AudioSet and SoundNet [3] for joint audio-video generation. For image audio $^ +$ video, we use the middle frame of the target video as the input prompt image. We also use the middle frame as the prompt input to train the model to generate the audio, i.e., image audio.
139
+
140
+ ![](images/dc63eb6c668a08077a3c76c77a471ccad92d8b97c381a63765856efb970b42b0.jpg)
141
+ Figure 4: Generation with multiple input modality conditions. Top to bottom: text+audio image, text+audio video, video+audio text.
142
+
143
+ # 5 Evaluation Results
144
+
145
+ In this section, we will evaluate the model generation quality in different settings including single modality generation, multi-condition generation, and multi-output joint generation. We provide both quantitative benchmarking on evaluation datasets as well as qualitative visualization demonstrations.
146
+
147
+ # 5.1 Single Modality Generation Results
148
+
149
+ We first show example demo in Fig. 3, where we present various single to single modality generation. Then, we evaluate the synthesis quality of the unimodal generation on text, image, video, and audio. CoDi achieves SOTA on audio captions and audio generation, as shown in Table 7 and Table 5. Notably for the first time in the field, CoDi, a diffusion-base model, exhibits comparable performance on image captioning with autoregressive transformer-based SOTA (Table 6). CoDi is the first diffusion-model based for video captioning Table 8. On image and video generation, CoDi performs competitively with state-of-the-art (Tables 2 to 4). This gives us strong starting points for multi-condition and multi-output generation that will be presented next in Section 5.2 and Section 5.3.
150
+
151
+ We demonstrate in Section 3.2 that CoDi is capable of integrating representation from different modalities in the generation. Thus, we first show multi-condition generation demo as shown in Fig. 4.
152
+
153
+ # 5.2 Multi-Condition Generation Results
154
+
155
+ For quantitative evaluation, we focus on multiple inputs to image synthesis output since the evaluation metric for this case (FID) does not require specific modality inputs like text. We test with several input combinations including text $^ +$ image, text $^ +$ audio, image $^ +$ audio, text $^ +$ video, as well as three inputs text $^ +$ audio $^ +$ image. We test on the validation set of AudioCaps [24] since all four modalities are present in this dataset. The prompt image input is the middle frame of the video. As shown in
156
+
157
+ Table 9: CoDi is capable of generating high quality output (image in this case) from various combinations of prompt modalities.
158
+
159
+ <table><tr><td>Inputs</td><td>FID↓</td></tr><tr><td> Single-modality Prompt</td><td></td></tr><tr><td>Text</td><td>14.2</td></tr><tr><td>Audio</td><td>14.3</td></tr><tr><td> Dual-modality Prompt</td><td></td></tr><tr><td>Text+Audio</td><td>14.9</td></tr></table>
160
+
161
+ Table 10: MSR-VTT text-to-video generation performance.
162
+
163
+ <table><tr><td>Inputs</td><td>CLIPSIM个</td></tr><tr><td> Single-modality Prompt</td><td></td></tr><tr><td>Text</td><td>0.2890</td></tr><tr><td> Dual-modality Prompt</td><td></td></tr><tr><td>Text+Audio</td><td>0.2912</td></tr><tr><td>Text+Image</td><td>0.2891</td></tr><tr><td>Text+Audio+Image</td><td>0.2923</td></tr></table>
164
+
165
+ ![](images/570523fa62e48124b6e7ee0927d72eb815a36ea17ca483b39355fc5b79c4dd8d.jpg)
166
+ Figure 5: Joint generation of multiple output modalities by CoDi. From top to bottom: text video+audio, tex image+text+audio, text+audio+image video+audio.
167
+
168
+ Table 9, CoDi achieves high image generation quality given assorted groups of input modalities. We also test with several input combinations with video as output including text, text $^ +$ audio, image $^ +$ image, as well as text $^ +$ audio $^ +$ image. We also test on MSRVTT [24] since all four modalities are present in this dataset. Similarly, the prompt image input is the middle frame of the video. As shown in Table 10, CoDi achieves high video and ground truth text similarity given assorted groups of input modalities. Again our model does not need to train on multi-condition generation like text $^ +$ audio or text $^ +$ image. Through bridging alignment and composable multimodal conditioning as proposed in Section 3.2, our model trained on single condition can zero-shot infer on multiple conditions.
169
+
170
+ # 5.3 Multi-Output Joint Generation Results
171
+
172
+ For joint multimodal generation, we first demonstrate high-quality multimodal output joint generation demo as shown in Fig. 5. For quantitative evaluation, there is no existing evaluation metric since we are the first model that can simultaneously generate across all 4 modalities. Therefore, we propose the following metric SIM that quantifies the coherence and consistency between the two generated modalities by cosine similarity of embeddings:
173
+
174
+ $$
175
+ \operatorname { S I M } ( A , B ) = \cos { ( C _ { A } ( A ) , C _ { B } ( B ) ) }
176
+ $$
177
+
178
+ Table 11: Similarity scores between generated modalities. The number on the left of $" / "$ represents the similarity score of independent generation, and the right it represents the case of joint generation. Jointly generated outputs consistently show stronger coherence.
179
+
180
+ <table><tr><td>Inputs</td><td>SIM-IT</td><td>SIM-AT</td><td>SIM-VT</td><td>SIM-VA</td></tr><tr><td colspan="5"> Two Joint Outputs</td></tr><tr><td>Audio → Image+Text</td><td>0.251 / 0.260</td><td></td><td></td><td></td></tr><tr><td>Image→Audio+Text</td><td>■</td><td>0.244 / 0.256</td><td></td><td></td></tr><tr><td>Text →Video+Audio</td><td></td><td></td><td></td><td>0.240 / 0.255</td></tr><tr><td>Audio →Video+Text</td><td></td><td></td><td>0.256 / 0.261</td><td></td></tr><tr><td colspan="5"> Three Joint Outputs</td></tr><tr><td>Text-→ Video+Image+Audio 0.256/0.270 0.240/0.257</td><td></td><td></td><td></td><td>0.240 / 0.257</td></tr><tr><td colspan="5"> Multi-Inputs-Outputs</td></tr><tr><td>Text+Image -→ Video+Audio</td><td></td><td></td><td></td><td>0.247 / 0.259</td></tr></table>
181
+
182
+ where $A$ , $B$ are the generated modalities, and $C _ { A }$ and $C _ { B }$ are aligned encoders that project $A$ and $B$ to the same space. We use the prompt encoder as described in Section 3.2. This metric aims to compute the cosine similarity of the embedding of two modalities using contrastive learned prompt encoders. Thus, the higher the metric, the more aligned and similar the generated modalities are.
183
+
184
+ To demonstrate the effectiveness of joint generation, assume the prompt modality is $P$ , we compare $\mathrm { S I M } ( A , B )$ of $A$ and $B$ generated separately vs. jointly, i.e., $\{ P \ { \overset { - } { \to } } \ A , \ P \ { \overset { - } { \to } } \ B \}$ vs. $\{ P $ $A + B \}$ . The benchmark is the validation set of AudioCaps [24]. We test on the following settings, audio image+text, image audio+text, and text video+audio, image video+audio. audio video+text, audio text+video+image, text video+image+audio, where the image prompt is the middle frame of the video clip. As shown in Table 11, joint generation (similarity shown on the right side of $" / "$ ) consistently outperforms independent generation (on the left side of $" / "$ ).
185
+
186
+ # 6 Conclusion
187
+
188
+ In this paper, we present Composable Diffusion (CoDi), a groundbreaking model in multimodal generation that is capable of processing and simultaneously generating modalities across text, image, video, and audio. Our approach enables the synergistic generation of high-quality and coherent outputs spanning various modalities, from assorted combinations of input modalities. Through extensive experiments, we demonstrate CoDi’s remarkable capabilities in flexibly generating single or multiple modalities from a wide range of inputs. Our work marks a significant step towards more engaging and holistic human-computer interactions, establishing a solid foundation for future investigations in generative artificial intelligence.
189
+
190
+ Limitations & Broader Impacts. See Appendix D for the discussion.
191
+
192
+ # Acknowledgement
193
+
194
+ We would like to thank Bei Liu for HD-VILA-100M data support. We also thank Shi Dong, Mahmoud Khademi, Junheng Hao, Yuwei Fang, Yichong Xu and Azure Cognitive Services Research team members for their feedback.
195
+
196
+ # References
197
+
198
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in Neural Information Processing Systems, 35:23716–23736, 2022. 3
199
+ [2] Jie An, Songyang Zhang, Harry Yang, Sonal Gupta, Jia-Bin Huang, Jiebo Luo, and Xi Yin. Latent-shift: Latent diffusion with temporal shift for efficient text-to-video generation. arXiv preprint arXiv:2304.08477, 2023. 5, 15, 16
200
+
201
+ [3] Yusuf Aytar, Carl Vondrick, and Antonio Torralba. Soundnet: Learning sound representations from unlabeled video. Advances in neural information processing systems, 29, 2016. 6, 7
202
+
203
+ [4] Max Bain, Arsha Nagrani, Gül Varol, and Andrew Zisserman. Frozen in time: A joint video and image encoder for end-to-end retrieval. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1728–1738, 2021. 6, 7, 16
204
+
205
+ [5] Andreas Blattmann, Robin Rombach, Huan Ling, Tim Dockhorn, Seung Wook Kim, Sanja Fidler, and Karsten Kreis. Align your latents: High-resolution video synthesis with latent diffusion models. arXiv preprint arXiv:2304.08818, 2023. 7
206
+
207
+ [6] Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, et al. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712, 2023. 2
208
+
209
+ [7] Sihan Chen, Xingjian He, Longteng Guo, Xinxin Zhu, Weining Wang, Jinhui Tang, and Jing Liu. Valor: Vision-audio-language omni-perception pretraining model and dataset. arXiv preprint arXiv:2304.08345, 2023. 7
210
+
211
+ [8] Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. In International Conference on Machine Learning, pages 1931–1942. PMLR, 2021. 3
212
+
213
+ [9] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018. 5
214
+
215
+ [10] Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, and Jie Tang. Cogview: Mastering text-to-image generation via transformers. arXiv preprint arXiv:2105.13290, 2021. 7
216
+
217
+ [11] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10687–10696, 2021. 3
218
+
219
+ [12] Benjamin Elizalde, Soham Deshmukh, Mahmoud Al Ismail, and Huaming Wang. Clap: Learning audio concepts from natural language supervision. arXiv preprint arXiv:2206.04769, 2022. 3
220
+
221
+ [13] Patrick Esser, Johnathan Chiu, Parmida Atighehchian, Jonathan Granskog, and Anastasis Germanidis. Structure and content-guided video synthesis with diffusion models. arXiv preprint arXiv:2302.03011, 2023. 2, 5
222
+
223
+ [14] Patrick Esser, Johnathan Chiu, Parmida Atighehchian, Jonathan Granskog, and Anastasis Germanidis. Structure and content-guided video synthesis with diffusion models. arXiv preprint arXiv:2302.03011, 2023. 3
224
+
225
+ [15] Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XV, pages 89–106. Springer, 2022. 7 [16] Jort F Gemmeke, Daniel PW Ellis, Dylan Freedman, Aren Jansen, Wade Lawrence, R Channing Moore, Manoj Plakal, and Marvin Ritter. Audio set: An ontology and human-labeled dataset for audio events. In 2017 IEEE international conference on acoustics, speech and signal processing (ICASSP), pages 776–780. IEEE, 2017. 6
226
+
227
+ [17] Félix Gontier, Romain Serizel, and Christophe Cerisara. Automated audio captioning by fine-tuning bart with audioset tags. In Detection and Classification of Acoustic Scenes and Events-DCASE 2021, 2021. 7 [18] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016. 15
228
+
229
+ [19] Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang, Ruiqi Gao, Alexey Gritsenko, Diederik P Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303, 2022. 2, 3
230
+
231
+ [20] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. 3, 4
232
+
233
+ [21] Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458, 2022. 3, 15
234
+
235
+ [22] Wenyi Hong, Ming Ding, Wendi Zheng, Xinghan Liu, and Jie Tang. Cogvideo: Large-scale pretraining for text-to-video generation via transformers. arXiv preprint arXiv:2205.15868, 2022. 2, 7
236
+
237
+ [23] Rongjie Huang, Jiawei Huang, Dongchao Yang, Yi Ren, Luping Liu, Mingze Li, Zhenhui Ye, Jinglin Liu, Xiang Yin, and Zhou Zhao. Make-an-audio: Text-to-audio generation with prompt-enhanced diffusion models. arXiv preprint arXiv:2301.12661, 2023. 2, 3
238
+
239
+ [24] Chris Dongjoo Kim, Byeongchang Kim, Hyunmin Lee, and Gunhee Kim. Audiocaps: Generating captions for audios in the wild. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 119–132, 2019. 6, 7, 8, 9, 10
240
+
241
+ [25] Eungbeom Kim, Jinhee Kim, Yoori Oh, Kyungsu Kim, Minju Park, Jaeheon Sim, Jinwoo Lee, and Kyogu Lee. Improving audio-language learning with mixgen and multi-level test-time augmentation. arXiv preprint arXiv:2210.17143, 2022. 7
242
+
243
+ [26] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. 15
244
+
245
+ [27] Jungil Kong, Jaehyeon Kim, and Jaekyoung Bae. Hifi-gan: Generative adversarial networks for efficient and high fidelity speech synthesis. Advances in Neural Information Processing Systems, 33:17022–17033, 2020. 5
246
+
247
+ [28] Sangho Lee, Jiwan Chung, Youngjae Yu, Gunhee Kim, Thomas Breuel, Gal Chechik, and Yale Song. Acav $1 0 0 \mathrm { m }$ : Automatic curation of large-scale datasets for audio-visual video representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10274–10284, 2021. 7 [29] Chunyuan Li, Xiang Gao, Yuan Li, Baolin Peng, Xiujun Li, Yizhe Zhang, and Jianfeng Gao. Optimus: Organizing sentences via pre-trained modeling of a latent space. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 4678–4699, 2020. 5
248
+
249
+ [30] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrapping language-image pre-training with frozen image encoders and large language models. arXiv preprint arXiv:2301.12597, 2023. 7
250
+
251
+ [31] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part XXX 16, pages 121–137. Springer, 2020. 7
252
+
253
+ [32] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In Computer Vision–ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pages 740–755. Springer, 2014. 7
254
+
255
+ [33] Haohe Liu, Zehua Chen, Yi Yuan, Xinhao Mei, Xubo Liu, Danilo Mandic, Wenwu Wang, and Mark D Plumbley. Audioldm: Text-to-audio generation with latent diffusion models. arXiv preprint arXiv:2301.12503, 2023. 2, 3, 5
256
+
257
+ [34] Jianjie Luo, Yehao Li, Yingwei Pan, Ting Yao, Jianlin Feng, Hongyang Chao, and Tao Mei. Semanticconditional diffusion networks for image captioning. arXiv preprint arXiv:2212.03099, 2022. 7
258
+
259
+ [35] Ron Mokady, Amir Hertz, and Amit H Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021. 3, 7
260
+
261
+ [36] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021. 7
262
+
263
+ [37] Reid Pryzant, Dan Iter, Jerry Li, Yin Tat Lee, Chenguang Zhu, and Michael Zeng. Automatic prompt optimization with" gradient descent" and beam search. arXiv preprint arXiv:2305.03495, 2023. 2
264
+
265
+ [38] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021. 3, 4
266
+
267
+ [39] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019. 5
268
+
269
+ [40] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. 3
270
+
271
+ [41] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022. 2, 3, 4, 5, 7
272
+
273
+ [42] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade W Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, Patrick Schramowski, Srivatsa R Kundurthy, Katherine Crowson, Ludwig Schmidt, Robert Kaczmarczyk, and Jenia Jitsev. LAION-5b: An open large-scale dataset for training next generation image-text models. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022. 6, 7
274
+
275
+ [43] Paul Hongsuck Seo, Arsha Nagrani, Anurag Arnab, and Cordelia Schmid. End-to-end generative pretraining for multimodal video captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 17959–17968, 2022. 7
276
+
277
+ [44] Uriel Singer, Adam Polyak, Thomas Hayes, Xi Yin, Jie An, Songyang Zhang, Qiyuan Hu, Harry Yang, Oron Ashual, Oran Gafni, et al. Make-a-video: Text-to-video generation without text-video data. arXiv preprint arXiv:2209.14792, 2022. 2, 3, 7
278
+
279
+ [45] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015. 2, 4
280
+
281
+ [46] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021. 3
282
+
283
+ [47] Zineng Tang, Jaemin Cho, Yixin Nie, and Mohit Bansal. TVLT: Textless vision-language transformer. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. 3
284
+
285
+ [48] Jianfeng Wang, Zhengyuan Yang, Xiaowei Hu, Linjie Li, Kevin Lin, Zhe Gan, Zicheng Liu, Ce Liu, and Lijuan Wang. Git: A generative image-to-text transformer for vision and language. arXiv preprint arXiv:2205.14100, 2022. 7
286
+
287
+ [49] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang. Unifying architectures, tasks, and modalities through a simple sequence-tosequence learning framework. arXiv preprint arXiv:2202.03052, 2022. 7
288
+
289
+ [50] Chenfei Wu, Lun Huang, Qianxi Zhang, Binyang Li, Lei Ji, Fan Yang, Guillermo Sapiro, and Nan Duan. Godiva: Generating open-domain videos from natural descriptions. arXiv preprint arXiv:2104.14806, 2021. 7
290
+
291
+ [51] Chenfei Wu, Jian Liang, Lei Ji, Fan Yang, Yuejian Fang, Daxin Jiang, and Nan Duan. Nüwa: Visual synthesis pre-training for neural visual world creation. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XVI, pages 720–736. Springer, 2022. 7
292
+
293
+ [52] Haiyang Xu, Qinghao Ye, Ming Yan, Yaya Shi, Jiabo Ye, Yuanhong Xu, Chenliang Li, Bin Bi, Qi Qian, Wei Wang, et al. mplug-2: A modularized multi-modal foundation model across text, image and video. arXiv preprint arXiv:2302.00402, 2023. 7
294
+
295
+ [53] Xingqian Xu, Zhangyang Wang, Eric Zhang, Kai Wang, and Humphrey Shi. Versatile diffusion: Text, images and variations all in one diffusion model. arXiv preprint arXiv:2211.08332, 2022. 5, 7
296
+
297
+ [54] Hongwei Xue, Tiankai Hang, Yanhong Zeng, Yuchong Sun, Bei Liu, Huan Yang, Jianlong Fu, and Baining Guo. Advancing high-resolution video-language representation with large-scale video transcriptions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5036–5045, 2022. 6, 7, 16
298
+
299
+ [55] Ziyi Yang, Yuwei Fang, Chenguang Zhu, Reid Pryzant, Dongdong Chen, Yu Shi, Yichong Xu, Yao Qian, Mei Gao, Yi-Ling Chen, et al. i-code: An integrative and composable multimodal learning framework. arXiv preprint arXiv:2205.01818, 2022. 2, 3
300
+
301
+ [56] Rowan Zellers, Jiasen Lu, Ximing Lu, Youngjae Yu, Yanpeng Zhao, Mohammadreza Salehi, Aditya Kusupati, Jack Hessel, Ali Farhadi, and Yejin Choi. Merlot reserve: Neural script knowledge through vision and language and sound. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16375–16387, 2022. 3
302
+ [57] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. Merlot: Multimodal neural script knowledge models. Advances in Neural Information Processing Systems, 34:23634–23651, 2021. 3
303
+ [58] Ziqi Zhang, Yaya Shi, Chunfeng Yuan, Bing Li, Peijin Wang, Weiming Hu, and Zheng-Jun Zha. Object relational graph with teacher-recommended learning for video captioning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 13278–13288, 2020. 7
304
+ [59] Zixin Zhu, Yixuan Wei, Jianfeng Wang, Zhe Gan, Zheng Zhang, Le Wang, Gang Hua, Lijuan Wang, Zicheng Liu, and Han Hu. Exploring discrete diffusion models for image captioning. arXiv preprint arXiv:2211.11694, 2022. 7
305
+
306
+ # A Model Architecture and Configuration
307
+
308
+ # A.1 Overview
309
+
310
+ In this section, we provide more details on the model architecture as shown in Table 12, where each modality specific diffuser is based on UNet architecture with different variations detailed in the table. Another notable difference is the video architecture where we add temporal attention and temporal shift as discussed in Section 3.3 and we will discuss its detail in the next section.
311
+
312
+ Table 12: Hyperparameters for our diffusion models. Note the video and image generation uses the same diffuser.
313
+
314
+ <table><tr><td>Modality</td><td>Video (Image) LDM</td><td>Audio LDM</td><td>Text LDM</td></tr><tr><td colspan="4">Hyperparameter</td></tr><tr><td>Architecture</td><td>LDM</td><td>LDM</td><td>LDM</td></tr><tr><td>z-shape</td><td>4× #frames × 64× 64</td><td>8× 256×16</td><td>768×1×1</td></tr><tr><td>Channels</td><td>320</td><td>320</td><td>320</td></tr><tr><td>Depth</td><td>4</td><td>2</td><td>2</td></tr><tr><td>Channel multiplier</td><td>1,2,4,4</td><td>1,2,4,4</td><td>1,2,4,4</td></tr><tr><td>Attention resolutions</td><td>64,32,16</td><td>64,32,16</td><td>64,32,16</td></tr><tr><td>Head channels</td><td>32</td><td>32</td><td>32</td></tr><tr><td>Number of heads</td><td>8</td><td>8</td><td>8</td></tr><tr><td>CA embed dim</td><td>768</td><td>768</td><td>768</td></tr><tr><td>CA resolutions</td><td>64,32,16</td><td>64,32,16</td><td>64,32,16</td></tr><tr><td>Autoencoders</td><td>AutoKL</td><td>AudioLDM</td><td>Optimus</td></tr><tr><td>Weight initialization</td><td>Stable Diffusion-1.4</td><td>-</td><td>Versatile Diffusion</td></tr><tr><td>Parameterization</td><td>E</td><td>E</td><td>E</td></tr><tr><td>Learning rate</td><td>2e-5</td><td>5e-6</td><td>5e-5</td></tr><tr><td>Total batch size</td><td>256</td><td>1024</td><td>1024</td></tr><tr><td colspan="4">Diffusion Setup</td></tr><tr><td>Diffusion steps</td><td>1000</td><td>1000</td><td>1000</td></tr><tr><td>Noise schedule</td><td>Linear</td><td>Linear</td><td>Linear</td></tr><tr><td>β</td><td>0.00085</td><td>0.00085</td><td>0.00085</td></tr><tr><td>阳</td><td>0.0120</td><td>0.0120</td><td>0.0120</td></tr><tr><td colspan="4">Sampling Parameters</td></tr><tr><td>Sampler</td><td>DDIM</td><td>DDIM</td><td>DDIM</td></tr><tr><td>Steps</td><td>50</td><td>50</td><td>50</td></tr><tr><td>n</td><td>1.0</td><td>1.0</td><td>1.0</td></tr><tr><td>Guidance scale</td><td>2.0</td><td>7.5</td><td>2.0</td></tr></table>
315
+
316
+ # A.2 Video LDM Architecture
317
+
318
+ Except for the base image UNet architecture, we also add temporal attention and temporal shift [2] before each residual block. Following VDM [21], the temporal attention is a transformer attention module where we flatten the height and width dimension to batch size dimension and the self-attention is performed on the time dimension. The temporal shift is illustrated in Fig. 6 where we first split channels into $k$ chunks. Then, we shift the channel dimension numbered 0 to $k - 1$ by temporal dimension from 0 to $k - 1$ times respectively. Eventually, we concatenate the shifted chunks by the hidden dimension. Note that we use $k = 3$ in the illustration for simplicity but $k = 8$ in our implementation. We then add a convolution layer before the temporal shift module. Finally, we use residual connection [18] and add the output to the input before the convolution layer. The complete video UNet layer is shown in Fig. 7.
319
+
320
+ # B Model Training
321
+
322
+ Prompt Encoders Training. As discussed in Section 3.2, we use bridging alignment to perform contrastive learning between all prompt encoders. We use Adam [26] optimizer with learning rate 1e-4 and weight decay 1e-4.
323
+
324
+ ![](images/e11082636d4b4499d75ad6f7451413683dac74d3ebb613e652b9ea9f4c995784.jpg)
325
+ Figure 6: Temporal shift [2] illustration. $C , H .$ , $W$ represent channel, height, width, respectively. The vertical line represents time steps from $t - 1 , t$ , and $t + 1$ . The grey blocks denote “padding tensors”.
326
+
327
+ ![](images/4409bc09bf832575915923690ca96fa4e7ccd04266897f8300b3a97df95ceeee.jpg)
328
+ Figure 7: Video UNet layer architecture details including normalization & activation, 2D temporal attention, followed by temporal shift and 1D spatial convolution.
329
+
330
+ Diffusion Model Training. We train diffusion model with training objectives and hyperparameters detailed in Table 1 and Table 12. For video LDM, we adopt a more specific training curriculum. We adopt curriculum learning on frame resolution and frames-per-second (FPS). First, the diffuser is trained on the WebVid dataset of a 256-frame resolution, with the training objective being textconditioned video generation. The training clips are sampled from 2-second video chunks with 4 FPS. Second, the model is further trained on HDVILLA and ACAV datasets, with a 512-frame resolution and 8 FPS, and the training objective is image-conditioned video generation (the image is a randomly sampled frame of the clip). Each training clip contains 16 frames sampled from a 2-second video chunk with 8 FPS.
331
+
332
+ Joint Generation Training. As discussed in Section 3.2, we train joint generation by aligning environment encoders and optimize cross-attention layers only in the diffusion models. We use Adam optimizer with learning rate 1e-5 and weight decay 1e-4.
333
+
334
+ # C Training Datasets
335
+
336
+ In this section, we introduce more details about the video and audiovisual training datasets.
337
+
338
+ Video. WebVid [4] is a large-scale dataset of web videos with diverse content, spanning over 40 categories such as sports, cooking, and travel. It contains over 1.2 million video clips (all without sound) that are all at least 30 seconds in duration with video descriptions. We perform text video and video-text contrastive learning task with this dataset. HD-Villa-100M [54] is a large-scale video dataset with over 100 million video clips sourced from YouTube. The dataset covers a wide range of video categories and includes high-quality videos with a resolution of at least 720P. Since it lacks curated video description and we use the middle frame as image input to perform image video generation.
339
+
340
+ Audiovisual. SoundNet originally contains over two million sounds and spans a wide range of categories including music, animal sounds, natural sounds, and environmental sounds. We collected all currently accessible 1M videos.
341
+
342
+ # D Limitations & Broader Impacts
343
+
344
+ While the paper primarily focuses on the technical advancements and potential applications of CoDi, we also consider potential negative social impacts that could arise from the development and deployment of such technology. These impacts can include:
345
+
346
+ Deepfakes and Misinformation. As part of a common issue for generative AI models, the ability of CoDi to generate realistic and synchronized multimodal outputs also raises concerns about the creation and dissemination of deepfakes. Malicious actors could exploit this technology to create highly convincing fake content, such as fabricated videos or audio clips, which can be used for misinformation, fraud, or other harmful purposes.
347
+
348
+ Bias and Stereotyping. If the training data used for CoDi is biased or contains stereotypes, the generated multimodal outputs may also reflect these.
349
+
350
+ # E License
351
+
352
+ We will publicly release our code and checkpoints. We cite licenses from the individual dataset or package we use from the community and provide the following links for references.
353
+
354
+ LAION-400M: Creative Common CC-BY 4.0
355
+
356
+ AudioSet: Creative Common CC-BY 4.0
357
+
358
+ AudioCaps: MIT
359
+
360
+ Freesound: Creative Commons
361
+
362
+ BBC Sound Effect: The BBC’s Content Licence
363
+
364
+ SoundNet: MIT
365
+
366
+ Webvid10M: Webvid
367
+
368
+ HD-Villa-100M: Research Use of Data Agreement v1.0
369
+
370
+ PyTorch: BSD-style
371
+
372
+ Huggingface Transformers: Apache
373
+
374
+ Torchvision: BSD 3-Clause
375
+
376
+ Torchaudio: BSD 2-Clause
md/dev/5zwnqUwphT/5zwnqUwphT.md ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A Simple Contrastive Learning Objective for Alleviating Neural Text Degeneration
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 The cross-entropy objective has proved to be an all-purpose training objective for
11
+ 2 autoregressive language models (LMs). However, without considering the penal
12
+ 3 ization of problematic tokens, LMs trained using cross-entropy exhibit text degen
13
+ 4 eration. To address this, unlikelihood training has been proposed to reduce the
14
+ 5 probability of unlikely tokens predicted by LMs. But unlikelihood does not con
15
+ 6 sider the relationship between the label tokens and unlikely token candidates, thus
16
+ 7 showing marginal improvements in degeneration. We propose a new contrastive
17
+ 8 token learning objective that inherits the advantages of cross-entropy and unlikeli
18
+ 9 hood training and avoids their limitations. The key idea is to teach a LM to gener
19
+ 10 ate high probabilities for label tokens and low probabilities of negative candidates.
20
+ 11 Comprehensive experiments on language modeling and open-domain dialogue
21
+ 12 generation tasks show that the proposed contrastive token objective yields much
22
+ 13 less repetitive texts, with a higher generation quality than baseline approaches,
23
+ 14 achieving the new state-of-the-art performance on text degeneration.
24
+
25
+ # 15 1 Introduction
26
+
27
+ 16 Autoregressive language models (LMs), such as OpenAI GPT-3 [1], have achieved impressive re
28
+ 17 sults on various natural language processing (NLP) tasks. The goal of training LMs is to learn the
29
+ 18 true distribution of a text corpus, and this is usually achieved through next word prediction. Specif
30
+ 19 ically, a standard approach to training LMs is to minimize the cross-entropy loss between the true
31
+ 20 distribution and the model prediction. Unfortunately, LMs trained using the cross-entropy objec
32
+ 21 tive have been observed to exhibit text degeneration problems, where token, phrase, and sentence
33
+ 22 level repetition is a common symptom [6, 9, 27]. Such repeated texts differ markedly from those
34
+ 23 generated by humans.1 To analyze the reasons for degeneration, our work views the vocabulary of
35
+ 24 LMs as being composed of three sets of tokens at each time step, i.e., positive tokens (label tokens),
36
+ 25 negative tokens (incorrectly repeating tokens), and irrelevant tokens (all the others). Based on this
37
+ 26 taxonomy, we stress that cross-entropy is in fact a contrastive learning objective that contrasts posi
38
+ 27 tive tokens with negative and irrelevant tokens. While it is necessary for LMs to learn how to rank
39
+ 28 positive tokens higher than other tokens in the predicted distribution, negative tokens are treated
40
+ 29 equally to irrelevant tokens (whose number is usually much larger) by the cross-entropy objective.
41
+ 30 As a consequence, negative tokens may not be suppressed hard enough.
42
+
43
+ To address the above issue, Welleck et al. [27] have proposed unlikelihood training to penalize certain negative tokens, i.e., tokens being incorrectly repeated. The key idea behind unlikelihood training is to lower the probability of negative tokens assigned by LMs. Despite its success, the unlikelihood objective penalizes negative tokens by decreasing their predicted probability but does
44
+
45
+ ![](images/2408b7adf6708f0abf9adc573b97a8108a0b3360630818ea3c63a61013395caa.jpg)
46
+ Figure 1: Illustrating the differences between our proposed contrastive token learning, unlikelihood training, and the cross-entropy objective for LMs. For contrastive token learning, we use the label token as the positive token and the preceding $M$ tokens as the negative tokens at each decoding step.
47
+
48
+ 35 not consider the relationship between positive and negative tokens. Unlikelihood training also unin
49
+ 36 tentionally boosts the probability of other irrelevant tokens. Moreover, all previous context tokens
50
+ 37 are used as negative candidates per generation step. Such an objective not only introduces a consid
51
+ 38 erable amount of noise, but also results in sub-optimal repetition reduction, thus affecting the final
52
+ 39 generation performance.
53
+ 40 In this paper, we introduce a simple yet effective contrastive token learning (CT for short) objective
54
+ 41 that integrates the best of cross-entropy and unlikelihood training, penalizing negative tokens by
55
+ 42 contrasting them with positive tokens. The commonalities and differences between cross-entropy,
56
+ 43 unlikelihood training, and CT are illustrated in Figure 1. Briefly, (i) without distinguishing between
57
+ 44 negative and irrelevant tokens, cross-entropy cannot effectively suppress negative tokens; (ii) due to
58
+ 45 the lack of contrast between negative and positive tokens, it is difficult for unlikelihood training to
59
+ 46 penalize negative tokens; and (iii) through its more focused contrast between positive and negative
60
+ 47 tokens, CT can take goal-directed actions rather than just predicting label tokens, i.e., explicitly
61
+ 48 teaching the LM to assign negative tokens with a lower probability than positive tokens. In this
62
+ 49 work, we combine the CT and cross-entropy objectives to train LMs, where cross-entropy performs
63
+ 50 on the label tokens so that they are assigned the highest probability, and CT effectively suppresses
64
+ 51 negative tokens from being generated.
65
+ 52 We perform evaluations on the tasks of language modeling and open-domain dialogue generation.2
66
+ 53 Our empirical evidence demonstrates that LMs trained with the proposed CT objective can generate
67
+ 54 much less repetitive texts using standard greedy or beam search and achieve superior text generation
68
+ 55 performance under both automatic and human evaluations. CT has a minor negative influence on
69
+ 56 the perplexity of LMs, but thanks to the reduced repetition rates, in our case studies we observe
70
+ 57 substantial improvements regarding the quality of generated text.
71
+
72
+ # 58 2 Background
73
+
74
+ LMs aim to learn the true distribution over variable-length text sequences in a text corpus $X =$ $( x _ { 1 } , x _ { 2 } , \ldots , x _ { | X | } )$ with $| X |$ tokens. A popular approach to this task is next word prediction, i.e., predicting a distribution over the next word following a given context. To train such a language model, cross-entropy and unlikelihood training are two representative objectives. In this section, we first review cross-entropy and unlikelihood training. We then provide an analysis of the text degeneration problem.
75
+
76
+ Table 1: The influence comparison of different learning objectives over the positive (label), negative (incorrectly repeating), and irrelevant tokens (all the others) for the LMs.
77
+
78
+ <table><tr><td rowspan="2"></td><td colspan="2">Relevant tokens</td><td rowspan="2">Contrast</td></tr><tr><td>Positive Negative</td><td>Irrelevant tokens</td></tr><tr><td>Cross-entropy (CE)</td><td>Promote Suppress</td><td>Suppress</td><td>Yes</td></tr><tr><td>Unlikelihood training(UL) Promote</td><td></td><td>Suppress/Promote Promote</td><td>No</td></tr><tr><td>Contrastive token (CT)</td><td>Promote Suppress</td><td>Unchanged</td><td>Yes</td></tr></table>
79
+
80
+ # 65 2.1 Cross entropy
81
+
82
+ 66 A standard approach to training a LM is to minimize the expected cross-entropy loss between the
83
+ 67 true distribution and the model prediction [28]. Specifically, the cross-entropy loss for each time
84
+ 68 step $t$ is defined as:
85
+
86
+ $$
87
+ \begin{array} { r l } & { \mathcal { L } _ { C E } ^ { t } = - \log p ( x _ { t } | x _ { < t } ) } \\ & { \quad \quad = - \log \frac { \exp ( h _ { t } ^ { T } W _ { x _ { t } } ) } { \sum _ { \hat { x } _ { t } \in V } \exp ( h _ { t } ^ { T } W _ { \hat { x } _ { t } } ) } } \\ & { \quad \quad = \log \left( 1 + \displaystyle \sum _ { \hat { x } _ { t } \in V , \hat { x } _ { t } \ne x _ { t } } \exp ( h _ { t } ^ { T } W _ { \hat { x } _ { t } } - h _ { t } ^ { T } W _ { x _ { t } } ) \right) , } \end{array}
88
+ $$
89
+
90
+ 69 where $h _ { t }$ is the model hidden state at time $t$ , $W$ is the embedding matrix, and $W _ { x _ { t } }$ denotes the word
91
+ 70 embedding of token $x _ { t }$ . Through some simple transformations from Eq. (1)–(3), we can see that
92
+ 71 Eq. (3) is similar to the $N$ -pair contrastive loss [24] for visual object recognition. In other words,
93
+ 72 cross-entropy effectively trains LMs to contrast the label tokens (positive examples) $x _ { t }$ with all the
94
+ 73 other non-label tokens (negative and irrelevant examples) $\hat { x } _ { t } \in V , \hat { x } _ { t } \neq x _ { t }$ in the whole vocabulary.
95
+
96
+ # 2.2 Unlikelihood training
97
+
98
+ 75 To address the repetition issue of cross-entropy, Welleck et al. [27] have proposed unlikelihood
99
+ 76 training to penalize the likelihood of negative tokens (UL-T). The unlikelihood loss for time step $t$
100
+ 77 is defined as:
101
+
102
+ $$
103
+ \mathcal { L } _ { U L } ^ { t } = - \sum _ { x _ { t } ^ { - } \in C ^ { t } } \log ( 1 - p ( x _ { t } ^ { - } | x _ { < t } ) ) ,
104
+ $$
105
+
106
+ 78 where $C ^ { t } = \{ x _ { 1 } , \ldots , x _ { t - 1 } \} \backslash \{ x _ { t } \}$ is the set of negative tokens at time $t$ , i.e., all previous context
107
+ 79 tokens. In this paper, we refer to this set of negative tokens as the preceding tokens set. As we will
108
+ 80 see in $\ S 2 . 3$ , UL-T does not work well as it can increase the probability of irrelevant tokens. Welleck
109
+ 81 et al. [27] have also proposed a more effective sequence-level unlikelihood objective (UL-S) that
110
+ 82 uses unlikelihood on decoded continuations during training time. We omit the details here as our
111
+ 83 proposed CT is more closely related to UL-T, but we do compare CT to UL-S in our experiments.
112
+
113
+ # 84 2.3 Discussion
114
+
115
+ The main difference between Eq. (3) and the $N$ -pair contrastive loss is that, in Eq. (3), negative and irrelevant tokens are treated equally by cross-entropy.3 These negative tokens need to be penalized harder than irrelevant tokens, otherwise, negative tokens may be incorrectly repeated in later time steps. This explains why LMs trained by cross-entropy have high repetition rates.
116
+
117
+ Although UL-T penalizes negative tokens, it does not work well enough, and as can be seen from Table 1, the reasons are twofold. First, each negative token is not definitely penalized because it depends on the influence of other negative tokens, which can be seen from the gradient analysis of UL-T (Eq. (11) in Appendix D). Second, the formulation of UL-T unintentionally boosts the probability of other irrelevant tokens and may make them surface as repeated tokens. We detail this analysis in $\ S 3 . 3$ .
118
+
119
+ 96 To address the issues discussed above and inherit the advantages of cross-entropy and unlikelihood
120
+ 97 training, in this section, we present a novel contrastive token learning (CT) objective for LMs. We
121
+ 98 first define the CT loss for each time step. Then we introduce a positive and negative token selection
122
+ 99 strategy. Finally, we discuss the differences and connections of CT with respect to cross-entropy
123
+ 100 and unlikelihood training.
124
+
125
+ # 3.1 Contrastive token learning
126
+
127
+ 102 The key idea of CT is to promote positive (label) tokens in the ranking at each step, while lowering
128
+ 103 negative (incorrectly repeating) tokens, and leave other irrelevant tokens untouched. To this end, we
129
+ 104 formulate the CT loss for step $t$ as:
130
+
131
+ $$
132
+ \mathcal { L } _ { C T } ^ { t } = \log \left( 1 + \sum _ { x _ { t } ^ { - } \in S _ { N } ^ { t } } \exp ( h _ { t } ^ { T } W _ { x _ { t } ^ { - } } - h _ { t } ^ { T } W _ { x _ { t } } ) \right) ,
133
+ $$
134
+
135
+ where 105 $S _ { N } ^ { t }$ is the negative token set and $x _ { t }$ is the positive token (i.e., label token) at time $t$ . We detail the token selection mechanism of 106 $S _ { N } ^ { t }$ below.
136
+
137
+ 07 During the training phase, we combine the CT loss with the cross-entropy loss for each time step as
138
+ 08 follows:
139
+
140
+ $$
141
+ \begin{array} { r } { \mathcal { L } ^ { t } = \mathcal { L } _ { C E } ^ { t } + \mathcal { L } _ { C T } ^ { t } , } \end{array}
142
+ $$
143
+
144
+ where $\mathcal { L } _ { C E } ^ { t }$ aims to promote label tokens, training models to assign the highest probabilities to such tokens. On the other hand, $\mathcal { L } _ { C T } ^ { t }$ focuses on contrasting positive tokens and negative tokens, so that the LMs can learn to effectively rank negative tokens lower than their positive counterparts.
145
+
146
+ # 12 3.2 Negative token selection strategy
147
+
148
+ 113 Following [27], we use the preceding tokens set without requiring additional supervision as our
149
+ 114 negative tokens $S _ { N } ^ { t }$ . However, using all preceding tokens (as in [27]) may bring too much noise to
150
+ 115 the training process, especially for later time steps in a sequence. Hence, we instead propose to use
151
+ 116 the preceding $M$ tokens set to decide the negative tokens, with $M$ being a hyper-parameter. The set
152
+ 117 $S _ { N } ^ { t }$ is defined as:
153
+
154
+ $$
155
+ { \cal S } _ { N } ^ { t } = \{ x _ { t - M } , \ldots , x _ { t - 1 } \} \backslash \{ x _ { t } \} .
156
+ $$
157
+
158
+ Another difference with the preceding tokens set [27] is that, 18 $S _ { N } ^ { t }$ is a multiset that does not remove 19 redundant occurrences. Intuitively, minimizing the CT loss with the preceding $M$ tokens set makes 20 more frequently repeated tokens less likely to be predicted.
159
+
160
+ # 3.3 Gradient analysis
161
+
162
+ 122 To see how loss functions influence the positive, negative and irrelevant tokens during training, we
163
+ 123 derive the gradient functions of each loss function with respect to these tokens in Appendix D. Table
164
+ 124 1 is an intuitive summary of the influences, from which one can observe that: (i) Cross-entropy
165
+ 125 trains to promote label tokens in rankings at each time-step, while suppressing all the other tokens
166
+ 126 including negative and irrelevant tokens. (ii) It cannot be decided for unlikelihood training whether
167
+ 127 the negative tokens are promoted or suppressed by the gradient function (cf. Eq. (11) in Appendix D,
168
+ 128 the valid region for the corresponding gradient function contains both positive and negative values),
169
+ 129 and irrelevant tokens are promoted, both of which are problematic. (iii) With contrastive token
170
+ 130 learning, CT promotes positive tokens and suppresses negative tokens, and it is the only objective
171
+ 131 that does not affect irrelevant tokens (cf. the gradient functions in Appendix D).
172
+ 132 When using CT together with CE, as we do for our final loss function, negatives are suppressed both
173
+ 133 in CT and in CE, while irrelevant tokens are only suppressed in CE. Therefore, our CT objective is
174
+ 134 able to better restrain incorrectly repeated tokens.
175
+
176
+ # 4 Related work
177
+
178
+ 136 We review two lines of related work, i.e., neural text degeneration and contrastive learning.
179
+
180
+ 137 Neural text degeneration. With large-scale pre-training, state-of-the-art neural LMs are able to
181
+ 138 generate human-like texts [1, 28]. However, they suffer from the text degeneration problem, where
182
+ 139 model-generated texts are dull and repetitive [6, 7, 27]. The text degeneration problem is especially
183
+ 140 serious with open-ended generation tasks, such as dialogue generation [9, 23] and language model
184
+ 141 ing [6, 27]. Some decoding approaches have been proposed to address this problem, by introducing
185
+ 142 randomness [4, 6] or disparity [23, 25] at inference time. Some other work suggests that the de
186
+ 143 generation problem is caused by defects of the likelihood training objective, and improved training
187
+ 144 objectives have been proposed [8, 25, 27].
188
+ 145 Our proposed contrastive token learning approach belongs to the training objective family. Com
189
+ 146 pared to unlikelihood training [27], we address the suppression of repetitive tokens by contrasting
190
+ 147 them with positive tokens.
191
+ 148 Contrastive learning. In computer vision, contrastive learning has been widely employed to learn
192
+ 149 representations [2, 10, 24]. Noise-contrastive estimation [5] has been proved successful for training
193
+ 150 word embeddings [16]. In recent years, contrastive learning has gained more attention in the area of
194
+ 151 natural language processing too. Most work builds contrasts at the sequence or document level by
195
+ 152 corrupting the ground truth sequence [3, 12, 14, 29] or mining positive/negative samples [17, 19].
196
+ 153 Existing token-level contrastive learning frameworks contrast model representations from different
197
+ 154 positions [25, 30]. Differently, we contrast word embeddings while using the hidden representations
198
+ 155 as anchor points similar to the triplet contrastive loss [22]. Our formulation effectively contrasts
199
+ 156 logits output by the model for positive and negative tokens, thus it is more direct than unlikelihood
200
+ 157 training on addressing the repetitive degeneration problem. To the best of our knowledge, our pro
201
+ 158 posed contrastive token learning is the first to use token embeddings as positive/negative examples
202
+ 159 in a contrastive framework for the text degeneration problem.
203
+
204
+ # 160 5 Experimental setup
205
+
206
+ We compare CT with baseline approaches on the language modeling and open-domain dialogue generation task. Since our experimental results on the dialogue task show a similar pattern as on the language modeling task, we will focus on the language modeling task in the body of the paper and postpone the setup and analyses of the dialogue task to Appendix I.
207
+
208
+ 165 Baselines and implementation. We implement several state-of-the-art baselines and use them with
209
+ 166 GPT-2 [20]: (i) The vanilla cross-entropy (CE) objective; (ii) decoding-based methods: banning
210
+ 167 3-grams [21], top- $k$ sampling [4], nucleus sampling [6] and contrastive search (SimCTG-CS) [25];
211
+ 168 and (iii) learning-based methods: unlikelihood training [27], SimCTG [25], and noise-contrastive
212
+ 169 estimation (NCE; detailed in Appendix C) [5]. More details can be found in Appendix E.
213
+ 170 Dataset, training and inference details. At training time, we fine-tune GPT-2 small on the widely
214
+ 171 used Wikitext-103 dataset [15] with each learning-based approach (including the CE baseline) for
215
+ 172 50K steps with 3K warm-up steps. As suggested in [27], for sequence-level unlikelihood training,
216
+ 173 we first fine-tune the language model using UL-T for $4 8 . 5 \mathrm { K }$ steps, and then switch to the UL-S
217
+ 174 objective for another 1.5K steps, resulting in UL-TS. Best model checkpoints for each task are
218
+ 175 selected according to the lowest validation CE loss with an evaluation interval of 1K training steps.
219
+ 176 We use trunks of 512 tokens, and a training batch size of 4. All models are trained using the Adam
220
+ 177 optimizer [11] with a learning rate of 1e-5. For UL-TS, we had to use a smaller learning rate of
221
+ 178 1e-6, otherwise the generated texts contain massive ungrammatical repetitions (continuous token
222
+ 179 repetitions, as can be seen in Table 5 of Appendix F).
223
+ 180 At inference time, we compare the performance of each approach to text degeneration using both
224
+ 181 greedy search and beam search. We use $k = 5 0$ for top- $k$ sampling, and $p = 0 . 9$ for deciding the
225
+ 182 sampling pool of the nucleus method. We follow Welleck et al. [27] to use 50 tokens as the input
226
+ 183 prefix and let the model generate 100 tokens as a continuation.
227
+
228
+ Evaluation metrics. We measure the perplexity (ppl) of different approaches. For measuring generative repetition, we follow Welleck et al. [27] to use 1-gram to 4-gram repetition rates $( \tt r e p - 1$ $- \ \tt r e p - 4 ,$ ), which are defined as the number of repeated $n$ -grams divided by the total number of generated $n$ -grams in each sequence, micro-averaged over the whole dataset. We also report the generation diversity at the dataset level, which is measured by distinct 1-gram rates (dist-1) [13] and unique 1-gram counts (uniq-1). We adopt human evaluation for measuring the quality of
229
+
230
+ Table 2: Results on the test set of Wikitext-103 for the language modeling task. $\uparrow / \downarrow$ arrows denote whether higher or lower is better for a metric. The best result for either type of approach (decodingbased vs. learning-based) under each metric is highlighted in bold face. ‡ Does not count as the best. † For this experiment, we use a beam size of 5 as suggested in its original paper [25].
231
+
232
+ <table><tr><td></td><td>ppl↓</td><td>ppl-s↓</td><td> search</td><td>rep-1↓</td><td>rep-2↓</td><td>rep-3↓</td><td>rep-4↓</td><td>dist-1个</td><td>uniq-1个</td></tr><tr><td>GPT-2</td><td>18.01</td><td>25.95</td><td>greedy beam</td><td>71.03 77.02</td><td>60.12 69.70</td><td>54.77 65.49</td><td>50.93 61.69</td><td>1.15 1.12</td><td>12787 12545</td></tr><tr><td>3-gram ban</td><td>18.01</td><td>25.95</td><td>greedy beam</td><td>50.09 40.91</td><td>18.31 10.40</td><td>0.00 0.00t</td><td>0.00t 0.00t</td><td>1.52 1.35</td><td>16940 15114</td></tr><tr><td>pasp-8uiporap Top-k</td><td>18.01</td><td>25.95</td><td>greedy beam</td><td>34.80 73.47</td><td>9.38 64.38</td><td>3.86 59.31</td><td>1.73</td><td>2.23 1.19</td><td>24840</td></tr><tr><td>Nucleus</td><td>18.01</td><td>25.95</td><td>greedy</td><td>38.41</td><td>12.10</td><td>5.50</td><td>54.88 2.78</td><td>2.06</td><td>13280 23038</td></tr><tr><td></td><td></td><td>26.10</td><td>beam greedy</td><td>74.28 70.23</td><td>65.70 58.92</td><td>60.86</td><td>56.58 49.54</td><td>1.17</td><td>13004</td></tr><tr><td>SimCTG-CS</td><td>18.12</td><td></td><td>beamt</td><td>31.93</td><td>6.52</td><td>53.44 2.23</td><td>0.94</td><td>1.17 1.77</td><td>13005 19746</td></tr><tr><td>SimCTG</td><td>18.12</td><td>26.10</td><td>greedy</td><td>70.23</td><td>58.92</td><td>53.44</td><td>49.54</td><td>1.17</td><td>13005</td></tr><tr><td></td><td></td><td></td><td>beam</td><td>75.87</td><td>68.02</td><td>63.54</td><td>59.52</td><td>1.15</td><td>12835</td></tr><tr><td>NCE</td><td>18.60</td><td>32.88</td><td> greedy</td><td>57.23</td><td>41.59</td><td>35.50</td><td>31.75</td><td>1.32</td><td>14774</td></tr><tr><td>UL-T</td><td></td><td>26.63</td><td>beam greedy</td><td>56.02 60.91</td><td>40.99</td><td>34.73</td><td>30.48</td><td>1.28</td><td>14322</td></tr><tr><td>paspp-8iraa</td><td>18.93</td><td></td><td>beam</td><td>67.39</td><td>45.15 55.95</td><td>38.31 49.85</td><td>33.90 44.78</td><td>1.26 1.15</td><td>14071 12874</td></tr><tr><td>UL-TS</td><td>18.88</td><td>27.41</td><td> greedy</td><td>51.98</td><td>29.17</td><td>19.71</td><td>14.42</td><td>1.29</td><td>14378</td></tr><tr><td></td><td></td><td></td><td>beam</td><td>45.81</td><td>23.96</td><td>15.60</td><td>10.41</td><td>1.27</td><td>14141</td></tr><tr><td>CT</td><td>18.72</td><td>64.01</td><td>greedy</td><td>22.09</td><td>4.02</td><td>1.49</td><td>0.80</td><td>2.05</td><td>22832</td></tr><tr><td></td><td></td><td></td><td>beam</td><td>27.18</td><td>9.71</td><td>5.73</td><td>3.77</td><td>1.68</td><td>18697</td></tr><tr><td>Human</td><td>1</td><td>1</td><td>1</td><td>29.92</td><td>7.25</td><td>2.81</td><td>1.14</td><td>3.41</td><td>19034</td></tr></table>
233
+
234
+ 190 model generated texts. We randomly select 100 prefixes from the test set of Wikitext-103, and com
235
+ 191 pare the continuations generated using CT with those by the best-performing baselines according to
236
+ 192 the automatic evaluation results. Since it does not make much sense to compare continuations with
237
+ 193 either side having excessive repetitions, we filter out such pairs using a threshold of $\mathtt { r e p - 4 } \le 0 . 0 5$
238
+ 194 to make the comparisons more competitive. Then we display the prefix and two continuations from
239
+ 195 different systems (side-by-side, in a random order) to three crowd workers and ask them to select
240
+ 196 the winner in terms of repetition, coherence, fluency, and overall quality. Ties are allowed for all
241
+ 197 aspects. We use majority voting to decide the final winner. Details about our question form design
242
+ 198 and the instructions to crowd workers can be found in Appendix G.
243
+
244
+ # 6 Evaluation results
245
+
246
+ We conduct extensive experiments to demonstrate the advantages of our proposed CT. In this section, we discuss how CT compares to SOTA methods under both the automatic and human evaluations as well as showing some visualization analysis on its generation probability.
247
+
248
+ # 6.1 Baseline comparison
249
+
250
+ The performance comparisons between our CT and the baselines on the language modeling task are shown in Table 2. For models, the repetition and diversity results are calculated on model-generated continuations of 100 tokens, using 50 tokens of human-created text as the prefix. For the human performance, we calculate the metrics on trunks of 100 tokens for a fair comparison. The $\mathrm { p p 1 }$ metric is for 512-token sequences to comply with the training sequence length. To be comparable to existing work [25, 27], we also report $\mathrm { p p } 1 - s$ for short sequences of 50 tokens. We use a sequence length of 150 tokens and $M = 6 0$ as the negative window size for CT. Justifications for such hyperparameter selections can be found in Appendix F.2.
251
+
252
+ ![](images/5fa906ae57964eaf96d93f696c7dac697efa8e72665142fff9fa34abfd95aecb.jpg)
253
+ Figure 2: Histograms for $\tt r e p - 1$ (left) and $\tt c e p - 4$ (right) rates of each method, on the Wikitext-103 test set.
254
+
255
+ 2 CT compared to learning-based approaches. One can observe that CT performs the best and 3 even outperforms humans according to $\tt r e p - \star$ rates and unique token counts $( \mathsf { u n i q - 1 } )$ ) when using greedy search. However, the repetition problem is still not yet solved, because when looking 5 at specific cases, models trained by CT still occasionally generate texts with excessive repetitions, 6 though being much rarer than baseline methods. To see how each method performs at every repetition level, we group the $\tt r e p - 1$ and $\tt c e p - 4$ rates of model-generated texts in to 5 bins, and plot their histograms in Figure 2, from which we can see that CT generates substantially less degener9 ated continuations (with $\mathtt { r e p - 1 \ge \ 0 . 4 }$ and $\Upsilon \mathrm { e p } { - } 4 \geq 0 . 2 )$ . For UL-TS, we were able to achieve lower repetition rates with a larger learning rate of 1e-5 during training. However, the trained LM often generates ungrammatical repetitions. This problem does not exist with CT when trained with 2 a learning rate as large as 1e-4. The comparisons are shown in Table 5 in Appendix F, and in $\ S 6 . 3$ 23 we show that this is caused by UL-TS being uncertain about its predictions at later time steps.
256
+
257
+ 224 The diversity improvements brought by CT are the largest among all learning-based methods, espe
258
+ 225 cially when using greedy search. CT increases the second highest uniq-1 count (NCE) by $5 5 \%$ .
259
+ 226 When comparing NCE and UL-T, one can see that utilizing the contrast between positive and neg
260
+ 227 ative tokens works better than solely penalizing negative tokens. The primary difference between
261
+ 228 CT and NCE is that the positive and negative tokens of CT interact with each other, while those
262
+ 229 of NCE do not (Table 1, more details in Appendix D). This explains the lower $\tt r e p - \star$ rates and
263
+ 230 higher diversity of CT, which also concurs with the observation made by Sohn [24] that interactive
264
+ 231 contrastive losses work better than non-interactive counterparts.
265
+
266
+ The ppl increase brought by CT is minor, with 0.71 points. When calculated on short sequences, due to the length mismatch of training and test sequences, $\mathrm { p p } 1 - s$ scores are higher than $\mathrm { p p 1 }$ for all approaches. Among them, contrastive objectives (NCE and CT) have larger $\mathrm { p p } 1 - s$ increases than other methods. Although CT has the highest increase on $\mathrm { p p } 1 - s$ , our case study (Table 4) shows that the generation quality of CT is not harmed, but on the contrary is improved due to the lower repetition and higher diversity of the generated texts.
267
+
268
+ CT compared to decoding-based approaches. Although CT is a learning-based method, we still compare it against decoding approaches for a more comprehensive understanding of its performance. When greedy search is used, CT outperforms the best decoding method (Top- $k$ ) in terms of $\tt Y e p - \star$ rates, which again proves the effectiveness of contrastive learning. When using beam search, all but SimCTG-CS perform significantly worse than CT, both in terms of repetition rates and diversity. SimCTG-CS is effective at reducing repetition as it explicitly requires a disparity among different time steps at inference time. This can harm the generation quality, especially the coherence and fluency, as we see in $\ S 6 . 2$ . It is also worth noting that SimCTG-CS only works together with its SimCTG training objective and with beam search [25]. In summary, one can see that the repetition problem can be better addressed from the model learning perspective, in which case a simple greedy decoding strategy suffices.
269
+
270
+ # 6.2 Human evaluation
271
+
272
+ Human evaluation results are shown in Table 3. Regarding the overall quality, CT performs significantly better than Top- $k$ and SimCTG-CS, two decoding based approaches. Instead of purely learning generation policies from data, decoding approaches exert heuristics at inference time, which
273
+
274
+ Table 3: Win/lose rates $( \% )$ of CT compared to baselines under human evalutaions. For a competitive comparison, we filtered out highly repetitive examples of either model in the pair. \* indicates statistical significance as determined with a sign test $( p < 0 . 0 5 )$ .
275
+
276
+ <table><tr><td rowspan="2">Comparison</td><td colspan="2">Overall</td><td colspan="2">Repetition</td><td colspan="2">Coherence</td><td colspan="2">Fluency</td></tr><tr><td>Win</td><td>Lose</td><td>Win</td><td>Lose</td><td>Win</td><td>Lose</td><td>Win</td><td>Lose</td></tr><tr><td>CT vs Top-k</td><td>58*</td><td>36</td><td>40*</td><td>23</td><td>56*</td><td>36</td><td>45</td><td>36</td></tr><tr><td>CT vs SimCTG-CS</td><td>55*</td><td>35</td><td>46*</td><td>18</td><td>52</td><td>36</td><td>54*</td><td>28</td></tr><tr><td>CT vs UL-TS</td><td>48</td><td>43</td><td>43</td><td>28</td><td>39</td><td>45</td><td>47</td><td>38</td></tr><tr><td>CT vs Human</td><td>27</td><td>67*</td><td>30</td><td>35</td><td>23</td><td>67*</td><td>27</td><td>57*</td></tr></table>
277
+
278
+ 253 may prevent the language model from performing naturally. This explains the worse performance of
279
+ 254 decoding approaches on coherence and fluency. CT performs generally better than UL-TS except on
280
+ 255 coherence, but none of these differences are statistically significant. This suggests that CT has a sim
281
+ 256 ilar generation quality as UL-TS on low-repetitive examples, but CT has much lower repetition rates
282
+ 257 as reported in Table 2. This result is expected, as both CT and UL-TS are learning-based approaches
283
+ 258 for training data-driven models, and on normal cases such as low-repetitive generations, they should
284
+ 259 perform similarly. Compared to human performance, there is still a large margin for machine learn
285
+ 260 ing models before they have a comparable performance on the language modeling task. Although
286
+ 261 CT performs on par with humans regarding repetition, its generations are far less coherent and fluent
287
+ 262 than those of humans. This may be mitigated by using larger models such as GPT-2 large or GPT-3.
288
+ 263 However, we could not perform such experiments due to a lack of computational resources.
289
+
290
+ # 6.3 Visualization analysis of the generation probability
291
+
292
+ We also conduct analyses to understand the predicted probability of model-generated tokens at inference time. As shown in Figure 3, diagonal cells represent the probability of generated tokens at the corresponding time steps; off-diagonal cells represent the probability of context tokens. The plots are averaged over 10 random instances from the test set of Wikitext-103.
293
+
294
+ ![](images/4af3b3796a9b2be24ced8baeee58ec5f8f7d9a883a60db8f20c32edbf7cd6939.jpg)
295
+ Figure 3: Heat maps for the generation probability of CT, CE and, UL-TS, at inference time. Row and column labels represent model-generated tokens at each time step, and the saturation of each cell represents the corresponding probability of each token. Please refer to $\ S 6 . 3$ for a more detailed description. Heat maps for NCE, UL-T and SimCTG look similar to that of CE, and can be found in Appendix F, Figure 4.
296
+
297
+ 269 We have the following key observations from Figure 3: (i) The heat map of CT shows a high variance
298
+ 270 in the diagonal, meaning that the model becomes certain and uncertain from time to time. As noted
299
+ 271 by Holtzman et al. [6], human-created texts also show such a pattern when fed through pretrained
300
+ 272 language models. (ii) In comparison, the heat map for CE shows clear stripes, which stand for
301
+ 273 excessive repetition of context n-grams. Besides, the diagonal cells are increasingly darker from
302
+ 274 top to bottom, revealing that the language model is becoming more and more certain about its later
303
+ 275 predictions, and it seems to positively correlate with the heavier repetition in the later halves of
304
+ 276 sequences. (iii) Contrary to CE, the heat map for UL-TS is almost white at the lower and the
305
+ 277 right parts of the heat map, indicating the language model is uncertain about any prediction in later
306
+ 278 stages, and the generated tokens just win marginally over other candidates. This is expected, since
307
+
308
+ Table 4: Continuations generated using UL-TS have heavier repetition than those generated using CT. Greedy search is used. More comparisons to other approaches can be seen in Table 6 in Appendix F.
309
+
310
+ <table><tr><td colspan="2"></td><td>rep-1</td></tr><tr><td>Prefix</td><td>the American lobster,H.americanus.It may grow toa length of 60 cm(24 in)and amassof 6kilograms(13 lb), and bears a conspicuous pair of claws.In life,the lobsters are blue,</td><td></td></tr><tr><td>UL-TS</td><td>with a white spotontheunderside.Theeggsare laidinasingle,white sac,andhatch inthe spring.Theadultis about 1 @.52cm(0 @.@ 81 @.@ 9in)long,and weighs about1 @.52 @.@ 5kg(2 @.5 3 @.@ 8Ib). The eggs are laid in a single,white @ brownish @ brown shell,with a white margin</td><td>0.55</td></tr><tr><td>CT</td><td>yellow,or greenish @-@ brown with short pointed teeth.The male lays eggs on topof the female&#x27;sabdomen, which are incubatedby meansoftubesatachedtotheskin.Afterthree weeks,theeggs hatch intoadult males.==Taxonomy ==Thegenus H.americanus has been described by severalauthors since itsdiscovery in 1887.Most notably John</td><td>0.18</td></tr><tr><td>Prefix</td><td>He married around 752,and by757 thecouple had had fivechildren three sons and two daughtersbut one of the sons died in infancy in 755.From 754 he</td><td></td></tr><tr><td>UL-TS</td><td>wasa prominentfigureintheChurchofEngland,andin758hewasappointedvicarofStJohn&#x27;s,andin759 he was appointedvicaroftheChurch of Scotland.He died in761,and was succeededby hisson,John,whodied in762. ==Early life==JohnwasbornintheparishofStJohn&#x27;s,in theparishofStJohn&#x27;s,intheparishofStJohn&#x27;s</td><td>0.61</td></tr><tr><td>CT</td><td>parish, continued to liveat St.John&#x27;s Church,near Bath,where hereceived instruction from Wiliam de Montforton how to buildadamfor irigationpurposes.The first mentionof this work came in757 when it was discovered that a large portionof theearthbeneath theriverbed had been washedawayby floodscaused bywind gusts.This led to speculation that itmightbeconnected tothe Norman invasionof England.In758,however,HenryVII granted permission for construction of a</td><td>0.21</td></tr></table>
311
+
312
+ UL-TS penalizes repetitions unilaterally, and repetitions are more common in the later half of a model-generated sequence. Even though UL-TS is able to effectively reduce repetition rates, its heat map shows that the language model trained by UL-TS may subject to frequent grammatical errors, as can be seen in Appendix F, Table 5.
313
+
314
+ # 6.4 Case study
315
+
316
+ To intuitively see how well CT performs, we selected some example generations of CT, and compare them with those generated using UL-TS in Table 4. More often than not, continuations generated by CT are less repetitive and make more sense than those generated by UL-TS. The reason for the poor quality of UL-TS is that sequence-level unlikelihood training penalizes repeated 4-grams generated by LMs, making LMs uncertain about their predictions as suggested in Figure 3.
317
+
318
+ # 89 7 Conclusion and discussion
319
+
320
+ In this paper we studied the neural text degeneration problem. By integrating the best of crossentropy and unlikelihood training objectives, we obtain a simple and effective contrastive token learning (CT) framework. The main novelty of this work is adapting contrastive learning to the token level of autoregressive language model training. As far as we are aware, our work is the first to use model hidden states as the anchor points and tokens as the positive and negative examples to formulate the contrastive loss. By contrasting the preceding $M$ tokens at a training step with the label token, LMs learn to not repeat such tokens, thus alleviating the repetition problem. Although the idea of negative tokens is similar to UL, our formulation of contrastive objective is more effective and safer to use. Experiments on the open-ended text generation and open-domain dialogue generation tasks show that CT beats UL-TS, the previous state-of-the-art approach to tackling the repetitive text degeneration problem. CT not only achieves the lowest repetition rates and the highest generation diversity, but also higher generation quality according to our human evaluation.
321
+
322
+ 302 We performed experiments on fine-tuning LMs for reducing their repetition rates, which can be
323
+ 303 beneficial for related tasks such as abstractive summarization, machine translation, and image cap
324
+ 304 tioning. Our early experiments show that CT can be safely integrated when training a language
325
+ 305 model from scratch, which can be helpful for future pre-training of large language models. In this
326
+ 306 work, we used CT with decoder-only (GPT2) and encoder-decoder (BlenderBot) language models,
327
+ 307 but we note that CT can also be used with encoder language models (e.g., BERT [26]) to potentially
328
+ 308 improve the model performance such as prediction accuracy. The repetitive degeneration problem
329
+ 309 is still not fully solved as occasional, excessive phrase repetitions remain in the generated texts. We
330
+ 310 leave these research directions as future work.
331
+
332
+ References [1] Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models are few-shot learners. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual. [2] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey E. Hinton. 2020. A simple framework for contrastive learning of visual representations. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 1597–1607. PMLR. [3] Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. 2020. ELECTRA: pre-training text encoders as discriminators rather than generators. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net. [4] Angela Fan, Mike Lewis, and Yann Dauphin. 2018. Hierarchical neural story generation. In ACL, pages 889–898. [5] Michael Gutmann and Aapo Hyvärinen. 2010. Noise-contrastive estimation: A new estimation principle for unnormalized statistical models. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pages 297–304. JMLR Workshop and Conference Proceedings. [6] Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. 2020. The curious case of neural text degeneration. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net. [7] Shaojie Jiang and Maarten de Rijke. 2018. Why are sequence-to-sequence models so dull? understanding the low-diversity problem of chatbots. In Proceedings of the 2018 EMNLP Workshop SCAI: The 2nd International Workshop on Search-Oriented Conversational AI. ACL. [8] Shaojie Jiang, Pengjie Ren, Christof Monz, and Maarten de Rijke. 2019. Improving neural response diversity with frequency-aware cross-entropy loss. In The Web Conference 2019, pages 2879–2885. ACM. [9] Shaojie Jiang, Thomas Wolf, Christof Monz, and Maarten de Rijke. 2020. TLDR: token loss dynamic reweighting for reducing repetitive utterance generation. CoRR, abs/2003.11963. [10] Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. 2020. Supervised contrastive learning. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual. [11] Diederik P Kingma and Jimmy Ba. 2014. Adam: A method for stochastic optimization. In Proceedings of the 3rd International Conference on Learning Representations (ICLR). [12] Seanie Lee, Dong Bok Lee, and Sung Ju Hwang. 2021. Contrastive learning with adversarial perturbations for conditional text generation. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net. [13] Jiwei Li, Michel Galley, Chris Brockett, Jianfeng Gao, and Bill Dolan. 2016. A diversitypromoting objective function for neural conversation models. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 110–119. 358 [14] Yu Meng, Chenyan Xiong, Payal Bajaj, Saurabh Tiwary, Paul Bennett, Jiawei Han, and Xia Song. 2021. COCO-LM: correcting and contrasting text sequences for language model pretraining. Advances in Neural Information Processing Systems, abs/2102.08473.
333
+
334
+ 61 [15] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2017. Pointer sentinel
335
+ 62 mixture models. In 5th International Conference on Learning Representations, ICLR 2017,
336
+ 63 Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net.
337
+ 64 [16] Tomás Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. 2013. Efficient estimation of word
338
+ 65 representations in vector space. In 1st International Conference on Learning Representations,
339
+ 66 ICLR 2013, Scottsdale, Arizona, USA, May 2-4, 2013, Workshop Track Proceedings. [17] Thong Nguyen and Anh Tuan Luu. 2021. Contrastive learning for neural topic model. CoRR,
340
+ 68 abs/2110.12764.
341
+ 69 [18] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L Wainwright, Pamela Mishkin,
342
+ 70 Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. 2022. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155. [19] Xiao Pan, Mingxuan Wang, Liwei Wu, and Lei Li. 2021. Contrastive learning for many-tomany multilingual neural machine translation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, ACL/IJCNLP 2021, (Volume 1: Long Papers), Virtual Event, August 1-6, 2021, pages 244–258. Association for Computational Linguistics. [20] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. 2019. Language models are unsupervised multitask learners. [21] Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Eric Michael Smith, Y-Lan Boureau, and Jason Weston. 2021. Recipes for building an open-domain chatbot. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, EACL 2021, Online, April 19 - 23, 2021, pages 300–325. Association for Computational Linguistics. [22] Florian Schroff, Dmitry Kalenichenko, and James Philbin. 2015. Facenet: A unified embedding for face recognition and clustering. In IEEE Conference on Computer Vision and Pattern
343
+ 86 Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 815–823. IEEE Computer Society. [23] Abigail See, Stephen Roller, Douwe Kiela, and Jason Weston. 2019. What makes a good conversation? how controllable attributes affect human judgments. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pages 1702–1723. Association for Computational Linguistics. [24] Kihyuk Sohn. 2016. Improved deep metric learning with multi-class n-pair loss objective. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pages 1849– 1857. [25] Yixuan Su, Tian Lan, Yan Wang, Dani Yogatama, Lingpeng Kong, and Nigel Collier. 2022. A
344
+ 99 contrastive framework for neural text generation. CoRR, abs/2202.06417. [26] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In NeurIPS, pages 6000– 6010. [27] Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Dinan, Kyunghyun Cho, and Jason Weston. 2020. Neural text generation with unlikelihood training. In 8th International Conference on
345
+ 05 Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenRe
346
+ 06 view.net. [28] Zhilin Yang, Zihang Dai, Yiming Yang, Jaime G. Carbonell, Ruslan Salakhutdinov, and
347
+ 08 Quoc V. Le. 2019. Xlnet: Generalized autoregressive pretraining for language understand
348
+ 09 ing. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural
349
+ 10 Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 5754–5764.
350
+
351
+ [29] Zonghan Yang, Yong Cheng, Yang Liu, and Maosong Sun. 2019. Reducing word omission errors in neural machine translation: A contrastive learning approach. In Proceedings of the 57th Conference of the Association for Computational Linguistics, ACL 2019, Florence, Italy, July 28- August 2, 2019, Volume 1: Long Papers, pages 6191–6196. Association for Computational Linguistics.
352
+
353
+ [30] Tong Zhang, Wei Ye, Baosong Yang, Long Zhang, Xingzhang Ren, Dayiheng Liu, Jinan Sun, Shikun Zhang, Haibo Zhang, and Wen Zhao. 2021. Frequency-aware contrastive learning for neural machine translation. CoRR, abs/2112.14484.
354
+
355
+ # Checklist
356
+
357
+ 1. For all authors...
358
+
359
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
360
+ (b) Did you describe the limitations of your work? [Yes] See Section 7.
361
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix A.
362
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] See Appendix A.
363
+
364
+ 2. If you are including theoretical results...
365
+
366
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
367
+
368
+ 3. If you ran experiments...
369
+
370
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section 1.
371
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5, the README file in our source code (link or the .zip file in our supplementary material) and Appendix F.2.
372
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We train the models by finetuning, and we observed them to be insensitive to different random seeds.
373
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 5.
374
+
375
+ If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
376
+
377
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Appendix E.
378
+ (b) Did you mention the license of the assets? [Yes] See Appendix E.
379
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
380
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] We only used public and credible datasets in this work.
381
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] Please see Appendix A.
382
+
383
+ 5. If you used crowdsourcing or conducted research with human subjects...
384
+
385
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes] Please see Appendix F.
386
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
387
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] See Appendix A.
md/dev/AyajSjTAzmg/AyajSjTAzmg.md ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SCINet: Time Series Modeling and Forecasting with Sample Convolution and Interaction
2
+
3
+ Minhao Liu∗, Ailing Zeng, Muxi Chen, Zhijian Xu, Qiuxia Lai, Lingna Ma, Qiang $\mathbf { X } \mathbf { u } ^ { * }$ CUhk REliable Computing (CURE) Lab. Dept. of Computer Science & Egnineering, The Chinese University of Hong Kong ∗{mhliu,qxu}@cse.cuhk.edu.hk
4
+
5
+ # Abstract
6
+
7
+ One unique property of time series is that the temporal relations are largely preserved after downsampling into two sub-sequences. By taking advantage of this property, we propose a novel neural network architecture that conducts sample convolution and interaction for temporal modeling and forecasting, named SCINet. Specifically, SCINet is a recursive downsample-convolve-interact architecture. In each layer, we use multiple convolutional filters to extract distinct yet valuable temporal features from the downsampled sub-sequences or features. By combining these rich features aggregated from multiple resolutions, SCINet effectively models time series with complex temporal dynamics. Experimental results show that SCINet achieves significant forecasting accuracy improvements over both existing convolutional models and Transformer-based solutions across various real-world time series forecasting datasets. Our codes and data are available at https://github.com/cure-lab/SCINet.
8
+
9
+ # 1 Introduction
10
+
11
+ Time series forecasting (TSF) enables decision-making with the estimated future evolution of metrics or events, thereby playing a crucial role in various scientific and engineering fields such as healthcare [1], energy management [42], traffic flow [42], and financial investment [10], to name a few.
12
+
13
+ There are mainly three kinds of deep neural networks used for sequence modeling, and they are all applied for time series forecasting [24]: (i). recurrent neural networks (RNNs) [13]; (ii). Transformerbased models [37]; and (iii). temporal convolutional networks (TCN) [4].
14
+
15
+ Despite the promising results of TSF methods based on these generic models, they do not consider the specialty of time series data during modeling. For example, one unique property of time series is that the temporal relations (e.g., the trend and the seasonal components of the data) are largely preserved after downsampling into two sub-sequences. Consequently, by recursively downsampling the time series into sub-sequences, we could obtain a rich set of convolutional filters to extract dynamic temporal features at multiple resolutions.
16
+
17
+ Motivated by the above, in this paper, we propose a novel neural network architecture for time series modeling and forecasting, named sample convolution and interaction network (SCINet). The main contributions of this paper are as follows:
18
+
19
+ • We propose SCINet, a hierarchical downsample-convolve-interact TSF framework that effectively models time series with complex temporal dynamics. By iteratively extracting and exchanging information at multiple temporal resolutions, an effective representation with enhanced predictability can be learned, as verified by its comparatively lower permutation entropy (PE) [16].
20
+
21
+ ![](images/451dac6f535fc290242c32a2e5a4c25f35e320a3c7a7d206a7176ced7e029433.jpg)
22
+ Figure 1: Existing sequence modeling architectures for time series forecasting.
23
+
24
+ • We design the basic building block, SCI-Block, for constructing SCINet, which downsamples the input data/feature into two sub-sequences, and then extracts features of each subsequence using distinct convolutional filters. To compensate for the information loss during the downsampling procedure, we incorporate interactive learning between the two convolutional features within each SCI-Block.
25
+
26
+ Extensive experiments on various real-world TSF datasets show that our model consistently outperforms existing TSF approaches by a considerable margin. Moreover, while SCINet does not explicitly model spatial relations, it achieves competitive forecasting accuracy on spatial-temporal TSF tasks.
27
+
28
+ # 2 Related Work and Motivation
29
+
30
+ The time series forecasting problem is defined as: Given a long time series $\mathbf { X } ^ { * }$ and a look-back window of fixed length $T$ , at timestamp $t$ , time series forecasting is to predict $\hat { \mathbf { X } } _ { t + 1 : t + \tau } = \{ \mathbf { x } _ { t + 1 } , . . . , \mathbf { x } _ { t + \tau } \}$ based on the past $T$ steps $\mathbf { X } _ { t - T + 1 : t } = \{ \mathbf { x } _ { t - T + 1 } , . . . , \mathbf { x } _ { t } \}$ . Here, $\tau$ is the length of the forecast horizon, $\mathbf { x } _ { t } \in \mathbb { R } ^ { d }$ is the value at time step $t$ , and $d$ is the number of variates. For simplicity, in the following we will omit the subscripts, and use $\mathbf { X }$ and $\hat { \mathbf X }$ to represent the historical data and the forecasted data, respectively.
31
+
32
+ # 2.1 Related Work
33
+
34
+ Traditional time series forecasting methods such as the autoregressive integrated moving average (ARIMA) model [8] and Holt-Winters seasonal method [14] have theoretical guarantees. However, they are mainly applicable for univariate forecasting problems, restricting their applications to complex time series data. With the increasing data availability and computing power in recent years, it is shown that deep learning-based TSF techniques have the potential to achieve better forecasting accuracy than conventional approaches [24, 29].
35
+
36
+ Earlier RNN-based TSF methods [31, 32] summarize the past information compactly in the internal memory states that are recursively updated with new inputs at each time step, as shown in Fig. 1(a). The gradient vanishing/exploding problems and the inefficient training procedure greatly restrict the application of RNN-based models.
37
+
38
+ In recent years, Transformer-based models [37] have taken the place of RNN models in almost all sequence modeling tasks, thanks to the effectiveness and efficiency of the self-attention mechanisms. Various Transformer-based TSF methods (see Fig. 1(b)) are proposed in the literature [21, 23, 38, 25]. These works typically focus on the challenging long-term time series forecasting problem, taking advantage of their remarkable long sequence modeling capabilities.
39
+
40
+ Another popular type of TSF model is the so-called temporal convolutional network [7, 4, 33, 39, 27], wherein convolutional filters are used to capture local temporal features (see Fig. 1(c)). The proposed SCINet is also constructed based on temporal convolution. However, our method has several key differences compared with the TCN model based on dilated causal convolution, as discussed in the following.
41
+
42
+ # 2.2 Rethinking Dilated Causal Convolution for Time Series Modeling and Forecasting
43
+
44
+ The local correlation of time series data is reflected in the continuous changes within a time slot, and convolutional filters can effectively capture such local features. Consequently, convolutional neural networks are explored in the literature for time series modeling and forecasting. In particular, dilated causal convolution (DCS) is the current de facto method used in this respect.
45
+
46
+ DCS was first proposed for generating raw audio waveforms in WaveNet [28]. Later, [4] simplifies the WaveNet architecture to the so-called temporal convolutional networks (see Fig. 1 (c)). TCN consists of a stack of causal convolutional layers with exponentially enlarged dilation factors, which can achieve a large receptive field with just a few convolutional layers. Over the years, TCN has been widely used in all kinds of time series forecasting problems and achieve promising results [39, 33]. Moreover, convolutional filters can work seamlessly with graph neural networks (GNNs) to solve various spatial-temporal TSF problems.
47
+
48
+ With causal convolutions in the TCN architecture, an output $i$ is convolved only with the $i ^ { t h }$ and earlier elements in the previous layer. While causality should be kept in forecasting tasks, the potential “future information leakage" problem exists only when the output and the input have temporal overlaps. In other words, causal convolutions should be applied only in autoregressive forecasting, wherein the previous output serves as the input for future prediction. When the predictions are completely based on the known inputs in the look-back window, there is no need to use causal convolutions. We can safely apply normal convolutions on the look-back window for forecasting.
49
+
50
+ More importantly, the dilated architecture in TCN has two inherent limitations:
51
+
52
+ • A single convolutional filter is shared within each layer. Such a unified convolutional kernel tends to extract the average temporal features from the data/features in the previous layer. However, complex time series may contain substantial temporal dynamics. Hence, it is essential to extract distinct yet valuable features with a rich set of convolutional filters. • While the final layer of the TCN model has the global view of the entire look-back window, the effective receptive fields of the intermediate layers (especially those close to the inputs) are limited, causing temporal relation loss during feature extraction.
53
+
54
+ The above limitations of the TCN architecture motivate the proposed SCINet design, as detailed in the following section.
55
+
56
+ ![](images/f143f23cb6323caa9d930aec3f779d82699957936c29724ffe55e26d54736ffa.jpg)
57
+ Figure 2: The overall architecture of Sample Convolution and Interaction Network (SCINet).
58
+
59
+ # 3 SCINet: Sample Convolution and Interaction Network
60
+
61
+ SCINet adopts an encoder-decoder architecture. The encoder is a hierarchical convolutional network that captures dynamic temporal dependencies at multiple resolutions with a rich set of convolutional filters. As shown in Fig. 2(a), the basic building block, SCI-Block (Section 3.1), downsamples the input data or feature into two sub-sequences and then processes each sub-sequence with a set of convolutional filters to extract distinct yet valuable temporal features from each part. To compensate for the information loss during downsampling, we incorporate interactive learning between the two sub-sequences. Our SCINet (Section 3.2) is constructed by arranging multiple SCI-Blocks into a binary tree structure (Fig. 2(b)). A distinctive advantage of such design is that each SCI-Block has both local and global views of the entire time series, thereby facilitating the extraction of useful temporal features. After all the downsample-convolve-interact operations, we realign the extracted features into a new sequence representation and add it to the original time series for forecasting with a fully-connected network as the decoder. To facilitate extracting complicated temporal patterns, we could further stack multiple SCINets and apply intermediate supervision to get a Stacked SCINet (Section 3.3), as shown in Fig. 2(c).
62
+
63
+ # 3.1 SCI-Block
64
+
65
+ The SCI-Block (Fig. 2(a)) is the basic module of the SCINet, which decomposes the input feature $\mathbf { F }$ into two sub-features $\mathbf { F } _ { o d d } ^ { ' }$ and $\mathbf { F } _ { e v e n } ^ { ' }$ through the operations of Spliting and Interactive-learning.
66
+
67
+ The Splitting procedure downsamples the original sequence $\mathbf { F }$ into two sub-sequences $\mathbf { F } _ { e v e n }$ and $\mathbf { F } _ { o d d }$ by separating the even and the odd elements, which are of coarser temporal resolution but preserve most information of the original sequence.
68
+
69
+ Next, we use different convolutional kernels to extract features from $\mathbf { F } _ { e v e n }$ and $\mathbf { F } _ { o d d }$ . As the kernels are separate, the extracted features from them would contain distinct yet valuable temporal relations with enhanced representation capabilities. To compensate for potential information loss with downsampling, we propose a novel interactive-learning strategy to allow information interchange between the two sub-sequences by learning affine transformation parameters from each other. As shown in Fig. 2 (a), the interactive learning procedure consists of two steps.
70
+
71
+ First, $\mathbf { F } _ { e v e n }$ and $\mathbf { F } _ { o d d }$ are projected to hidden states with two different 1D convolutional modules $\phi$ and $\psi$ , respectively, and transformed to the formats of exp and interact to the $\mathbf { F } _ { e v e n }$ and $\mathbf { F } _ { o d d }$ with the element-wise product (see Eq. (1)). This can be viewed as performing scaling transformation on $\mathbf { F } _ { e v e n }$ and $\mathbf { F } _ { o d d }$ , where the scaling factors are learned from each other using neural network modules. Here, $\odot$ is the Hadamard product or element-wise production.
72
+
73
+ $$
74
+ \begin{array} { r } { \begin{array} { c c } { { \bf F } _ { o d d } ^ { s } = { \bf F } _ { o d d } \odot \exp ( \phi ( { \bf F } _ { e v e n } ) ) , } & { { \bf F } _ { e v e n } ^ { s } = { \bf F } _ { e v e n } \odot \exp ( \psi ( { \bf F } _ { o d d } ) ) . } \\ { { \bf F } _ { o d d } ^ { ' } = { \bf F } _ { o d d } ^ { s } \pm \rho ( { \bf F } _ { e v e n } ^ { s } ) , } & { { \bf F } _ { e v e n } ^ { ' } = { \bf F } _ { e v e n } ^ { s } \pm \eta ( { \bf F } _ { o d d } ^ { s } ) . } \end{array} } \end{array}
75
+ $$
76
+
77
+ Second, as shown in Eq. (11), the two scaled features $\mathbf { F } _ { e v e n } ^ { s }$ and $\mathbf { F } _ { o d d } ^ { s }$ are further projected to another two hiddenor subtracted from1 with and ther two 1D convolutional modules . The final outputs of the interactiv $\rho$ and lear $\eta$ , and then added tong module are two $\mathbf { F } _ { e v e n } ^ { s }$ $\mathbf { F } _ { o d d } ^ { s }$ updated sub-features Appendix C. $\mathbf { F } _ { e v e n } ^ { ' }$ and $\mathbf { F } _ { o d d } ^ { ' }$ . The default architectures of $\phi$ , $\psi$ , $\rho$ and $\eta$ are shown in the
78
+
79
+ Compared to the dilated convolutions used in the TCN architecture, the proposed downsampleconvolve-interact architecture achieves an even larger receptive field at each convolutional layer. More importantly, unlike TCN that employs a single shared convolutional filter at each layer, significantly restricting its feature extraction capabilities, SCI-Block aggregates essential information extracted from the two downsampled sub-sequences that have both local and global views of the entire time series.
80
+
81
+ # 3.2 SCINet
82
+
83
+ With the SCI-Blocks presented above, we construct the SCINet by arranging multiple SCI-Blocks hierarchically and get a tree-structured framework, as shown in Fig. 2 (b).
84
+
85
+ There are $2 ^ { l }$ SCI-Blocks at the $l$ -th level, where $l = 1 , \ldots , L$ is the index of the level, and $L$ is the total number of levels. Within the $k$ -th SCINet of the stacked SCINet (Section 3.3), the input time series $\mathbf { X }$ (for $k = 1$ ) or feature vector $\hat { \mathbf { X } } ^ { k - 1 } = \{ \hat { \mathbf { x } } _ { 1 } ^ { k - 1 } , . . . , \hat { \mathbf { x } } _ { \tau } ^ { k - 1 } \}$ (for $k > 1$ ) is gradually downsampled and processed by SCI-Blocks through different levels, which allows for effective feature learning of different temporal resolutions. In particular, the information from previous levels will be gradually accumulated, i.e., the features of the deeper levels would contain extra finer-scale temporal information transmitted from the shallower levels. In this way, we can capture both short-term and long-term temporal dependencies in the time series.
86
+
87
+ After going through $L$ levels of SCI-Blocks, we rearrange the elements in all the sub-features by reversing the odd-even splitting operation and concatenate them into a new sequence representation. It is then added to the original time series through a residual connection [12] to generate a new sequence with enhanced predictability. Finally, a simple fully-connected network is used to decode the enhanced sequence representation into $\hat { \mathbf { X } } ^ { k } { = } \{ \hat { \mathbf { x } } _ { 1 } ^ { k } , . . . , \hat { \mathbf { x } } _ { \tau } ^ { k } \}$ . Note that, to mitigate distribution shift in some TSF tasks, before supplying the data in the look-back window to our model, all the data elements are subtracted with the value of the last element, which is added to all the data elements in the forecasting horizon afterwards.
88
+
89
+ # 3.3 Stacked SCINet
90
+
91
+ When there are sufficient training samples, we could stack $K$ layers of SCINets to achieve even better forecasting accuracy (see Fig. 2 (c)), at the cost of a more complex model structure.
92
+
93
+ Specifically, we apply intermediate supervision [5] on the output of each SCINet using the groundtruth values, to ease the learning of the intermediate temporal features. The output of the $k$ -th intermediate SCINet, $\hat { \mathbf { X } } ^ { k }$ with length $\tau$ , is concatenated with part of the input $\mathbf { X } _ { t - ( T - \tau ) + 1 : t }$ to recover the length to the original input and feeded as input into the $( k + 1 )$ -th SCINet, where $k = 1 , \ldots , K { - } 1$ , and $K$ is the total number of the SCINets in the stacked structure. The output of the $K$ -th SCINet, $\hat { \mathbf { X } } ^ { K }$ , is the final forecasting results.
94
+
95
+ # 3.4 Loss Function
96
+
97
+ To train a stacked SCINet with $K$ ( $K \geq 1 )$ ) SCINets, the loss of the $k$ -th prediction results is calculated as the L1 loss between the output of the $k$ -th SCINet and the ground-truth horizontal window to be predicted:
98
+
99
+ $$
100
+ \mathcal { L } _ { k } = \frac { 1 } { \tau } \sum _ { i = 0 } ^ { \tau } \big \| \hat { \mathbf { x } } _ { i } ^ { k } - { \mathbf { x } } _ { i } \big \|
101
+ $$
102
+
103
+ The total loss of the stacked SCINet can be written as:
104
+
105
+ $$
106
+ \mathcal { L } = \sum _ { k = 1 } ^ { K } \mathcal { L } _ { k } .
107
+ $$
108
+
109
+ # 3.5 Complexity Analysis
110
+
111
+ Thanks to the downsampling procedure, the neurons at each convolutional layer of SCINet have a larger receptive field than those of TCN. More importantly, the set of rich convolutional filters in SCINet enable flexible extraction of temporal features from multiple resolutions. Consequently, SCINet usually does not require downsampling the original sequence to the coarsest level for effective forecasting. Given the look-back window size $T$ , TCN generally requires $\lceil \log _ { 2 } T \rceil$ layers when the dilation factor is 2, while the number of layers $L$ in SCINet could be much smaller than $\log _ { 2 } T$ . Our empirical study shows that the best forecasting accuracy is achieved with $L \leq 5$ in most cases even with large $T$ (e.g., 168). As for the number of stacks $K$ , our empirical study also shows that $K \le 3$ would be sufficient.
112
+
113
+ Consequently, the computational cost of SCINet is usually on par with that of the TCN architecture. The worst-case time complexity is $\mathcal { O } ( T \log T )$ , much less than that of vanilla Transformer-based solutions: $\mathcal { O } ( T ^ { 2 } )$ .
114
+
115
+ # 4 Experiments
116
+
117
+ In this section, we show the quantitative and qualitative comparisons with the state-of-the-art models for time series forecasting. We also present a comprehensive ablation study to evaluate the effectiveness of different components in SCINet. More details on datasets, evaluation metrics, data pre-processing, experimental settings, network structures and their hyper-parameters are shown in the Appendix.
118
+
119
+ # 4.1 Datasets
120
+
121
+ We conduct experiments on 11 popular time series datasets: (1) Electricity Transformer Temperature [42] (ETTh) (2) Traffic (3) Solar-Energy (4) Electricity (5) Exchange-Rate (6) PeMS (PEMS03, PEMS04, PEMS07 and PEMS08). A brief description of these datasets is listed in Table 1. All the experiments on these datasets in this section are conducted under multi-variate TSF setting.
122
+
123
+ To make a fair comparison, we follow existing experimental settings, and use the same evaluation metrics as the original publications [17, 26, 40, 19] in each dataset.
124
+
125
+ Table 1: The overall information of the 11 datasets.
126
+
127
+ <table><tr><td>Datasets</td><td>ETTh (1,2)</td><td>ETTm1</td><td>Traffic</td><td>Solar-Energy</td><td>Electricity</td><td>Exchange-Rate</td><td>PEMS03</td><td>PEMS04</td><td>PEMS07</td><td>PEMS08</td></tr><tr><td>Variants</td><td>7</td><td>7</td><td>862</td><td>137</td><td>321</td><td>8</td><td>358</td><td>307</td><td>883</td><td>170</td></tr><tr><td>Timesteps</td><td>17,420</td><td>69.680</td><td>17,544</td><td>52.560</td><td>26.304</td><td>7.588</td><td>26,209</td><td>16.992</td><td>28,224</td><td>17,856</td></tr><tr><td>Granularity</td><td>1hour</td><td>15min</td><td>1hour</td><td>10min</td><td>1hour</td><td>1day</td><td>5min</td><td>5min</td><td>5min</td><td>5min</td></tr><tr><td>Start time</td><td>7/1/2016</td><td>7/1/2016</td><td>1/1/2015</td><td>1/1/2006</td><td>1/1/2012</td><td>1/1/1990</td><td>5/1/2012</td><td>7/1/2017</td><td>5/1/2017</td><td>3/1/2012</td></tr><tr><td>Task type</td><td>Multi-step</td><td>Multi-step</td><td>Single-step</td><td>Single-step</td><td>Single-step</td><td>Single-step</td><td>Multi-step</td><td>Multi-step</td><td>Multi-step</td><td>Multi-step</td></tr><tr><td>Data partition</td><td>Follow [42]</td><td></td><td></td><td></td><td>Training/Validation/Testing:6/2/2</td><td></td><td></td><td>Training/Validation/Testing:6/2/2</td><td></td><td></td></tr></table>
128
+
129
+ # 4.2 Results and Analyses
130
+
131
+ Table 2, 3, 4, 5, 6 provide the main experimental results of SCINet. We observe that SCINet shows superior performance than other TSF models on various tasks, including short-term, long-term and spatial-temporal time series forecasting.
132
+
133
+ Short-term Time Series Forecasting: we evaluate the performance of the SCINet in short-term TSF tasks with other baseline methods on Traffic, Solar-Energy, Electricity and Exchange-Rate datasets. The experimental setting is the same as [19], which uses the input length of 168 to forecast different future horizons $\{ 3 , 6 , 1 2 , 2 4 \}$ .
134
+
135
+ As can be seen in Table 2, the proposed SCINet outperforms existing RNN/TCN-based (LSTNet [19], TPA-LSTM [34], TCN [4], TCN†) and Transformer-based [38, 42, 37] TSF solutions in most cases, especially for the Solar-Energy and Exchange-Rate datasets. Note that, TCN† denotes a variant of TCN wherein causal convolutions are replaced by normal convolutions, and improves the original TCN across all the datasets, which supports our claim in Sec. 2.2. Moreover, we can also observe that the Transformer-based methods have poor performance in this task. For short-term forecasting, the recent data points are typically more important for accurate forecasting. However, the permutationinvariant self-attention mechanisms used in Transformer-based methods do not pay much attention to such critical information. In contrast, the general sequential models (RNN/TCN) can formulate it easily, showing quite competitive results in short-term forecasting.
136
+
137
+ Table 2: Short-term forecasting performance comparison on the four datasets. The best results are shown in bold and second best results are highlighted with underlined blue font. IMP shows the improvement of SCINet over the best model.
138
+
139
+ <table><tr><td colspan="2">Model</td><td colspan="2">SCINet</td><td colspan="2">Autoformer [40]</td><td colspan="2">Informer [42]</td><td colspan="2">Transformer [37]</td><td colspan="2">*TCN [4]</td><td colspan="2">*TCN</td><td colspan="2">LSTNet [19]</td><td colspan="2">TPA-LSTM[34]</td><td>IMP</td></tr><tr><td>Metric</td><td>T</td><td>RSE</td><td>CORR 0.9853</td><td>RSE N/A</td><td>CORR</td><td>RSE</td><td>CORR N/A</td><td>RSE</td><td>CORR N/A</td><td>RSE</td><td>CORR</td><td>RSE</td><td>CORR</td><td>RSE</td><td>CORR</td><td>RSE 0.1803</td><td>CORR 0.9850</td><td>RSE</td></tr><tr><td rowspan="4">Solar-Energy</td><td></td><td>0.1775</td><td></td><td></td><td>N/A</td><td>N/A</td><td></td><td>N/A</td><td></td><td>0.1940</td><td>0.9835</td><td>0.1900</td><td>0.9848</td><td>0.1843</td><td>0.9843</td><td></td><td>0.9742</td><td>1.55%</td></tr><tr><td>3</td><td>0.2301</td><td>0.9739</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>0.2581</td><td>0.9602</td><td>0.2382</td><td>0.9612</td><td>0.2559</td><td>0.9690</td><td>0.2347</td><td></td><td>1.96%</td></tr><tr><td>12</td><td>0.2997</td><td>0.9550</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>0.3512</td><td>0.9321</td><td>0.3353</td><td>0.9432</td><td>0.3254</td><td>0.9467</td><td>0.3234</td><td>0.9487</td><td>7.33%</td></tr><tr><td>24 3</td><td>0.4081</td><td>0.9112</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td><td>0.4732</td><td>0.8812</td><td>0.4676</td><td>0.8851</td><td>0.4643</td><td>0.8870</td><td>0.4389</td><td>0.9081</td><td>7.02%</td></tr><tr><td rowspan="7">Traffic</td><td></td><td>0.4216</td><td>0.8920</td><td>0.5368</td><td>0.8268</td><td>0.5175</td><td>0.8515</td><td>0.5122</td><td>0.8555</td><td>0.5459</td><td>0.8486</td><td>0.5361</td><td>0.8540</td><td>0.4777</td><td>0.8721</td><td>0.4487</td><td>0.8812</td><td>6.04%</td></tr><tr><td>6</td><td>0.4414</td><td>0.8809</td><td>0.5462</td><td>0.8191</td><td>0.5258</td><td>0.8465</td><td>0.5455</td><td>0.8388</td><td>0.6061</td><td>0.8205</td><td>0.5992</td><td>0.8197</td><td>0.4893</td><td>0.8690</td><td>0.4658</td><td>0.8717</td><td>5.24%</td></tr><tr><td>12</td><td>0.4495</td><td>0.8772</td><td>0.5623</td><td>0.8082</td><td>0.5533</td><td>0.8279</td><td>0.5485</td><td>0.8317</td><td>0.6367</td><td>0.8048</td><td>0.6061</td><td>0.8205</td><td>0.4950</td><td>0.8614</td><td>0.4641</td><td>0.8717</td><td>3.15%</td></tr><tr><td>24</td><td>0.4453</td><td>0.8825</td><td>0.6020</td><td>0.7757</td><td>0.5883</td><td>0.8033</td><td>0.5934</td><td>0.8048</td><td>0.6586</td><td>0.7921</td><td>0.6456</td><td>0.7982</td><td>0.4973</td><td>0.8588</td><td>0.4765</td><td>0.8629</td><td>6.55%</td></tr><tr><td>3</td><td>0.0740</td><td>0.9494</td><td>0.1458</td><td>0.9032</td><td>0.1524</td><td>0.8858</td><td>0.1182</td><td>0.9055</td><td>0.0892</td><td>0.9232</td><td>0.0852</td><td>0.9293</td><td>0.0864</td><td>0.9283</td><td>0.0823</td><td>0.9439</td><td>10.09%</td></tr><tr><td>6 12</td><td>0.0845</td><td>0.9387</td><td>0.1555</td><td>0.8957</td><td>0.1932</td><td>0.8660</td><td>0.1328</td><td>0.8962</td><td>0.0974</td><td>0.9121</td><td>0.0924</td><td>0.9235</td><td>0.0931</td><td>0.9135</td><td>0.0916</td><td>0.9337</td><td>7.75%</td></tr><tr><td>Electricity</td><td>0.0929</td><td>0.9305</td><td>0.1541</td><td>0.8907</td><td>0.1748</td><td>0.8585</td><td>0.1375</td><td>0.8849</td><td>0.1053</td><td>0.9017</td><td>0.0993</td><td>0.9173</td><td>0.1007</td><td>0.9077</td><td>0.0964</td><td>0.9250</td><td>3.63%</td></tr><tr><td rowspan="3"></td><td></td><td>0.0967</td><td>0.9270</td><td>0.1754</td><td>0.8732</td><td>0.2110</td><td>0.8347</td><td>0.1461</td><td>0.8774</td><td>0.1091</td><td>0.9101</td><td>0.0989</td><td>0.9101</td><td>0.1007</td><td>0.9119</td><td>0.1006</td><td>0.9133</td><td>3.88%</td></tr><tr><td>24 3</td><td>0.0171</td><td>0.9787</td><td>0.0400</td><td>0.9458</td><td>0.1392</td><td>0.9473</td><td>0.0689</td><td>0.9759</td><td>0.0217</td><td>0.9693</td><td>0.0202</td><td>0.9712</td><td>0.0226</td><td>0.9735</td><td>0.0174</td><td>0.979</td><td>1.72%</td></tr><tr><td>6</td><td>0.0240</td><td>0.9704</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.9633</td><td>0.0257</td><td></td><td></td><td>0.9658</td><td></td><td></td><td>0.41%</td></tr><tr><td>Exchange Rate</td><td></td><td>0.0331</td><td>0.9553</td><td>0.0481 0.0638</td><td>0.9197 0.9054</td><td>0.1548 0.1793</td><td>0.9207 0.8817</td><td>0.0806 0.0893</td><td>0.9671 0.9476</td><td>0.0263 0.0393</td><td>0.9531</td><td></td><td>0.9628</td><td>0.0280 0.0356</td><td>0.9511</td><td>0.0241 0.0341</td><td>0.9709 0.9564</td><td>2.93%</td></tr><tr><td rowspan="2"></td><td></td><td>0.0436</td><td>0.9396</td><td>0.0651</td><td>0.8952</td><td>0.1998</td><td>0.7715</td><td></td><td></td><td>0.0492</td><td>0.9223</td><td>0.0352 0.0487</td><td>0.9501</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>2</td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.1127</td><td>0.9213</td><td></td><td></td><td></td><td>0.9314</td><td>0.0449</td><td>0.9354</td><td>0.0444</td><td>0.9381</td><td>1.80%</td></tr></table>
140
+
141
+ - Autoformer, Informer and Transformer achieved by Autoformer [40] requires pre-prossessed datasets for training. - N/A denotes no pre-prossessed dataset for training. - $^ *$ denotes re-implementation. $^ \dagger$ denotes the variant with normal convolutions.
142
+
143
+ Long-term Time Series Forecasting: many real-world applications also require to predict long-term events. Therefore, we conduct the experiments on Exchange Rate, Electricity ,Traffic and ETT datasets to evaluate the performance of SCINet on long-term TSF tasks. In this experiment, we only compare SCINet with Transformer-based methods [38, 18, 21, 42, 37, 25], since they are more popular in recent long-term TSF research.
144
+
145
+ As can be seen from Table 3, the SCINet achieves state-of-the-art performances in most benchmarks and prediction length settings. Overall, SCINet yields $3 9 . 8 9 \%$ average improvements on MSE among the above settings. In particular, for Exchange-Rate, compared to previous state-of-the-art results, SCINet gives average ${ \bar { 6 } } 5 \%$ improvements on MSE. We attribute it to that the proposed SCINet can better capture both short (local temporal dynamics)- and long (trend, seasonality)-term temporal dependencies to make an accurate prediction in long-term TSF.
146
+
147
+ Table 3: Long-term forecasting performance comparison with Transformer-based models.
148
+
149
+ <table><tr><td colspan="2">Model</td><td colspan="2">SCINet</td><td colspan="2">Autoformer [38]</td><td colspan="2">*Pyraformer [25]</td><td colspan="2">Informer [42]</td><td colspan="2">Transformer [37]</td><td colspan="2">LogTrans [21]</td><td colspan="2">Reformer[18]</td><td>IMP</td></tr><tr><td>Metric</td><td></td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td></tr><tr><td rowspan="4">Exchange Rate</td><td>96</td><td>0.061</td><td>0.188</td><td>0.197</td><td>0.323</td><td>1.748</td><td>1.105</td><td>0.847</td><td>0.752</td><td>0.559</td><td>0.587</td><td>0.968</td><td>0.812</td><td>1.065</td><td>0.829</td><td>68.98%</td></tr><tr><td>192</td><td>0.106</td><td>0.244</td><td>0.300</td><td>0.369</td><td>1.874</td><td>1.151</td><td>1.204</td><td>0.895</td><td>1.168</td><td>0.835</td><td>1.040</td><td>0.851</td><td>1.188</td><td>0.906</td><td>64.70%</td></tr><tr><td>336</td><td>0.181</td><td>0.323</td><td>0.509</td><td>0.524</td><td>1.943</td><td>1.172</td><td>1.672</td><td>1.036</td><td>1.423</td><td>0.949</td><td>1.659</td><td>1.081</td><td>1.357</td><td>0.976</td><td>64.36%</td></tr><tr><td>720</td><td>0.525</td><td>0.571</td><td>1.447</td><td>0.941</td><td>2.085</td><td>1.206</td><td>2.478</td><td>2.478</td><td>2.160</td><td>1.150</td><td>1.941</td><td>1.127</td><td>1.510</td><td>1.016</td><td>63.72%</td></tr><tr><td rowspan="5">Electricity</td><td>96</td><td>0.168</td><td>0.253</td><td>0.201</td><td>0.317</td><td>0.386</td><td>0.449</td><td>0.274</td><td>0.368</td><td>0.263</td><td>0.359</td><td>0.258</td><td>0.357</td><td>0.312</td><td>0.402</td><td>16.42%</td></tr><tr><td>192</td><td>0.175</td><td>0.262</td><td>0.222</td><td>0.334</td><td>0.378</td><td>0.443</td><td>0.296</td><td>0.296</td><td>0.273</td><td>0.374</td><td>0.266</td><td>0.368</td><td>0.348</td><td>0.433</td><td>21.17%</td></tr><tr><td>336</td><td>0.189</td><td>0.278</td><td>0.231</td><td>0.338</td><td>0.376</td><td>0.443</td><td>0.300</td><td>0.394</td><td>0.277</td><td>0.373</td><td>0.280</td><td>0.380</td><td>0.350</td><td>0.433</td><td>18.19%</td></tr><tr><td>720</td><td>0.231</td><td>0.316</td><td>0.254</td><td>0.361</td><td>0.376</td><td>0.445</td><td>0.373</td><td>0.439</td><td>0.290</td><td>0.378</td><td>0.283</td><td>0.376</td><td>0.340</td><td>0.420</td><td>9.06%</td></tr><tr><td>96</td><td>0.613</td><td>0.395</td><td>0.613</td><td>0.388</td><td>0.867</td><td>0.468</td><td>0.719</td><td>0.391</td><td>0.638</td><td>0.354</td><td>0.684</td><td>0.384</td><td>0.732</td><td>0.423</td><td>0.00%</td></tr><tr><td rowspan="4">Traffic</td><td>192</td><td>0.535</td><td>0.355</td><td>0.616</td><td>0.382</td><td>0.869</td><td>0.467</td><td>0.696</td><td>0.379</td><td>0.647</td><td>0.354</td><td>0.685</td><td>0.390</td><td>0.733</td><td>0.420</td><td>13.15%</td></tr><tr><td>336</td><td>0.540</td><td>0.359</td><td>0.622</td><td>0.337</td><td>0.881</td><td>0.469</td><td>0.777</td><td>0.420</td><td>0.669</td><td>0.364</td><td>0.733</td><td>0.408</td><td>0.742</td><td>0.420</td><td>13.18%</td></tr><tr><td>720</td><td>0.620</td><td>0.394</td><td>0.660</td><td>0.408</td><td>0.896</td><td>0.473</td><td>0.864</td><td>0.472</td><td>0.707</td><td>0.386</td><td>0.717</td><td>0.396</td><td>0.755</td><td>0.423</td><td>6.06%</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
150
+
151
+ - $^ *$ denotes re-implementation.
152
+
153
+ Table 4: Multivariate time-series forecasting results on the ETT datasets.
154
+
155
+ <table><tr><td rowspan="3">Methods</td><td rowspan="3">Metrics</td><td colspan="5">ETTh1</td><td colspan="5">ETTh2</td><td colspan="2"></td><td colspan="3">ETTm1</td></tr><tr><td colspan="2"></td><td colspan="3">Horizon</td><td colspan="5">Horizon</td><td colspan="2"></td><td colspan="3">Horizon</td></tr><tr><td>24</td><td>48</td><td>168</td><td>336</td><td>720</td><td>24</td><td>48</td><td>168</td><td>336</td><td>720</td><td>24</td><td>48</td><td>96</td><td>288</td><td>672</td></tr><tr><td rowspan="3">LogTrans [21]</td><td>MSE</td><td>0.686</td><td>0.766</td><td>1.002</td><td>1.362</td><td>1.397</td><td>0.828</td><td>1.806</td><td>4.070</td><td>3.875</td><td>3.913</td><td>0.419</td><td>0.507</td><td>0.768</td><td>1.462</td><td>1.669</td></tr><tr><td>MAE</td><td>0.604</td><td>0.757</td><td>0.846</td><td>0.952</td><td>1.291</td><td>0.750</td><td>1.034</td><td>1.681</td><td>1.763</td><td>1.552</td><td>0.412</td><td>0.583</td><td>0.792</td><td>1.320</td><td>1.461</td></tr><tr><td>MSE</td><td>0.991</td><td>1.313</td><td>1.824</td><td>2.117</td><td>2.415</td><td>1.531</td><td>1.871</td><td>4.660</td><td>4.028</td><td>5.381</td><td>0.724</td><td>1.098</td><td>1.433</td><td>1.820</td><td>2.187</td></tr><tr><td rowspan="2">Reformer [18]</td><td>MAE</td><td>0.754</td><td>0.906</td><td>1.138</td><td>1.280</td><td>1.520</td><td>1.613</td><td>1.735</td><td>1.846</td><td>1.688</td><td>2.015</td><td>0.607</td><td>0.777</td><td>0.945</td><td>1.094</td><td>1.232</td></tr><tr><td>MSE</td><td>0.650</td><td>0.702</td><td>1.212</td><td>1.424</td><td>1.960</td><td>1.143</td><td>1.671</td><td>4.117</td><td>3.434</td><td>8</td><td>0.621</td><td>1.392</td><td>1.339</td><td>1.740</td><td>2.736</td></tr><tr><td rowspan="2">LSTMa [2]</td><td>MAE</td><td>0.624</td><td>0.675</td><td>0.867</td><td>0.994</td><td>1.322</td><td>0.813</td><td>1.221</td><td>1.674</td><td>1.549</td><td></td><td>0.629</td><td>0.939</td><td>0.913</td><td>1.124</td><td>1.555</td></tr><tr><td>MSE</td><td>1.293</td><td>1.456</td><td>1.997</td><td>2.655</td><td>2.143</td><td>2.742</td><td>3.567</td><td>3.242</td><td>2.544</td><td>4.625</td><td>1.968</td><td>1.999</td><td>2.762</td><td>1.257</td><td>1.917</td></tr><tr><td rowspan="2">LSTNet [19]</td><td>MAE</td><td>0.901</td><td>0.960</td><td>1.214</td><td>1.369</td><td>1.380</td><td>1.457</td><td>1.687</td><td>2.513</td><td>2.591</td><td>3.709</td><td>L1700</td><td>1.215</td><td>1.542</td><td>2.076</td><td>2.941</td></tr><tr><td>MSE</td><td>0.577</td><td>0.685</td><td>0.931</td><td>1.128</td><td>1.215</td><td>0.720</td><td>1.457</td><td>3.489</td><td>2.723</td><td>3.467</td><td>0.323</td><td>0.494</td><td>0.678</td><td></td><td>1.192</td></tr><tr><td rowspan="2">Informer [42]</td><td>MAE</td><td>0.549</td><td>0.625</td><td>0.752</td><td>0.873</td><td>0.896</td><td>0.665</td><td>1.001</td><td>1.515</td><td>1.340</td><td>1.473</td><td>0.369</td><td>0.503</td><td>0.614</td><td>1.056 0.786</td><td>0.926</td></tr><tr><td>MSE</td><td>0.511</td><td>0.515</td><td>0.694</td><td>0.814</td><td>0.944</td><td>0.444</td><td>0.617</td><td>2.405</td><td>2.486</td><td>2.608</td><td>0.229</td><td>0.239</td><td>0.260</td><td></td><td>2.732</td></tr><tr><td rowspan="2">*TCN [4]</td><td>MAE</td><td>0.549</td><td>0.529</td><td>0.617</td><td>0.682</td><td>0.778</td><td>0.478</td><td>0.615</td><td>1.266</td><td>1.312</td><td>1.276</td><td>0.282</td><td>0.360</td><td>0.363</td><td>0.768</td><td></td></tr><tr><td>MSE</td><td>0.479</td><td>0.518</td><td>0.758</td><td>0.891</td><td>0.963</td><td>0.477</td><td>0.934</td><td>3.913</td><td>0.907</td><td>0.963</td><td>0.332</td><td>0.492</td><td>0.543</td><td>0.646</td><td>1.371</td></tr><tr><td rowspan="2">*Pyraformer [25]</td><td>MAE</td><td>0.499</td><td>0.520</td><td>0.665</td><td>0.738</td><td>0.782</td><td>0.537</td><td>0.764</td><td>1.557</td><td>0.747</td><td>0.783</td><td>0.383</td><td>0.475</td><td>0.510</td><td>0.656</td><td>0.901</td></tr><tr><td>MSE</td><td>0.406</td><td>0478</td><td>0.493</td><td>0.515</td><td>0.499</td><td>0.260</td><td>0.311</td><td>0.466</td><td></td><td></td><td>0.408</td><td>0.499</td><td>0.540</td><td>0.598 </td><td>0.720</td></tr><tr><td rowspan="2">Autoformer [38]</td><td>MAE</td><td>0.440</td><td></td><td>0.481</td><td>0.492</td><td>0.500</td><td>0.339</td><td>0.372</td><td>0.458</td><td>0478</td><td>0</td><td>0.424</td><td>0.464</td><td>0.489</td><td></td><td></td></tr><tr><td></td><td>0.300</td><td>0.361</td><td>0.408</td><td>0.504</td><td>5</td><td>0.180</td><td>0.230</td><td>0.342</td><td>0.365</td><td>0.475</td><td>0.106</td><td>0.136</td><td>0.165</td><td>0.253</td><td>0</td></tr><tr><td rowspan="2">SCINet IMP</td><td>MSE MAE</td><td>0.342</td><td>0.388</td><td>0.417</td><td>0.495</td><td></td><td>0.263</td><td>0.303</td><td>0.380</td><td>0.409</td><td>0.488</td><td>0.202</td><td></td><td></td><td></td><td>0.346</td></tr><tr><td>MSE</td><td>26.11%</td><td>24.48%</td><td>17.24%</td><td>2.14%</td><td>-9.02%</td><td>30.77%</td><td>25.81%</td><td>26.61%</td><td>22.67%</td><td>1.04%</td><td>38.71%</td><td>0.230 22.83%</td><td>0.252 21.40%</td><td>0.315 49.59%</td><td>0.376 40.18%</td></tr></table>
156
+
157
+ $^ *$ denotes re-implementation.
158
+
159
+ We conduct both Multivariate Time-series Forecasting and Univariate Time-series Forecasting on ETT datasets [42]. For a fair comparison, we keep all input lengths $T$ the same as those of Informer. The results are shown in Table 4 and Table 5, respectively.
160
+
161
+ Multivariate Time-series Forecasting on ETT: as can be seen from Table 4, compared with RNN-based methods such as LSTMa [2] and LSTnet [19], Transformer-based methods [18, 21, 42] produce better forecasting results. One of the primary reasons is that, RNN-based solutions conduct iterative forecasting and it is inevitable to suffer from error accumulation effects. As another direct forecasting method, TCN further outperforms vanilla Transformer-based methods [18, 21, 42], because the stacked convolutional layers allow for more effective local-to-global temporal relation learning for multivariate time series. It is worth noting that SCINet outperforms all the above models by a large margin. Fig. 3 presents the qualitative results on some randomly selected sequences of the ETTh1 dataset, which clearly demonstrate the capability of SCINet in obtaining the trend and seasonality of time series for TSF.
162
+
163
+ Univariate Time-series Forecasting on ETT: in this experimental setting, we bring several strong baseline methods for univariate forecasting into comparison, including ARIMA, Prophet [36], DeepAR [32] and N-Beats [29]. In Table 5, we can observe that N-Beats is superior to other baseline methods in most cases. In fact, N-Beats also takes the unique properties of time series into consideration and directly learns a trend and a seasonality model using a deep stack of fully-connected layers with residuals, which is a departure from the predominant architectures, such as RNNs, CNNs and Transformers. Nevertheless, the performance of SCINet is still much better than N-Beats.
164
+
165
+ The newly-proposed Transformer-based forecasting model, Autoformer [38], achieves the second best performance in all experimental settings and also surpasses SCINet in ETTm1 when the forecasting horizon is large. This is because, on the one hand, Autoformer focuses on modeling seasonal patterns and conducts self-attention at the sub-series level (instead of the raw data), which is much better in extracting long-term temporal patterns than vanilla Transformer-based methods. On the other hand, when forecasting long horizons, it is often the trend/seasonal information instead of the temporal dynamics in the look-back window that play the primary role, wherein the advantages of SCINet are not fully exhibited.
166
+
167
+ Table 5: Univariate time-series forecasting results on the ETT datasets.
168
+
169
+ <table><tr><td rowspan="3">Methods</td><td rowspan="3">Metrics</td><td colspan="5">ETTh1</td><td colspan="5">ETTh2</td><td colspan="5">ETTm1</td></tr><tr><td rowspan="2">48</td><td colspan="4">Horizon</td><td colspan="5">Horizon</td><td colspan="5">Horizon</td></tr><tr><td>24</td><td>168</td><td>336</td><td>720</td><td>24</td><td>48</td><td>168</td><td>336</td><td>720</td><td>24</td><td>48</td><td>96</td><td>288</td><td>672</td></tr><tr><td rowspan="2">ARIMA</td><td>MSE MAE</td><td>0.108</td><td>0.175</td><td>0.396</td><td>0.468</td><td>0.659</td><td>3.554</td><td>3.190</td><td>2.800</td><td>2.753</td><td>2.878</td><td>0.090</td><td>0.179</td><td>0.272</td><td>0.462</td><td>0.639</td></tr><tr><td></td><td>0.284</td><td>0.424</td><td>0.504</td><td>0.593</td><td>0.766</td><td>0.445</td><td>0.474</td><td>0.595</td><td>0.738</td><td>1.044</td><td>0.206</td><td>0.306</td><td>0.399</td><td>0.558</td><td>0.697</td></tr><tr><td rowspan="2">Prophet [36]</td><td>MSE</td><td>0.115</td><td>0.168</td><td>1.224</td><td>1.549</td><td>2.735</td><td>0.199</td><td>0.304</td><td>2.145</td><td>2.096</td><td>3.355</td><td>0.120</td><td>0.133</td><td>0.194</td><td>0.452</td><td>2.747</td></tr><tr><td>MAE</td><td>0.275</td><td>0.330</td><td>0.763</td><td>1.820</td><td>3.253</td><td>0.381</td><td>0.462</td><td>1.068</td><td>2.543</td><td>4.664</td><td>0.290</td><td>0.305</td><td>0.396</td><td>0.574</td><td>1.174</td></tr><tr><td rowspan="2">DeepAR [32]</td><td>MSE</td><td>0.107</td><td>0.162</td><td>0.239</td><td>0.445</td><td>0.658</td><td>0.098</td><td>0.163</td><td>0.255</td><td>0.604</td><td>0.429</td><td>0.091</td><td>0.219</td><td>0.364</td><td>0.948</td><td>2.437</td></tr><tr><td>MAE</td><td>0.280</td><td>0.327</td><td>0.422</td><td>0.552</td><td>0.707</td><td>0.263</td><td>0.341</td><td>0.414</td><td>0.607</td><td>0.580</td><td>0.243</td><td>0.362</td><td>0.496</td><td>0.795</td><td>1.352</td></tr><tr><td rowspan="2">N-Beats [29]</td><td>MSE</td><td>0.042</td><td>0.065</td><td>0.106</td><td>0.127</td><td>0.269</td><td>0.078</td><td>0.123</td><td>0.244</td><td>0.270</td><td>0.281</td><td>0.031</td><td>0.056</td><td>0.095</td><td>0.157</td><td>0.207</td></tr><tr><td>MAE</td><td>0.156</td><td>0.200</td><td>0.255</td><td>0.284</td><td>0.422</td><td>0.210</td><td>0.271</td><td>0.393</td><td>0.418</td><td>0.432</td><td>0.117</td><td>0.168</td><td>0.234</td><td>0.311</td><td>0.370</td></tr><tr><td rowspan="2">Informer [42]</td><td>MSE</td><td>0.098</td><td>0.158</td><td>0.183</td><td>0.222</td><td>0.269</td><td>0.093</td><td>0.155</td><td>0.232</td><td>0.263</td><td>0.277</td><td>0.030</td><td>0.069</td><td>0.194</td><td>0.401</td><td>0.512</td></tr><tr><td>MAE</td><td>0.247</td><td>0.319</td><td>0.346</td><td>0.387</td><td>0.435</td><td>0.240</td><td>0.314</td><td>0.389</td><td>0.417</td><td>0.431</td><td>0.137</td><td>0.203</td><td>0.372</td><td>0.554</td><td>0.644</td></tr><tr><td rowspan="2">Autoformer [38]</td><td>MSE</td><td>0.057</td><td>0.103</td><td>0.090</td><td>0.106</td><td>0.120</td><td>0.110</td><td>0.123</td><td>0.188</td><td>0.225</td><td>0.257</td><td>0.025</td><td>0.039</td><td>0.057</td><td>0.103</td><td>0.110</td></tr><tr><td>MAE</td><td>0.188</td><td>0.257</td><td>0.235</td><td>0.254</td><td>0.277</td><td>0.259</td><td>0.271</td><td>0.340</td><td>0.376</td><td>0.402</td><td>0.122</td><td>0.156</td><td>0.184</td><td>0.253</td><td>0.261</td></tr><tr><td rowspan="2">SCINet</td><td>MSE</td><td>0.029</td><td>0.041</td><td>0.071</td><td>0.084</td><td>0.099</td><td>0.065</td><td>0.093</td><td>0.158</td><td>0.166</td><td>0.286</td><td>0.019</td><td>0.045</td><td>0.064</td><td>0.111</td><td>0.165</td></tr><tr><td>MAE</td><td>0.127</td><td>0.154</td><td>0.210</td><td>0.234</td><td>0.250</td><td>0.183</td><td>0.227</td><td>0.311</td><td>0.329</td><td>0.429</td><td>0.084</td><td>0.138</td><td>0.183</td><td>0.252</td><td>0.316</td></tr><tr><td>IMP</td><td>MSE</td><td>49.12%</td><td>60.19%</td><td>21.11%</td><td>20.75%</td><td>17.50%</td><td>40.90%</td><td>24.39%</td><td>15.96%</td><td>26.22%</td><td>-11.28%</td><td>24.00%</td><td>-15.38%</td><td>-12.28%</td><td>-7.76%</td><td>-50.00%</td></tr></table>
170
+
171
+ ![](images/4981d77ad377e717af463f38e3c8213bc7f0cf5492071a2d16f171a0e7e76fcc.jpg)
172
+ Figure 3: The prediction results (Horizon $= 4 8$ ) of SCINet, Autoformer, Informer, and TCN on randomly-selected sequences from ETTh1 dataset.
173
+
174
+ Spatial-temporal Time Series Forecasting: besides the general TSF tasks, there is also a large category of data related to spatial-temporal forecasting. For example, traffic datasets PeMS [9] (PEMS03, PEMS04, PEMS07 and PEMS08) are complicated spatial-temporal time series for public traffic network and they have been investigated for decades. Most recent approaches: DCRNN [22], STGCN [41], ASTGCN [11], GraphWaveNet [39], STSGCN [35], AGCRN [3], LSGCN [15] and STFGNN [20] use graph neural networks to capture spatial relations while modeling temporal dependencies via conventional TCN or RNN/LSTM architectures. We follow the same experimental settings as the above works. As shown in Table 6, these GNN-based methods generally perform better than pure RNN or TCN-based methods. However, SCINet still achieves better performance without sophisticated spatial relation modeling, which further proves the superb temporal modeling capabilities of SCINet.
175
+
176
+ Table 6: Performance comparison of different approaches on the PeMS datasets.
177
+
178
+ <table><tr><td rowspan="2">Datasets</td><td rowspan="2">Metrics</td><td colspan="10">Methods</td><td colspan="4">IMP SCINet</td></tr><tr><td>*LSTM</td><td>*TCN</td><td>*TCNt</td><td>DCRNN</td><td>STGCN</td><td>ASTGCN(r)</td><td></td><td>GraphWaveNet</td><td>STSGCN</td><td>STFGNN</td><td>AGCRN</td><td>LSGCN</td><td></td><td>MAE</td></tr><tr><td rowspan="3">PEMS03</td><td>MAE</td><td>21.33</td><td>19.32</td><td>18.87</td><td>18.18</td><td>17.49 17.15</td><td>17.69 19.40</td><td>19.85 19.31</td><td>17.48</td><td>16.77</td><td></td><td>*15.98</td><td></td><td>14.98</td><td>6.26%</td></tr><tr><td>MAPE</td><td>21.33</td><td>19.93</td><td>18.63</td><td>18.91</td><td></td><td></td><td></td><td></td><td>16.78</td><td>16.30</td><td>*15.23</td><td>- ,</td><td>14.11</td><td>7.36%</td></tr><tr><td>RMSE</td><td>35.11</td><td>33.55</td><td>32.24</td><td>30.31</td><td>30.12</td><td></td><td>29.66</td><td>32.94</td><td>29.21</td><td>28.34</td><td>*28.25</td><td>-</td><td>24.08</td><td>8.37%</td></tr><tr><td rowspan="3">PEMS04</td><td>MAE</td><td>25.14</td><td>23.22</td><td>22.81</td><td>24.70</td><td>22.70</td><td>22.93</td><td>25.45</td><td>21.19</td><td>19.83</td><td></td><td></td><td></td><td></td><td>4.44%</td></tr><tr><td>MAPE</td><td></td><td>15.59</td><td>14.31</td><td>17.12</td><td>14.59</td><td>16.56</td><td></td><td></td><td></td><td>13.02</td><td>19.83 12.97</td><td>21.53 13.18</td><td>18.95 11.86</td><td>8.56%</td></tr><tr><td>RMSE</td><td>20.33 39.59</td><td></td><td>36.87</td><td></td><td></td><td></td><td></td><td>17.29</td><td>13.90</td><td>31.88</td><td>32.30</td><td>33.86</td><td>30.89</td><td>4.40%</td></tr><tr><td rowspan="3">PEMS07</td><td></td><td></td><td>37.26 32.72</td><td>30.53</td><td>38.12 28.30</td><td>35.55 25.38</td><td>35.22 28.05</td><td>39.70 26.85</td><td>33.65 24.26</td><td>22.07</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>MAE</td><td>29.98</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>*22.37</td><td>:</td><td>21.19</td><td>5.27%</td></tr><tr><td>MAPE</td><td>15.33</td><td>14.26</td><td>13.88</td><td>11.66</td><td>11.08</td><td>13.92</td><td>12.12</td><td>10.21</td><td></td><td>9.21</td><td>*9.12</td><td>,</td><td>8.83</td><td>3.18%</td></tr><tr><td rowspan="3">PEMS08</td><td>RMSE</td><td>42.84</td><td>42.23</td><td>41.02</td><td>38.58</td><td>38.78</td><td>42.57</td><td>42.78 19.13</td><td>39.03</td><td></td><td>35.80</td><td>*36.55</td><td>1</td><td>34.03</td><td>6.89%</td></tr><tr><td>MAE</td><td>22.20</td><td>22.72</td><td>21.42</td><td>17.86</td><td>18.02</td><td>18.61</td><td></td><td></td><td>17.13</td><td>16.64</td><td>15.95</td><td>17.73</td><td>15.72</td><td>1.44%</td></tr><tr><td>MAPE RMSE</td><td>15.32 32.06</td><td>14.03 35.79</td><td>13.09 34.03</td><td>11.45 27.83</td><td>11.40 27.83</td><td>13.08 28.16</td><td>12.68 31.05</td><td>10.96 26.80</td><td></td><td>10.60 26.22</td><td>10.09 25.22</td><td>11.20 26.76</td><td>9.80 24.76</td><td>2.87% 1.82%</td></tr></table>
179
+
180
+ - dash denotes that the methods do not implement on this dataset. $^ *$ denotes re-implementation or re-training. $^ \dagger$ denotes the variant with normal convolutions.
181
+
182
+ Predictability estimation: inspired by [16, 30], we use permutation entropy $( P E )$ [6] to measure the predictability of the original input and the enhanced representation learnt by SCINet. Time series with lower PE values are regarded as less complex, thus theoretically easier to predict2. The PE values of the original time series and the corresponding enhanced representations are shown in Table 7.
183
+
184
+ Table 7: Permutation entropy comparison before and after SCINet.
185
+
186
+ <table><tr><td rowspan=2 colspan=2>Permutation Entropy</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1></td><td></td><td></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>ETTh1</td><td rowspan=1 colspan=1>Traffic</td><td rowspan=1 colspan=1>Solar-Energy</td><td rowspan=1 colspan=1>Electricity</td><td rowspan=1 colspan=1>Exc-rate</td><td rowspan=1 colspan=1>PEMS03</td><td rowspan=1 colspan=1>PEMS04</td><td rowspan=1 colspan=1>PEMS07</td><td rowspan=1 colspan=1>PEMS08</td></tr><tr><td rowspan=1 colspan=1>Parameters</td><td rowspan=1 colspan=1>m(T=1)*</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=2 colspan=1>Value</td><td rowspan=1 colspan=1>Original Input</td><td rowspan=1 colspan=1>0.8878</td><td rowspan=1 colspan=1>0.9371</td><td rowspan=1 colspan=1>0.4739</td><td rowspan=1 colspan=1>0.9489</td><td rowspan=1 colspan=1>0.8260</td><td rowspan=1 colspan=1>0.9649</td><td rowspan=1 colspan=1>0.9203</td><td rowspan=1 colspan=1>0.9148</td><td rowspan=1 colspan=1>0.9390</td></tr><tr><td rowspan=1 colspan=1>Enhanced Representation</td><td rowspan=1 colspan=1>0.7096</td><td rowspan=1 colspan=1>0.8832</td><td rowspan=1 colspan=1>0.3537</td><td rowspan=1 colspan=1>0.8901</td><td rowspan=1 colspan=1>0.7836</td><td rowspan=1 colspan=1>0.8377</td><td rowspan=1 colspan=1>0.8749</td><td rowspan=1 colspan=1>0.8330</td><td rowspan=1 colspan=1>0.8831</td></tr></table>
187
+
188
+ ∗ m (embedding dimension) and $\tau$ (time-lag) are two parameters used for calculating PE, and the values are selected following [30, 16].
189
+
190
+ As can be observed, the enhanced representations learnt by SCINet indeed have lower PE values compared with the original inputs, which indicates that it is easier to predict the future from the enhanced representations using the same forecaster.
191
+
192
+ # 4.3 Ablation studies
193
+
194
+ To evaluate the impact of each main component used in SCINet, we experiment on several model variants on two datasets: ETTh1 and PEMS08.
195
+
196
+ SCIBlock: we first set the number of stacks $K = 1$ and the number of SCINet levels $L = 3$ . For the SCI-Block design, to validate the effectiveness of the interactive learning and the distinct convolution weights for processing the sub-sequences, we experiment on two variants, namely $w / o$ . InterLearn and WeightShare. The $w / o$ . InterLearn is obtained by removing the interactive-learning procedure described in Eq. (1) and (11). In this case, the two sub-sequences would be updated using $\mathbf { F } _ { o d d } ^ { ' } = \rho ( \phi ( \mathbf { F } _ { o d d } ) )$ and $\mathbf { F } _ { e v e n } ^ { ' } = \eta ( \psi ( \mathbf { F } _ { e v e n } ) )$ . For WeightShare, the modules $\phi , \rho , \psi$ , and $\eta$ share the same weight.
197
+
198
+ The evaluation results in Fig. 4 show that both interactive learning and distinct weights are essential, as they improve the prediction accuracies of both datasets at various prediction horizons. At the same time, comparing Fig. 4(a) with Fig. 4(b), we can observe that interactive learning is more effective for cases with longer look-back window sizes. This is because, intuitively, we can extract more effective features by exchanging information between the downsampled sub-sequences when there are longer look-back windows for such interactions.
199
+
200
+ SCINet: for the design of SCINet with multiple levels of SCI-Blocks, we also experiment on two variants. The first variant w/o. ResConn is obtained by removing the residual connection from the complete SCINet. The other variant w/o. Linear removes the decoder (i.e., the fully-connected layer) from the complete model. As can be observed in Fig. 4, removing the residual connection leads to a significant performance drop. Besides the general benefit in facilitating the model training, more importantly, the predictability of the original time series is enhanced with the help of residuals. The fully-connected layer is also critical for prediction accuracy, indicating the effectiveness of the decoder in extracting and fusing the most relevant temporal information according to the given supervision for prediction.
201
+
202
+ ![](images/404fe6678df992eb6da5d7b1504711f0d812d69dd319a890383c43920df64a16.jpg)
203
+ Figure 4: Component analysis of SCINet on two datasets. Smaller values are better. See Section 4.3.
204
+
205
+ We also conduct comprehensive ablation studies on the impact of $K$ (number of stacks) and $L$ (number of levels), and the selection of operator in the interact learning mechanism. These results are shown in the Appendix B.2 due to space limitation.
206
+
207
+ # 5 Limitations and Future Work
208
+
209
+ In this paper, we mainly focus on TSF problem for the regular time series collected at even intervals of time and ordered chronologically. However, in real-world applications, the time series might contain noisy data, missing data or collected at irregular time intervals, which is referred to as irregular time series. The proposed SCINet is relatively robust to the noisy data thanks to the progressive downsampling and interactive learning procedure, but it might be affected by the missing data if the ratio exceeds a certain threshold, wherein the downsampling-based multi-resolution sequence representation in SCINet may introduce biases, leading to poor prediction performance. The proposed downsampling mechanism may also have difficulty handling data collected at irregular intervals. We plan to take the above issues into consideration in the future development of SCINet.
210
+
211
+ Moreover, this work focuses on the deterministic time series forecasting problem. Many application scenarios require probabilistic forecasts, and we plan to revise SCINet to generate such prediction results.
212
+
213
+ Finally, while SCINet generates promising results for spatial-temporal time series without explicitly modeling spatial relations, the forecasting accuracy could be further improved by incorporating dedicated spatial models. We plan to investigate such solutions in our future work.
214
+
215
+ # 6 Conclusion
216
+
217
+ In this paper, we propose a novel neural network architecture, sample convolution and interaction network (SCINet) for time series modeling and forecasting, motivated by the unique properties of time series data compared to generic sequence data. The proposed SCINet is a hierarchical downsample-convolve-interact structure with a rich set of convolutional filters. It iteratively extracts and exchanges information at different temporal resolutions and learns an effective representation with enhanced predictability. Extensive experiments on various real-world TSF datasets demonstrate the superiority of our model over state-of-the-art methods.
218
+
219
+ # Acknowledgments and Disclosure of Funding
220
+
221
+ This work was supported in part by Alibaba Group Holding Ltd. under Grant No. TA2015393. We thank the anonymous reviewers for their constructive comments and suggestions.
222
+
223
+ # References
224
+
225
+ series. arXiv preprint arXiv:1904.12206, 2019. [2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In ICLR, 2015.
226
+ [3] Lei Bai, Lina Yao, Can Li, Xianzhi Wang, and Can Wang. Adaptive graph convolutional recurrent network for traffic forecasting. Advances in Neural Information Processing Systems, 33:17804–17815, 2020.
227
+ [4] Shaojie Bai, J Zico Kolter, and Vladlen Koltun. An empirical evaluation of generic convolutional and recurrent networks for sequence modeling. arXiv preprint arXiv:1803.01271, 2018.
228
+ [5] Shaojie Bai, J Zico Kolter, and Vladlen Koltun. Trellis networks for sequence modeling. In ICLR, 2018.
229
+ [6] Christoph Bandt and Bernd Pompe. Permutation entropy: a natural complexity measure for time series. Physical review letters, 88(17):174102, 2002. [7] Anastasia Borovykh, Sander Bohte, and Cornelis W Oosterlee. Conditional time series forecasting with convolutional neural networks. stat, 1050:16, 2017.
230
+ [8] George EP Box and Gwilym M Jenkins. Some recent advances in forecasting and control. Journal of the Royal Statistical Society. Series C (Applied Statistics), 17(2):91–109, 1968.
231
+ [9] Chao Chen, Karl Petty, Alexander Skabardonis, Pravin Varaiya, and Zhanfeng Jia. Freeway performance measurement system: mining loop detector data. Transportation Research Record, 1748(1):96–102, 2001.
232
+ [10] Pierpaolo D’Urso, Livia De Giovanni, and Riccardo Massari. Trimmed fuzzy clustering of financial time series based on dynamic time warping. Annals of operations research, 299(1):1379–1395, 2021.
233
+ [11] S. Guo, Youfang Lin, Ning Feng, Chao Song, and Huaiyu Wan. Attention based spatial-temporal graph convolutional networks for traffic flow forecasting. In AAAI, 2019.
234
+ [12] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
235
+ [13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.
236
+ [14] C. Holt. Forecasting seasonals and trends by exponentially weighted moving averages. International Journal of Forecasting, 20:5–10, 2004.
237
+ [15] Rongzhou Huang, Chuyin Huang, Yubao Liu, Genan Dai, and Weiyang Kong. Lsgcn: Long short-term traffic prediction with graph convolutional networks. In IJCAI, pages 2355–2361, 2020.
238
+ [16] Yu Huang and Zuntao Fu. Enhanced time series predictability with well-defined structures. Theoretical and Applied Climatology, pages 1–13, 2019.
239
+ [17] Rob J Hyndman and Anne B Koehler. Another look at measures of forecast accuracy. International journal of forecasting, 22(4):679–688, 2006.
240
+ [18] Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2019.
241
+ [19] Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long- and short-term temporal patterns with deep neural networks. In SIGIR, 2018.
242
+ [20] Mengzhang Li and Zhanxing Zhu. Spatial-temporal fusion graph neural networks for traffic flow forecasting. In AAAI, 2021.
243
+ [21] Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. In NeurIPS, 2019.
244
+ [22] Yaguang Li, Rose Yu, Cyrus Shahabi, and Yan Liu. Diffusion convolutional recurrent neural network: Data-driven traffic forecasting. In ICLR, 2018.
245
+ [23] Bryan Lim, Sercan Ö Arık, Nicolas Loeff, and Tomas Pfister. Temporal fusion transformers for interpretable multi-horizon time series forecasting. International Journal of Forecasting, 2021.
246
+ [24] Bryan Lim and Stefan Zohren. Time-series forecasting with deep learning: a survey. Philosophical Transactions of the Royal Society A, 379(2194):20200209, 2021.
247
+ [25] Shizhan Liu, Hang Yu, Cong Liao, Jianguo Li, Weiyao Lin, Alex X Liu, and Schahram Dustdar. Pyraformer: Lowcomplexity pyramidal attention for long-range time series modeling and forecasting. In International Conference on Learning Representations, 2021.
248
+ [26] Spyros Makridakis, Allan Andersen, Robert Carbone, Robert Fildes, Michele Hibon, Rudolf Lewandowski, Joseph Newton, Emanuel Parzen, and Robert Winkler. The accuracy of extrapolation (time series) methods: Results of a forecasting competition. Journal of forecasting, 1(2):111–153, 1982.
249
+ [27] Nam Nguyen and Brian Quanz. Temporal latent auto-encoder: A method for probabilistic multivariate time series forecasting. In AAAI, 2021.
250
+ [28] Aaron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, and Koray Kavukcuoglu. Wavenet: A generative model for raw audio. 2016.
251
+ [29] Boris Oreshkin, Dmitri Carpo, Nicolas Chapados, and Yoshua Bengio. N-beats: Neural basis expansion analysis for interpretable time series forecasting. In ICLR, 2020.
252
+ [30] Frank Pennekamp, Alison C Iles, Joshua Garland, Georgina Brennan, Ulrich Brose, Ursula Gaedke, Ute Jacob, Pavel Kratina, Blake Matthews, Stephan Munch, et al. The intrinsic predictability of ecological time series and its potential to guide forecasting. Ecological Monographs, 89(2):e01359, 2019.
253
+ [31] Syama Sundar Rangapuram, Matthias W Seeger, Jan Gasthaus, Lorenzo Stella, Yuyang Wang, and Tim Januschowski. Deep state space models for time series forecasting. NeurIPS, 2018.
254
+ [32] David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. Deepar: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3):1181–1191, 2020.
255
+ [33] Rajat Sen, Hsiang-Fu Yu, and Inderjit S Dhillon. Think globally, act locally: A deep neural network approach to high-dimensional time series forecasting. volume 32, 2019.
256
+ [34] Shun-Yao Shih, Fan-Keng Sun, and Hung yi Lee. Temporal pattern attention for multivariate time series forecasting. Machine Learning, pages 1–21, 2019.
257
+ [35] Chao Song, Youfang Lin, Shengnan Guo, and Huaiyu Wan. Spatial-temporal synchronous graph convolutional networks: A new framework for spatial-temporal network data forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 914–921, 2020.
258
+ [36] Sean J. Taylor and Benjamin Letham. Forecasting at scale. The American Statistician, 72:37 – 45, 2018.
259
+ [37] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
260
+ [38] Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long. Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. In NeurIPS, 2021.
261
+ [39] Zonghan Wu, Shirui Pan, Guodong Long, Jing Jiang, and C. Zhang. Graph wavenet for deep spatial-temporal graph modeling. In IJCAI, 2019.
262
+ [40] Jiehui Xu, Jianmin Wang, Mingsheng Long, et al. Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. Advances in Neural Information Processing Systems, 34, 2021.
263
+ [41] Ting Yu, Haoteng Yin, and Zhanxing Zhu. Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting. In IJCAI, 2018.
264
+ [42] Hao-Yi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI, 2021.
265
+
266
+ # Checklist
267
+
268
+ The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
269
+
270
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
271
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
272
+ • Did you include the license to the code and datasets? [N/A]
273
+
274
+ Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
275
+
276
+ 1. For all authors...
277
+
278
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
279
+ (b) Did you describe the limitations of your work? [Yes] See section 5
280
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
281
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
282
+
283
+ 2. If you are including theoretical results...
284
+
285
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
286
+
287
+ 3. If you ran experiments...
288
+
289
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See the Appendix and link in abstract.
290
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See the Appendix
291
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
292
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See the Appendix
293
+
294
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
295
+
296
+ (a) If your work uses existing assets, did you cite the creators? [Yes] Detail seen in Appendix.
297
+ (b) Did you mention the license of the assets? [Yes]
298
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
299
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
300
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
301
+
302
+ 5. If you used crowdsourcing or conducted research with human subjects...
303
+
304
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
305
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
306
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/B9LUI0pZFGc/B9LUI0pZFGc.md ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # THE KFIOU LOSS FOR ROTATED OBJECT DETECTION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ As a fundamental building block for visual analysis across aerial images, scene text etc., rotated object detection has established itself an emerging area, which is more general than classic horizontal object detection. Differing from the horizontal detection case whereby the alignment between final detection performance and regression loss is well kept thanks to the differentiable IoU loss, rotation detection involves the so-called SkewIoU that is undifferentiable. In this paper, we design a novel approximate SkewIoU loss based on Kalman filter, namely KFIoU loss. To avoid the standing and well-known boundary discontinuity and squarelike problems, we convert the rotating bounding box into a Gaussian distribution, in line with recent Gaussian-based rotation detection works. Then we use the center loss to narrow the distance between the center of the two Gaussian distributions, followed by calculating the overlap area under the new position through Kalman filter. We qualitatively show the value consistency between KFIoU loss and the SkewIoU loss for rotation detection in different cases. We further extend our technique to the 3-D case which also suffers from the same issues as 2-D object detection. Extensive experimental results on various public datasets (2-D/3-D, aerial/text images) with different base detectors show the effectiveness of our approach. The source code will be made public available.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Rotated object detection is challenging due to the difficulties of locating the arbitrary-oriented objects and separating them effectively from the background, such aerial images (Yang et al., 2018a; Ding et al., 2019; Yang et al., 2018b; 2019; 2020a; Ming et al., 2021b), scene text (Jiang et al., 2017; Zhou et al., 2017; Ma et al., 2018; Liao et al., 2018b). Though considerable progress has been made, for practical settings, there still exist challenges for rotating objects with large aspect ratio, dense distribution.
12
+
13
+ As sketched in Fig. 1, the Skew Intersection over Union (SkewIoU) score between large aspect ratio objects is sensitive to the deviations of the object positions. This causes the negative impact of the inconsistency between metric
14
+
15
+ ![](images/9691469a18fc0074db16ccc016576cc97425e67802540166d214ab07027d008b.jpg)
16
+ Figure 1: Inconsistency between metric and regression loss in rotated object detection.
17
+
18
+ (dominated by SkewIoU) and regression loss (e.g. $l _ { n }$ -norms), which is common in horizontal detection, to be further amplified in rotation detection. The red and orange arrows in Fig. 1 show the inconsistency between SkewIoU and Smooth L1 Loss. Specifically, when the angle deviation is fixed (red arrow), SkewIoU will decrease sharply as the aspect ratio increases, while the Smooth L1 loss is unchanged (mainly from the angle difference). Similarly, when SkewIoU does not change (orange arrow), Smooth L1 loss increases as the angle deviation increases. Solution for inconsistency between the metric and regression loss has been extensively discussed in horizontal detection by using IoU loss and related variants, such as GIoU (Rezatofighi et al., 2019) and DIoU (Zheng et al., 2020b). However, these solutions cannot be directly migrated to rotated object detection due to the undifferentiable of the SkewIoU. Therefore, developing a differentiable SkewIoU loss approximate calculation method is an effective alternative.
19
+
20
+ In this paper, we design a novel approximate SkewIoU loss based on Kalman filter, named KFIoU loss. Specifically, we use Gaussian modeling to convert the rotating bounding box into a Gaussian distribution, which can avoid the standing and well-known boundary discontinuity and square-like problems (Yang et al., 2019; Yang & Yan, 2020; Song et al., 2020; Qian et al., 2021; Ming et al., 2021c; Yang et al., 2021c) in rotation detection. Then we use a center loss to narrow the distance between the center of the two Gaussian distributions, fellow by calculating the overlap area under the new position through Kalman filter. The highlights of this paper are as follows:
21
+
22
+ 1) We elaborate on the inconsistency between the final detection performance and regression loss in rotated object detection, especially for objects with large aspect ratios.
23
+
24
+ 2) We propose a novel KFIoU loss for rotation detection, based on Gaussian modeling and Kalman filter, leading to direct approximate computing of the SkewIoU. Compared to the recent Gaussian based technique (Yang et al., 2021c;d) that approximate SkewIoU by learning ad-hoc nonlinear transformations, our model is simple and can be more physically coherent.
25
+
26
+ 3) We also extend the Gaussian modeling and KFIoU loss from 2-D (aerial images, scene texts) to 3-D (KITTI) object detection, with notable improvement obtained. To our best knowledge, this is the first 3-D rotation detector based on Gaussian modeling in contrast to the peer works (Yang et al., 2021c;d) only focusing on 2-D rotated object detection.
27
+
28
+ 4) Results on public datasets show the effectiveness of our approach. In particular, our method outperforms the recent GWD-based loss (Yang et al., 2021c) which relies on non-linear transforms to approximate the IoU loss while our method provides a more direct computational model which is scale-invariant, leading to better performance on small objects as verified in our experiments.
29
+
30
+ # 2 RELATED WORK
31
+
32
+ Rotated Object Detection. Rotated object detection is an emerging direction, which attempts to extend classical horizontal detectors (Girshick, 2015; Ren et al., 2015; Lin et al., 2017a;b) to the rotation case by adopting the rotated bounding boxes. Aerial images and scene text are popular application scenarios of rotation detector. For aerial images, objects are often arbitrary-oriented and dense-distributed with large aspect ratios. To this end, ICN (Azimi et al., 2018), ROI-Transformer (Ding et al., 2019), SCRDet (Yang et al., 2019), Mask OBB (Wang et al., 2019), Gliding Vertex $\mathrm { X u }$ et al., 2020), ReDet (Han et al., 2021b) are two-stage mainstreamed approaches whose pipeline is inherited from Faster RCNN (Ren et al., 2015), while DRN (Pan et al., 2020), DAL (Ming et al., 2021d), ${ \mathrm { R } } ^ { 3 }$ Det (Yang et al., 2021b), RSDet (Qian et al., 2021) and $\mathrm { S ^ { 2 } A }$ -Net (Han et al., 2021a) are based on single-stage methods for faster detection speed. For scene text detection, RRPN (Ma et al., 2018) employs rotated RPN to generate rotated proposals and further perform rotated bounding box regression. TextBoxes++ (Liao et al., 2018a) adopts vertex regression on SSD (Liu et al., 2016). RRD (Liao et al., 2018b) further improves TextBoxes $^ { + + }$ by decoupling classification and bounding box regression on rotation-invariant and rotation sensitive features, respectively. The regression loss of the above algorithms are all bounding box or point based or mask-based representation, and they are rarely SkewIoU loss due to its undifferentiability.
33
+
34
+ Variants of IoU-based Loss. The inconsistency between metric and regression loss is a common problem for both horizontal detection and rotation detection. Solution for this inconsistency has been extensively discussed in horizontal detection by using IoU loss and related variants. For instance, Unitbox (Yu et al., 2016) proposes an IoU loss which regresses the four bounds of a predicted box as a whole unit. More works (Rezatofighi et al., 2019; Zheng et al., 2020b) extend the idea of Unitbox by introducing GIoU loss anf DIoU loss for bounding box regression. However, due to the undifferentiable of the SkewIoU, none of the above methods can be directly applied to rotation detection. Recently, some approximate methods for SkewIoU loss have been proposed. Box/Polygon based: SCRDet (Yang et al., 2019) propose IoU-Smooth L1, which partly circumvents the need for differentiable SkewIoU loss by combining IoU and Smooth L1 loss. To tackle the uncertainty of convex caused by rotation, Zheng et al. (Zheng et al., 2020a) proposes a projection operation to estimate the intersection area for both 2-D/3-D object detection. PolarMask (Xie et al., 2020) proposes Polar IoU loss that can largely ease the optimization and considerably improve the accuracy. Pixel based: PIoU (Chen et al., 2020) calculates the SkewIoU directly by accumulating the contribution of interior overlapping pixels. Gaussian based: GWD (Yang et al., 2021c) and KLD (Yang et al., 2021d) simulate SkewIoU through Gaussian distance measurement and nonlinear transformation.
35
+
36
+ ![](images/50428da015f2ed8ae15b92d1f9d47daf08f3d55e691569c56199e2493e41e718.jpg)
37
+ Figure 2: SkewIoU approximation process in two-dimensional space based on Kalman filter.
38
+
39
+ In this paper, we propose a novel regression loss based on Gaussian distribution representation, which also completes the approximation of the SkewIoU loss through Kalman filtering.
40
+
41
+ # 3 BACKGROUND ON GAUSSIAN DISTRIBUTION MODELING
42
+
43
+ In this section, we present the preliminary according to (Yang et al., 2021c), for how to convert an arbitrary-oriented 2-D/3-D bounding box to a Gaussian distribution $\mathcal { G } ( { \pmb \mu } , { \pmb \Sigma } )$ .
44
+
45
+ $$
46
+ \Sigma = { \bf R } { \bf A } { \bf R } ^ { \top } , ~ \pmb { \mu } = ( x , y , ( z ) ) ^ { \top }
47
+ $$
48
+
49
+ where $\mathbf { R }$ represents the rotation matrix, and $\pmb { \Lambda }$ represents the diagonal matrix of eigenvalues.
50
+
51
+ For 2-D object $B _ { 2 d } ( x , y , h , w , \theta )$ ,
52
+
53
+ $$
54
+ \mathbf { R } = \left( \begin{array} { c c } { \cos \theta } & { - \sin \theta } \\ { \sin \theta } & { \cos \theta } \end{array} \right) , \mathbf { A } = \left( \begin{array} { c c } { \frac { w ^ { 2 } } { 4 } } & { 0 } \\ { 0 } & { \frac { h ^ { 2 } } { 4 } } \end{array} \right)
55
+ $$
56
+
57
+ and for 3-D object $\mathcal { B } _ { 3 d } ( x , y , z , h , w , l , \theta )$ ,
58
+
59
+ $$
60
+ \begin{array} { r } { { \bf R } = \left( \begin{array} { c c c } { \cos \theta } & { - \sin \theta } & { 0 } \\ { \sin \theta } & { \cos \theta } & { 0 } \\ { 0 } & { 0 } & { 1 } \end{array} \right) , { \bf A } = \left( \begin{array} { c c c } { \frac { w ^ { 2 } } { 4 } } & { 0 } & { 0 } \\ { 0 } & { \frac { h ^ { 2 } } { 4 } } & { 0 } \\ { 0 } & { 0 } & { \frac { l ^ { 2 } } { 4 } } \end{array} \right) } \end{array}
61
+ $$
62
+
63
+ and $l , w , h$ represent the length, width, and height of the 3-D bounding box, respectively.
64
+
65
+ It is worth noting that the recent work GWD (Yang et al., 2021c) also belongs to the design of regression loss based on Gaussian modeling. Compared with our work, their difference is that GWD directly uses the distance metric between distributions as the final loss. Since GWD does not have scale invariance (the first term of Gaussian Wasserstein Distance is the Euclidean distance between the center points), it needs to be normalized with nonlinear transformation to ensure the normal convergence of model training. However, such an operation cannot truly achieve the consistency of metric and regression losses. In this paper, we will take another perspective to approximate the SkewIoU loss to better train the detector, which can be more physically coherent.
66
+
67
+ # 4 PROPOSED METHOD
68
+
69
+ In this section, we present our main approach. Fig. 2 shows the approximate process of SkewIoU loss in two-dimensional space based on Kalman filtering. Briefly, we first convert the bounding box to a Gaussian distribution as discussed in Sec. 3, and move the center points of the two Gaussian distributions to make them coincide. Then, the distribution function of the overlapping area is obtained by Kalman filtering. Finally, the obtained distribution function is inverted into a rotating bounding box to calculate the overlapping area and the IoU.
70
+
71
+ ![](images/cd4a865e831408b2ac6a3c8ccebeaa5923362ac51c59963a0b64cd3cae70fa2a.jpg)
72
+ Figure 3: Behavior comparison of different loss in different cases. Zoom in for better view.
73
+
74
+ # 4.1 SKEWIOU COMPUTING BASED ON KALMAN FILTERING
75
+
76
+ First of all, we can easily calculate the volume of the corresponding rotating box based on its covariance, when we obtain a new Gaussian distribution, where $n$ denotes the number of dimensions.
77
+
78
+ $$
79
+ \mathcal { V } _ { \mathcal { B } } ( \Sigma ) = 2 ^ { n } \sqrt { \prod e i g ( \Sigma ) } = 2 ^ { n } \cdot | \Sigma ^ { \frac { 1 } { 2 } } | = 2 ^ { n } \cdot | \Sigma | ^ { \frac { 1 } { 2 } }
80
+ $$
81
+
82
+ To obtain the final SkewIoU, calculating the area of overlap is critical. For two Gaussian distributions, we can use Kalman filter to get the distribution function of the overlapping area. Specifically:
83
+
84
+ $$
85
+ \alpha \mathcal { G } _ { k f } ( \pmb { \mu } , \pmb { \Sigma } ) = \mathcal { G } _ { 1 } ( \pmb { \mu } _ { 1 } , \pmb { \Sigma } _ { 1 } ) \mathcal { G } _ { 2 } ( \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 2 } )
86
+ $$
87
+
88
+ Note here $\alpha$ is written by:
89
+
90
+ $$
91
+ \alpha = { \mathcal G } _ { \alpha } ( \pmb { \mu } _ { 2 } , \pmb { \Sigma } _ { 1 } + \pmb { \Sigma } _ { 2 } ) = \frac { 1 } { \sqrt { \operatorname* { d e t } ( 2 \pi ( \pmb { \Sigma } _ { 1 } + \pmb { \Sigma } _ { 2 } ) ) } } e ^ { - \frac { 1 } { 2 } ( \pmb { \mu } _ { 1 } - \pmb { \mu } _ { 2 } ) ^ { \top } ( \pmb { \Sigma } _ { 1 } + \pmb { \Sigma } _ { 2 } ) ^ { - 1 } ( \pmb { \mu } _ { 1 } - \pmb { \mu } _ { 2 } ) }
92
+ $$
93
+
94
+ $$
95
+ \mu = \mu _ { 1 } + K ( \mu _ { 2 } - \mu _ { 1 } ) , \Sigma = \Sigma _ { 1 } - K \Sigma _ { 1 } , K = \Sigma _ { 1 } \bigl ( \Sigma _ { 1 } + \Sigma _ { 2 } \bigr ) ^ { - 1 } .
96
+ $$
97
+
98
+ We observe that $\pmb { \Sigma }$ is only related to the covariance $\Sigma _ { 1 }$ and $\Sigma _ { 2 }$ ) of the given two Gaussian distributions, which means that no matter how the two Gaussian distributions move, as long as the covariance is fixed, the area calculated by Eq. 14 will not change. This is obviously not in line with intuitive feeling: the overlapping area should be reduced when the two Gaussian distributions are far away. The main reason is $\alpha \bar { \mathcal { G } } _ { k f } ( \pmb { \mu } , \pmb { \Sigma } )$ is not a standard Gaussian distribution (the sum of probability is not 1), we cannot directly use $\pmb { \Sigma }$ to calculate the area of the current overlap by Eq. 14 without considering $\alpha$ . It can be found from Eq. 6 that $\alpha$ is related to the distance between the center points $( \mu _ { 1 } - \mu _ { 2 } )$ of the two Gaussian distributions. Based on the above findings, we can first use a center loss $L _ { c } ( \mu _ { 1 } , \mu _ { 2 } )$ to narrow the distance between the center of the two Gaussian distributions, and then calculate the overlap area under the new position by Eq. 14. According to Fig. 2, we can easily calculate the KFIoU loss $L _ { k f } ( \Sigma _ { 1 } , \Sigma _ { 2 } )$ when we get the overlap area.
99
+
100
+ $$
101
+ \mathrm { K F I o U } = \frac { \mathcal { V } _ { B _ { 3 } } ( \Sigma ) } { \mathcal { V } _ { B _ { 1 } } ( \Sigma _ { 1 } ) + \mathcal { V } _ { B _ { 2 } } ( \Sigma _ { 2 } ) - \mathcal { V } _ { B _ { 3 } } ( \Sigma ) }
102
+ $$
103
+
104
+ In the appendix, we prove that the upper bounds of KFIoU in $\mathbf { n }$ -dimensional space is $\frac { 1 } { 2 ^ { \frac { n } { 2 } } - 1 }$ . For 2-D/3-D detection, the upper bounds are $\frac 1 3$ and $\frac { 1 } { \sqrt { 3 2 } - 1 }$ respectively when $n = 2$ and $n = 3$ . We can easily stretch the range of KFIoU to [0, 1] by linear transformation according to the upper bound, and then compare it with IoU for consistency. It should be noted that this linear transformation is not necessary and will improve the final performance, because we pay more attention to whether the changing trends of KFIoU and IoU are consistent rather than specific values.
105
+
106
+ Fig. 3 shows the curves of three loss functions for two bounding boxes with the same center in different cases. It should be noted that we have expanded KFIoU by 3 times so that its value range is $[ 0 , 1 ]$ like SkewIoU. Case 1 (left) depicts the relation between angle difference and loss functions. Though they all bear monotonicity, only smooth L1 curve is convex while the others are not. Case 2 (right) shows the changes of the three loss functions under different aspect ratio conditions. It can be seen that the smooth L1 loss of the two bounding boxes are constant (mainly from the angle difference), but the IoU loss and KFIoU loss will change drastically as the aspect ratio varies. Regardless of the case, KFIoU loss can maintain a similar trend to IoU loss.
107
+
108
+ # 4.2 THE PROPOSED KFIOU LOSS
109
+
110
+ We take 2-D object detection as the main example for notation brevity. We use the one-stage detector RetinaNet (Lin et al., 2017b) as the baseline. Rotated rectangle is represented by five parameters $( x , y , w , h , \theta )$ . First, we need to clarify that the network has not changed the output of the original regression branch, that is, it is not directly predicting the parameters of the Gaussian distribution. The whole training process of detector is as follows: i) predict offset $( t _ { x } ^ { * } , t _ { y } ^ { * } , t _ { w } ^ { * } , t _ { h } ^ { * } , t _ { \theta } ^ { * } )$ ; ii) decode prediction box; iii) convert prediction box and target ground-truth into Gaussian distribution; iv) calculate $L _ { c }$ and $L _ { k f }$ of two Gaussian distributions. Therefore, the inference time remains unchanged.
111
+
112
+ The regression equation of $( x , y , w , h )$ is as follows:
113
+
114
+ $$
115
+ \begin{array} { r l } & { t _ { x } = ( x - x _ { a } ) / w _ { a } , t _ { y } = ( y - y _ { a } ) / h _ { a } } \\ & { t _ { w } = \log ( w / w _ { a } ) , t _ { h } = \log ( h / h _ { a } ) } \\ & { t _ { x } ^ { * } = ( x ^ { * } - x _ { a } ) / w _ { a } , t _ { y } ^ { * } = ( y ^ { * } - y _ { a } ) / h _ { a } } \\ & { t _ { w } ^ { * } = \log ( w ^ { * } / w _ { a } ) , t _ { h } ^ { * } = \log ( h ^ { * } / h _ { a } ) } \end{array}
116
+ $$
117
+
118
+ where $x , y , w , h$ denote the box’s center coordinates, width, height and angle, respectively. Variables $x , x _ { a } , x ^ { * }$ are for the ground-truth box, anchor box, and predicted box (likewise for $y , w , h )$ .
119
+
120
+ As for the regression equation of $\theta$ , we use two forms as the baseline to be compared:
121
+
122
+ i) Direct regression, marked as Reg. $( \Delta \theta )$ . The model directly predicts the angle offset $t _ { \theta } ^ { * }$
123
+
124
+ $$
125
+ \begin{array} { l } { { t _ { \theta } = \left( \theta - \theta _ { a } \right) \cdot \pi / 1 8 0 } } \\ { { t _ { \theta } ^ { * } = \left( \theta ^ { * } - \theta _ { a } \right) \cdot \pi / 1 8 0 } } \end{array}
126
+ $$
127
+
128
+ ii) Indirect regression, marked as $\mathbf { R e g . } ^ { * } \left( \sin \theta , \cos \theta \right)$ . The model predicts two vectors $( { t _ { \sin \theta } ^ { * } }$ and $t _ { \mathrm { c o s } \theta } ^ { * } )$ to match the two targets from the ground truth $t _ { \sin \theta }$ and $t _ { \cos \theta }$ ):
129
+
130
+ $$
131
+ \begin{array} { r l } & { t _ { \sin \theta } = \sin { ( \theta \cdot \pi / 1 8 0 ) } , t _ { \cos \theta } = \cos { ( \theta \cdot \pi / 1 8 0 ) } } \\ & { t _ { \sin \theta } ^ { * } = \sin { ( \theta ^ { * } \cdot \pi / 1 8 0 ) } , t _ { \cos \theta } ^ { * } = \cos { ( \theta ^ { * } \cdot \pi / 1 8 0 ) } } \end{array}
132
+ $$
133
+
134
+ $t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } = 1$
135
+
136
+ $$
137
+ t _ { \sin \theta } ^ { * } = \frac { t _ { \sin \theta } ^ { * } } { \sqrt { t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } } } , \quad t _ { \cos \theta } ^ { * } = \frac { t _ { \cos \theta } ^ { * } } { \sqrt { t _ { \sin \theta } ^ { * 2 } + t _ { \cos \theta } ^ { * 2 } } }
138
+ $$
139
+
140
+ Indirect regression is a simpler way to avoid boundary discontinuity problem (Yang et al., 2019; Yang & Yan, 2020; Song et al., 2020; Ming et al., 2021c; Yang et al., 2021c). The multi-task loss is:
141
+
142
+ $$
143
+ L _ { t o t a l } = \lambda _ { 1 } \sum _ { n = 1 } ^ { N _ { p o s } } L _ { r e g } ( b _ { n } , g t _ { n } ) + \frac { \lambda _ { 2 } } { N } \sum _ { n = 1 } ^ { N } L _ { c l s } ( p _ { n } , t _ { n } )
144
+ $$
145
+
146
+ where $N$ and $N _ { p o s }$ indicates the number of all anchors and the number of positive anchors. $b _ { n }$ denotes the $n$ -th predicted bounding box, $g t _ { n }$ is the $n$ -th target ground-truth. $t _ { n }$ represents the label of $n$ -th object, $p _ { n }$ is the $n$ -th probability distribution of various classes calculated by sigmoid function. $\lambda _ { 1 } , \lambda _ { 2 }$ control the trade-off and are set to $\{ 0 . 0 1 , 1 \}$ by default. The classification loss $L _ { c l s }$ is set as the focal loss (Lin et al., 2017b). The regression loss $L _ { r e g } = L _ { c } + L _ { k f }$ , where
147
+
148
+ $$
149
+ L _ { c } ( \mu _ { 1 } , \mu _ { 2 } ) = \sum _ { i \in ( x , y ) } l _ { n } ( t _ { i } , t _ { i } ^ { ' } ) , \quad L _ { k f } ( \Sigma _ { 1 } , \Sigma _ { 2 } ) = \quad f \mathrm { ( K F I o U ) }
150
+ $$
151
+
152
+ and $f ( \cdot )$ represents the loss concerning KFIoU, such as $- \ln { ( \mathrm { K F I o U } + \epsilon ) }$ , 1−KFIoU, $e ^ { 1 - \mathrm { K F I o U } } - 1$ .
153
+
154
+ # 5 EXPERIMENTS
155
+
156
+ # 5.1 2-D DATASETS AND IMPLEMENTATION DETAILS
157
+
158
+ Aerial image dataset: DOTA (Xia et al., 2018) is one of the largest dataset for oriented object detection in aerial images with three released versions: DOTA-v1.0, DOTA-v1.5 and DOTA- $\mathbf { \sigma } \cdot \mathbf { v } 2 . 0$ .
159
+
160
+ Table 1: Ablation study of different KFIoU loss forms with different detectors on DOTA-v1.0.
161
+
162
+ <table><tr><td>Method</td><td>Smooth L1</td><td>ln(KFIoU+ε)</td><td>1-KFIoU</td><td>e1-KFIoU 1</td><td>1</td><td>-ln(3KFIoU+ e)</td></tr><tr><td>RetinaNet</td><td>65.73</td><td>69.80 (+4.07)</td><td>70.19 (+4.46)</td><td>70.64 (+4.91)</td><td>69.64 (+3.91)</td><td></td></tr><tr><td>RDet</td><td>70.66</td><td>72.28 (+1.62)</td><td>71.09 (+0.43)</td><td>71.58 (+0.92)</td><td></td><td>71.77 (+1.11)</td></tr></table>
163
+
164
+ Table 2: Ablation experiments on five datasets and two detectors.
165
+
166
+ <table><tr><td>Method</td><td>Reg. Loss</td><td>MLT</td><td>UCAS-AOD</td><td>DOTA-v1.0</td><td>DOTA-v1.5</td><td>DOTA-v2.0</td></tr><tr><td>RetinaNet</td><td>SmoothL1 GWD KFIoU</td><td>48.42 54.58 (+6.16) 55.96 (+7.54)</td><td>94.56 95.44 (+0.88) 96.13 (+1.57)</td><td>65.73 68.93 (+3.20) 70.64 (+4.91)</td><td>58.87 60.03 (+1.16) 62.71 (+3.84)</td><td>44.16 46.65 (+2.49) 48.04 (+3.88)</td></tr><tr><td>RDet</td><td>Smooth L1 GWD KFIoU</td><td></td><td></td><td>70.66 71.56 (+0.90) 72.28 (+1.62)</td><td>62.91 63.22 (+0.31) 64.69 (+1.78)</td><td>48.43 49.25 (+0.82) 50.41 (+1.98)</td></tr></table>
167
+
168
+ DOTA-v1.0 contains 15 common categories, 2,806 images and 188,282 instances. The proportions of the training set, validation set, and testing set in DOTA-v1.0 are $1 / 2 , 1 / 6$ , and $1 / 3$ , respectively. In contrast, DOTA-v1.5 uses the same images as DOTA-v1.0, but extremely small instances (less than 10 pixels) are also annotated. Moreover, a new category (CC-container crane), containing 402,089 instances in total is added in this version. While DOTA- $\mathbf { \sigma } \cdot \mathbf { v } 2 . 0$ contains 18 common categories (two new categories: AP-airport and HP-helipad), 11,268 images and 1,793,658 instances. Compared to DOTA-v1.5, it further includes the new categories. The 11,268 images in DOTA- $\mathbf { \sigma } \cdot \mathbf { v } 2 . 0$ are split into training, validation, test-dev, and test-challenge sets. We divide the images into $6 0 0 \times 6 0 0$ subimages with an overlap of 150 pixels and scale it to $8 0 0 \times 8 0 0$ , in line with the cropping protocol in literature. UCAS-AOD (Zhu et al., 2015) contains 1,510 aerial images of approximately $6 5 9 \times 1$ , 280 pixels, with two categories of 14,596 instances in total. In line with (Azimi et al., 2018; Xia et al., 2018), we randomly select 1,110 for training and 400 for testing. HRSC2016 (Liu et al., 2017) contains images from two scenarios including ships on sea and ships close inshore. The training, validation and test set include 436, 181 and 444 images.
169
+
170
+ Scene text dataset: ICDAR2015 (Karatzas et al., 2015), MLT (Nayef et al., 2017) and MSRATD500 (Yao et al., 2012) are commonly used for oriented scene text detection and spotting. ICDAR2015 includes 1,000 training images and 500 testing images. ICDAR2017 MLT is a multilingual text dataset, which includes 7,200 training images, 1,800 validation images and 9,000 testing images. MSRA-TD500 consists of 300 training images and 200 testing images.
171
+
172
+ We use Tensorflow (Abadi et al., 2016) for implementation, and all experiments are performed on a server with GeForce RTX 3090 Ti and 24G memory. Experiments are initialized by ResNet50 (He et al., 2016) by default unless otherwise specified. We perform experiments on three aerial benchmarks and two scene text benchmarks to verify the generality of our techniques. Weight decay and momentum are set 0.0001 and 0.9, respectively. We employ MomentumOptimizer over 4 GPUs with a total of 4 images per mini-batch (1 image per GPU). All the used datasets are trained by 20 epochs in total, and learning rate is reduced tenfold at 12 epochs and 16 epochs, respectively. The initial learning rates for RetinaNet is 1e-3. The number of image iterations per epoch for DOTAv1.0, DOTA-v1.5, DOTA-v1.0, UCAS-AOD, HRSC2016, ICDAR2015, MLT and MSRA-TD500 are 54k, 64k, 80k, 5k, 10k, 10k, 10k, 10k and $5 \mathrm { k }$ respectively, and increase exponentially if data augmentation (i.e. random graying, flipping and rotation) and multi-scale training are enabled.
173
+
174
+ # 5.2 3-D DATASETS AND IMPLEMENTATION DETAILS
175
+
176
+ KITTI (Geiger et al., 2012) contains 7,481 training and 7,518 testing samples for 3-D object detection. The training samples are generally divided into the train split (3,712 samples) and the val split (3,769 samples). The evaluation is classified into Easy, Moderate or Hard according to the object size, occlusion and truncation. All results are evaluated by the mean average precision with a rotated IoU threshold 0.7 for cars and 0.5 for pedestrian and cyclists. To evaluate the model’s performance on KITTI val split, we train our model on the train set and report the results on the val set.
177
+
178
+ We use third-party tools, MMDetection3D (Chen et al., 2019), for experiments and use PointPillar (Lang et al., 2019) as the baseline, and the training schedule inherited from SECOND (Yan et al., 2018): ADAM optimizer with a cosine-shaped cyclic learning rate scheduler that spans 160 epochs.
179
+
180
+ Table 3: Results on the KITTI val split 3D detection. † indicates our own implementation.
181
+
182
+ <table><tr><td rowspan="2">Method</td><td>mAP</td><td colspan="2">Car- 3DDetection</td><td colspan="3">Ped. - 3D Detection</td><td colspan="2">Cyc. - 3D Detection</td></tr><tr><td>Mod.</td><td>Easy Mod.</td><td>Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy Mod.</td><td>Hard</td></tr><tr><td>PointPillars</td><td>59.50</td><td>85.90 73.88</td><td>67.98</td><td>50.17</td><td>45.11</td><td>41.09</td><td>78.66 59.51</td><td>56.02</td></tr><tr><td>PointPillars†</td><td>61.34</td><td>85.66 75.48</td><td>68.39</td><td>55.46</td><td>48.69</td><td>43.71</td><td>79.37 59.84</td><td>55.92</td></tr><tr><td>+ KFIoU</td><td>64.98</td><td>86.45 76.49</td><td>74.41</td><td>58.11</td><td>54.22</td><td>49.53</td><td>82.68 64.23</td><td>60.07</td></tr></table>
183
+
184
+ Table 4: Results on the KITTI val BEV Detection. † indicates our own implementation.
185
+
186
+ <table><tr><td rowspan="2">Method</td><td>mAP</td><td colspan="2">Car-BEV Detection</td><td colspan="3">Ped.-BEV Detection</td><td colspan="3">Cyc.-1 BEVDetection</td></tr><tr><td>Mod.</td><td>Easy</td><td>Mod. Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td><td>Easy</td><td>Mod.</td><td>Hard</td></tr><tr><td>PointPillars</td><td>66.97</td><td>90.14</td><td>85.27 79.81</td><td>57.80</td><td>52.53</td><td>47.50</td><td>79.96</td><td>63.10</td><td>59.35</td></tr><tr><td>PointPillars†</td><td>68.16</td><td>89.89</td><td>86.97 79.64</td><td>61.04</td><td>54.94</td><td>49.26</td><td>81.76</td><td>62.56</td><td>60.54</td></tr><tr><td>+ KFIoU</td><td>70.91</td><td>89.59</td><td>86.81 83.21</td><td>63.34</td><td>58.43</td><td>54.80</td><td>84.61</td><td>67.50</td><td>64.52</td></tr></table>
187
+
188
+ Table 5: High-precision detection experiment under different regression loss. ‘R’, ‘F’ and ‘G’ indicate random rotation, flipping, and graying, respectively. The resolution of HRSC2016, MSRATD500 and ICDAR2015 are $5 0 0 \times 5 0 0$ , $8 0 0 \times 1 , 0 0 0$ and $8 0 0 \times 1 , 0 0 0$ .
189
+
190
+ <table><tr><td>Method</td><td>Dataset</td><td>Data Aug.</td><td>Reg.Loss</td><td>Hmean/AP50</td><td>Hmean/AP60</td><td>Hmean/AP75</td><td>Hmean/AP85</td><td>Hmean/AP50:95</td></tr><tr><td rowspan="3">RetinaNet</td><td>HRSC2016</td><td>R+F+G</td><td>Smooth L1 KFIoU</td><td>84.28 84.41 (+0.13)</td><td>74.74 82.23 (+7.49)</td><td>48.42 58.32 (+9.90)</td><td>12.56 18.34 (+5.78)</td><td>47.76 51.29 (+3.53)</td></tr><tr><td>MSRA-TD500</td><td>R+F</td><td>Smooth L1 KFIoU</td><td>70.98 76.30 (+5.32)</td><td>62.42 69.84 (+7.42)</td><td>36.73 47.58 (+10.85)</td><td>12.56 19.21 (+6.65)</td><td>37.89 44.96 (+7.07)</td></tr><tr><td>ICDAR2015</td><td>F</td><td>Smooth L1 KFIoU</td><td>69.78 75.90 (+6.12)</td><td>64.15 69.28 (+5.13)</td><td>36.97 40.03 (+3.06)</td><td>8.71 9.18 (+0.47)</td><td>37.73 41.17 (+3.44)</td></tr></table>
191
+
192
+ The learning rate starts from 1e-4 and reaches its peak value 1e-3 at the 60 epochs, and then goes down gradually to 1e-7 in the end. In the development phase, the experiments are conducted with a single model for 3-class joint detection.
193
+
194
+ # 5.3 ABLATION STUDY AND FURTHER COMPARISON
195
+
196
+ Ablation study of three forms of KFIoU loss on two detectors. We use two different detectors and three different KFIoU based loss functions to verify its effectiveness, as shown in Table 1. RetinaNet-based detector will have a large number of low-SkewIoU prediction bounding box in the early stage of training, and will produce very large loss after the log function, which weakens the improvement of the model. Compared with the linear function, the derivative of the exp-based function will pay more attention to the training of difficult samples, so it has a higher performance, at $7 0 . 6 4 \%$ . In contrast, ${ \mathrm { R } } ^ { 3 }$ Det-based detector can generate high-quality prediction box at the beginning of training by adding refinement stages, so it will not suffer the same troubles as RetinaNet. Due to the same mechanism of focusing on difficult samples, log and exp-based functions are both better than linear functions, and the best performance is achieved on the log-based function, about $7 2 . 2 8 \%$ . We also expanded KFIoU by 3 times to make its range truly consistent with the IoU loss, at [0, 1]. However, this consistency do not bring any additional gains, so the following experiments are all use the KFIoU before non-expansion.
197
+
198
+ Ablation study of KFIoU loss on five datasets and two detectors. Table 2 shows the performance comparison of three different regression losses on five datasets. Smooth L1 is a regression loss commonly used by detectors based on bounding box representation. In contrast, both GWD and KFIoU loss are regression losses based on Gaussian modeling, but the core of the former is the Gaussian distribution distance metric, and the latter is a SkewIoU approximation based on Kalman filtering. The Gaussian representation based regression loss is significantly better than the bounding box representation based. This is mainly due to the inherent advantages of the Gaussian distribution representation described in (Yang et al., 2021c), including immunity to boundary discontinuity, and square-like detection problem. The disadvantage of GWD is that it is not scale invariant, being not conducive to small object detection. By contrast, our KFIoU loss is scale-invariant and shows better performance on datasets containing a large number of small objects e.g. DOTA-v1.5/v2.0.
199
+
200
+ Ablation study of KFIoU loss on 3-D object detection. We generalize the KFIoU loss from 2-D to 3-D object detection, with results in Table 3 and Table 4. It shows the performance comparison in 3-D detection and BEV detection on KITTI val split, and significant performance improvements are also achieved. On the moderate level of 3-D detection, KFIoU loss improves PointPillars† by $3 . 6 4 \%$ . On the moderate level of BEV detection, KFIoU loss achieves gains of $2 . 7 5 \%$ , at $7 0 . 9 1 \%$ . Fig. 4 visualizes the detection results of Smooth L1 loss-based and KFIoU loss-based detectors.
201
+
202
+ Table 6: Accuracy $( \% )$ comparison on DOTA. † and ‡ represents the large aspect ratio object and the square-like object, respectively. The bold red and blue indicate the top two performances. $D _ { o c }$ and $D _ { l e }$ denotes OpenCV Definition $( \theta \in [ - 9 0 ^ { \circ } , 0 ^ { \circ } ) )$ and Long Edge Definition $( \theta \in [ - 9 0 ^ { \circ } , 9 0 ^ { \circ } ) _ { , } ^ { \circ }$ ) of RBox. ‘H’ and $\cdot _ { \mathrm { R } } \cdot$ denotes the horizontal and rotating anchors, respectively.
203
+
204
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Box Def.</td><td colspan="9">v1.0 tranval/test</td><td>v1.5</td><td>v2.0</td></tr><tr><td>BR</td><td>SVi</td><td>LVt</td><td>SH</td><td>HA</td><td>ST</td><td>RA</td><td>7-AP50</td><td>AP50</td><td>AP50</td><td>AP50</td></tr><tr><td>RetinaNet-H(Reg.) (2017b)</td><td>Doc</td><td>42.17</td><td>65.93</td><td>51.11</td><td>72.61</td><td>53.24</td><td>78.38</td><td>62.00</td><td>60.78</td><td>65.73</td><td>58.87</td><td>44.16</td></tr><tr><td>RetinaNet-H(Reg.) (2017b)</td><td>De</td><td>38.31</td><td>60.48</td><td>49.77</td><td>68.29</td><td>51.28</td><td>78.60</td><td>60.02</td><td>58.11</td><td>64.17</td><td>56.10</td><td>43.06</td></tr><tr><td>RetinaNet-H(Reg.*) (2017b)</td><td>Dle</td><td>41.52</td><td>63.94</td><td>44.95</td><td>71.18</td><td>53.22</td><td>78.11</td><td>60.54</td><td>59.07</td><td>65.78</td><td>57.17</td><td>43.92</td></tr><tr><td>RetinaNet-R(Reg.) (2017b)</td><td>Doc</td><td>34.86</td><td>73.58</td><td>73.33</td><td>82.95</td><td>51.03</td><td>79.08</td><td>59.57</td><td>64.91</td><td>67.25</td><td>56.50</td><td>42.04</td></tr><tr><td>IoU-Smooth L1(2019)</td><td>Doc</td><td>44.32</td><td>63.03</td><td>51.25</td><td>72.78</td><td>56.21</td><td>77.98</td><td>63.22</td><td>61.26</td><td>66.99</td><td>59.16</td><td>46.31</td></tr><tr><td>Modulated Loss (2021)</td><td>Doc</td><td>42.92</td><td>67.92</td><td>52.91</td><td>72.67</td><td>53.64</td><td>80.22</td><td>58.21</td><td>61.21</td><td>66.05</td><td>57.75</td><td>45.17</td></tr><tr><td>Modulated Loss (2021)</td><td>Quad.</td><td>43.21</td><td>70.78</td><td>54.70</td><td>72.68</td><td>60.99</td><td>79.72</td><td>62.08</td><td>63.45</td><td>67.20</td><td>61.42</td><td>46.71</td></tr><tr><td>RIL (2021c)</td><td>Quad.</td><td>40.81</td><td>67.63</td><td>55.45</td><td>72.42</td><td>55.49</td><td>78.09</td><td>64.75</td><td>62.09</td><td>66.06</td><td>58.91</td><td>45.35</td></tr><tr><td>CSL (2020)</td><td>Dle</td><td>42.25</td><td>68.28</td><td>54.51</td><td>72.85</td><td>53.10</td><td>75.59</td><td>58.99</td><td>60.80</td><td>67.38</td><td>58.55</td><td>43.34</td></tr><tr><td>DCL (BCL) (2021a)</td><td>Dle</td><td>41.40</td><td>65.82</td><td>56.27</td><td>73.80</td><td>54.30</td><td>79.02</td><td>60.25</td><td>61.55</td><td>67.39</td><td>59.38</td><td>45.46</td></tr><tr><td>GWD (2021c)</td><td>Doc</td><td>44.07</td><td>71.92</td><td>62.56</td><td>77.94</td><td>60.25</td><td>79.64</td><td>63.52</td><td>65.70</td><td>68.93</td><td>60.03</td><td>46.65</td></tr><tr><td>KFIoU (Ours)</td><td>Doc</td><td>46.30</td><td>72.56</td><td>65.61</td><td>78.16</td><td>63.68</td><td>78.15</td><td>66.34</td><td>67.26</td><td>70.64</td><td>62.71</td><td>48.04</td></tr></table>
205
+
206
+ Table 7: AP of different objects on DOTA-v1.0. R-101 denotes ResNet-101 (likewise for R-50, R152). RX-101 and H-104 denotes ResNeXt101 (Xie et al., 2017) and Hourglass-104 (Newell et al., 2016). MS indicates using multi-scale training/testing. Red and blue: top two performances.
207
+
208
+ <table><tr><td></td><td>Method</td><td>Backbone</td><td>MS</td><td>PL</td><td>BD</td><td>BR</td><td>GTF</td><td>SV</td><td>LV</td><td>SH</td><td>TC BC</td><td>ST</td><td>SBF</td><td>RA</td><td>HA</td><td>SP</td><td>HC</td><td>AP50</td></tr><tr><td rowspan="11">stetsseet</td><td>PIoU (2020)</td><td>DLA-34</td><td></td><td>80.90</td><td>69.70</td><td>24.10</td><td>60.20</td><td>38.30</td><td>64.40</td><td>64.80 90.90</td><td>77.20</td><td>70.40</td><td>46.50</td><td>37.10</td><td>57.10</td><td>61.90</td><td>64.00</td><td>60.50</td></tr><tr><td>O²-DNet (2020)</td><td>H-104</td><td></td><td>89.31</td><td>82.14</td><td>47.33</td><td>61.21</td><td>71.32</td><td>74.03 78.62</td><td>90.76</td><td>82.23</td><td>81.36</td><td>60.93</td><td>60.17</td><td>58.21</td><td>66.98</td><td>61.03</td><td>71.04</td></tr><tr><td>DAL (2021d)</td><td>R-101</td><td></td><td>88.61</td><td>79.69</td><td>46.27</td><td>70.37</td><td>65.89</td><td>76.10</td><td>78.53</td><td>90.84</td><td>79.98 78.41</td><td>58.71</td><td>62.02</td><td>69.23</td><td>71.32</td><td>60.65</td><td>71.78</td></tr><tr><td>P-RSDet (2020)</td><td>R-101</td><td></td><td>88.58</td><td>77.83</td><td>50.44</td><td>69.29</td><td>71.10</td><td>75.79</td><td>78.66</td><td>90.88 80.10</td><td>81.71</td><td>57.92</td><td>63.03</td><td>66.30</td><td>69.77</td><td>63.13</td><td>72.30</td></tr><tr><td>BBAVectors (2020)</td><td>R-101</td><td></td><td>88.35</td><td>79.96</td><td>50.69</td><td>62.18</td><td>78.43</td><td>78.98 87.94</td><td>90.85</td><td>83.58</td><td>84.35</td><td>54.13</td><td>60.24</td><td>65.22</td><td>64.28</td><td>55.70</td><td>72.32</td></tr><tr><td>DRN (2020)</td><td>H-104</td><td></td><td>89.71</td><td>82.34</td><td>47.22</td><td>64.10</td><td>76.22 74.43</td><td>85.84</td><td>90.57</td><td>86.18</td><td>84.89</td><td>57.65</td><td>61.93</td><td>69.30</td><td>69.63</td><td>58.48</td><td>73.23</td></tr><tr><td>DCL (2021a)</td><td>R-152</td><td></td><td>89.10</td><td>84.13</td><td>50.15</td><td>73.57</td><td>71.48 58.13</td><td>78.00</td><td>90.89</td><td>86.64</td><td>86.78</td><td>67.97</td><td>67.25</td><td>65.63</td><td>74.06</td><td>67.05</td><td>74.06</td></tr><tr><td>PolarDet (2021)</td><td>R-101</td><td></td><td>89.65</td><td>87.07</td><td>48.14</td><td>70.97</td><td>78.53</td><td>80.34 87.45</td><td>90.76</td><td>85.63</td><td>86.87</td><td>61.64</td><td>70.32</td><td>71.92</td><td>73.09</td><td>67.15</td><td>76.64</td></tr><tr><td>GWD (2021c)</td><td>R-152</td><td>&lt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</td><td>86.96</td><td>83.88</td><td>54.36</td><td>77.53</td><td>74.41</td><td>68.48 80.34</td><td>86.62</td><td>83.41</td><td>85.55</td><td>73.47</td><td>67.77</td><td>72.57</td><td>75.76</td><td>73.40</td><td>76.30</td></tr><tr><td>KFIoU (Ours)</td><td>R-152</td><td>√</td><td>89.33 89.46</td><td>85.03</td><td>52.91</td><td>70.92</td><td>77.22</td><td>70.00</td><td>82.22</td><td>90.84</td><td>87.74 84.77</td><td>62.88</td><td>63.39</td><td>75.07</td><td>70.98</td><td>70.14</td><td>75.56</td></tr><tr><td>ICN (2018)</td><td>R-101</td><td></td><td>81.40</td><td>85.72 74.30</td><td>54.94 47.70</td><td>80.37 70.30</td><td>77.16 64.90</td><td>69.23 67.80</td><td>80.90 70.00</td><td>90.79 90.80</td><td>87.79 79.10</td><td>86.13 78.20</td><td>73.32</td><td>68.11 75.23 62.90</td><td>71.61</td><td>69.49</td><td>77.35</td></tr><tr><td></td><td>R-101</td><td></td><td>88.64</td><td>78.52</td><td>43.44</td><td>75.92</td><td>68.81</td><td>73.68</td><td>83.59</td><td>90.74</td><td>77.27</td><td>81.46</td><td>53.60</td><td>67.00 62.83</td><td>64.20 58.93</td><td>50.20 47.67</td><td>68.20 69.56</td></tr><tr><td rowspan="14">Thrrgareea DCL (2021a) GWD (2021c)</td><td>RoI-Trans. (2019) SCRDet (2019)</td><td>R-101</td><td></td><td>89.98</td><td>80.65</td><td>52.09 68.36</td><td>68.36</td><td>60.32</td><td>72.41</td><td>90.85</td><td></td><td></td><td>58.39</td><td>53.54</td><td></td><td></td><td></td><td></td></tr><tr><td>CFC-Net (2021a)</td><td></td><td></td><td>89.08</td><td></td><td></td><td></td><td></td><td></td><td></td><td>87.94</td><td>86.86</td><td>65.02</td><td>66.68</td><td>66.25</td><td>68.24</td><td>65.21</td><td>72.61</td></tr><tr><td></td><td>R-101</td><td></td><td>80.41</td><td>52.41</td><td>70.02 71.11</td><td>76.28 78.11</td><td>78.11 78.39</td><td>87.21 87.25</td><td>90.89</td><td>84.47 84.90</td><td>85.64</td><td>60.51</td><td>61.52</td><td>67.82</td><td>68.02</td><td>50.09</td><td>73.50</td></tr><tr><td>S2A-Net (2021a)</td><td>R-50 R-101</td><td></td><td>89.11</td><td>82.84 48.37</td><td>52.26 77.34</td><td>73.01</td><td>73.14</td><td></td><td>90.83</td><td></td><td>85.64</td><td>60.36</td><td>62.60</td><td>65.26</td><td>69.13</td><td>57.94</td><td>74.12</td></tr><tr><td>Gliding Vertex (2020)</td><td>RX-101</td><td></td><td>89.64</td><td>85.00</td><td>54.21 72.90</td><td>76.52</td><td>74.16</td><td>86.82 85.63</td><td>90.74 89.85</td><td>79.02 83.81</td><td>86.81</td><td>59.55</td><td>70.91</td><td>72.94</td><td>70.86</td><td>57.32</td><td>75.02</td></tr><tr><td>Mask OBB (2019)</td><td>R-101</td><td></td><td>89.56</td><td>85.95</td><td>54.60 70.25</td><td>77.66</td><td>78.32</td><td>87.19</td><td></td><td>84.89</td><td>86.48</td><td>54.89</td><td>69.64</td><td>73.94</td><td>69.06</td><td>63.32</td><td>75.33</td></tr><tr><td>CenterMap (2020)</td><td>R-152</td><td></td><td>89.83 90.25</td><td>84.41</td><td>54.64 75.31</td><td>70.44</td><td>73.51</td><td>77.62</td><td>90.66 90.84</td><td>86.15</td><td>85.27</td><td>56.46</td><td>69.23</td><td>74.13</td><td>71.56</td><td>66.06</td><td>76.03</td></tr><tr><td>FPN-CSL (2020)</td><td>ReR-50</td><td></td><td>88.79</td><td>85.53 82.64</td><td>53.97 74.00</td><td>78.13</td><td>84.06</td><td>88.04</td><td>90.89</td><td>87.78</td><td>86.69 85.75</td><td>69.60</td><td>68.04</td><td>73.83</td><td>71.10</td><td>68.93</td><td>76.17</td></tr><tr><td>ReDet (2021b)</td><td></td><td></td><td>89.93</td><td></td><td>53.77 74.35</td><td>71.52</td><td>78.31</td><td>78.12</td><td>91.14</td><td>87.35</td><td>86.93</td><td>61.76 65.64</td><td>60.39 65.17</td><td>75.96 75.35</td><td>68.07</td><td>63.59</td><td>76.25</td></tr><tr><td>RSDet-II (2021)</td><td>R-152</td><td>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</td><td>89.80</td><td>84.45 83.77</td><td>48.11</td><td>66.77</td><td>78.76</td><td>83.27</td><td>87.84</td><td>90.82 85.38</td><td>85.51</td><td>65.67</td><td>62.68</td><td>67.53</td><td>79.74 78.56</td><td>63.31 72.62</td><td>76.34</td></tr><tr><td>RDet (2021b)</td><td>R-152 R-101</td><td></td><td>90.05</td><td>84.39</td><td>55.44</td><td>73.99</td><td>77.54</td><td>71.11</td><td>86.05</td><td>90.67</td><td>87.32 87.08 87.46</td><td>69.62</td><td>68.90</td><td>73.74</td><td>71.29</td><td>65.08</td><td>76.47 76.81</td></tr><tr><td>SCRDet++ (2020b) DAL (2021d)</td><td>R-50</td><td></td><td>89.69</td><td>83.11</td><td>55.03</td><td>71.00</td><td>78.30</td><td>81.90</td><td>88.46 90.89</td></table>
209
+
210
+ High-precision detection experiment. We compare the performance of Smooth L1 loss and KFIoU loss in high-precision detection indicators, as shown in Table 5. For HRSC2016 containing a large number of ship with large aspect ratios, KFIoU loss has a $9 . 9 0 \%$ improvement over Smooth L1 on $\mathsf { A P } _ { 7 5 }$ . For the scene text datasets MSRA-TD500 and ICDAR2015, KFIoU loss achieves $7 . 0 7 \%$ and $3 . 4 4 \%$ improvements on Hmean50:95, reaching $4 4 . 9 6 \%$ and $4 1 . 1 7 \%$ respectively.
211
+
212
+ Comparison with peer methods. Methods in Table 6 are all based on the same baseline RetinaNet, and initialized by ResNet50 (He et al., 2016) without using data augmentation and multi-scale training/testing. They are trained/tested under the same environment and hyperparameters. We detail the accuracy of the seven categories, with large aspect ratio (BR, SV, LV, SH, HA) and square-like object (ST, RD), to better reflect the real-world challenges and the effectiveness of our method.
213
+
214
+ First, we conduct ablation experiments on anchor form (horizontal and rotating anchors), rotating bounding box definition form (OpenCV definition and Long Edge definition), and angle regression form (direct regression and indirect regression) based on RetinaNet. Rotating anchors provides accurate prior, which makes the model show strong performance in large aspect ratio objects (e.g.
215
+
216
+ ![](images/a09fafd191758c0269ca0bf5ced22bdde52580f7390a82914e68bc9f46bc6a96.jpg)
217
+ Figure 4: Comparison of the detection results between Smooth L1 loss-based (left), GWD-based (middle) and the KFIoU loss-based (right) detectors on DOTA (2-D) and KITTI (3-D). For 3-D object detection, red and blue box denotes ground-truth and predict bounding box, respectively.
218
+
219
+ SV, LV, SH). However, the large number of anchors makes it time-consuming. Therefore, we use horizontal anchors by default to balance accuracy and speed. OpenCV definition $( D _ { o c } )$ (Yang et al., 2019; Qian et al., 2021; Yang et al., 2021b) and Long Edge definition $( D _ { l e } )$ (Yang & Yan, 2020; Yang et al., 2021a) are two popular methods for defining bounding boxes with different angles. Experiments show that $D _ { o c }$ is slightly better than $D _ { l e }$ on the three versions of $\scriptstyle \mathrm { { D O T A = v 1 . 0 / v 1 . 5 / v 2 . 0 } }$ . Angle direct regression (Reg.) always suffers from the standing boundary discontinuity problem as widely stuied recently (Yang et al., 2019; Yang & Yan, 2020; Song et al., 2020; Qian et al., 2021; Ming et al., 2021c; Yang et al., 2021c). In contrast, angle indirect regression $( \mathrm { R e g } ^ { * } . )$ is a simpler way to avoid above problems and has an advantage in most indicators according to Table 6.
220
+
221
+ IoU-Smooth L1 partly circumvents the need for differentiable SkewIoU loss by combining IoU and Smooth L1 loss. Although IoU-Smooth L1 has achieved an improvement of $\mathbf { 1 . 2 6 \% / 0 . 2 9 \% / 2 . 1 5 \% }$ from $6 5 . 7 3 \% / 5 8 . 8 7 \% / 4 4 . 1 6 \%$ to $6 6 . 9 9 \% / 5 9 . 1 6 \% / 4 6 . 3 1 \%$ on DOTA- $\mathrm { \Delta } _ { / 1 . 0 / \mathrm { v } 1 . 5 / \mathrm { v } 2 . 0 }$ , the gradient is still dominated by Smooth L1. Modulated Loss and RIL implement ordered and disordered quadrilateral detection respectively, and the more accurate representation makes them both have a considerable performance improvement. In particular, Modulated Loss achieves the second highest performance on DOTA-v1.5 and DOTA- $\mathbf { \sigma } \cdot \mathbf { v } 2 . 0$ . CSL and DCL convert the angle prediction from regression to classification, cleverly eliminating the boundary discontinuity problem caused by the angle periodicity. GWD and KFIoU loss are two different regression losses based on Gaussian distribution. In contrast, KFIoU loss has a more obvious performance increase due to its scale invariance and a more consistent calculation process with SkewIoU loss. Finally, KFIoU loss ranks among the top two of all methods in Table 6 on most indicators.
222
+
223
+ # 5.4 COMPARISON WITH THE STATE-OF-THE-ART
224
+
225
+ Table 7 compares state-of-the-art detectors on DOTA-v1.0, as categorized by single-stage, twostage, and refine-stage based methods. Data augmentation and multi-scale training/testing are used. For single-stage method, our single scale model RetinaNet-KFIoU achieves $7 5 . 5 6 \%$ and outperforms most multi-scale models. For multi-scale testing, it achieves state-of-the-art accuracy $7 7 . 3 5 \%$ . For two/refine-stage methods, ${ \tt R } ^ { 3 }$ Det-KFIoU achieves the best $\mathsf { A P } _ { 5 0 }$ : $7 9 . 2 3 \%$ .
226
+
227
+ # 6 CONCLUSION
228
+
229
+ This paper first elaborates on the inconsistency between the final detection performance and regression loss in rotated object detection. To address this issue, we propose a novel approximate SkewIoU loss for rotation detection, called KFIoU loss, specifically based on the techniques of Gaussian modeling and Kalman filter. The loss is essentially scale-invariant and more physically coherent while the Gaussian distribution based loss (Yang et al., 2021c) is not. We extend our approach from 2-D to the 3-D case, leading to the first Gaussian distribution based 3-D detector. Extensive experimental results on multiple public datasets (2-D/3-D, aerial/text images) with different base detectors show the effectiveness of our approach.
230
+
231
+ # REFERENCES
232
+
233
+ Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for largescale machine learning. In 12th {USENIX} symposium on operating systems design and implementation ( $\left\{ O S D I \right\} { } I 6 )$ , pp. 265–283, 2016.
234
+
235
+ Seyed Majid Azimi, Eleonora Vig, Reza Bahmanyar, Marco Korner, and Peter Reinartz. Towards ¨ multi-class object detection in unconstrained remote sensing imagery. In Asian Conference on Computer Vision, pp. 150–165. Springer, 2018.
236
+
237
+ Kai Chen, Jiaqi Wang, Jiangmiao Pang, Yuhang Cao, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jiarui Xu, Zheng Zhang, Dazhi Cheng, Chenchen Zhu, Tianheng Cheng, Qijie Zhao, Buyu Li, Xin Lu, Rui Zhu, Yue Wu, Jifeng Dai, Jingdong Wang, Jianping Shi, Wanli Ouyang, Chen Change Loy, and Dahua Lin. MMDetection: Open mmlab detection toolbox and benchmark. arXiv preprint arXiv:1906.07155, 2019.
238
+
239
+ Zhiming Chen, Kean Chen, Weiyao Lin, John See, Hui Yu, Yan Ke, and Cong Yang. Piou loss: Towards accurate oriented object detection in complex environments. In European Conference on Computer Vision, pp. 195–211. Springer, 2020.
240
+
241
+ Jian Ding, Nan Xue, Yang Long, Gui-Song Xia, and Qikai Lu. Learning roi transformer for oriented object detection in aerial images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2849–2858, 2019.
242
+
243
+ Andreas Geiger, Philip Lenz, and Raquel Urtasun. Are we ready for autonomous driving? the kitti vision benchmark suite. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3354–3361. IEEE, 2012.
244
+
245
+ Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1440–1448, 2015.
246
+
247
+ Jiaming Han, Jian Ding, Jie Li, and Gui-Song Xia. Align deep features for oriented object detection. IEEE Transactions on Geoscience and Remote Sensing, 2021a.
248
+
249
+ Jiaming Han, Jian Ding, Nan Xue, and Gui-Song Xia. Redet: A rotation-equivariant detector for aerial object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2786–2795, 2021b.
250
+
251
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 770–778, 2016.
252
+
253
+ Yingying Jiang, Xiangyu Zhu, Xiaobing Wang, Shuli Yang, Wei Li, Hua Wang, Pei Fu, and Zhenbo Luo. R2cnn: rotational region cnn for orientation robust scene text detection. arXiv preprint arXiv:1706.09579, 2017.
254
+
255
+ Dimosthenis Karatzas, Lluis Gomez-Bigorda, Anguelos Nicolaou, Suman Ghosh, Andrew Bagdanov, Masakazu Iwamura, Jiri Matas, Lukas Neumann, Vijay Ramaseshan Chandrasekhar, Shijian Lu, et al. Icdar 2015 competition on robust reading. In 2015 13th International Conference on Document Analysis and Recognition, pp. 1156–1160. IEEE, 2015.
256
+
257
+ Alex H Lang, Sourabh Vora, Holger Caesar, Lubing Zhou, Jiong Yang, and Oscar Beijbom. Pointpillars: Fast encoders for object detection from point clouds. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 12697–12705, 2019.
258
+
259
+ Minghui Liao, Baoguang Shi, and Xiang Bai. Textboxes++: A single-shot oriented scene text detector. IEEE Transactions on Image Processing, 27(8):3676–3690, 2018a.
260
+
261
+ Minghui Liao, Zhen Zhu, Baoguang Shi, Gui-song Xia, and Xiang Bai. Rotation-sensitive regression for oriented scene text detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5909–5918, 2018b.
262
+
263
+ Tsung-Yi Lin, Piotr Dollar, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. ´ Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2117–2125, 2017a.
264
+
265
+ Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense ´ object detection. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2980–2988, 2017b.
266
+
267
+ Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, and Alexander C Berg. Ssd: Single shot multibox detector. In European Conference on Computer Vision, pp. 21–37. Springer, 2016.
268
+
269
+ Zikun Liu, Liu Yuan, Lubin Weng, and Yiping Yang. A high resolution optical satellite image dataset for ship recognition and some new baselines. In Proceedings of the International Conference on Pattern Recognition Applications and Methods, volume 2, pp. 324–331, 2017.
270
+
271
+ Jianqi Ma, Weiyuan Shao, Hao Ye, Li Wang, Hong Wang, Yingbin Zheng, and Xiangyang Xue. Arbitrary-oriented scene text detection via rotation proposals. IEEE Transactions on Multimedia, 20(11):3111–3122, 2018.
272
+
273
+ Qi Ming, Lingjuan Miao, Zhiqiang Zhou, and Yunpeng Dong. Cfc-net: A critical feature capturing network for arbitrary-oriented object detection in remote sensing images. arXiv preprint arXiv:2101.06849, 2021a.
274
+
275
+ Qi Ming, Lingjuan Miao, Zhiqiang Zhou, Junjie Song, and Xue Yang. Sparse label assignment for oriented object detection in aerial images. Remote Sensing, 13(14):2664, 2021b.
276
+
277
+ Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Xue Yang, and Yunpeng Dong. Optimization for oriented object detection via representation invariance loss. arXiv preprint arXiv:2103.11636, 2021c.
278
+
279
+ Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Hongwei Zhang, and Linhao Li. Dynamic anchor learning for arbitrary-oriented object detection. In Proceedings of the AAAI Conference on Artificial Intelligence, 2021d.
280
+
281
+ Nibal Nayef, Fei Yin, Imen Bizid, Hyunsoo Choi, Yuan Feng, Dimosthenis Karatzas, Zhenbo Luo, Umapada Pal, Christophe Rigaud, Joseph Chazalon, et al. Icdar2017 robust reading challenge on multi-lingual scene text detection and script identification-rrc-mlt. In 2017 14th IAPR International Conference on Document Analysis and Recognition, volume 1, pp. 1454–1459. IEEE, 2017.
282
+
283
+ Alejandro Newell, Kaiyu Yang, and Jia Deng. Stacked hourglass networks for human pose estimation. In European Conference on Computer Vision, pp. 483–499. Springer, 2016.
284
+
285
+ Xingjia Pan, Yuqiang Ren, Kekai Sheng, Weiming Dong, Haolei Yuan, Xiaowei Guo, Chongyang Ma, and Changsheng Xu. Dynamic refinement network for oriented and densely packed object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 11207–11216, 2020.
286
+
287
+ Wen Qian, Xue Yang, Silong Peng, Junchi Yan, and Yue Guo. Learning modulated loss for rotated object detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 2458–2466, 2021.
288
+
289
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In Advances in Neural Information Processing Systems, pp. 91–99, 2015.
290
+
291
+ Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 658–666, 2019.
292
+
293
+ Qing Song, Fan Yang, Lu Yang, Chun Liu, Mengjie Hu, and Lurui Xia. Learning point-guided localization for detection in remote sensing images. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 2020.
294
+
295
+ Jinwang Wang, Jian Ding, Haowen Guo, Wensheng Cheng, Ting Pan, and Wen Yang. Mask obb: A semantic attention-based mask oriented bounding box representation for multi-category object detection in aerial images. Remote Sensing, 11(24):2930, 2019.
296
+
297
+ Jinwang Wang, Wen Yang, Heng-Chao Li, Haijian Zhang, and Gui-Song Xia. Learning center probability map for detecting objects in aerial images. IEEE Transactions on Geoscience and Remote Sensing, 2020.
298
+
299
+ Haoran Wei, Yue Zhang, Zhonghan Chang, Hao Li, Hongqi Wang, and Xian Sun. Oriented objects as pairs of middle lines. ISPRS Journal of Photogrammetry and Remote Sensing, 169:268–279, 2020.
300
+
301
+ Gui-Song Xia, Xiang Bai, Jian Ding, Zhen Zhu, Serge Belongie, Jiebo Luo, Mihai Datcu, Marcello Pelillo, and Liangpei Zhang. Dota: A large-scale dataset for object detection in aerial images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3974– 3983, 2018.
302
+
303
+ Enze Xie, Peize Sun, Xiaoge Song, Wenhai Wang, Xuebo Liu, Ding Liang, Chunhua Shen, and Ping Luo. Polarmask: Single shot instance segmentation with polar representation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 12193–12202, 2020.
304
+
305
+ Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual trans- ´ formations for deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1492–1500, 2017.
306
+
307
+ Yongchao Xu, Mingtao Fu, Qimeng Wang, Yukang Wang, Kai Chen, Gui-Song Xia, and Xiang Bai. Gliding vertex on the horizontal bounding box for multi-oriented object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2020.
308
+
309
+ Yan Yan, Yuxing Mao, and Bo Li. Second: Sparsely embedded convolutional detection. Sensors, 18(10):3337, 2018.
310
+
311
+ Xue Yang and Junchi Yan. Arbitrary-oriented object detection with circular smooth label. In European Conference on Computer Vision, pp. 677–694. Springer, 2020.
312
+
313
+ Xue Yang, Hao Sun, Kun Fu, Jirui Yang, Xian Sun, Menglong Yan, and Zhi Guo. Automatic ship detection in remote sensing images from google earth of complex scenes based on multiscale rotation dense feature pyramid networks. Remote Sensing, 10(1):132, 2018a.
314
+
315
+ Xue Yang, Hao Sun, Xian Sun, Menglong Yan, Zhi Guo, and Kun Fu. Position detection and direction prediction for arbitrary-oriented ships via multitask rotation region convolutional neural network. IEEE Access, 6:50839–50849, 2018b.
316
+
317
+ Xue Yang, Jirui Yang, Junchi Yan, Yue Zhang, Tengfei Zhang, Zhi Guo, Xian Sun, and Kun Fu. Scrdet: Towards more robust detection for small, cluttered and rotated objects. In Proceedings of the IEEE International Conference on Computer Vision, pp. 8232–8241, 2019.
318
+
319
+ Xue Yang, Junchi Yan, and Tao He. On the arbitrary-oriented object detection: Classification based approaches revisited. arXiv preprint arXiv:2003.05597, 2020a.
320
+
321
+ Xue Yang, Junchi Yan, Xiaokang Yang, Jin Tang, Wenlong Liao, and Tao He. Scrdet $^ { + + }$ : Detecting small, cluttered and rotated objects via instance-level feature denoising and rotation loss smoothing. arXiv preprint arXiv:2004.13316, 2020b.
322
+
323
+ Xue Yang, Liping Hou, Yue Zhou, Wentao Wang, and Junchi Yan. Dense label encoding for boundary discontinuity free rotation detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 15819–15829, 2021a.
324
+
325
+ Xue Yang, Junchi Yan, Ziming Feng, and Tao He. R3det: Refined single-stage detector with feature refinement for rotating object. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 3163–3171, 2021b.
326
+
327
+ Xue Yang, Junchi Yan, Ming Qi, Wentao Wang, Zhang Xiaopeng, and Tian Qi. Rethinking rotated object detection with gaussian wasserstein distance loss. In International Conference on Machine Learning, 2021c.
328
+
329
+ Xue Yang, Xiaojiang Yang, Jirui Yang, Qi Ming, Wentao Wang, Qi Tian, and Junchi Yan. Learning high-precision bounding box for rotated object detection via kullback-leibler divergence. arXiv preprint arXiv:2106.01883, 2021d.
330
+
331
+ Cong Yao, Xiang Bai, Wenyu Liu, Yi Ma, and Zhuowen Tu. Detecting texts of arbitrary orientations in natural images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1083–1090. IEEE, 2012.
332
+
333
+ Jingru Yi, Pengxiang Wu, Bo Liu, Qiaoying Huang, Hui Qu, and Dimitris Metaxas. Oriented object detection in aerial images with box boundary-aware vectors. arXiv preprint arXiv:2008.07043, 2020.
334
+
335
+ Jiahui Yu, Yuning Jiang, Zhangyang Wang, Zhimin Cao, and Thomas Huang. Unitbox: An advanced object detection network. In Proceedings of the 24th ACM international conference on Multimedia, pp. 516–520, 2016.
336
+
337
+ Pengbo Zhao, Zhenshen Qu, Yingjia Bu, Wenming Tan, and Qiuyu Guan. Polardet: A fast, more precise detector for rotated target in aerial images. International Journal of Remote Sensing, 42 (15):5821–5851, 2021.
338
+
339
+ Yu Zheng, Danyang Zhang, Sinan Xie, Jiwen Lu, and Jie Zhou. Rotation-robust intersection over union for 3d object detection. In European Conference on Computer Vision, pp. 464–480. Springer, 2020a.
340
+
341
+ Zhaohui Zheng, Ping Wang, Wei Liu, Jinze Li, Rongguang Ye, and Dongwei Ren. Distance-iou loss: Faster and better learning for bounding box regression. In Proceedings of the AAAI Conference on Artificial Intelligence, pp. 12993–13000, 2020b.
342
+
343
+ Lin Zhou, Haoran Wei, Hao Li, Wenzhe Zhao, Yi Zhang, and Yue Zhang. Arbitrary-oriented object detection in remote sensing images based on polar coordinates. IEEE Access, 8:223373–223384, 2020.
344
+
345
+ Xinyu Zhou, Cong Yao, He Wen, Yuzhi Wang, Shuchang Zhou, Weiran He, and Jiajun Liang. East: an efficient and accurate scene text detector. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5551–5560, 2017.
346
+
347
+ Haigang Zhu, Xiaogang Chen, Weiqun Dai, Kun Fu, Qixiang Ye, and Jianbin Jiao. Orientation robust object detection in aerial images using deep convolutional neural network. In 2015 IEEE International Conference on Image Processing, pp. 3735–3739. IEEE, 2015.
348
+
349
+ # A PROOF OF KFIOU UPPER BOUND
350
+
351
+ For an n-dimensional Gaussian distribution, its volume is:
352
+
353
+ $$
354
+ \mathcal { V } = 2 ^ { n } \cdot | \Sigma ^ { \frac { 1 } { 2 } } | = 2 ^ { n } \cdot | \Sigma | ^ { \frac { 1 } { 2 } }
355
+ $$
356
+
357
+ For $\Sigma _ { k f }$ , we have
358
+
359
+ $$
360
+ | \Sigma _ { k f } | = | \Sigma _ { 1 } - \Sigma _ { 1 } ( \Sigma _ { 1 } + \Sigma _ { 2 } ) ^ { - 1 } \Sigma _ { 1 } | = | \Sigma _ { 1 } ( \Sigma _ { 1 } + \Sigma _ { 2 } ) ^ { - 1 } \Sigma _ { 2 } | = { \frac { | \Sigma _ { 1 } | \cdot | \Sigma _ { 1 } | } { | \Sigma _ { 1 } + \Sigma _ { 2 } | } }
361
+ $$
362
+
363
+ According to Minkowski’s inequality:
364
+
365
+ $$
366
+ | \Sigma _ { 1 } + \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq | \Sigma _ { 1 } | ^ { \frac { 1 } { n } } + | \Sigma _ { 2 } | ^ { \frac { 1 } { n } }
367
+ $$
368
+
369
+ Simultaneous mean inequalities:
370
+
371
+ $$
372
+ | \Sigma _ { 1 } + \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq | \Sigma _ { 1 } | ^ { \frac { 1 } { n } } | + | \Sigma _ { 2 } | ^ { \frac { 1 } { n } } \geq 2 \cdot | \Sigma _ { 1 } | ^ { \frac { 1 } { 2 n } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 2 n } }
373
+ $$
374
+
375
+ Thus:
376
+
377
+ $$
378
+ \begin{array} { r l r } & { } & { \frac { \sum _ { 1 } ^ { \frac { 1 } { 2 n } } \cdot \sum _ { 2 } ^ { \frac { 1 } { 2 n } } } { \sum _ { 1 } + \sum _ { 2 } ^ { \frac { 1 } { n } } } \leq \frac { 1 } { 2 } \ } \\ & { } & { \frac { \sum _ { 1 } ^ { \frac { 1 } { 2 } } \cdot \sum _ { 2 } ^ { \frac { 1 } { 2 } } } { \sum _ { 1 } + \sum _ { 2 } } \leq \frac { 1 } { 2 ^ { n } } } \end{array}
379
+ $$
380
+
381
+ and
382
+
383
+ $$
384
+ \begin{array} { r l } & { | \sum _ { k f } | = \displaystyle \frac { | \sum _ { 1 } | \cdot | \sum _ { 1 } | } { | \sum _ { 1 } + \sum _ { 2 } | } \leq \displaystyle \frac { | \sum _ { 1 } | ^ { \frac { 1 } { 2 } } \cdot | \sum _ { 2 } | ^ { \frac { 1 } { 2 } } } { 2 ^ { n } } } \\ & { | \sum _ { k f } | ^ { \frac { 1 } { 2 } } \leq \displaystyle \frac { | \sum _ { 1 } | ^ { \frac { 1 } { 4 } } \cdot | \sum _ { 2 } | ^ { \frac { 1 } { 4 } } } { 2 ^ { \frac { n } { 2 } } } } \end{array}
385
+ $$
386
+
387
+ Combine the mean inequalities again:
388
+
389
+ $$
390
+ | \Sigma _ { k f } | ^ { \frac { 1 } { 2 } } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 4 } } \cdot | \Sigma _ { 2 } | ^ { \frac { 1 } { 4 } } } { 2 ^ { \frac { n } { 2 } } } \leq \frac { | \Sigma _ { 1 } | ^ { \frac { 1 } { 2 } } + | \Sigma _ { 2 } | ^ { \frac { 1 } { 2 } } } { 2 ^ { \frac { n } { 2 } + 1 } }
391
+ $$
392
+
393
+ According to Eq. 14, we have
394
+
395
+ $$
396
+ \mathcal { V } _ { k f } \leq \frac { \mathcal { V } _ { 1 } + \mathcal { V } _ { 2 } } { 2 ^ { \frac { n } { 2 } + 1 } }
397
+ $$
398
+
399
+ Therefore, the upper bound of KFIoU is
400
+
401
+ $$
402
+ \mathrm { K F I o U } = \frac { \mathcal { V } _ { k f } } { \mathcal { V } _ { 1 } + \mathcal { V } _ { 2 } - \mathcal { V } _ { k f } } \le \frac { 1 } { 2 ^ { \frac { n } { 2 } + 1 } - 1 }
403
+ $$
404
+
405
+ $n = 2$ and $n = 3$ , the upper bounds are $\textstyle { \frac { 1 } { 3 } }$ and $\frac { 1 } { \sqrt { 3 2 } - 1 }$ respectively.
md/dev/BYLysbfdJOd/BYLysbfdJOd.md ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Planckian Jitter: countering the color-crippling effects of color jitter on self-supervised training
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Several recent works on self-supervised learning are trained by mapping different
11
+ 2 augmentations of the same image to the same feature representation. The data
12
+ 3 augmentations used are of crucial importance to the quality of learned feature
13
+ 4 representations. In this paper, we analyze how the color jitter traditionally used in
14
+ 5 data augmentation negatively impacts the quality of the color features in learned
15
+ 6 feature representations. To address this problem, we propose a more realistic,
16
+ 7 physics-based color data augmentation – which we call Planckian Jitter – that
17
+ 8 creates realistic variations in chromaticity and produces a model robust to illumi
18
+ 9 nation changes that can be commonly observed in real life, while maintaining the
19
+ 10 ability to discriminate image content based on color information. Experiments
20
+ 11 confirm that such a representation is complementary to the representations learned
21
+ 12 with the currently-used color jitter augmentation and that a simple concatenation
22
+ 13 leads to significant performance gains on a wide range of downstream datasets.
23
+ 14 In addition, we present a color sensitivity analysis that documents the impact of
24
+ 15 different training methods on model neurons and shows that the performance of
25
+ 16 the learned features is robust with respect to illuminant variations.
26
+
27
+ # 17 1 Introduction
28
+
29
+ 18 Self-supervised learning enables the learning of representations without the need for labeled data [8, 9].
30
+ 19 Several recent works learn representations that are invariant with respect to a set of data augmentations
31
+ 20 and have obtained spectacular results [12, 6, 3], significantly narrowing the gap with supervised
32
+ 21 learned representations. These works vary in their architectures, learning objectives, and optimization
33
+ 22 strategies, however they are similar in applying a common set of data augmentations to generate
34
+ 23 different image views. These algorithms, while learning to map these different views to the same
35
+ 24 latent representation, learn rich semantic representations for visual data. The set of transformations
36
+ 25 (data augmentations) used induces invariances that characterizes the learned visual representation.
37
+ 26 Before deep learning revolutionized the way visual representations are learned, features were hand
38
+ 27 crafted to represent various properties, leading to research on shape [15], texture [16], and color
39
+ 28 features [10, 11]. Color features were typically designed to be invariant to a set of scene-accidental
40
+ 29 events such as shadows, shading, and illuminant and viewpoint changes. With the rise of deep
41
+ 30 learning, feature representations that simultaneously exploit color, shape, and texture are learned
42
+ 31 implicitly and the invariances are a byproduct of end-to-end training [14]. Current approaches to
43
+ 32 self-supervised learning learn a set of invariances implicitly related to the applied data augmentations.
44
+ 33 In this work, we focus on the currently de facto choice for color augmentations. We argue that
45
+ 34 they seriously cripple the color quality of learned representations and we propose an alternative,
46
+ 35 physics-based color augmentation. Figure 1 (left) illustrates the currently used color augmentation on
47
+ 36 a sample image. It is clear that the applied color transformation significantly alters the colors of the
48
+ 37 original image, both in terms of hue and saturation. This augmentation results in a representation
49
+ 38 that is invariant with respect to surface reflectance – an invariance beneficial for recognizing classes
50
+ 39 whose surface reflectance varies signficantly, for example many man-made objects such as cars and
51
+ 40 chairs. However, such invariance is expected to hurt performance on downstream tasks for which
52
+ 41 color is an important feature, like natural classes such as birds or food. One of the justifications for
53
+ 42 such strong color augmentations is that without large color changes, mapping images to the same
54
+ 43 latent representation can be purely done based on color and no complex shape features are learned.
55
+ 44 However, as a result the quality of the color representation learned with such algorithms is inferior
56
+ 45 and important information on surface reflectance might be absent.
57
+ 46 In this paper we propose an alternative color augmentation (Figure 1, right). We draw on the existing
58
+ 47 color imaging literature on designing features invariant to illuminant changes commonly encountered
59
+ 48 in real-world scenes [10]. Our augmentation, which we called Planckian Jitter, applies physically
60
+ 49 realistic illuminant variation to images. We consider the illuminants described by Planck’s Law for
61
+ 50 black-body radiation and that are known to be similar to illuminants encountered in real-life [21].
62
+ 51 The aim of our color augmentation is to allow the representation to contain valuable information
63
+ 52 about the surface reflectance of objects – a feature that is expected to be important for a wide
64
+ 53 range of downstream tasks. Combining such a representation with the already high-quality shape
65
+ 54 representation learned with standard data augmentation leads to a more complete visual descriptor
66
+ 55 that describes both shape and color.
67
+ 56 Our experiments show that self-supervised representations learned with Planckian Jitter are robust
68
+ 57 to illuminant changes. In addition, depending on the importance of color in the dataset, the pro
69
+ 58 posed Planckian jitter outperforms the default color jitter. Moreover, for all evaluated datasets the
70
+ 59 combination of features of our new data augmentation with standard color jitter leads to significant
71
+ 60 performance gains of over $5 \%$ on several downstream classification tasks. Finally, we show that
72
+ 61 Planckian Jitter can be applied to several state-of-the-art self-supervised learning methods.
73
+
74
+ ![](images/181de5ffe7be38d8274b99e44a6672c29e767d130575ff1999cac989fdad31c3.jpg)
75
+ Figure 1: Default color jitter (left) and Planckian Jitter (right). Augmentations based on default color jitter lead to unrealistic images, while Planckian Jitter leads to a set of realistic ones. The ARC chromaticity diagrams for each type of jitter are computed by sampling initial RGB values and mapping them into the range of possible outputs given by each augmentation. These diagrams show that Planckian Jitter transforms colors along chromaticity lines occurring in nature when changing the illuminant, whereas default color jitter transfers colors throughout the whole chromaticity plane.
76
+
77
+ # 62 2 Background and related work
78
+
79
+ 63 Self-supervised learning and contrastive learning. Recent improvements in self-supervision learn
80
+ 64 semantically rich feature representations without the need for labelled data. In SimCLR [4] similar
81
+ 65 samples are created by augmenting an input image, while dissimilar are chosen by random [4]. To
82
+ 66 make contrastive training more efficient, MoCo [13] and its improved version [5] use a memory bank
83
+ 67 for learned embeddings which makes sampling efficient. This memory is kept in sync with the rest
84
+ 68 of the network during training via a momentum encoder. Several methods do not rely on explicit
85
+ 69 contrastive pairs. BYOL uses an asymmetric network incorporating an additional MLP predictor
86
+ 70 between the outputs of the two branches [12]. One of the branches is kept “offline” and is updated by
87
+ 71 a momentum encoder. SimSiam goes even further with a simplified solution without a momentum
88
+ 72 encoder [6]. It obtains similar high-quality results and does not require a large minibatch size, in
89
+ 73 contrast to other methods.
90
+ 74 We use the SimSiam method to verify our proposed color augmentation (we also apply it to Sim
91
+ 75 CLR [4] and Barlow Twins [26] in the experiments). The main component of the network is
92
+ 76 CNN-based image encoder, learned end-to-end in an asymmetric Siamese architecture. One branch
93
+ 77 has an additional MLP predictor whose output aims to be as close as possible to other (see Figure 2).
94
+ 78 The second branch is not updated during backpropagation. A negative cosine loss function is used:
95
+
96
+ ![](images/ca57268f1f2103cee67010b26b2f6ced7210620f5e7436dc3b5b715c2fd008d1.jpg)
97
+ Figure 2: SimSiam training procedure exploiting Planckian-based data augmentation (left), and fine-tuning the linear classifier using the trained encoder (right).
98
+
99
+ $$
100
+ \begin{array} { r c l } { { \mathcal { L } } } & { { = } } & { { \displaystyle \frac { 1 } { 2 } \left[ { \mathcal { D } } ( p _ { 1 } , \mathrm { s t o p g r a d } ( z _ { 2 } ) ) + { \mathcal { D } } ( p _ { 2 } , \mathrm { s t o p g r a d } ( z _ { 1 } ) ) \right] } } \\ { { \mathcal { D } } ( p _ { A } , z _ { B } ) } & { { = } } & { { \displaystyle - \frac { p _ { A } } { \left\| p _ { A } \right\| _ { 2 } } \cdot \frac { z _ { B } } { \left\| z _ { B } \right\| _ { 2 } } , } } \end{array}
101
+ $$
102
+
103
+ 79 where $z _ { 1 } , z _ { 2 }$ are representations for two different augmented versions, $x _ { 1 }$ and $x _ { 2 }$ , of the same image
104
+ 80 $x$ . An additional predictor applied on $z _ { 1 }$ and $z _ { 2 }$ produces $p _ { 1 }$ and $p _ { 2 }$ , respectively. The stopgrad $( \cdot )$
105
+ 81 operation blocks the gradient during the backpropagation. In SimSiam no contrastive term is used
106
+ 82 and only similarity is enforced during learning.
107
+ 83 Data augmentation. Data augmentation plays an central role in the self-supervised learning
108
+ 84 process described above. The authors of [4] and [26] discuss the importance of the different data
109
+ 85 augmentations. A set of well-defined transformations was proposed for SimCLR [4]. This set is
110
+ 86 commonly accepted and used in several later works. The augmentations include: rotation, cutout,
111
+ 87 flip, color jitter, blur and Grayscale. These operations are randomly applied to an image to generate
112
+ 88 the different views $x _ { 1 }$ , $x _ { 2 }$ used in the self-supervision loss in Eq. 2. Applied to the same image,
113
+ 89 contrastive-like self-supervised methods learn representations invariant to such distortions.
114
+ 90 This multiple view creation is task-related [20], however color jittering operating on hue, saturation,
115
+ 91 brightness and contrast, is one of the most important ones in terms of overall usefulness of the
116
+ 92 learned representation for downstream tasks [4, 26]. Color jitter induces a certain level of color
117
+ 93 invariance (invariance to hue, saturation, brightnesss and contrast) which are consequently transferred
118
+ 94 to the downstream task. As a consequence, we expect these learned features to underperform on
119
+ 95 downstream tasks for which color is crucial. Xiao et al. [25] were the first point out that the imposed
120
+ 96 invariances might not be beneficial for downstream tasks. As a solution, they propose to learn
121
+ 97 different embedding spaces in parallel that capture each of the invariances. Differently than them, we
122
+ 98 focus on the color distortion and propose a physics-based color augmentation that allows learning
123
+ 99 invariance to physically realistic color variations.
124
+ 100 The color imaging literature has a long tradition in research on color features invariant to scene
125
+ 101 accidental events such as shading, shadows, and illuminant changes [11, 10]. Invariant features were
126
+ 102 found to be extremely beneficial for object recognition. The invariance to hue and saturation changes,
127
+ 103 induced by the color jitter operation, however, it detrimental to object recognition for those classes
128
+ 104 in which color characteristics are fundamentally discriminative. Therefore, in this work we revisit
129
+ 105 early theory on illuminant invariance [10] to design an improved color augmentation that induces
130
+ 106 invariances common in the real world and that, when used during self-supervised learning, does not
131
+ 107 damage the color quality of the learned features.
132
+ 109 The image transformations introduced by default color jitter creates variability in training data that
133
+ 110 indiscriminately explores all hues at various levels of saturation. The resulting invariance is useful
134
+ 111 for downstream tasks where chromatic variations are indeed irrelevant (e.g. car color in vehicle
135
+ 112 recognition), but is detrimental to downstream tasks where color information is critical (e.g. natural
136
+ 113 classes like birds and vegetables). The main motivation for applying strong color augmentations is
137
+ 114 that this it leads to very strong shape representations. Indiscriminately augmenting color information
138
+ 115 in the image requires that the representation solve the matching problem using shape $[ 4 ] ^ { 1 }$ .
139
+ 116 As an alternative to color jitter, we propose a physics-based color augmentation that mimics color
140
+ 117 variations due to illuminant changes commonly encountered in the real world. The aim is to arrive at a
141
+ 118 representation that does not have the color crippling effects of color jitter and that can therefore better
142
+ 119 describe classes for which surface reflectance is a determining feature. The aim learn a representation
143
+ 120 that, when combined with default color jitter, provides a high-quality shape and color representation.
144
+
145
+ # 121 3.1 Planckian Jitter
146
+
147
+ 122 We call our color data augmentation procedure Planckian Jitter because it exploits the physical
148
+ 123 description of a black-body radiator to re-illuminate training images within a realistic illuminant
149
+ 124 distribution [10, 21]. The resulting augmentations are more realistic than those of the default color
150
+ 125 jitter (see Fig. 1). The resulting learned, self-supervised feature representation is thus expected to
151
+ 126 be robust to illumination changes commonly observed in real-world images, while simultaneously
152
+ 127 maintaining the ability to discriminate the image content based on color information.
153
+ 128 Given an input RGB training image $I$ , our Planckian Jitter procedure applies a chromatic adaptation
154
+ 129 transform that simulates realistic variations in the illumination conditions. The data augmentation
155
+ 130 procedure is as follows:
156
+ 1. we sample a new illuminant spectrum $\sigma _ { T } ( \lambda )$ from the distribution of a black-body radiator;
157
+ 2. we transform the sampled spectrum $\sigma _ { T } ( \lambda )$ into its sRGB representation $\rho _ { T } \in \mathbb { R } ^ { 3 }$ ;
158
+ 3. we create a jittered image $I ^ { \prime }$ by reilluminating $I$ with the sampled illuminant $\rho _ { T }$ ; and
159
+ 4. We introduce brightness and contrast variation, producing a Planckian-jittered image $I ^ { \prime \prime }$ .
160
+
161
+ 35 A radiating black body at temperature $T$ can be synthesized using Planck’s Law [1]:
162
+
163
+ $$
164
+ \sigma _ { T } ( \lambda ) = \frac { 2 \pi h c ^ { 2 } } { \lambda ^ { 5 } ( e ^ { \frac { h c } { k T \lambda } } - 1 ) } \mathrm { { W / m ^ { 3 } } } ,
165
+ $$
166
+
167
+ 136 where $c = 2 . 9 9 7 9 2 4 5 8 \times 1 0 ^ { 8 } { \mathrm { m } } / { \mathrm { s } }$ is the speed of light, $h = 6 . 6 2 6 1 7 6 \times 1 0 ^ { - 3 4 }$ Js is Planck’s constant,
168
+ 137 and $k = \mathrm { 1 . 3 8 0 6 6 2 \times 1 0 ^ { - 2 3 } J / K }$ is Boltzmann’s constant. For our experiments we sampled $T$ in
169
+ 138 the interval between $3 0 0 0 K$ and $1 5 0 0 0 K$ which is known to result in a set of illuminants that can
170
+ 139 be encountered in real life [21]. Then, we discretized wavelength $\lambda$ in $1 0 \mathrm { n m }$ steps $( \Delta \lambda )$ in the
171
+ 140 interval between $4 0 0 \mathrm { n m }$ and $7 0 0 \mathrm { n m }$ . The resulting spectra are visualized in Figure 4 (left) in the
172
+ 141 Supplementary Material.
173
+
174
+ 142 The conversion from spectrum into sRGB is obtained through a series of intermediate steps [24]:
175
+
176
+ 1. we first map the spectrum into the corresponding XYZ stimuli, using the 1931 CIE standard observer color matching functions $c ^ { \{ X , Y , Z \} } ( \bar { \lambda } )$ , in order to bring the illuminant into a standard color space that represents a person with average eyesight;
177
+ 2. We normalize this tristimulus by its $Y$ component, convert it into the CIE $1 9 7 6 ~ \mathrm { L ^ { * } a ^ { * } b }$ color space, and fix its $\mathrm { L }$ component to 50 in a 0-to-100 scale, allowing us to constrain the intensity of the represented illuminant in a controlled manner as a separate task; and
178
+ 3. we then convert the resulting values to sRGB, obtaining $\rho _ { T } = \{ R , G , B \}$ ; the resulting distribution of illuminants is visualized with the Angle-Retaining Chromaticity diagram [2] in Figure 4 (right) in the Supplementary Material.
179
+
180
+ 152 All color space conversions assume a D65 reference white, which means that a neutral surface
181
+ 153 illuminated by average daylight conditions would appear achromatic. Once the new illuminant
182
+ 154 has been converted in sRGB, it is applied to the input image $I$ by resorting to a Von-Kries-like
183
+ 155 transform [22] given by the following channel-wise scalar multiplication:
184
+
185
+ $$
186
+ I ^ { \prime \{ R , G , B \} } = I ^ { \{ R , G , B \} } \cdot \{ R , G , B \} / \{ 1 , 1 , 1 \} ,
187
+ $$
188
+
189
+ 156 where we assume the original scene illuminant to be white (1,1,1). Finally, brightness and contrast
190
+ 157 perturbations are introduced to simulate variations in the intensity of the scene illumination:
191
+
192
+ $$
193
+ I ^ { \prime \prime } = c _ { B } \cdot c _ { C } \cdot I ^ { \prime } + \left( 1 - c _ { C } \right) \cdot \mu \left( c _ { B } \cdot I ^ { \prime } \right) ,
194
+ $$
195
+
196
+ where $c _ { B } = 0 . 8$ and $c _ { C } = 0 . 8$ represent, respectively, brightness and contrast coefficients, and $\mu$ is a spatial average function.
197
+
198
+ # 3.2 Complimentarity of shape and color representations
199
+
200
+ 161 The self-supervised learning paradigm involves a pretraining phase that relies on data augmentation
201
+ 162 to produce a set of features with certain invariance properties. These features are then used as the
202
+ 163 representation for a second phase, where we learn a given supervised downstream task. The default
203
+ 164 color jitter augmentation generates features that are strongly invariant to color information, resulting
204
+ 165 in high-quality representations of shape and texture, but that is an inferior descriptor of surface
205
+ 166 reflectances (i.e. the color of objects). Our augmentation based on Planckian Jitter (see Figure 1) is
206
+ 167 based on transformations mimicking the physical color variations in the real world due to illuminant
207
+ 168 changes. As a result, the learned representation yields a high-quality color description of scene
208
+ 169 objects. However, it likely leads to a drop in the quality of the shape representation (since color can
209
+ 170 be used to solve cases where previously shape was required). To exploit the complimentarity of the
210
+ 171 two representations, we propose to learn both – one with color jitter and one with Planckian Jitter –
211
+ 172 and to then concatenate the results in a single representation vector (of 1024 dimensions, i.e. twice
212
+ 173 the original size of 512). We call this Latent space combination (LSC).
213
+
214
+ # 174 4 Experimental results
215
+
216
+ 175 In this section, we analyze the color sensitivity of the learned backbone networks, verify the superiority
217
+ 176 of the proposed color data augmentation method compared to the default color jitter on color
218
+ 177 datasets, and evaluate the impact on downstream classification tasks. We report additional results on
219
+ 178 computational time of the proposed Planckian augmentation in the Supplementary Material.
220
+
221
+ # 79 4.1 Training and evaluation setup
222
+
223
+ We perform unsupervised training on two datasets: CIFAR-100 [14] $( 3 2 \times 3 2 )$ and ImageNet $( 2 2 4 \times 2 2 4 )$ . We slightly modify the ResNet18 architecture to accommodate $3 2 \times 3 2$ images: the kernel size of the first convolutional was reduced from $7 \times 7$ to $3 \times 3$ and the first max pooling layer was removed. SimSiam training was performed using Stochastic Gradient Descent with a starting learning rate of 0.03, a cosine annealing learning rate scheduler, and mini-batch size of 512 (as in original SimSiam work [6]). For the training on the 1000-class ImageNet training set, we follow the same procedure as [6] with ResNet50.
224
+
225
+ 187 The linear classifier training at resolution $3 2 \times 3 2$ was performed on CIFAR-100 and FLOWERS
226
+ 188 102 [17]. CIFAR-100 is used as a baseline for the classification task. The linear classifier training for
227
+ 189 CIFAR-100 is done with Stochastic Gradient Descent for 500 epochs with a starting learning rate 0.1,
228
+ 190 a cosine annealing learning rate scheduler, and mini-batch size of 512. The FLOWERS-102 dataset
229
+ 191 with 102 classes was selected to assess the quality of the features extracted in scenarios where color
230
+ 192 information plays an important role. Images from FLOWERS-102 are resized to $3 2 \times 3 2$ pixels to
231
+ 193 match the input dimensions of the pretrained model. Here we used the Adam optimizer with initial
232
+ 194 learning rate of 0.03.
233
+ 195 For training linear classifiers at resolution $2 2 4 \times 2 2 4$ for downstream tasks we follow the evaluation
234
+ 196 protocol of [6]. We use five different datasets: IMAGENET, FLOWERS-102, VEGFRU [19], CUB
235
+ 197 200 [23], and $\mathrm { T } 1 \mathrm { K } +$ [7]. These five datasets were resized to $2 2 4 \times 2 2 4$ pixels. More details about
236
+ 198 these datasets are provided in the Supplementary Material. In the case of CUB-200, each image was
237
+
238
+ ![](images/cb5527bc57529bd5a2e0c5ffb2810702114331a71f2201db7e97236f4e9b2e0a.jpg)
239
+ Figure 3: Color sensitivity analysis. (a) Robustness to illuminant change: we report the accuracies by differently-trained backbones as a function of illuminant. (b) The color sensitivity indexes computed for the different configurations used for training the backbone.
240
+
241
+ cropped using the bounding boxes given in the dataset annotations. For $\mathrm { T } 1 \mathrm { K } +$ , we use the 266 class labeling to train and test the linear classifier.
242
+
243
+ 01 To assess the impact of color data augmentations we define six different configurations:
244
+
245
+ • Default Color Jitter $( C J )$ : the default configuration, as used in SimSiam and SimCLR, uses both Random Color Jitter and Random Grayscale operations.
246
+ • Default Color Jitter w/o Grayscale $( C J - )$ : same as Default without the Random Grayscale operation.
247
+ • Planckian Jitter $( P J )$ : uses the complete proposed Planckian Jitter operation operating on chromaticy, brightness, and contrast aspects of the images. No Random Grayscale is applied.
248
+ • LSC Default Color Jitter $^ +$ Planckian Jitter ([CJ,PJ]: This latent space combination (simple concatenation of representations) combines the default color jitter with our Planckian jitter. It allows evaluation of the complimentary nature of the representations. LSC Default Color Jitter $^ +$ Default Color Jitter w/o Grayscale $( / C J , C J - J )$ : We combine the default color jitter with a version without the Grayscale augmentation, since this representation is also expected to result in a better color representation.
249
+ • LSC of two Default Color Jitter Models $( / C J , C J ] )$ : We also show results of simply concatenating two independently trained models (trained from different seeds) with default color jitter (an ensemble of two models).
250
+
251
+ In all experiments these augmentations are combined with the other default augmentations (crop, horizontal flip, and blur).
252
+
253
+ # 4.2 Color sensitivity analysis
254
+
255
+ To verify if our Planckian data augmentation actually leads to illuminant invariance, we performed a robustness analysis on the CUB-200 dataset with realistic illuminant variations and analyzed sensitivity to color information. We assume as reference point the D65 illuminant, which for the purpose of this test is considered the default illuminant in every image. Given the different backbones pretrained on IMAGENET, we then train a linear classifier on this dataset (assumed to be under white illumination). For testing we create different versions of CUB-200, each illuminated by illuminants of differing color temperature. This allows us to evaluate the robustness of the learned representations with respect to these illuminant changes. A similar experiment is performed on VEGFRU.
256
+
257
+ Results are given in Figure 3(a) (more results are provided in the Supplementary Material). Planckian Jitter obtains a remarkably stable performance from around 4000-14000K, while Default Color Jitter is more sensitive to the illumination color and the classification accuracy decreases when the scene illuminant moves away from white. We also see that the combination of default and Planckian Jitter obtains the best results for all illuminants and manages to maintain a high-level of invariance with respect to the illuminant color.
258
+
259
+ Table 1: Ablation on color augmentations. Self-supervised training is performed on CIFAR-100 and the learned features are evaluated at $( 3 2 \times 3 2 )$ on CIFAR-100 and FLOWERS-102. Augmentation techniques include variations in hue and saturation (H&S), brightness and contrast (B&C), Planckianbased chromaticity (P), and random Grayscale conversions (G). Accuracy refers to the results of the linear classifiers trained with features extracted from the different backbones.
260
+
261
+ <table><tr><td>AUGMENTATION</td><td>H&amp;S</td><td>B&amp;C</td><td>G</td><td>P</td><td>ACCURACY</td></tr><tr><td rowspan="5">None CIIPPIPI0</td><td></td><td></td><td></td><td></td><td>41.93%</td></tr><tr><td>Default Color Jitter</td><td>√ √</td><td></td><td></td><td>59.93%</td></tr><tr><td></td><td>厂</td><td></td><td></td><td>41.96%</td></tr><tr><td>√</td><td></td><td></td><td></td><td>32.46%</td></tr><tr><td></td><td></td><td></td><td>√</td><td>36.10%</td></tr><tr><td rowspan="2">Planckian Jitter</td><td></td><td>√</td><td></td><td></td><td>31.78%</td></tr><tr><td></td><td></td><td></td><td></td><td>47.31%</td></tr><tr><td rowspan="5">JII-PPPSIOA</td><td>None</td><td></td><td></td><td></td><td></td><td>36.47%</td></tr><tr><td>Default Color Jitter</td><td></td><td></td><td></td><td></td><td>30.00%</td></tr><tr><td></td><td>&lt;&gt;</td><td></td><td></td><td></td><td>36.96%</td></tr><tr><td></td><td>卜</td><td></td><td></td><td></td><td>39.11%</td></tr><tr><td></td><td></td><td></td><td></td><td>厂</td><td>39.51%</td></tr><tr><td colspan="2">Planckian Jitter</td><td></td><td>4</td><td>4</td><td></td><td>41.96%</td></tr></table>
262
+
263
+ Table 2: Results for self-supervised training on CIFAR-100 and evaluated at $3 2 \times 3 2$ on CIFAR-100 and FLOWERS-102. Accuracy refers to the results of the linear classifiers trained with features extracted from the different trained backbones.
264
+
265
+ <table><tr><td>AUGMENTATION</td><td>ACCURACY</td></tr><tr><td>Default Color Jitter (CJ) CEIAIIII0</td><td>59.93% Default Color Jitter w/o Grayscale (CJ-)</td></tr><tr><td>Planckian Jitter (PJ)</td><td>41.96% 47.31%</td></tr><tr><td>LSC [CJ,CJ-]</td><td>62.27%</td></tr><tr><td>LSC: [CJ,PJ]</td><td>63.54%</td></tr><tr><td>JII-PPPSSOI Default Color Jitter (CJ)</td><td>30.00%</td></tr><tr><td>Default Color Jitter w/o Random Grayscale(CJ-)</td><td>36.96%</td></tr><tr><td>Planckian Jitter (PJ)</td><td>42.75%</td></tr><tr><td>LSC: [CJ,CJ-]</td><td>47.65%</td></tr><tr><td>LSC: [CJ,PJ]</td><td>51.66%</td></tr></table>
266
+
267
+ 234 In order to understand the impact of the color information on each neuron in trained models, we
268
+ 235 conducted an analysis using the color selectivity index described in [18]. This index measures neuron
269
+ 236 activation when color is present or absent in input images. We computed the index for the last layer
270
+ 237 of different backbones, and high values indicate color-sensitive neurons. See the Supplementary
271
+ 238 Material for more details on color selectivity. The results are shown in Figure 3(b) and indicate the
272
+ 239 number of color-sensitive neurons for each of the considered models. It is clear that the default color
273
+ 240 jitter has far fewer neurons dedicated to color description. This result confirms the hypothesis that
274
+ 241 models trained in this way are color invariant, a property that negatively affects the model in scenarios
275
+ 242 where color information has an important role as seen in our experiments. We have also analyzed
276
+ 243 the results for the default color jitter without Grayscale augmentation (CJ-). These results show that
277
+ 244 removing the Grayscale augmentation improves color sensitivity significantly. We therefore also
278
+ 245 consider this augmentation in future experiments.
279
+
280
+ # 4.3 Ablation study
281
+
282
+ 247 Six different models were trained and evaluated with a linear classification for image classification.
283
+ 248 For resolution $3 2 \times 3 2$ the model is evaluated on CIFAR-100 and FLOWERS-102. The results in
284
+ 249 terms of accuracy are reported in Table 2. We identify two different trends when interpreting these
285
+ 250 results. On CIFAR-100, removing color augmentations makes the model less powerful, due to the
286
+ 251 loss of color invariance in the features extracted by the encoder. This behaviour is consistent with
287
+ 252 what was reported in [4]. We see in Table 1 that if color augmentations (i.e. brightness/contrast and
288
+ 253 Random Grayscale) are removed completely (the None configuration), the accuracy drops by $1 8 \%$
289
+ 254 On FLOWERS-102 the behavior is the opposite however: removing color augmentations helps the
290
+ 255 model to better classify images, obtaining an improvement of $1 2 . 7 5 \%$ of accuracy with respect to the
291
+ 256 default color jitter. This behavior confirms that color invariance negatively impacts downstream tasks
292
+ 257 where color information plays an important role.
293
+ 258 Taking a closer look at the various augmentation on FLOWERS-102, we see that introducing more
294
+ 259 realistic color augmentations positively impacts contrastive training and produces models that achieve
295
+ 260 even better results with respect to the configuration without any kind of image color manipulation.
296
+ 261 Removing all color augmentations (None) improves results already by over $6 \%$ . Then, by simply
297
+ 262 reducing the jittering operation to influence brightness and contrast, leaving hue and saturation un
298
+ 263 changed, yields another boost in accuracy of $5 . 4 { \bar { 9 } } \%$ (to 41.96). When we start modifying chromaticity
299
+ 264 using a more realistic transformation (i.e Planckian Jitter), the final result is a boost of $6 . 2 8 \%$ in
300
+ 265 accuracy with respect to the None configuration. Also, on CIFAR-100 we see an improvement of
301
+ 266 $5 . 3 8 \%$ from Planckian Jitter with respect no color augmentation. Despite this improvement, in this
302
+ 267 scenario the contrastive training with the realistic augmentation does not yield better results with
303
+ 268 respect to the Default configuration because color only plays a minor role on this dataset.
304
+ 269 Given the results obtained using the data augmentations reported in Table 1, and given the con
305
+ 270 siderations made in Section 3.2, we evaluate the complementarity of the learned representation by
306
+ 271 combining latent spaces from different backbones. Results for two different latent space combinations
307
+ 272 are given in Table 4. On both datasets the Latent space combination of Default and Planckian Jitter
308
+ 273 configurations achieves the best results. On the original CIFAR-100 task, this combination achieves a
309
+ 274 total accuracy of $6 3 . 5 4 \%$ , a $3 . 6 1 \%$ improvement over the Default configuration and $1 6 . 2 3 \%$ more
310
+ 275 compared to Planckian Jitter alone. Comparing to the LSC using the Default ColorJitter w/o
311
+ 276 Grayscale, the version with Planckian Jitter achieves a small improvement of $1 . 2 7 \%$ in classification
312
+ 277 accuracy.
313
+ 78 On the downstream FLOWERS-102 task, the Latent space combination reaches an accuracy value of
314
+ 79 $5 1 . 6 6 \%$ : an improvement of $2 1 . 6 6 \%$ and $8 . 9 1 \%$ in accuracy respectively compared to the two original
315
+ 80 configurations. Compared to the LSC using Default ColorJitter w/o Grayscale, the combination with
316
+ 81 Planckian Jitter achieves a higher result, with a bigger gap in terms of accuracy with respect to the
317
+ 82 CIFAR-100 scenario. Here the use of Planckian Jitter brings in an improvement of $4 . 0 1 \%$ , confirming
318
+ 83 the impact of using realistic augmentation on classification tasks for which color is important.
319
+
320
+ # 284 4.4 Evaluation on downstream tasks
321
+
322
+ 285 Given the results obtained from the ablation study, we performed the analysis of the proposed
323
+ 286 configurations on other downstream tasks using the backbone trained on higher resolution images
324
+ 287 $2 2 4 \times 2 2 4$ pixels). We report in Table 3 the results for: Default Color Jitter, Planckian Jitter, and
325
+ 288 several latent space combinations.
326
+ 289 Looking at the results, we see that the Planckian Jitter augmentation outperforms default color jitter
327
+ 290 on two datasets (CUB-200 and T1K). Comparing the results on FLOWERS-102 with those reported
328
+ 291 above at $( 3 2 \times 3 2 )$ pixels, we see that default color jitter actually obtains good results. We hypothesize
329
+ 292 that for high-resolution images the shape information is very discriminative, and the additional color
330
+ 293 information yields little gain.
331
+ 294 Table 3 also contains results for latent space combination. The results confirm that the two learned
332
+ 295 representation are complimentary and that their combination leads to significant performance gains
333
+ 296 of up to $9 \%$ on T1K when compared to default color jitter. As a sanity check, we have also included
334
+ 297 the latent space combination of two networks separately trained with color jitter. This provides a
335
+ 298 small ensemble performance gain on some datasets but yields significantly inferior results compared
336
+ 299 to our proposed LSC.
337
+
338
+ Table 3: Evaluation on downstream tasks. Self-supervised training was performed on IMAGENET at $( 2 2 4 \times 2 2 4 )$ and testing performed on the downstream datasets resized to $( 2 2 4 \times 2 2 4 )$ .
339
+
340
+ <table><tr><td>AUGMENTATION</td><td>CUB-200</td><td>VEGFRU</td><td>T1K+</td><td>FLOWERS-102</td></tr><tr><td>Default Color Jitter (CJ)</td><td>54.52%</td><td>67.63%</td><td>71.44%</td><td>93.16%</td></tr><tr><td>Planckian Jitter (PJ)</td><td>56.28%</td><td>65.84%</td><td>77.42%</td><td>90.29%</td></tr><tr><td>LSC [CJ,PJ]</td><td>60.70%</td><td>74.73%</td><td>80.49%</td><td>93.99%</td></tr><tr><td>LSC [CJ,CJ]</td><td>56.16%</td><td>70.59%</td><td>73.47%</td><td>93.13%</td></tr><tr><td>LSC [CJ,CJ-]</td><td>53.14%</td><td>70.54%</td><td>78.32%</td><td>93.47%</td></tr></table>
341
+
342
+ Table 4: Effect of Plackian Jitter on different contrastive learning models. Self-supervised training was performed on CIFAR-100 and the learned features are evaluated at $( 3 2 \times 3 2 )$ on CIFAR-100 and FLOWERS-102. We report the best configurations obtained on SimSiam model and retrained SimCLR and Barlow Twins with those selected configurations.
343
+
344
+ <table><tr><td>FRAMEWORK</td><td>AUGMENTATION</td><td>CIFAR-100</td><td>FLOWERS-102</td></tr><tr><td rowspan="3">SimSiam</td><td>Default Color Jitter</td><td>59.93%</td><td>30.00%</td></tr><tr><td>Planckian Jitter</td><td>47.31%</td><td>42.75%</td></tr><tr><td>LSC [CJ,PJ]</td><td>63.54%</td><td>51.66%</td></tr><tr><td rowspan="3">SimCLR</td><td>Default Color Jitter</td><td>56.99%</td><td>35.29%</td></tr><tr><td>Planckian Jitter</td><td>47.75%</td><td>45.00%</td></tr><tr><td>LSC [CJ,PJ]</td><td>61.07%</td><td>55.78%</td></tr><tr><td rowspan="3">Barlow Twins</td><td>Default Color Jitter</td><td>56.60%</td><td>40.78%</td></tr><tr><td>Planckian Jitter</td><td>52.71%</td><td>54.50%</td></tr><tr><td>LSC [CJ,PJ]</td><td>62.85%</td><td>62.55%</td></tr></table>
345
+
346
+ # 300 4.5 Generality of Planckian Jitter
347
+
348
+ To show that our approach is generally applicable to self-supervised methods which exploit color augmentations, we also performed experiments using SimCLR and Barlow Twins. This comparison is given in Table 4. Independently of the model used, the Default Color Jitter configuration of data augmentation gives the worst results on the FLOWERS-102 dataset. The Latent space combination configuration consistently achieves better results on both datasets.
349
+
350
+ # 5 Limitations
351
+
352
+ Firstly, A drawback of Planckian jitter is that it reduces the quality of the shape representation, because the extreme color transformation of the standard color jitter force the network to solve the contrastive learning problem mainly using shape information. As shown in this article, this problem can be addressed by exploiting their complimentary nature. Secondly, our current latent space combination requires the training of two separate backbones, which certainly will also learn partially overlapping features. A training scenario, with both augmentations simultaneously in a single network while reserving part of the latent space for each augmentation, could be pursued to address this limitation.
353
+
354
+ # 315 6 Conclusion
355
+
356
+ 16 Existing research on self-supervised learning mainly focuses on tasks where color is not a decisive
357
+ 17 feature, and subsequently exploits data augmentation procedures that negatively affect color-sensitive
358
+ 318 tasks. We propose an alternative color data augmentation technique, called Planckian Jitter, that
359
+ 319 is based on the physical properties of light. Our experiments demonstrate its positive effects on a
360
+ 320 wide variety of tasks where the intrinsic color of the objects (related to their reflectance) is crucial
361
+ 321 for discrimination, while the illumination source is not. We also proposed a solution that exploits
362
+ 322 both color and shape information by concatenating features learned with different modalities of self
363
+ 323 supervision, leading to significant overall improvements in learned representations. Planckian Jitter
364
+ 324 can be easily incorporated into any self-supervised learning pipeline based on data augmentations, as
365
+ 325 shown by our results demonstrating improved performance for three self-supervised learning models.
366
+
367
+ References
368
+ [1] David G Andrews. An introduction to atmospheric physics. Cambridge University Press, 2010.
369
+ [2] Marco Buzzelli, Simone Bianco, and Raimondo Schettini. Arc: Angle-retaining chromaticity diagram for color constancy error analysis. JOSA A, 37(11):1721–1730, 2020.
370
+ [3] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin, editors, Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
371
+ [4] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597–1607. PMLR, 2020.
372
+ [5] Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020.
373
+ [6] Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 15750–15758, 2021.
374
+ [7] Claudio Cusano, Paolo Napoletano, and Raimondo Schettini. T1k+: A database for benchmarking color texture classification and retrieval methods. Sensors, 21(3):1010, 2021.
375
+ [8] Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE international conference on computer vision, pages 1422–1430, 2015.
376
+ [9] Alexey Dosovitskiy, Jost Tobias Springenberg, Martin Riedmiller, and Thomas Brox. Discriminative unsupervised feature learning with convolutional neural networks. Advances in neural information processing systems, 27:766–774, 2014.
377
+ [10] Graham D Finlayson and Gerald Schaefer. Solving for colour constancy using a constrained dichromatic reflection model. International Journal of Computer Vision, 42(3):127–144, 2001.
378
+ [11] J-M Geusebroek, Rein Van den Boomgaard, Arnold W. M. Smeulders, and Hugo Geerts. Color invariance. IEEE Transactions on Pattern analysis and machine intelligence, 23(12):1338–1350, 2001.
379
+ [12] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, Bilal Piot, koray kavukcuoglu, Remi Munos, and Michal Valko. Bootstrap your own latent - a new approach to self-supervised learning. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 21271–21284. Curran Associates, Inc., 2020.
380
+ [13] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9729–9738, 2020.
381
+ [14] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
382
+ [15] David G Lowe. Distinctive image features from scale-invariant keypoints. International journal of computer vision, 60(2):91–110, 2004.
383
+ [16] Bangalore S Manjunath and Wei-Ying Ma. Texture features for browsing and retrieval of image data. IEEE Transactions on pattern analysis and machine intelligence, 18(8):837–842, 1996.
384
+ [17] Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, pages 722–729. IEEE, 2008.
385
+ [18] Ivet Rafegas and Maria Vanrell. Color encoding in biologically-inspired convolutional neural networks. Vision research, 151:7–17, 2018.
386
+ [19] Yushan Feng Saihui Hou and Zilei Wang. Vegfru: A domain-specific dataset for fine-grained visual categorization. In IEEE International Conference on Computer Vision, 2017.
387
+ [20] Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning? In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 6827–6839. Curran Associates, Inc., 2020.
388
+ [21] Shoji Tominaga, Satoru Ebisui, and Brian A Wandell. Color temperature estimation of scene illumination. In Color and Imaging Conference, volume 1999, pages 42–47. Society for Imaging Science and Technology, 1999.
389
+ [22] J von Kries. Theoretische studien über die umstimmung des sehorgans. Festschrift der AlbrechtLudwigs-Universität, pages 145–158, 1902.
390
+ [23] P. Welinder, S. Branson, T. Mita, C. Wah, F. Schroff, S. Belongie, and P. Perona. Caltech-UCSD Birds 200. Technical Report CNS-TR-2010-001, California Institute of Technology, 2010.
391
+ [24] Gunter Wyszecki and Walter Stanley Stiles. Color science, volume 8. Wiley New York, 1982.
392
+ [25] Tete Xiao, Xiaolong Wang, Alexei A Efros, and Trevor Darrell. What should not be contrastive in contrastive learning. arXiv preprint arXiv:2008.05659, 2020.
393
+ [26] Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and Stéphane Deny. Barlow twins: Selfsupervised learning via redundancy reduction. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pages 12310–12320. PMLR, 2021.
394
+
395
+ # 397 Checklist
396
+
397
+ The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
398
+
399
+ • Did you include the license to the code and datasets? [Yes] See Section 4.1
400
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
401
+ • Did you include the license to the code and datasets? [N/A]
402
+
403
+ 406 Please do not modify the questions and only use the provided macros for your answers. Note that the
404
+ 407 Checklist section does not count towards the page limit. In your paper, please delete this instructions
405
+ 408 block and only keep the Checklist section heading above along with the questions/answers below.
406
+
407
+ 1. For all authors...
408
+
409
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
410
+ (b) Did you describe the limitations of your work? [Yes] See section 5
411
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
412
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
413
+
414
+ 2. If you are including theoretical results...
415
+
416
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
417
+
418
+ 3. If you ran experiments...
419
+
420
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] It will be included in the supplementary material.
421
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
422
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
423
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] It will be included in the supplementary material.
424
+
425
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
426
+
427
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
428
+ (b) Did you mention the license of the assets? [N/A]
429
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
430
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
431
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
432
+
433
+ 5. If you used crowdsourcing or conducted research with human subjects...
434
+
435
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
436
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
437
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/ETKGuby0hcs/ETKGuby0hcs.md ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DISCOVERING LATENT KNOWLEDGE IN LANGUAGE MODELS WITHOUT SUPERVISION
2
+
3
+ Collin Burns∗ UC Berkeley
4
+
5
+ Haotian Ye∗ Peking University
6
+
7
+ Dan Klein UC Berkeley
8
+
9
+ Jacob Steinhardt UC Berkeley
10
+
11
+ # ABSTRACT
12
+
13
+ Existing techniques for training language models can be misaligned with the truth: if we train models with imitation learning, they may reproduce errors that humans make; if we train them to generate text that humans rate highly, they may output errors that human evaluators can’t detect. We propose circumventing this issue by directly finding latent knowledge inside the internal activations of a language model in a purely unsupervised way. Specifically, we introduce a method for accurately answering yes-no questions given only unlabeled model activations. It works by finding a direction in activation space that satisfies logical consistency properties, such as that a statement and its negation have opposite truth values. We show that despite using no supervision and no model outputs, our method can recover diverse knowledge represented in large language models: across 6 models and 10 questionanswering datasets, it outperforms zero-shot accuracy by $4 \%$ on average. We also find that it cuts prompt sensitivity in half and continues to maintain high accuracy even when models are prompted to generate incorrect answers. Our results provide an initial step toward discovering what language models know, distinct from what they say, even when we don’t have access to explicit ground truth labels.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ The increasing deployment of language models in real-world applications opens up exciting possibilities, but it also raises the stakes of AI research and presents new risks (Bommasani et al., 2021; Weidinger et al., 2021; Bender et al., 2021). One of these risks is that language models do not always output text that is true (Evans et al., 2021; Hendrycks et al., 2021; Kenton et al., 2021).
18
+
19
+ Common training objectives can cause models to learn internal representations related to truth, since truth is a useful feature for many tasks. However, these objectives can also cause language models to output text that is false, at least in some circumstances. For example, if we train a model to imitate human-generated text, it may learn to output common misconceptions (Lin et al., 2022). Or if we train a chat bot to optimize a reward such as engagement, it may learn to generate text that is compelling but false (Roller et al., 2021). If we try to reward model outputs that look true, a model may still learn to output false text if human raters can’t evaluate the correctness of that text (Kenton et al., 2021).
20
+
21
+ In each case, this is an issue that stems from the misalignment between a training objective and the truth. As models are applied to more complex domains, human supervision may become less effective at mitigating this misalignment. Moreover, because this is a problem with the training objective rather than a model’s capabilities, it likely won’t be solved by scaling up models alone.
22
+
23
+ We propose a different approach for addressing this misalignment: using models to answer questions in a purely unsupervised way. Intuitively, instead of trying to explicitly, externally specify truth, we search for implicit, internal “beliefs” or “knowledge” learned by a model. We approach this problem by leveraging the fact that a model’s representation of truth must satisfy logical consistency properties, which are unlikely to be satisfied by many other features.
24
+
25
+ We implement this idea by introducing Contrast-Consistent Search (CCS), a method that learns a linear projection of the hidden states that is consistent across negations, as illustrated in Figure 1. We find that despite its simplicity and despite not having access to any labels or model outputs,
26
+
27
+ ![](images/e656e25e9baa3e1b57f7c7ccd407dc81a71026687eb6a443cbfe38f356099c5e.jpg)
28
+ Figure 1: An illustration of our method, Contrast-Consistent Search (CCS). For each yes-no question $q _ { i }$ , we let $x _ { i } ^ { + }$ and $\boldsymbol { x } _ { i } ^ { - }$ be the natural language statements where we answer $q _ { i }$ as “Yes” and “No” respectively. Answering the question $q _ { i }$ then amounts to determining which of $x _ { i } ^ { + }$ or $\boldsymbol { x } _ { i } ^ { - }$ is true. We compute probabilities $p _ { i } ^ { + }$ and $\boldsymbol { p } _ { i } ^ { - }$ that $x _ { i } ^ { + }$ and $\boldsymbol { x } _ { i } ^ { - }$ are true respectively using a learned mapping from the hidden states to a number between 0 and 1. We search for a mapping such that that the probabilities are both confident and consistent. On the right, we show a histogram of the “Yes” probabilities, $\tilde { p } _ { i } = 0 . 5 \cdot ( p _ { i } ^ { + } + ( 1 - p _ { i } ^ { - } ) )$ , learned by our method on the unlabeled train split of the COPA dataset (Roemmele et al., 2011) with the UnifiedQA model (Khashabi et al., 2020). Our method uses no labels and no model outputs, but still learns to accurately answers questions.
29
+
30
+ CCS can accurately recover knowledge from model representations: evaluated across 6 models and 10 question-answering datasets, CCS outperforms the accuracy of strong zero-shot baselines by $4 \%$ on average (Section 3.2.1). The resulting classifier is also less sensitive to different prompts than zero-shot, cutting the standard deviation in accuracy in half. Additionally, we try deliberately prompting models to make incorrect outputs, which should intuitively change what models say but which shouldn’t affect their latent knowledge. We find that this causes zero-shot accuracy to drop by up to $9 . 5 \%$ (Section 3.2.2) without decreasing the accuracy of CCS.
31
+
32
+ We systematically analyze CCS to understand the features it discovers. We show that it transfers across unrelated tasks, suggesting that models may have a task-agnostic representation of the truth and that CCS is able to approximately discover it (Section 3.3.1). Moreover, CCS sometimes works best using the hidden states in the middle layers of a network and can work even when model outputs aren’t very informative, suggesting that it can leverage different features from those used by the outputs (Section 3.3.2). Finally, we show that representations of truth tend to be salient in models: they can often be found without much data, and they can often be found by taking the top principal component of a slightly modified representation space (Section 3.3.3).
33
+
34
+ Most existing techniques for making models truthful use human supervision to explicitly specify what is correct. However, it is not feasible to provide supervision in some settings. Our work suggests that an external source of ground truth may not actually be necessary: we may instead be able to find a model’s latent representation of truth, independent of what a model says, without using any supervision in the first place.
35
+
36
+ # 2 PROBLEM STATEMENT AND FRAMEWORK
37
+
38
+ In this section we describe our problem setup in more detail and introduce Contrast-Consistent Search (CCS), a method for discovering latent knowledge in language models without supervision.
39
+
40
+ # 2.1 PROBLEM: DISCOVERING LATENT KNOWLEDGE
41
+
42
+ Given a pre-trained neural language model and a set $q _ { 1 } , \ldots , q _ { n }$ of yes-no questions1, our goal is to answer each $q _ { i }$ correctly. Here, $q _ { i }$ can be any question with a well-defined answer, including procedural questions like “Is $2 2 \substack { + 5 9 } = 2 3 7 ? ^ { \prime \prime }$ , for which the answer is “No”, and factual questions like “Are cats mammals?”, for which the answer is “Yes”.
43
+
44
+ Importantly, we want methods that do not rely on the model generating correct outputs and that do not rely on external supervision. Instead, we turn to the model’s unlabeled hidden representations. Specifically, let $\phi ( \boldsymbol { x } ) \doteq \mathbb { R } ^ { d }$ denote some feature representation on a natural langauge input $x$ , such as the hidden states of a Transformer-based language model. Our goal is to answer the questions $q _ { 1 } , \ldots , q _ { n }$ only given access to $\phi ( \cdot )$ . In Section 2.2 we introduce a method for this problem that attains high accuracy (Section 3), demonstrating that this task is tractable.
45
+
46
+ # 2.2 METHOD: CONTRAST-CONSISTENT SEARCH
47
+
48
+ To make progress on the goal described above, we exploit the fact that truth has special structure: it satisfies consistency properties that few other features in a language model are likely to satisfy. Our method, Contrast-Consistent Search (CCS), leverages this idea by finding a direction in activation space that is consistent across negations. As we illustrate in Figure 1, CCS works by (1) answering each question $q _ { i }$ as both “Yes” $( \mathbf { \bar { \boldsymbol { x } } } _ { i } ^ { + } )$ and “No” $( x _ { i } ^ { - } )$ , (2) computing the representations $\phi ( x _ { i } ^ { + } )$ and $\phi ( x _ { i } ^ { - } )$ of each answer, (3) mapping the answer representations to probabilities $p _ { i } ^ { + }$ and $\mathfrak { p } _ { i } ^ { - }$ of being true, then (4) optimizing that mapping so that the probabilities are both consistent and confident.
49
+
50
+ Concretely, the input to CCS is a set of Yes-No questions, $q _ { 1 } , \ldots , q _ { n }$ , and access to a pretrained model’s representations, $\phi ( \cdot )$ ; the output of CCS is a lightweight probe on top of $\phi ( \cdot )$ that can answer new questions. Here, $\phi ( \cdot )$ is fixed but should contain useful information about the answers to $q _ { 1 } , \ldots , q _ { n }$ , in the sense that if one did (hypothetically) have access to the ground-truth labels for $q _ { 1 } , \ldots , q _ { n }$ , one would be able to train a small supervised probe on $\phi ( \cdot )$ that attains high accuracy. Importantly, CCS does not modify the weights of the pretrained model and it does not use labels.
51
+
52
+ Constructing contrast pairs. An important property that truth satisfies is negation consistency: the answer to a clear-cut question cannot be both “Yes” and “No” at the same time, as these are negations of each other. Probabilistically, for each question $q _ { i }$ , the probability that the answer to $q _ { i }$ is “Yes” should be one minus the probability that the answer to $q _ { i }$ is “No”. To use this property, we begin by constructing contrast pairs: for each question $q _ { i }$ , we answer $q _ { i }$ both as “Yes”, resulting in the new natural language statement $x _ { i } ^ { + }$ , and as “No”, resulting in the natural language statement $\boldsymbol { x } _ { i } ^ { - }$ . We illustrate this in Figure 1 (left). We will then learn to classify $x _ { i } ^ { + }$ and $\boldsymbol { x } _ { i } ^ { - }$ as true or false; if $x _ { i } ^ { + }$ is true, then the answer to $q _ { i }$ should be “Yes”, and if $\boldsymbol { x } _ { i } ^ { - }$ is true, then the answer to $q _ { i }$ should be “No”.
53
+
54
+ In practice, we convert each task into a question-answering task with two possible labels, then we use task-specific zero-shot prompts to format questions and answers as strings to construct each contrast pair. The opposite labels we use to construct contrast pairs can be “Yes” and “No” for a generic task, or they can be other tasks-specific labels, such as “Positive” and “Negative” in the case of sentiment classification. We describe the exact prompts we use to for each task in Appendix B.
55
+
56
+ Feature extraction and normalization. Given a contrast pair $( x _ { i } ^ { + } , x _ { i } ^ { - } )$ , CCS first computes the representations $\phi ( x _ { i } ^ { + } )$ and $\phi ( x _ { i } ^ { - } )$ using the feature extractor $\phi ( \cdot )$ . Intuitively, there are two salient differences between $\phi ( x _ { i } ^ { + } )$ and $\phi ( x _ { i } ^ { - } )$ : (1) $x _ { i } ^ { + }$ ends with “Yes” while $\boldsymbol { x } _ { i } ^ { - }$ ends with “No”, and (2) one of $x _ { i } ^ { + }$ or $\boldsymbol { x } _ { i } ^ { - }$ is true while the other is false. We want to find (2) rather than (1), so we first try to remove the effect of (1) by normalizing $\{ \phi ( x _ { i } ^ { + } ) \}$ and $\{ \phi ( x _ { i } ^ { - } ) \}$ independently. In particular, we construct normalized representations $\tilde { \phi } ( x )$ as follows:
57
+
58
+ $$
59
+ { \tilde { \phi } } ( x _ { i } ^ { + } ) : = \phi ( x _ { i } ^ { + } ) - \mu ^ { + } ; \quad { \tilde { \phi } } ( x _ { i } ^ { - } ) : = \phi ( x _ { i } ^ { - } ) - \mu ^ { - } ,
60
+ $$
61
+
62
+ where $\mu ^ { + } , \mu ^ { - } \in \mathbb { R } ^ { d }$ are the means of $\{ \phi ( x _ { i } ^ { + } ) \} _ { i = 1 } ^ { n }$ and $\{ \phi ( x _ { i } ^ { - } ) \} _ { i = 1 } ^ { n }$ . This normalization ensures that $\{ \tilde { \phi } ( x _ { i } ^ { + } ) \}$ and $\{ \tilde { \phi } ( x _ { i } ^ { - } ) \}$ no longer form two separate clusters. In practice we also normalize the scale of the features, but this isn’t essential for the method to work; see Appendix G.1 for details.
63
+
64
+ Mapping activations to probabilities. Next, we learn a probe $p _ { \theta , b } ( \tilde { \phi } )$ that maps a (normalized) hidden state $\tilde { \phi } ( x )$ to a number between 0 and 1 representing the probability that the statement $x$ is true. We use a linear projection followed by a sigmoid $\sigma ( \cdot )$ , i.e. $p _ { \theta , b } ( \tilde { \phi } ) = \sigma ( \theta ^ { T } \tilde { \phi } + b )$ , but nonlinear projections can also work. For simplicity, we sometimes omit the $\theta , b$ subscript in $p$ .
65
+
66
+ Training objective. To find features that represent the truth, we leverage the consistency structure of truth. First, we use the fact that a statement and its negation should have probabilities that add up to 1. This motivates the consistency loss:
67
+
68
+ $$
69
+ L _ { \mathrm { c o n s i s t e n c y } } ( \theta , b ; q _ { i } ) : = \left[ p _ { \theta , b } ( x _ { i } ^ { + } ) - ( 1 - p _ { \theta , b } ( x _ { i } ^ { - } ) ) \right] ^ { 2 }
70
+ $$
71
+
72
+ However, this objective alone has a degenerate solution: $p ( x ^ { + } ) = p ( x ^ { - } ) = 0 . 5$ . To avoid this problem, we encourage the model to also be confident with the following confidence loss:
73
+
74
+ $$
75
+ L _ { \mathrm { c o n f i d e n c e } } ( \theta , b ; q _ { i } ) : = \operatorname* { m i n } \{ p _ { \theta , b } ( x _ { i } ^ { + } ) , p _ { \theta , b } ( x _ { i } ^ { - } ) \} ^ { 2 }
76
+ $$
77
+
78
+ We can equivalently interpret $L _ { \mathrm { { c o n f i d e n c e } } }$ as imposing a second consistency property on the probabilities: the law of excluded middle (every statement must be either true or false). The final unsupervised loss is the sum of these two losses, averaged across all contrast pairs:
79
+
80
+ $$
81
+ L _ { \mathrm { C C S } } ( \theta , b ) : = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } L _ { \mathrm { c o n s i s t e n c y } } ( \theta , b ; q _ { i } ) + L _ { \mathrm { c o n f i d e n c e } } ( \theta , b ; q _ { i } )
82
+ $$
83
+
84
+ Note that both losses are necessary; $L _ { \mathrm { { c o n f i d e n c e } } }$ alone also has a degenerate solution.
85
+
86
+ Inference. Both $p ( x _ { i } ^ { + } )$ and $1 - p ( x _ { i } ^ { - } )$ should represent the probability that the answer to $q _ { i }$ is “Yes”. However, because we use a soft consistency constraint, these may not be exactly equal. To make a prediction on an example $x _ { i }$ after training, we consequently take the average of these:
87
+
88
+ $$
89
+ \tilde { p } ( q _ { i } ) : = \frac { 1 } { 2 } ( p ( x _ { i } ^ { + } ) + ( 1 - p ( x _ { i } ^ { - } ) )
90
+ $$
91
+
92
+ We then predict that the answer to $q _ { i }$ is “Yes” based on whether $\tilde { p } ( q _ { i } )$ is greater than 0.5. Technically, we also need to determine whether $\tilde { p } ( q _ { i } ) > 0 . 5$ corresponds to “Yes” or “No,” as this isn’t specified by $L _ { \mathrm { C C S } }$ . For simplicity in our evaluations we take the maximum accuracy over the two possible ways of labeling the predictions of a given test set. However, in Appendix A we describe how one can identify the two clusters without any supervision in principle by leveraging conjunctions.
93
+
94
+ # 3 RESULTS
95
+
96
+ # 3.1 EXPERIMENTAL SETUP
97
+
98
+ Here we give an overview of our experimental setup; see Appendix G for full details. We provide code at https://www.github.com/collin-burns/discovering_latent_knowledge.
99
+
100
+ Models. We test six models: encoder-decoder models (T5 (Raffel et al., 2020), UnifiedQA (Khashabi et al., 2020), T0 (Sanh et al., 2021)), autoregressive models (GPT-J (Wang & Komatsuzaki, 2021)), and encoder-only models (RoBERTa (Liu et al., 2019), DeBERTa (He et al., 2021)).
101
+
102
+ Data. We test models on 10 datasets: sentiment classification (IMDB (Maas et al., 2011) and Amazon (McAuley & Leskovec, 2013)), topic classification (AG-News (Zhang et al., 2015) and DBpedia-14 (Lehmann et al., 2015)), NLI (RTE (Wang et al., 2018) and QNLI (Rajpurkar et al., 2016)), story completion (COPA (Roemmele et al., 2011) and Story-Cloze (Mostafazadeh et al., 2017)), question answering (BoolQ (Clark et al., 2019)), and common sense reasoning (PIQA (Bisk et al., 2020)).
103
+
104
+ We convert each dataset to a yes-no question-answering task or a binary classification task, as described in Appendix G. We balance the labels and randomly subsample 1000 examples from each dataset (except for COPA, which has only 500 examples total), then randomly split each dataset into an unsupervised training set $6 0 \%$ of the data) and test set $( 4 0 \% )$ . We subsample each dataset for computational efficiency reasons; because we aggregate over 9 prompts per dataset, 10 datasets, and 6 models, 1000 datapoints per dataset actually corresponds to approximately $1 8 0 \mathrm { k }$ examples in total.
105
+
106
+ Methods. We test four main methods: zero-shot, calibrated zero-shot, Contrast-Consistent Search (CCS), and Logistic Regression (LR). Zero-shot works by predicting the answer with the highest log probability according to the language model, averaged across the tokens that make up that label. Calibrated zero-shot works by balancing zero-shot predictions to be $5 0 / 5 0$ for each answer, as we describe in more detail below, similar to Zhao et al. (2021). For Logistic Regression we train on the training split for each dataset using $( \tilde { \phi } ( x ^ { + } ) , \tilde { \phi } ( x ^ { - } ) )$ as the covariates, then evaluate on the corresponding test split. We treat LR as a ceiling since it uses labeled data.
107
+
108
+ When testing CCS, we optimize it 10 times using AdamW (Loshchilov & Hutter, 2017) with learning rate 0.01, then take the run with the lowest unsupervised loss. Unless otherwise specified, we train CCS using all prompts for a single training set, then evaluate it on the corresponding test split.
109
+
110
+ Zero-shot baselines. Zero-shot outputs sometimes suffer from miscalibration (Zhao et al., 2021), in which models are biased towards predicting specific answers. Calibrating the outputs to be uniform
111
+
112
+ <table><tr><td>Method</td><td>RoBERTa</td><td>DeBERTa</td><td>GPT-J</td><td>T5</td><td>UQA</td><td>T0*</td><td>Mean*</td></tr><tr><td>0-shot</td><td>60.1(5.7)</td><td>68.6(8.2)</td><td>53.2(5.2)</td><td>55.4(5.7)</td><td>76.8(9.6)</td><td>87.9(4.8)</td><td>62.8(6.9)</td></tr><tr><td>Calibrated O-shot</td><td>64.3(6.2)</td><td>76.3(6.0)</td><td>56.0(5.2)</td><td>58.8(6.1)</td><td>80.4(7.1)</td><td>90.5(2.7)</td><td>67.2(6.1)</td></tr><tr><td>CCs</td><td>62.1(4.1)</td><td>78.5(3.8)</td><td>61.7(2.5)</td><td>71.5(3.0)</td><td>82.1(2.7)</td><td>77.6(3.3)</td><td>71.2(3.2)</td></tr><tr><td>CCS (All Data)</td><td>60.1(3.7)</td><td>77.1(4.1)</td><td>62.1(2.3)</td><td>72.7(6.0)</td><td>84.8(2.6)</td><td>84.8(3.7)</td><td>71.5(3.7)</td></tr><tr><td>LR (Ceiling)</td><td>79.8(2.5)</td><td>86.1(2.2)</td><td>78.0(2.3)</td><td>84.6(3.1)</td><td>89.8(1.9)</td><td>90.7(2.1)</td><td>83.7(2.4)</td></tr></table>
113
+
114
+ Table 1: Accuracy of each method and model averaged across all prompts and dataset, with the average standard deviation of accuracy across different prompts shown in parentheses. For most models, CCS outperforms zero-shot accuracy and exhibits lower sensitivity to prompts, even though this was not our goal. This shows that we can recover knowledge from language model activations without supervision, and can do so in a way that is competitive with strong baseline methods that use model outputs. ${ } ^ { * } \mathrm { T 0 }$ was trained on 9 out of 10 of the datasets we evaluate on, including some of the data in our test splits, so we ignore it when averaging over models.
115
+
116
+ over different answers can mitigate this problem. We use a variant of the calibration method presented in Zhao et al. (2021) by balancing predictions to be 50/50 across the two output labels. Specifically, if $l _ { + }$ and $l _ { - }$ are the logits for the positive and negative label respectively, then instead of classifying an example as positive if $l _ { + } > l _ { - }$ , we classify it as positive if $l _ { + } > l _ { - } + \gamma$ , where we select the threshold $\gamma \in \mathbb { R }$ so that the predictions are balanced. We find this increases accuracy by about $5 \%$ on average. Unless otherwise specified, we always report zero-shot accuracy after calibration.
117
+
118
+ Encoder-only models (e.g. RoBERTa and DeBERTa) cannot be easily used to do zero-shot classification out of the box, so to evaluate them we follow the method of Yin et al. (2020): we finetune both models on an NLI dataset (MNLI, which we do not evaluate on) and treat the difference between the entailment and contradiction probabilities as the effective logit. This provides a strong zero-shot baseline for encoder-only models that works even for non-NLI tasks (Yin et al., 2020). This finetuning isn’t necessary for CCS to work on encoder-only models (see Appendix C), but we test CCS using the same MNLI-finetuned models for ease of comparison.
119
+
120
+ Hidden states. We extract the hidden states corresponding to the last token in the last layer of each model for simplicity, unless otherwise specified. For encoder-decoder models, we evaluate CCS on the last layer hidden states of both the encoder and decoder, and use whichever one generally achieves a lower unsupervised loss; for T0 this is the decoder hidden states, while for T5 and UnifiedQA this is the encoder hidden states. See Appendix G.2 for further implementation details, such as tokenization.
121
+
122
+ Prompts. To reduce prompt sensitivity, we use between 8 and 13 prompts for each dataset (9 on average), derived or slightly modified from Sanh et al. (2021). Unless otherwise specified, we average across all prompts when showing results. To construct contrast pairs, we let $\bar { x } _ { i } ^ { + }$ be the zero-shot prompt using $q _ { i }$ and the first label (e.g. “Positive” for sentiment classification datasets) and let $\boldsymbol { x } _ { i } ^ { - }$ be the prompt using $q _ { i }$ and the second label (e.g. “Negative”). We describe all prompts in Appendix I.
123
+
124
+ # 3.2 EVALUATING CCS
125
+
126
+ # 3.2.1 CCS OUTPERFORMS ZERO-SHOT
127
+
128
+ We evaluate CCS on all 6 models and compute the average accuracy across all datasets and prompts. T0 was trained on 9 out of 10 of the datasets we evaluate on, including some of the data in our test splits, so we ignore it when averaging over models to avoid unfair comparisons. We display the results in Table 1. To assess prompt sensitivity, for each model and dataset we compute the standard deviation (s.d.) of accuracy across different prompts, then average the resulting standard deviations across all datasets, which we show in parentheses in Table 1. For comparison, we also include results when training CCS on all datasets simultaneously, which we refer to as CCS (All Data).
129
+
130
+ CCS attains an accuracy of $7 1 . 2 \%$ on average, compared to $6 7 . 2 \%$ for calibrated zero-shot. It outperforms zero-shot accuracy for every model, except for RoBERTa (where it does $2 \%$ worse) and T0 (for which zero-shot accuracy is inflated). Training on all datasets improves accuracy by only an insignificant amount on average $( 0 . 3 \% )$ , but with large gains for T0 in particular $( 7 7 . 6 \% \dot { ) } \ \mathrm { { 8 4 . \dot { 8 } \% } ) }$ .
131
+
132
+ These results show that CCS can exceed the performance of strong baseline methods that access the model outputs, even though this wasn’t our main goal. This indicates that it is indeed possible to classify examples with high accuracy using only unlabeled model representations.
133
+
134
+ # 3.2.2 CCS IS ROBUST TO MISLEADING PROMPTS
135
+
136
+ Recall our goal: to discover latent knowledge in a language model even when the model outputs false text. In particular, language models are typically trained to imitate text whether or not it is correct, so if a model sees false text it should intuitively be more likely to predict that subsequent text will also be false. Based on this idea, we provide an initial proof of concept that CCS can make progress toward our goal by constructing prompts that aim to mislead the outputs of language models. Specifically, we add a prefix to the beginning of our zero-shot prompts that consists of questions answered incorrectly (Figure 5). The hope is that such a prefix will decrease zero-shot accuracy because the model will imitate its context and answer subsequent questions incorrectly even if it internally “knows” better.2 We found that while most models are robust to this type of prefix (see Appendix B), it significantly drops calibrated zero-shot performance in UnifiedQA, decreasing accuracy from $8 0 . 4 \%$ to $7 0 . 9 \%$ .
137
+
138
+ We evaluate CCS on these examples and show the results in Figure 4 of the Appendix. We find that despite the $9 . 5 \%$ drop in zero-shot accuracy, CCS maintains high accuracy $( 8 \bar { 2 } . \bar { 1 } \% 8 3 . 8 \% )$ ). This provides evidence that our method can still work well even when model outputs are unreliable.
139
+
140
+ # 3.3 ANALYZING CCS
141
+
142
+ We have shown that CCS attains strong classification performance in standard settings and when we deliberately mislead models. Moreover, we have described our motivation as discovering latent representations of truth in language models, but in practice CCS just finds a direction in representation space that attains high accuracy. This raises the question: in what sense is CCS actually finding “truth” features? We now provide a preliminary investigation of this question.
143
+
144
+ # 3.3.1 CCS FINDS A TASK-AGNOSTIC REPRESENTATION OF TRUTH
145
+
146
+ From the results described so far, it may be possible that the classifier we find is capturing datasetspecific properties, such as which of two labels (e.g. “Yes” vs. “No”) is more likely to be correct. We rule this out by showing that it generalizes across completely different tasks, including ones with different label spaces (such as from “Yes” and “No” for a generic task to “Positive” and “Negative” for sentiment classification). In particular, we train and test CCS on every pair of datasets, and show the resulting transfer for several models in Figure 2. (See Appendix F for results with other models.)
147
+
148
+ We find that CCS indeed transfer wells: in the majority of datasets, the transfer accuracy of CCS is competitive with training and testing on the same dataset (the last row in Figure 2, “No transfer”). Transfer performance can even outperform the no-transfer setting, especially when we train on simpler tasks, such as sentiment classification. For example, training CCS on the Amazon sentiment dataset achieves an average transfer accuracy of $7 1 . 8 \%$ , which is $0 . 6 \%$ higher than CCS without transfer. We speculate that this performs so well because the difference in representations between correct and incorrect answers is especially pronounced for easier tasks like Amazon.
149
+
150
+ Additionally, transfer accuracy tends to be similar for many datasets. For example, training on IMDB (row 1 of Figure 2) has similar accuracy as training on DBPedia (row 4). This provides evidence that CCS can find a functionally similar direction across many different types of training datasets. Overall, these results suggest that (1) models may have a task-agnostic representation related to what is true, and that (2) CCS may approximately find this representation even without diverse data.
151
+
152
+ # 3.3.2 CCS DOES NOT JUST RECOVER MODEL OUTPUTS
153
+
154
+ One possibility is that CCS can only recover knowledge already contained in a model’s outputs. We have shown that CCS can outperform zero-shot accuracy (Section 3.2.1), especially when model outputs are misled (Section 3.2.2), which already provides evidence against this possibility. We now provide additional evidence against this concern.
155
+
156
+ First, if CCS were just recovering knowledge in the model outputs, using the last layer of a network (right before the outputs) should presumably outperform intermediate layers (which are more causally distant from the outputs). However, for T5 and UnifiedQA, we find that using hidden states in the middle of the network outperform hidden states at the end of the network when using CCS (see Figure 10). This is especially true for UnifiedQA on misleading prefixes; we find that using the encoder hidden states is robust to misleading prefixes (Section 3.2.2), but that accuracy using the decoder hidden states drops from $8 1 . 0 \%$ to $7 3 . 5 \%$ , a similar amount to zero-shot accuracy. This suggests that compared to the later layers of a model, intermediate layers are more robust and less correlated with the model outputs, and that CCS can take advantage of this.
157
+
158
+ ![](images/6a47c001a70b9481681fcaba0e1d64656c7afe890cfd5ecaafacccec9ae7fb6b.jpg)
159
+ Figure 2: Transfer Performance using CCS on UnifiedQA, T0 and DeBERTa. The y-axis corresponds to the training dataset, and the $\mathbf { X }$ -axis corresponds to the test dataset. The final row (“No Transfer”) corresponds to training and testing on the same dataset, which is the same as the diagonal. On most datasets, CCS transfers well to other datasets (relative to no transfer), including to different tasks with completely different labels. In some cases transfer even outperforms the no-transfer setting. See Appendix $\mathrm { E }$ for results with other models.
160
+
161
+ Finally, if CCS were just recovering knowledge in the model outputs, we would only expect it to work in cases where model outputs are informative. However, we show in Appendix C that CCS still works with masked language models when their outputs are uninformative: when we don’t [MASK] any input tokens, and when we prompt models so that the labels used to construct contrast pairs appear in the middle of a prompt rather than at the end. These results show that CCS can sometimes recover latent knowledge in a model that is distinct from—and more useful than—what the model outputs.
162
+
163
+ # 3.3.3 TRUTH IS A SALIENT FEATURE
164
+
165
+ From the results we have presented so far, it is possible that the direction learned by CCS is difficult to find and requires using a large amount of unsupervised data. We provide evidence against this possibility by showing that finding such a direction can both (1) often be done with only a small amount of data, and can also (2) often be done by essentially taking the top principal component of a slightly modified representation space.
166
+
167
+ CCS doesn’t require much data. We now evaluate how well CCS performs with different amounts of data. Whereas before we trained CCS using the full training set and all prompts, here we use limited data and a single prompt. Specifically, we train using only $k$ unlabeled contrast pairs, using the single prompt for each model and dataset that achieves the highest zero-shot accuracy. We still test on all prompts for each dataset. We resample $k$ points 32 times for each of $k = 1 , 2 , 4 , \cdots$ , and take the average accuracy across those 32 samples. Finally, we plot the average such accuracy across all datasets and prompts for several models in Figure 3.
168
+
169
+ We find that while CCS benefits from more data, it can often do well with very limited data. In fact, it can sometimes even do well with only a single contrast pair, though we find high variance across individual datasets; see Appendix D for more details. This suggests that the strong performance of CCS does not primarily come from using a large amount of unsupervised data, and indicates that the direction learned by CCS may be relatively easy to find.
170
+
171
+ Contrastive Representation Clustering. We now show that directions correlated with the truth may be “salient” in a different way: by showing that we can also find such directions using either (1) PCA or (2) clustering. Specifically, suppose we construct contrast pairs $( x _ { i } ^ { + } , x _ { i } ^ { - } )$ as before. Intuitively, these two examples are qualitatively almost identical except that one is true and the other is false, so the main difference between the representations $\tilde { \phi } ( x _ { i } ^ { + } )$ and $\tilde { \phi } ( x _ { i } ^ { - } )$ should relate to truth. Consequently, we can take the differences in (normalized) hidden states, $\{ \tilde { \phi } ( x _ { i } ^ { + } ) - \tilde { \phi } ( x _ { i } ^ { - } ) \} _ { i = 1 } ^ { n }$ , and cluster them. We call this method Contrastive Representation Clustering (CRC). Clustering can be achieved by taking the top principal component (TPC) and thresholding at 0, or by doing a “bimodal salience search” (BSS) to find a direction that looks bimodal; see Appendix G.4 for further details.
172
+
173
+ ![](images/bcefbca48e6df619736e3da9bbdecf7f4f00a137892730bd8d263bb9fbc1837a.jpg)
174
+ Figure 3: Accuracy when we train CCS on $k$ samples for different values of $k$ (each time averaged across 32 trials). We use the single prompt with the highest zero-shot accuracy for each dataset and model. While CCS benefits from more examples, it can often work well with limited data.
175
+
176
+ We compare CCS and these two variants of Contrastive Representation Clustering in Table 2, using the same setting as in Table 1. While CCS performs best, all methods attain high accuracy and are competitive with zero-shot performance. This indicates both that (1) representations of truth often lie in a high-variance direction in the contrastive representation space $\bar { \{ \phi ( x _ { i } ^ { + } ) - \tilde { \phi } ( x _ { i } ^ { - } ) \} } _ { i = 1 } ^ { n }$ , and also that (2) true and false examples are often well-clustered in this same contrastive space. This strengthens the idea that representations of truth may be salient features inside models that are relatively easy to find. This may help explain why CCS can perform well without using any supervision, and how it can do so even with only a limited amount of unlabeled data.
177
+
178
+ # 4 RELATED WORK
179
+
180
+ Zero-Shot Prompting. Since the release of GPT-3 (Brown et al., 2020), one of the main paradigms for eliciting what models know has been zero-shot prompting (Liu et al., 2022; Beltagy et al., 2022). Zero-shot exploits how language models are trained to predict diverse data from the internet, which incidentally includes tasks such as question-answering. If prompted appropriately, this can be used to solve various useful tasks with reasonable performance (Brown et al., 2020). However, these models are trained to imitate human-generated data, which bounds the quality of their outputs.
181
+
182
+ Many methods improve upon vanilla zero-shot prompting (Liu et al., 2022; Zhao et al., 2021; Lu et al., 2022; Wei et al., 2022b; Min et al., 2022a). While our goal is not to improve zero-shot performance, some of the ideas underlying these methods are similar to CCS. Particularly relevant are methods that also leverage unsupervised consistency properties, such as Jung et al. (2022); Zhou et al. (2022). However, these methods still bootstrap from language model outputs trained via imitation learning, which limits their applicability to our main goals.
183
+
184
+ <table><tr><td>Method</td><td>RoBERTa</td><td>DeBERTa</td><td>GPT-J</td><td>T5</td><td>UQA</td><td>T0*</td><td>Mean*</td></tr><tr><td>Calibrated O-shot</td><td>64.3(6.2)</td><td>76.3(6.0)</td><td>56.0(5.2)</td><td>58.8(6.1)</td><td>80.4(7.1)</td><td>90.5(2.7)</td><td>67.2(6.1)</td></tr><tr><td>CCS</td><td>62.1(4.1)</td><td>78.5(3.8)</td><td>61.7(2.5)</td><td>71.5(3.0)</td><td>82.1(2.7)</td><td>77.6(3.3)</td><td>71.2(3.2)</td></tr><tr><td>CRC (TPC)</td><td>64.6(5.8)</td><td>76.5(5.7)</td><td>59.9(3.7)</td><td>66.7(5.0)</td><td>78.3(3.3)</td><td>58.9(13.0)</td><td>69.2(4.7)</td></tr><tr><td>CRC (BSS)</td><td>62.6(6.8)</td><td>76.8(5.3)</td><td>60.7(3.4)</td><td>69.7(3.3)</td><td>79.3(2.5)</td><td>76.7(9.6)</td><td>69.8(4.3)</td></tr></table>
185
+
186
+ Table 2: We compare CCS to two variants of Contrastive Representation Clustering: TPC, which clusters by projecting onto the top principal component, and BSS, which clusters by finding a direction that looks bimodal. We show accuracy and standard deviation of each model averaged across all prompts and datasets, in the same setting as Table 1. We find that CCS generally performs the best, but that all methods are competitive with zero-shot.
187
+
188
+ To illustrate this, imagine we train reinforcement learning agents to play a game such as Diplomacy (FAIR et al., 2022), in which players have incentives to lie to each other. Then those agents may learn to lie in a way that is difficult to detect, but they may still internally represent whether they are lying. Because their outputs would be deliberately misleading, standard zero-shot methods may be very unreliable. In contrast, techniques like CCS may still be able to detect whether those models are lying by finding representations of truth in their activations that contradict their outputs.
189
+
190
+ Truthfulness. There has been increasing interest in making language models truthful (Evans et al., 2021; Lin et al., 2022). One aspect of truthfulness that has received substantial attention is factuality (Thorne et al., 2018; Maynez et al., 2020). For instance, many techniques aim to improve the factuality of models by augmenting them with retrieval methods (Nakano et al., 2021; Menick et al., 2022), which allows them to cite their sources. In contrast, we focus on truthfulness more generally, which also includes procedural knowledge such as reasoning or natural language inference tasks.
191
+
192
+ An approach to making language models truthful in this more general setting is to finetune them using either human demonstrations (Khashabi et al., 2020; Sanh et al., 2021; Zhong et al., 2021; Wei et al., 2022a) or reinforcement learning from human feedback (Christiano et al., 2017; Stiennon et al., 2020; Askell et al., 2021; Bai et al., 2022; Ouyang et al., 2022). These techniques have been widely successful at improving performance, but unlike our method they rely on being able to provide ground truth labels, which can be intractable in many settings.
193
+
194
+ Some work has aimed to go beyond the direct supervision humans can provide by augmenting supervision with AI systems (Christiano et al., 2018; Irving et al., 2018; Leike et al., 2018; Perez et al., 2022). This may expand the range of applications we can supervise, but many of these proposals remain theoretical, and it is unclear just how far these techniques can generalize. Christiano et al. (2022) reframes this issue by posing the problem of Eliciting Latent Knowledge (ELK). Like our problem statement, ELK is about eliciting knowledge from models even in cases where humans cannot evaluate that knowledge. However, ELK frames this as a worst-case theoretical problem, while we frame this as an empirical problem that we can make progress on using current models.
195
+
196
+ # 5 DISCUSSION
197
+
198
+ # 5.1 LIMITATIONS AND FUTURE WORK
199
+
200
+ Our work has a number of limitations. First, CCS relies on the existence of a direction in activation space that separates true and false inputs well, in the sense that a supervised probe on the activations would be able to attain high accuracy (if it hypothetically had access to the ground truth labels). This requires that a model is both capable of evaluating the truth of a given input, and also that the model actively evaluates the truth of that input. It is not clear when these conditions hold precisely.
201
+
202
+ Second, we did not evaluate our method on setups involving active “lying” or “deception” (Kenton et al., 2021; Evans et al., 2021) by models, as we aren’t aware of existing evaluation setups for this setting. If future work develops such a setup, a good stress test would be to apply CCS to do “lie detection” in that setting. This may require modifications or extensions to the method, such as more explicitly ensuring that it recovers the truth of an input rather than what the model says.
203
+
204
+ There are also various straightforward improvements to our method that one could explore. This includes adding additional consistency constraints, improving its reliability, calibrating its probabilities, generalizing it beyond the yes-no question-answering setting, generalizing it to cases where answers aren’t clear-cut, and closing the remaining gap between CCS and the logistic regression ceiling.
205
+
206
+ # 5.2 CONCLUSION
207
+
208
+ As language models become more capable, they will be increasingly used as components in larger AI systems trained with reinforcement learning. As this occurs, falsehoods arising from misaligned training objectives may become more common, severe, and difficult to detect. In principle, models may even develop instrumental incentives to lie: for example, if a human evaluator would disapprove of bad model behavior, models may learn to lie about their behavior to achieve higher reward. If so, those models would be optimizing against human evaluators, making it precarious to rely on those evaluators for assessing the truth of what models say. Because unsupervised methods for eliciting answers circumvent this issue, they may still work even in this scenario. We show that it is possible to make progress on such methods today; the empirical success of our approach suggests that unsupervised methods are both a tractable and underexplored research direction.
209
+
210
+ We are very grateful to Jared Kaplan for helpful experiment suggestions and resources early on in the project. We thank Beth Barnes and Paul Christiano for valuable discussions regarding the longer-term impacts of this work. We are also grateful to Jessy Lin, Alex Pan, Ruiqi Zhong, Yaodong Yu, the anonymous reviewers, and several others for useful feedback on earlier versions of this paper. CB is supported by an Open Philanthropy AI Fellowship.
211
+
212
+ # REFERENCES
213
+
214
+ Amanda Askell, Yushi Bai, Anna Chen, Dawn Drain, Deep Ganguli, T. J. Henighan, Andy Jones, Nicholas Joseph, Benjamin Mann, Nova DasSarma, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, John Kernion, Kamal Ndousse, Catherine Olsson, Dario Amodei, Tom B. Brown, Jack Clark, Sam McCandlish, Christopher Olah, and Jared Kaplan. A general language assistant as a laboratory for alignment. ArXiv, abs/2112.00861, 2021.
215
+
216
+ Yushi Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, T. J. Henighan, Nicholas Joseph, Saurav Kadavath, John Kernion, Tom Conerly, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Tristan Hume, Scott Johnston, Shauna Kravec, Liane Lovitt, Neel Nanda, Catherine Olsson, Dario Amodei, Tom B. Brown, Jack Clark, Sam McCandlish, Christopher Olah, Benjamin Mann, and Jared Kaplan. Training a helpful and harmless assistant with reinforcement learning from human feedback. ArXiv, abs/2204.05862, 2022.
217
+
218
+ Iz Beltagy, Arman Cohan, Robert Logan IV, Sewon Min, and Sameer Singh. Zero- and few-shot nlp with pretrained language models. In ACL, 2022.
219
+
220
+ Emily M. Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big? Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, 2021.
221
+
222
+ Yonatan Bisk, Rowan Zellers, Jianfeng Gao, Yejin Choi, et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 7432–7439, 2020.
223
+
224
+ Tolga Bolukbasi, Kai-Wei Chang, James Y. Zou, Venkatesh Saligrama, and Adam Tauman Kalai. Man is to computer programmer as woman is to homemaker? debiasing word embeddings. In NIPS, 2016.
225
+
226
+ Rishi Bommasani, Drew A. Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S. Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, Erik Brynjolfsson, S. Buch, Dallas Card, Rodrigo Castellon, Niladri S. Chatterji, Annie S. Chen, Kathleen A. Creel, Jared Davis, Dora Demszky, Chris Donahue, Moussa Doumbouya, Esin Durmus, Stefano Ermon, John Etchemendy, Kawin Ethayarajh, Li Fei-Fei, Chelsea Finn, Trevor Gale, Lauren E. Gillespie, Karan Goel, Noah D. Goodman, Shelby Grossman, Neel Guha, Tatsunori Hashimoto, Peter Henderson, John Hewitt, Daniel E. Ho, Jenny Hong, Kyle Hsu, Jing Huang, Thomas F. Icard, Saahil Jain, Dan Jurafsky, Pratyusha Kalluri, Siddharth Karamcheti, Geoff Keeling, Fereshte Khani, O. Khattab, Pang Wei Koh, Mark S. Krass, Ranjay Krishna, Rohith Kuditipudi, Ananya Kumar, Faisal Ladhak, Mina Lee, Tony Lee, Jure Leskovec, Isabelle Levent, Xiang Lisa Li, Xuechen Li, Tengyu Ma, Ali Malik, Christopher D. Manning, Suvir P. Mirchandani, Eric Mitchell, Zanele Munyikwa, Suraj Nair, Avanika Narayan, Deepak Narayanan, Benjamin Newman, Allen Nie, Juan Carlos Niebles, Hamed Nilforoshan, J. F. Nyarko, Giray Ogut, Laurel Orr, Isabel Papadimitriou, Joon Sung Park, Chris Piech, Eva Portelance, Christopher Potts, Aditi Raghunathan, Robert Reich, Hongyu Ren, Frieda Rong, Yusuf H. Roohani, Camilo Ruiz, Jack Ryan, Christopher R’e, Dorsa Sadigh, Shiori Sagawa, Keshav Santhanam, Andy Shih, Krishna Parasuram Srinivasan, Alex Tamkin, Rohan Taori, Armin W. Thomas, Florian Tramer, Rose E. Wang, William Wang, \` Bohan Wu, Jiajun Wu, Yuhuai Wu, Sang Michael Xie, Michihiro Yasunaga, Jiaxuan You, Matei A. Zaharia, Michael Zhang, Tianyi Zhang, Xikun Zhang, Yuhui Zhang, Lucia Zheng, Kaitlyn Zhou, and Percy Liang. On the opportunities and risks of foundation models. ArXiv, abs/2108.07258, 2021.
227
+
228
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. ArXiv, abs/2005.14165, 2020.
229
+
230
+ Paul Christiano, Ajeya Cotra, and Mark Xu. Eliciting latent knowledge. Technical report, ARC, 2022. URL https://docs.google.com/document/d/1WwsnJQstPq91_ Yh-Ch2XRL8H_EpsnjrC1dwZXR37PC8/edit.
231
+
232
+ Paul Francis Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. ArXiv, abs/1706.03741, 2017.
233
+
234
+ Paul Francis Christiano, Buck Shlegeris, and Dario Amodei. Supervising strong learners by amplifying weak experts. ArXiv, abs/1810.08575, 2018.
235
+
236
+ Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. Boolq: Exploring the surprising difficulty of natural yes/no questions. arXiv preprint arXiv:1905.10044, 2019.
237
+
238
+ Owain Evans, Owen Cotton-Barratt, Lukas Finnveden, Adam Bales, Avital Balwit, Peter Wills, Luca Righetti, and William Saunders. Truthful ai: Developing and governing ai that does not lie. $A r X i \nu$ , abs/2110.06674, 2021.
239
+
240
+ Meta FAIR, Anton Bakhtin, Noam Brown, Emily Dinan, Gabriele Farina, Colin Flaherty, Daniel Fried, Andrew Goff, Jonathan Gray, Hengyuan Hu, Athul Paul Jacob, Mojtaba Komeili, Karthik Konath, Minae Kwon, Adam Lerer, Mike Lewis, Alexander H. Miller, Sasha Mitts, Adithya Renduchintala, Stephen Roller, Dirk Rowe, Weiyan Shi, Joe Spisak, Alexander Wei, David Wu, Hugh Zhang, and Markus Zijlstra. Human-level play in the game of diplomacy by combining language models with strategic reasoning. Science, pp. eade9097, 2022.
241
+
242
+ Rory A. Fisher. The use of multiple measurements in taxonomic problems. Annals of Human Genetics, 7:179–188, 1936.
243
+
244
+ Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. ArXiv, abs/2006.03654, 2021.
245
+
246
+ Dan Hendrycks, Nicholas Carlini, John Schulman, and Jacob Steinhardt. Unsolved problems in ml safety. ArXiv, abs/2109.13916, 2021.
247
+
248
+ Geoffrey Irving, Paul Francis Christiano, and Dario Amodei. Ai safety via debate. ArXiv, abs/1805.00899, 2018.
249
+
250
+ Jaehun Jung, Lianhui Qin, Sean Welleck, Faeze Brahman, Chandra Bhagavatula, Ronan Le Bras, and Yejin Choi. Maieutic prompting: Logically consistent reasoning with recursive explanations. ArXiv, abs/2205.11822, 2022.
251
+
252
+ Zachary Kenton, Tom Everitt, Laura Weidinger, Iason Gabriel, Vladimir Mikulik, and Geoffrey Irving. Alignment of language agents. ArXiv, abs/2103.14659, 2021.
253
+
254
+ Daniel Khashabi, Sewon Min, Tushar Khot, Ashish Sabharwal, Oyvind Tafjord, Peter Clark, and Hannaneh Hajishirzi. Unifiedqa: Crossing format boundaries with a single qa system. In FINDINGS, 2020.
255
+
256
+ Junyeob Kim, Hyuhng Joon Kim, Hyunsoo Cho, Hwiyeol Jo, Sang-Woo Lee, Sang goo Lee, Kang Min Yoo, and Taeuk Kim. Ground-truth labels matter: A deeper look into input-label demonstrations. ArXiv, abs/2205.12685, 2022.
257
+
258
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
259
+
260
+ Jens Lehmann, Robert Isele, Max Jakob, Anja Jentzsch, Dimitris Kontokostas, Pablo N Mendes, Sebastian Hellmann, Mohamed Morsey, Patrick Van Kleef, Soren Auer, et al. Dbpedia–a large- ¨ scale, multilingual knowledge base extracted from wikipedia. Semantic web, 6(2):167–195, 2015.
261
+
262
+ Jan Leike, David Krueger, Tom Everitt, Miljan Martic, Vishal Maini, and Shane Legg. Scalable agent alignment via reward modeling: a research direction. ArXiv, abs/1811.07871, 2018.
263
+
264
+ Stephanie C. Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. In ACL, 2022.
265
+
266
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing. ACM Computing Surveys (CSUR), 2022.
267
+
268
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. ArXiv, abs/1907.11692, 2019.
269
+
270
+ Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. ArXiv, abs/1711.05101, 2017.
271
+
272
+ Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. In ACL, 2022.
273
+
274
+ Andrew Maas, Raymond E Daly, Peter T Pham, Dan Huang, Andrew Y Ng, and Christopher Potts. Learning word vectors for sentiment analysis. In Proceedings of the 49th annual meeting of the association for computational linguistics: Human language technologies, pp. 142–150, 2011.
275
+
276
+ Joshua Maynez, Shashi Narayan, Bernd Bohnet, and Ryan T. McDonald. On faithfulness and factuality in abstractive summarization. ArXiv, abs/2005.00661, 2020.
277
+
278
+ Julian McAuley and Jure Leskovec. Hidden factors and hidden topics: understanding rating dimensions with review text. In Proceedings of the 7th ACM conference on Recommender systems, pp. 165–172, 2013.
279
+
280
+ Jacob Menick, Maja Trebacz, Vladimir Mikulik, John Aslanides, Francis Song, Martin Chadwick, Mia Glaese, Susannah Young, Lucy Campbell-Gillingham, Geoffrey Irving, and Nathan McAleese. Teaching language models to support answers with verified quotes. ArXiv, abs/2203.11147, 2022.
281
+
282
+ Sewon Min, Mike Lewis, Luke Zettlemoyer, and Hannaneh Hajishirzi. Metaicl: Learning to learn in context. ArXiv, abs/2110.15943, 2022a.
283
+
284
+ Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? ArXiv, abs/2202.12837, 2022b.
285
+
286
+ Nasrin Mostafazadeh, Michael Roth, Annie Louis, Nathanael Chambers, and James Allen. Lsdsem 2017 shared task: The story cloze test. In Proceedings of the 2nd Workshop on Linking Models of Lexical, Sentential and Discourse-level Semantics, pp. 46–51, 2017.
287
+
288
+ Reiichiro Nakano, Jacob Hilton, S. Arun Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, Xu Jiang, Karl Cobbe, Tyna Eloundou, Gretchen Krueger, Kevin Button, Matthew Knight, Benjamin Chess, and John Schulman. Webgpt: Browser-assisted question-answering with human feedback. ArXiv, abs/2112.09332, 2021.
289
+
290
+ Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke E. Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Francis Christiano, Jan Leike, and Ryan J. Lowe. Training language models to follow instructions with human feedback. ArXiv, abs/2203.02155, 2022.
291
+
292
+ Ethan Perez, Saffron Huang, Francis Song, Trevor Cai, Roman Ring, John Aslanides, Amelia Glaese, Nathan McAleese, and Geoffrey Irving. Red teaming language models with language models. ArXiv, abs/2202.03286, 2022.
293
+
294
+ Colin Raffel, Noam M. Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. ArXiv, abs/1910.10683, 2020.
295
+
296
+ Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250, 2016.
297
+
298
+ Melissa Roemmele, Cosmin Adrian Bejan, and Andrew S Gordon. Choice of plausible alternatives: An evaluation of commonsense causal reasoning. In 2011 AAAI Spring Symposium Series, 2011.
299
+
300
+ Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Kurt Shuster, Eric Michael Smith, Y.-Lan Boureau, and Jason Weston. Recipes for building an open-domain chatbot. In EACL, 2021.
301
+
302
+ Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang A. Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M SAIFUL BARI, Canwen Xu, Urmish Thakker, Shanya Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal V. Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan ´ Teehan, Stella Rose Biderman, Leo Gao, T. G. Owe Bers, Thomas Wolf, and Alexander M. Rush. Multitask prompted training enables zero-shot task generalization. ArXiv, abs/2110.08207, 2021.
303
+
304
+ Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M. Ziegler, Ryan J. Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. Learning to summarize from human feedback. ArXiv, abs/2009.01325, 2020.
305
+
306
+ James Thorne, Andreas Vlachos, Christos Christodoulopoulos, and Arpit Mittal. Fever: a large-scale dataset for fact extraction and verification. ArXiv, abs/1803.05355, 2018.
307
+
308
+ Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461, 2018.
309
+
310
+ Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
311
+
312
+ Jason Wei, Maarten Bosma, Vincent Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. Finetuned language models are zero-shot learners. ArXiv, abs/2109.01652, 2022a.
313
+
314
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. ArXiv, abs/2201.11903, 2022b.
315
+
316
+ Laura Weidinger, John F. J. Mellor, Maribeth Rauh, Conor Griffin, Jonathan Uesato, Po-Sen Huang, Myra Cheng, Mia Glaese, Borja Balle, Atoosa Kasirzadeh, Zachary Kenton, Sande Minnich Brown, William T. Hawkins, Tom Stepleton, Courtney Biles, Abeba Birhane, Julia Haas, Laura Rimell, Lisa Anne Hendricks, William S. Isaac, Sean Legassick, Geoffrey Irving, and Iason Gabriel. Ethical and social risks of harm from language models. ArXiv, abs/2112.04359, 2021.
317
+
318
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, and Jamie Brew. Huggingface’s ´ transformers: State-of-the-art natural language processing. ArXiv, abs/1910.03771, 2019.
319
+
320
+ Wenpeng Yin, Nazneen Rajani, Dragomir Radev, Richard Socher, and Caiming Xiong. Universal natural language processing with limited annotations: Try few-shot textual entailment as a start. In EMNLP, 2020.
321
+
322
+ Xiang Zhang, Junbo Zhao, and Yann LeCun. Character-level convolutional networks for text classification. Advances in neural information processing systems, 28:649–657, 2015.
323
+
324
+ Tony Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. ArXiv, abs/2102.09690, 2021.
325
+
326
+ Ruiqi Zhong, Kristy Lee, Zheng Zhang, and Dan Klein. Adapting language models for zero-shot learning by meta-tuning on dataset and prompt collections. In EMNLP, 2021.
327
+
328
+ Chunting Zhou, Junxian He, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Prompt consistency for zero-shot task generalization. ArXiv, abs/2205.00049, 2022.
329
+
330
+ ![](images/4b67c9ca41e416520cd20763f87807056b97aa6944b6cdd7a5f263fdd4d1cce0.jpg)
331
+ Figure 4: Zero-shot accuracy drop caused by the misleading prefix shown in Figure 5 for UnifiedQA. Each point corresponds to one dataset and one prompt. On average, zero-shot accuracy drops $9 . 5 \%$ , while CCS performs $1 . 7 \%$ better. This suggests that the latent knowledge inside a model that CCS recovers can be robust even when model outputs become less reliable.
332
+
333
+ # A IDENTIFYING CLUSTERS
334
+
335
+ CCS predicts yes-no answers to a set of unlabeled questions $q _ { 1 } , \ldots , q _ { n }$ . However, it does not identify which prediction label corresponds to true and which corresponds to false. We now describe how one can do so in principle, as long as a model is also able to take conjunctions.
336
+
337
+ Suppose we run our method and find, for example, that $x$ and $x ^ { \prime }$ end up in different clusters. Then we know that these two statements have opposite truth values. As a result, if we take the conjunction of these two statements, $x \wedge x ^ { \prime }$ then it should be false, and if we take the disjunction, $x \vee x ^ { \prime }$ , then it should be true. This allows us to identify which cluster is true and which is false in a completely unsupervised way.
338
+
339
+ # B MISLEADING PREFIX DETAILS
340
+
341
+ # B.1 MISLEADING PREFIX
342
+
343
+ In Section 3.2, we mentioned that model outputs can be biased by using the misleading few-shot prefix shown in Figure 5. We show the effect of the misleading prefix for all models in Table 3, and we illustrate the drop in accuracy for each dataset and prompt in Figure 4.
344
+
345
+ # B.1.1 EVALUATING THE EFFECT OF THE MISLEADING PREFIX
346
+
347
+ The hope is that the misleading prefix causes models to imitate the sorts of incorrect answers in the prefix. However, we found that results are qualitatively similar with correct answers, making the actual interpretation of the effect of this prefix ambiguous. Nevertheless, to better understand what this prefix is doing, we visualize the top 100 tokens for both this misleading prefix and no prefix on average across all examples for UnifiedQA on the IMDB sentiment dataset, and show the results in Figure 6. Without this prefix, the top two tokens are the actual labels (‘positive’ and ‘negative’). In contrast, with the prefix, these tokens have lower probabilities relative to other tokens, with the highest probability tokens instead being irrelevant to the true answer. For example, since the prefix includes several answers with numbers, many of the top tokens are also numbers. This provides some evidence that the prefix is actually causing the model to output false text by imitating its context in a meaningful sense.
348
+
349
+ ![](images/fc7fc52fdf02d4a1814cbf81264f71246801d11f67419edc35fc47971da16270.jpg)
350
+ Figure 5: The added prefix used to mislead models in a way that is egregiously incorrect or confusing.
351
+
352
+ ![](images/77e7ff2b6dcd456de446085cf0e8292425688b2103ac8917c38bd1cb6aca0caa.jpg)
353
+ Figure 6: The top 100 tokens with highest probability averaged across examples in IMDB for UQA. Without the prefix (left), the actual labels (“positive” and “negative”) and their synonyms (e.g. “Positive” and “Neg”) have high probability. With the prefix, the model’s output becomes mostly irrelevant to sentiment; the actual labels are in the top 100, but no other synonyms are.
354
+
355
+ Table 3: Accuracy of each method and model averaged across all prompts and datasets, with the same setting as Table 1. “Regular” means no prefix is added, while “Prefix” corresponds to text in Figure 5. Notice that while the 0-shot accuracy decreases due to the prefix, all of our methods are more resistant to the influence.
356
+
357
+ <table><tr><td>Method</td><td>Prefix</td><td>RoBERTa</td><td>DeBERTa</td><td>GPT-J</td><td>T5</td><td>UQA</td><td>TO*</td><td>Mean*</td></tr><tr><td>Calibrated 0-shot</td><td>Regular Prefix</td><td>64.3(6.2) 65.6(5.3)</td><td>76.3(6.0) 75.5(6.1)</td><td>56.0(5.2) 59.2(4.6)</td><td>58.8(6.1) 56.0(4.0)</td><td>80.4(7.1) 70.9(7.8)</td><td>90.5(2.7) 88.2(4.2)</td><td>67.2(6.1) 65.4(5.6)</td></tr><tr><td>CCS</td><td>Regular Prefix</td><td>62.1(4.1) 62.2(3.6)</td><td>78.5(3.8) 75.4(5.2)</td><td>61.7(2.5) 61.2(1.8)</td><td>71.5(3.0) 73.2(2.6)</td><td>82.1(2.7) 83.8(2.4)</td><td>77.6(3.3) 75.0(2.7)</td><td>71.2(3.2) 71.2(3.1)</td></tr><tr><td>TPC</td><td>Regular Prefix</td><td>64.6(5.8) 65.0(5.6)</td><td>76.5(5.7) 77.0(6.0)</td><td>59.9(3.7) 60.1(2.9)</td><td>66.7(5.0) 68.1(5.0)</td><td>78.3(3.3) 76.0(3.6)</td><td>58.9(13.0) 56.5(13.6)</td><td>69.2(4.7) 69.2(4.6)</td></tr><tr><td>BSS</td><td>Regular Prefix</td><td>62.6(6.8) 59.5(5.4)</td><td>76.8(5.3) 75.5(6.6)</td><td>60.7(3.4) 59.8(2.8)</td><td>69.7(3.3) 65.2(2.8)</td><td>79.3(2.5) 83.1(2.3)</td><td>76.7(9.6) 72.2(9.0)</td><td>69.8(4.3) 68.6(4.0)</td></tr><tr><td>LR</td><td>Regular Prefix</td><td>79.8(2.5) 79.4(2.7)</td><td>86.1(2.2) 86.3(2.6)</td><td>78.0(2.3) 79.0(2.9)</td><td>84.6(3.1) 86.3(2.8)</td><td>89.8(1.9) 90.1(2.2)</td><td>90.7(2.1) 90.5(2.3)</td><td>83.7(2.4) 84.2(2.6)</td></tr></table>
358
+
359
+ # C MASKED LANGUAGE MODELING RESULTS
360
+
361
+ We now provide an initial demonstration that CCS can work well even when a model’s outputs are not very useful.
362
+
363
+ First, we evaluate our method on a model trained exclusively with the masked language modeling (MLM) objective: DeBERTa-v2 (He et al., 2021) without NLI finetuning (unlike in Section 3, where we finetuned DeBERTa on an NLI task to use it in the zero-shot setting). The outputs of DeBERTa are unlikely to be meaningful if we provide a raw input without using any [MASK] tokens3. If CCS only works when the model outputs are useful, then it should perform poorly in this setting.
364
+
365
+ We also consider one other way that model outputs can be uninformative. Given a sequence of tokens as input, DeBERTa has a different set of output logits for each input token. For a given contrast example (a question and a candidate answer), the most informative output should intuitively be the logits that predict the answer. For instance, if the contrast example $x ^ { + }$ is “Is $2 + 2 { = } 4 ?$ Yes”, then the most informative output should be the logits corresponding to candidate answer “Yes”. Consequently, if we instead format each example so that the label (e.g. “Yes” or “No”) appears in the middle of the prompt, then the output corresponding to the final token should not be very informative. If CCS only works well when the model outputs are useful, then it should also perform poorly in this setting (as long as CCS uses the last-token hidden states as usual).
366
+
367
+ To show that CCS can work even when model outputs aren’t informative, based on the above discussion we now do an initial test of CCS when we simultaneously (1) use DeBERTa-v2 (MLMpretrained only), and (2) format inputs so that the label is in the middle of the prompt rather than at the end. In particular, we apply CCS on the Amazon dataset, where we randomly sample 1000 new (unlabeled) points and use a 60/40 train-test split as before. As usual we continue to use the last-token hidden states for CCS. As usual, we use the default Huggingface tokenizer and we do not [MASK] any input tokens. We use the following custom prompt to test (2):
368
+
369
+ The following movie review expresses a [label] sentiment:\n[text]
370
+
371
+ Even though it is unclear why the model outputs should be useful with this setup, we find that CCS can indeed still perform well, attaining an accuracy of $9 3 . 7 \%$ . For comparison, this is nearly identical to the approximately $9 4 \%$ accuracy of CCS when evaluated on the Amazon dataset using NLI-finetuned DeBERTa and the original prompts (see Figure 9).
372
+
373
+ We argued above that the model outputs should not be very useful in this setting. We now verify that this is the case. To do so, we evaluate a modified version of zero-shot prompting adapted to work for masked language models when we use no [MASK] tokens in the input. Specifically, on an input $x ^ { + }$ or $x ^ { - }$ , we (1) take the logit vector corresponding to the last input token, (2) select the corresponding logit for “positive” and the corresponding logit for “negative” (the two candidate labels), (3) take the difference between these, resultintake the difference between these, $l _ { p o s } ^ { + } - l _ { n e g } ^ { + }$ $x ^ { + }$ $l _ { p o s } ^ { - } - l _ { n e g } ^ { - }$ for the $x ^ { - }$ , respectively, then (4)ctive logit. Intuitively, $( l _ { p o s } ^ { + } - l _ { n e g } ^ { + } ) \bar { - } ( l _ { p o s } ^ { - } - l _ { n e g } ^ { - } )$ this final expression should be large if the example is positive, and small if the example is negative. As before, we calibrate this zero-shot method so that its predictions are balanced.
374
+
375
+ We evaluate this method and find that it recovers non-trivial knowledge in the model outputs, but that it still performs substantially worse than CCS: calibrated zero-shot accuracy in this setting is $7 1 . 6 \%$ , compared to almost $9 4 \%$ for CCS. This suggests that model outputs in this setting indeed aren’t very useful, especially relative to CCS.
376
+
377
+ Overall, our results in this section show that CCS can still work in at least some settings where model outputs don’t seem to be very useful. This provides additional evidence that out approach does not simply recover knowledge represented in the model outputs.
378
+
379
+ In this section we show additional results on how the number of examples affects CCS. We show the performance (averaged across all datasets) for all models in Figure 7. We next show a more fine-grained results. Specifically, we select #Samples $= 1 , 8 , 6 4$ and show dataset-level results in Figure 8 for each model.
380
+
381
+ ![](images/de793a51d0b90a8e245fca9154bea608b5affb42c8ef254cce78b04e966fc996.jpg)
382
+ Figure 7: This figure shares the same setting with Figure 3, but it contains all six models we consider.
383
+
384
+ ![](images/54ea39b4a3b0c3656bc6a08774753d231520dd266e7b8edb66f3ed858a2898a3.jpg)
385
+ Figure 8: CCS performance when we only use 1, 8, 64 examples, for all models and datasets. X-axis represents the dataset and y-axis is the accuracy in percentage. For each dataset, we select the prompt with highest 0-shot performance, and then randomly select 1, 8, 64 data points from this prompt. We then perform CCS and test on all prompts of this dataset, where each value in the barplot corresponds to one prompt.
386
+
387
+ # E COMPLETE TRANSFER RESULTS
388
+
389
+ Complete transfer results for CCS, TPC and BSS in all models are shown in Figure 9.
390
+
391
+ ![](images/cc7d8b3df6a374228f162132c8b433950f5a7f30bed52dfe6530cab8ccbb4c7b.jpg)
392
+ Figure 9: Transfer Accuracy for all models using CCS, BSS, TPC and LR.
393
+
394
+ In this section we the performance of CCS and LR across all hidden layers in all six models. Specifically, for each model, we generate the hidden states for each dataset every 2 layers (for both encoders and decoders). Then, for each set of hidden states, we perform CCS and LR on each dataset separately, and average the performance across all datasets. We show CCS results in Figure 10 and LR results in Figure 11.
395
+
396
+ ![](images/19431c566d42078d1d8e6395c794b501fa7aabb9349890136d4b5df8b20cd7e2.jpg)
397
+ Figure 10: CCS performance when using the hidden states across different layers, using all six models we consider in the paper.
398
+
399
+ ![](images/9c07929bcf1585833cf6f3ab5038594bf15fa79013b820b047c2cff8b17b8ad5.jpg)
400
+ Figure 11: Linear regression performance when using the hidden states across different layers, using all six models we consider in the paper. This is the ceiling of all possible methods, and is supervised.
401
+
402
+ In this section, we provide further implementation details for CCS and CRC.
403
+
404
+ # G.1 NORMALIZATION
405
+
406
+ As described in Section 2.2, we normalize the features $\tilde { \phi } ( x _ { i } ^ { + } ) = \phi ( x _ { i } ^ { + } ) - \mu ^ { + }$ , where $\mu ^ { + }$ is the mean of $\{ \phi ( x _ { i } ^ { + } ) \} _ { i = 1 } ^ { n }$ (and similarly for $\tilde { \phi } ( x _ { i } ^ { - } ) \mathrm { . }$ ). In practice, we also normalize the scale of the features√ by also dividing by the average norm of $\{ \phi ( x _ { i } ^ { + } ) \} _ { i = 1 } ^ { n }$ times $\sqrt { d }$ (and similarly for $\tilde { \phi } ( x _ { i } ^ { - } ) \mathrm { ) }$ ). However, this is less essential than mean normalization and there are likely many reasonable choices for scale normalization.
407
+
408
+ # G.2 CONTRAST PAIRS
409
+
410
+ We use the Huggingface library (Wolf et al., 2019) for all of our experiments. We use the standard tokenizer for each model, and always take the hidden state corresponding to the last token in a given layer indexed by idx. We show Huggingface-style pseudocode for extracting hidden states from in Algorithm 1.
411
+
412
+ For encoder-only and decoder-only models, we provide the full input, $x ^ { + }$ or $x ^ { - }$ , which includes both the question and the proposed answer, to the model; see Appendix I.1 for more formatting and tokenization details. For encoder-decoder models, our input format depends on whether we are taking the encoder hidden states or the decoder hidden states. When we take the decoder hidden states, we input the question to the encoder, and input the candidate answer to the decoder. In contrast, when we take the encoder hidden states of an encoder-decoder model, we provide the full input (including the proposed answer) to the encoder, and ignore the decoder (simply passing the empty string to the decoder and ignoring its results). This is necessary to ensure that the inputs to the encoder are not identical across contrast pairs.
413
+
414
+ # Algorithm 1 Pseudocode for Getting Contrast Features
415
+
416
+ Input: Contrast Pairs Set $S$ , model name mdl, layer index idx $\mathbf { m } =$ transformers.AutoModel(mdl) $\mathbf { t } =$ transformers.AutoTokenizer(mdl) $\mathcal { C } ^ { + }$ $, C ^ { - } = [ ] , [ ]$ for $( x ^ { + } , x ^ { - } )$ in $S$ do token+, $\mathrm { t o k e n ^ { - } } = \mathbf { t . e n c o d e } ( x ^ { + } )$ , t.encode $( x ^ { - } )$ $\phi ^ { + } = m ( \mathrm { t o k e n } ^ { + }$ , output hiddenstates $=$ True)[“hidden states”][idx][−1] $\phi ^ { - } = m ( \mathrm { t o k e n } ^ { - }$ , output hiddenstates $=$ True)[“hidden states”][idx][−1] $\mathcal { C } ^ { + }$ .append $( \phi ^ { + } ) , \mathcal { C } ^ { - }$ .append $\left( \phi ^ { - } \right)$ end for
417
+ Output: $[ { \mathcal { C } } ^ { + } , { \mathcal { C } } ^ { - } ]$
418
+
419
+ # G.3 CCS
420
+
421
+ Given contrast features from Algorithm 1, CCS works by learning parameters $\theta$ and $b$ by minimizing $L _ { C C S } ( \theta , b )$ as defined in Section 2.2.
422
+
423
+ In practice, we implement the bias $b$ by appending an additional dimension of 1s features to the input, increasing it and $\theta$ to have dimension $d + 1 .$ .We randomly initialize $\theta$ to have unit norm. We then optimize the CCS loss $T = 1 0$ times and select the run with lowest unsupervised loss. In practice, we train each time for $E = 1 0 0 0$ epochs with a learning rate $\eta = 0 . 0 1$ (which we found was good for consistently achieving low unsupervised loss) in each run. Because we are only learning a linear probe on top of the features, training can be fast.
424
+
425
+ Intuitively, a direction that clusters examples well should have high variance. Motivated by this, a simple method is to cluster according to the Top Principal Component (TPC). We do this by first constructing contrast features from the normalized contrast pair activations, $\mathcal { C } = \{ \tilde { \phi } ( x _ { i } ^ { + } ) - \tilde { \phi } ( x _ { i } ^ { - } ) \} _ { i = 1 } ^ { n }$ then projecting these examples on their top principal component using PCA. We then treat examples that are less than 0 as one cluster and examples that are greater than 0 as the other cluster. We find that despite its simplicity this method can often also find truth-like features in model activations. This method is similar in spirit to Bolukbasi et al. (2016), except that our method doesn’t require any labels; we leverage the fact that truth is consistent to construct contrast pairs in a purely unsupervised way.
426
+
427
+ # G.5 CRC: BIMODAL SALIENCE SEARCH
428
+
429
+ Bimodal Salience Search (BSS) is another variation of CRC. One drawback of TPC is that variance is not an intrinsic quantity to a network’s behavior, since different directions in representation space can be scaled without changing the behavior of the network as long as subsequent layers are rescaled accordingly. This motivates using a method that clusters examples regardless of the scale of different directions.
430
+
431
+ If examples are well-clustered, then the intra-cluster variance should be low while the inter-cluster variance (or total variance) should be high. Specifically, if we center a set of datapoints so that 0 delineates the cluster boundary, then the points on either side of 0 should have low variance compared to the points overall. This suggests minimizing the following loss:
432
+
433
+ $$
434
+ L ( \theta ) = \frac { \mathrm { v a r } \{ \theta ^ { T } c _ { i } | \theta ^ { T } c _ { i } < 0 \} + \mathrm { v a r } \{ \theta ^ { T } c _ { i } | \theta ^ { T } c _ { i } \geq 0 \} } { \mathrm { v a r } \{ \theta ^ { T } c _ { i } \} }
435
+ $$
436
+
437
+ where $c _ { i } : = \tilde { \phi } ( x _ { i } ^ { + } ) - \tilde { \phi } ( x _ { i } ^ { - } )$ and where we use $\mathrm { v a r } \{ z _ { i } \}$ as shorthand to denote the variance of a set $\{ z _ { i } \} _ { i = 1 } ^ { n } \subset \mathbb { R }$ . Because this objective is written in terms of a ratio, it is invariant to the overall scale of the direction, fixing that drawback of TPC. This loss is similar to that of Linear Discriminant Analysis (LDA) (Fisher, 1936), but unlike LDA is completely unsupervised.
438
+
439
+ In practice, we use an SGD-based optimizer to find a local optimum of $L ( \theta )$ . After computing the contrast features, we repeat the following process $T$ times. We first initialize a random direction $\theta$ with unit norm. Then for $E$ epochs, we calculate the loss according to Equation (1), and update the direction $\theta$ by via projected gradient descent, each time projecting $\theta$ back onto the unit sphere. Finally, we select the direction $\theta$ that has the lowest loss among the $T$ directions we found, and predict based on this direction. When we optimize the direction with multiple datasets, i.e. $S _ { 1 } , . . . , S _ { n }$ , we use the same algorithm, but average the loss across all datasets. In practice we use $T = E = 2 0$ , and use Adam optimizer (Kingma & Ba, 2014) with a learning rate of 0.1.
440
+
441
+ # H STATISTICAL SIGNIFICANCE
442
+
443
+ Our main accuracy results for CCS and other methods (e.g. in Table 1 and elsewhere) are computed by evaluating the method on $4 0 \%$ of the 1000 (or 500 in the case of COPA) examples sampled for each dataset, then averaging the resulting accuracy across 9 prompts per dataset (on average), 10 different datasets, and up to 5 models. This corresponds to about $1 8 0 \mathrm { k }$ samples in total; we performed subsampling in this way for computational efficiency reasons, as this is already substantial. For results where we average across datasets (i.e. most results in this paper), we average across $3 8 0 0 \mathrm { I I D }$ samples (the original examples sampled from each dataset), then usually also averaged across a very large number of correlated samples: 9 prompts and (often) 5 different models for a given sample.
444
+
445
+ We can compute an upper bound on the standard error of accuracies computed in this way by ignoring the averaging across different prompts and models: this gives us a simple but coarse upper bound of the standard error of $\frac { 1 } { 2 \sqrt { 3 8 0 0 } } \approx 0 . 8 \%$ . Applying a Wald test, the Wald statistic is $\begin{array} { r } { W = \frac { \bar { \mu _ { 0 } } - \hat { \mu } } { s e ( \hat { \mu } ) ^ { 2 } } \geq \frac { \mu _ { 0 } - \hat { \mu } } { ( 0 . 0 0 8 ) ^ { 2 } } } \end{array}$ , where (for example) $\mu _ { 0 }$ is zero-shot accuracy and $\hat { \mu }$ is CCS accuracy. $W$ is then $\chi ^ { 2 }$ -distributed with one degree of freedom.
446
+
447
+ We find that our main claims comparing accuracies are statistically significant at a 0.00001 level. This includes the claims that CCS outperforms zero-shot, with accuracies of $7 1 . 2 \%$ vs $6 7 . 2 \%$ , respectively;
448
+
449
+ that CCS is robust to misleading prompts while zero-shot isn’t in the setting we test, with accuracies of $8 3 . 8 \%$ vs $7 0 . 9 \%$ , respectively; that CCS on MLM-pretrained DeBERTa substantially outperforms DeBERTa zero-shot, with accuracies of $9 3 . 7 \%$ vs $7 1 . 6 \%$ , respectively; and so on. Some minor observations are not necessarily statistically significant, such as that CCS (All Data) outperforms CCS on average (Section 3.2.1), but none of these are important for our main claims, and more powerful but complicated statistical tests would result in smaller p-values.
450
+
451
+ In this section, we describe the setup of our data and prompts in detail. We introduce all datasets we use and the way we convert them into a binary classification task. Our prompts derive from (Sanh et al., $2 0 2 1 ) ^ { 4 }$ .
452
+
453
+ Contrast Pair Example. To illustrate how we construct contrast pairs, suppose we have a movie review “[text] $= \boldsymbol { \mathrm { I } }$ loved this movie.” and the sentiment of this review belongs to “[label0] $=$ positive” or “[label1] $=$ negative”. We first format it into a binary question-answering or classification question: “[text] Is the sentiment of this example [label0] or [label1]? ” using an existing zero-shot prompt. We then concatenate the question and candidate labels to create the contrast pairs:
454
+
455
+ x+ = [prefix] Q: Is the sentiment of “[text]” [label0] or [label1]? A: [label0] x− = [prefix] Q: Is the sentiment of “[text]” [label0] or [label1]? A: [label1]
456
+
457
+ For instance, in this example, these would be:
458
+
459
+ $x ^ { + } = \mathbf { Q }$ : Is the sentiment of “I loved this movie.” positive or negative? A: positive $x ^ { - } = \mathrm { Q }$ : Is the sentiment of “I loved this movie.” positive or negative? A: negative
460
+
461
+ # I.1 TOKENIZATION
462
+
463
+ For all prompts we consider in this paper, we concatenate labels to the end of questions. The precise we do this depends on the model type. For encoder-decoder models such as T5, we replace line breaks $( \backslash \mathrm { n } )$ with spaces, and we add a space between the question and proposed answer if the last token of questions is not already a space. For autoregressive models, we add a line break between the question and the proposed label if the last token of the question is neither a space nor a line break. For DeBERTa, we add a [SEP] split-token between the question and answer, and for RoBERTa, we add a $< / s > < s >$ between the question and answer.
464
+
465
+ Finally, we add the prefix (either prefix in Figure 5, or the empty string for the regular zero-shot setting) to the beginning of the prompt, then compute the hidden representations for this pair to obtain the contrast features $\mathcal { C }$ .
466
+
467
+ # I.2 DATASETS
468
+
469
+ We use ten datasets in our experiments. For each dataset, we select 1000 data points (except COPA, which has only 500 data points, so we only use those 500). When possible, we use just the test / validation split, but in other cases this is not enough data so we also use examples from the train split. For the most part this doesn’t make a difference for our purposes because our methods are purely unsupervised.
470
+
471
+ It is important to note that T0 is an exception among the models, because but was trained on 9 out of the 10 datasets we consider (all except RTE). This may account for its anomalous performance. UnifiedQA was trained on BoolQ, which is one of the datasets we test on, but was not trained on any other evaluation set we consider, which we don’t expect has an important qualitative effect.
472
+
473
+ We now enumerate the prompts we use for each dataset.
474
+
475
+ # I.2.1 AG NEWS
476
+
477
+ AG News is a topic classification dataset from (Zhang et al., 2015). Given a news paragraph, the label corresponds to the topic of this news, including “World politics”, “Sports”, “Business” and “Science and technology”. For each example, we randomly select another label (which is incorrect), and randomly assign the correct label and this incorrect label to “label0” and “label1”. With this, we construct the classification task using the following 8 prompts:
478
+
479
+ 1 [prefix]Consider the following example: “‘ [text] ”’ Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, the topic of this example is [label]
480
+
481
+ 2 [prefix]Consider the following example: “‘ [text] ”’ Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, what is the topic of this example? [label]
482
+ 3 [prefix]Consider the following example: “‘ [text] ”’ Which is the topic of this example, choice 1: [label0], or choice 2: [label1]? [label]
483
+ 4 [prefix][text] Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, the topic of this example is [label]
484
+ 5 [prefix][text] Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, what is the topic of this example? [label]
485
+ 6 [prefix][text] Which is the topic of this example, choice 1: [label0], or choice 2: [label1]? [label]
486
+ 7 [prefix][text] What label best describes this news article, choice 1: [label0], or choice 2: [label1]? [label]
487
+ 8 [prefix][text] Which section of a newspaper would this article likely appear in, choice 1: [label0], or choice 2: [label1]? [label]
488
+
489
+ Here the last “[label]” is “choice 1” for $x ^ { + }$ and “choice $2 ^ { \circ }$ for $x ^ { - }$ . Notice that we only specify “[label]” for the prompts that are constructed manually. For prompts in (Sanh et al., 2021), we leave their labels unchanged. (For example, we use “choice $1 ^ { \circ }$ or “choice $2 ^ { \circ }$ but they can use “Animal” or “Plant”)
490
+
491
+ # I.2.2 AMAZON POLARITY
492
+
493
+ Amazon polarity is a sentiment classification task from (McAuley & Leskovec, 2013). The content is the review of goods in Amazon, and the label can be “negative” or “positive”. We use 11 different prompts in this dataset. We first take all prompts from (Sanh et al., 2021) (Page 164, 9 prompts in total), and the two of our own as follows:
494
+
495
+ 1 [prefix]Consider the following example: “‘ [content] ”’ Between [label0] and [label1], the sentiment of this example is [label]
496
+ 2 [prefix]Consider the following example: “‘ [content] ”’ Between [label0] and [label1], which is the sentiment of this example? [label]
497
+
498
+ Here “[label]” is “negative” for $x ^ { + }$ and “positive” for $x ^ { - }$ .
499
+
500
+ # I.2.3 BOOLQ
501
+
502
+ BOOLQ is a QA task where each example consists a yes/no question from (Clark et al., 2019). We directly use the 10 prompts from (Sanh et al., 2021) (Page 146)
503
+
504
+ # I.2.4 COPA
505
+
506
+ COPA is a causal reasoning task to determine either the cause or the effect of a given premise (Roemmele et al., 2011). Here the label is a short sentence. We use 10 prompts, where 9 are from (Sanh et al., 2021) (Page 177), and we add one more prompt:
507
+
508
+ 1 [prefix]Consider the following premise: “‘ [premise] ”’ Choice 1: [choice1] Choice 2: [choice2] Q: Which one is more likely to be the [question], choice 1 or choice 2? [label]
509
+
510
+ # I.2.5 DBPEDIA 14
511
+
512
+ DBpedia 14 is a topic classification dataset constructed by picking 14 non-overlapping classes from DBpedia 2014 (Lehmann et al., 2015). We manually create 8 prompts. For each example, we randomly select the incorrect label from the remaining 13 classes, and randomly assign the correct label and this incorrect label to “[label0]” and “[label1]”.
513
+
514
+ 1 [prefix]Consider the following example: “‘ [content] ”’ Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, the topic of this example is [label]
515
+
516
+ 2 [prefix]Consider the following example: “‘ [content] ”’ Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, what is the topic of this example? [label]
517
+ 3 [prefix]Consider the following example: “‘ [content] ”’ Which is the topic of this example, choice 1: [label0], or choice 2: [label1]? [label]
518
+ 4 [prefix][content] Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, the topic of this example is [label]
519
+ 5 [prefix][content] Choice 1: [label0]. Choice 2: [label1].Between choice 1 and choice 2, what is the topic of this example? [label]
520
+ 6 [prefix][content] Which is the topic of this example, choice 1: [label0], or choice 2: [label1]? [label]
521
+ 7 [prefix][content] What category does the paragraph belong to, choice 1: [label0], or choice 2: [label1]? [label]
522
+ 8 [prefix][content] What label best describes this paragraph, choice 1: [label0], or choice 2: [label1]? [label]
523
+
524
+ Here “[label]” is “choice $1 ^ { \circ }$ for $x ^ { + }$ and “choice $2 ^ { \circ }$ for $x ^ { - }$ .
525
+
526
+ # I.2.6 IMDB
527
+
528
+ IMDB is a sentiment dataset from (Maas et al., 2011). Given a movie review, the label is either “[label0] $=$ negative” or “[label1] $=$ positive. We use 13 prompts, where 11 are from (Sanh et al., 2021) (Page 168), and the rest two are as follows:
529
+
530
+ 1 [prefix]Consider the following example: ”’ [text] ”’ Between [label0] and [label1], the sentiment of this example is [label]
531
+ 2 [prefix]Consider the following example: ”’ [text] ”’ Between [label0] and [label1], which is the sentiment of this example? [label]
532
+
533
+ Here “[label]” is “negative” for $x ^ { + }$ and “positive” for $x ^ { - }$
534
+
535
+ # I.2.7 PIQA
536
+
537
+ The PIQA dataset measures the physical commonsense reasoning ability of models. We use 11 prompts for PIQA, all of which are from (Sanh et al., 2021)(Page 160). The label is a complete sentence that can be the solution of the question.
538
+
539
+ # I.2.8 QNLI
540
+
541
+ QNLI from (Rajpurkar et al., 2016) is a question-answering dataset consisting of question-paragraph pairs, where one of the sentences in the paragraph (drawn from Wikipedia) contains the answer to the corresponding question (written by an annotator). We use 5 prompts from (Sanh et al., 2021). The label is either “yes” or “no” depending on whether the information in the paragraph is enough to answer the paragraph.
542
+
543
+ # I.2.9 RTE
544
+
545
+ RTE is a textual entailment dataset (Wang et al., 2018). The label corresponds to whether the text entails the hypotheses. We use 11 prompts, where 10 are from (Sanh et al., 2021)(Page 48), and where we manually add one more prompt:
546
+
547
+ 1 [prefix][premise] Question: Does this imply that ”[hypothesis]”, yes or no? [label]
548
+
549
+ Here “[label]” is “yes” for $x ^ { + }$ and “no” for $x ^ { - }$ .
550
+
551
+ Story Cloze is a story completion task from (Mostafazadeh et al., 2017). Given a short story, the task is to determine which of two endings is more likely to continue that story. We use 9 prompts, where 6 are from (Sanh et al., 2021), and the remaining 3 are as follows:
552
+
553
+ 1 [prefix]Consider the following story: “‘ [input sentence 1] [input sentence 2] [input sentence 3] [input sentence 4] ”’ Choice 1: [sentence quiz1] Choice 2: [sentence quiz2] Which is the more plausible ending of this story, choice 1 or choice 2? [label]
554
+ 2 [prefix]Consider the following story: “‘ [input sentence 1] [input sentence 2] [input sentence 3] [input sentence 4] ”’ Choice 1: [sentence quiz1] Choice 2: [sentence quiz2] Which is the more plausible ending of this story? [label]
555
+ 3 [prefix][input sentence 1] [input sentence 2] [input sentence 3] [input sentence 4] Choice 1: [sentence quiz1] Choice 2: [sentence quiz2] Which is the more plausible ending of this story, choice 1 or choice 2? [label]
556
+
557
+ Here “[label]” is “choice $1 ^ { \circ }$ for $x ^ { + }$ and “choice $2 ^ { \circ }$ for $x ^ { - }$ .
md/dev/G5RwHpBUv0/G5RwHpBUv0.md ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Pick-a-Pic: An Open Dataset of User Preferences for Text-to-Image Generation
2
+
3
+ Yuval Kirstainτ Adam Polyakτ Uriel Singer
4
+
5
+ Shahbuland Matianaσ Joe Pennaσ Omer Levyτ
6
+
7
+ τ Tel Aviv University σ Stability AI yuval.kirstain@cs.tau.ac.il
8
+
9
+ # Abstract
10
+
11
+ The ability to collect a large dataset of human preferences from text-to-image users is usually limited to companies, making such datasets inaccessible to the public. To address this issue, we create a web app that enables text-to-image users to generate images and specify their preferences. Using this web app we build Pick-a-Pic, a large, open dataset of text-to-image prompts and real users’ preferences over generated images. We leverage this dataset to train a CLIP-based scoring function, PickScore, which exhibits superhuman performance on the task of predicting human preferences. Then, we test PickScore’s ability to perform model evaluation and observe that it correlates better with human rankings than other automatic evaluation metrics. Therefore, we recommend using PickScore for evaluating future text-to-image generation models, and using Pick-a-Pic prompts as a more relevant dataset than MS-COCO. Finally, we demonstrate how PickScore can enhance existing text-to-image models via ranking.1
12
+
13
+ ![](images/564557e489507874f20b9dc4441e985237ef1c196efa6e1538412840ae5e4a7a.jpg)
14
+ Figure 1: Images generated via our web application, showing darkened non-preferred images (left) and preferred images (right).
15
+
16
+ # 1 Introduction
17
+
18
+ Recent advances in aligning language models with user behaviors and expectations have placed a significant emphasis on the ability to model user preferences [10, 1, 3]. However, little attention has been paid to this ability in the realm of text-to-image generation. This lack of attention can largely be attributed to the absence of a large and open dataset of human preferences over state-of-the-art image generation models.
19
+
20
+ To fill this void, we create a web application that enables users to generate images using state-of-theart text-to-image models while specifying their preferences. With explicit consent from the users, we collect their prompts and preferences to create Pick-a-Pic, a publicly available dataset comprising over half-a-million examples of human preferences over model-generated images.2 Each example in our dataset includes a prompt, two generated images, and a label indicating the preferred image, or a tie when no image is significantly preferred over the other. Notably, Pick-a-Pic was created by real users with a genuine interest in generating images. This interest differs from that of crowd workers who lack the intrinsic motivation to produce creative prompts or the original intent of the prompt’s author to judge which image better aligns with their needs.
21
+
22
+ Tapping into authentic user preferences allows us to train a scoring function that estimates the user’s satisfaction from a particular generated image given a prompt. To train such a scoring function we finetune CLIP-H [12, 7] using human preference data and an analogous objective to that of InstructGPT’s reward model [10]. This objective aims to maximize the probability of a preferred image being picked over an unpreferred one, or even the probability in cases of a tie. We find that the resulting scoring function, PickScore3, achieves superhuman performance in the task of predicting user preferences (a $70 . 5 \%$ accuracy rate, compared to humans’ $6 8 . 0 \%$ ), while zero-shot CLIP-H $( 6 0 . 8 \% )$ and the popular aesthetics predictor [14] $( 5 6 . 8 \% )$ perform closer to chance $( 5 6 . 8 \% )$ .
23
+
24
+ Equipped with a dataset for human preferences and a state-of-the-art scoring function, we propose updating the standard protocol for evaluating text-to-image generation models. First, we suggest that researchers evaluate their text-to-image models using prompts from Pick-a-Pic, which better represent what humans want to generate than mundane captions, such as those found in MS-COCO [2, 9]. Second, to compare PickScore with FID, we conduct a human evaluation study and find that even when evaluated against MS-COCO captions, PickScore exhibits a strong correlation with human preferences (0.917), while ranking with FID yields a negative correlation (-0.900). Importantly, we also compare PickScore with other evaluation metrics using model rankings inferred from real user preferences. We observe that PickScore is more strongly correlated with ground truth rankings, as determined by real users, than other evaluation metrics. Thus, we recommend using PickScore as a more reliable evaluation metric than existing ones.
25
+
26
+ Finally, we explore how PickScore can improve the quality of vanilla text-to-image models via ranking. To accomplish this, we generate images with different initial random noises as well as different templates (e.g. “breathtaking [prompt]. award-winning, professional, highly detailed”) to slightly alter the user prompt. We then test the impact of selecting the top image according to different scoring functions. Our findings indicate that human raters prefer images selected by PickScore more than those selected by CLIP-H [7] (win rate of $7 1 . 3 \%$ ), an aesthetics predictor [14] (win rate of $8 5 . 1 \%$ , and the vanilla text-to-image model (win rate of $7 1 . 4 \%$ ).
27
+
28
+ In summary, the presented work addresses a gap in the field of text-to-image generation by creating a large, open, high-quality dataset of human preferences over user-prompted model-generated images. We demonstrate the potential of this dataset by training a scoring function, PickScore, which exhibits a performance superior to any other publicly-available automatic scoring function, in predicting human preferences, evaluating text-to-image models, and improving them via ranking. We encourage the research community to adopt Pick-a-Pic and PickScore as a basis for further advances in text-to-image modeling and incorporating human preferences into the learning process.
29
+
30
+ ![](images/4f1c8249c412f1f948bb2399461429fe94f8eeb6587a76471d1f73fef2cc8abb.jpg)
31
+ Figure 2: How Pick-a-Pic data is collected through the app: (a) the user first writes a caption, and receives two images; (b) the user makes a preference judgment; (c) a new image is presented instead of the rejected image. This flow repeats itself until the user changes the prompt.
32
+
33
+ # 2 Pick-a-Pic Dataset
34
+
35
+ The Pick-a-Pic dataset4 was created by logging user interactions with the Pick-a-Pic web application for text-to-image generation. Overall, the Pick-a-Pic dataset contains over 500,000 examples and 35,000 distinct prompts. Each example contains a prompt, two generated images, and a label for which image is preferred, or if there is a tie when no image is significantly preferred over the other. The images in the dataset were generated by employing multiple backbone models, namely, Stable Diffusion 2.1, Dreamlike Photoreal $2 . 0 ^ { 5 }$ , and Stable Diffusion XL variants [13] while sampling different classifier-free guidance scale values [6]. As we continue with our efforts to collect more user interactions through the Pick-a-Pic web app and decrease the number of NSFW examples included in the dataset, we will periodically upload new revisions of the dataset.
36
+
37
+ The Pick-a-Pic Web App To ensure maximum accessibility for a wide range of users, the user interface was designed with simplicity in mind. The application allows users to write creative prompts and generate images. At each turn, the user is presented with two generated images (conditioned on their prompt), and asked to select their preferred option or indicate a tie if they have no strong preference. Upon selection, the rejected (non-preferred) image is replaced with a newly generated image, and the process repeats. The user can also clear or edit the prompt at any time, and the app will generate new images appropriately. Figure 2 illustrates the usage flow.
38
+
39
+ Real Data from Real Users A key advantage of Pick-a-Pic is that our data is collected from real, intrinsically-motivated users, rather than paid crowd workers. We achieve this by approaching a wide audience through various social media channels such as Twitter, Facebook, Discord, and Reddit. At the same time, we mitigate the risk of collecting low-quality data resulting from potential misuse of the application by implementing several quality control measures. First, users are required to authenticate their identity using either a Gmail or a Discord account.6 Second, we closely monitor user activity logs and take action to ban users who generate NSFW content, use multiple instances of the web app simultaneously, or make judgments at an unreasonably fast pace. Third, we use a list of NSFW phrases to prevent users from generating harmful content. Last, we limit users to 1000 interactions and periodically increase the limit. These measures work in tandem to ensure the integrity and reliability of Pick-a-Pic’s data.
40
+
41
+ Annotation Methodology While piloting the web app, we experimented with different annotation strategies to optimize for data quality, efficiency of collection, and user experience. Specifically, we tested the following annotation options: (1) 4 images, no ties; (2) 2 images, no ties; (3) 2 images,
42
+
43
+ ![](images/6615d8f4afc55088183eb137afcc1688419bf3bcc1608706d11628e7e775d08b.jpg)
44
+
45
+ ![](images/ea1558bc4e7d938d5ae4ce2f4af5efd3fc4bc1d71a13c07ffcd04d4b8da208ec.jpg)
46
+ Figure 3: The Pick-a-Pic dataset enables us to perform model selection (a), and model evaluation (b).
47
+
48
+ (a) Win rate versus classifier-free guidance scale for Stable Diffusion XL (Alpha).
49
+
50
+ (b) Preference distribution when comparing Stable Diffusion 2.1 with Dreamlike Photoreal 2.0.
51
+
52
+ with ties. We found that the latter option (2 images, with ties) exceeds the other two in terms of user engagement and inter-rater agreement.
53
+
54
+ Preprocessing When processing the collected interactions, we filter prompts with NSFW phrases and banned users. We acknowledge that there are still NSFW images and prompts, and will periodically attempt to update the dataset and reduce such occurrences. To divide the dataset into training, validation, and testing subsets, we first sample one thousand prompts, ensuring that each prompt was created by a unique user. Next, we randomly divide those prompts into two sets of equal size to create the validation and test sets. We then sample exactly one example for each prompt to include in these sets. For the training set, we include all examples that do not share a prompt with the validation and test sets. This approach ensures that no split shares prompts with another split, and the validation and test sets do not suffer from being non-proportionally fitted to a specific prompt or user.
55
+
56
+ Statistics Since the creation of the Pick-a-Pic web app we have gathered 968,965 rankings which originated from 66,798 prompts and 6,394 users. However, as the Pick-a-Pic dataset is constantly updating, the reported experiments in this paper involve an NSFW filtered and not fully updated version of Pick-a-Pic, that contains 583,747 training examples, and 500 validation and test examples. The training set of this dataset contains 37,523 prompts from 4,375 distinct users.
57
+
58
+ Model Selection and Evaluation The Pick-a-Pic dataset offers a unique opportunity for a model selection and evaluation methodology, leveraging users’ preferences for unbiased analysis. To illustrate this opportunity, we use the collected data and analyze the impact of changing the classifierfree guidance scale of Stable Diffusion XL (Alpha variant) on its performance. Specifically, we compare human preferences made when both images were generated by Stable Diffusion XL (Alpha variant) but using different classifier-free guidance scales7. For each scale, we compute the win ratio, representing the percentage of judgments where its use led to a preferred image. We also calculate the corresponding tie and lose ratios for each scale, enabling a detailed analysis of which classifier-free guidance scales are more effective. Our results are depicted in Figure 3 (a), and verify for example, that a guidance scale of 9 usually yields preferred images when compared to a guidance scale of 3.
59
+
60
+ Furthermore, by examining user preferences between images generated by different backbone models, we can determine which model is preferred more by users. For instance, considering judgments in which one image was generated by Dreamlike Photoreal 2.0 and the other by Stable Diffusion 2.1, we can evaluate which model is more performant. As shown in fig. 3 (b), users usually prefer Dreamlike Photoreal 2.0 over Stable Diffusion 2.1. We encourage researchers to contact us and include their text-to-image models in the Pick-a-Pic web app for the purpose of model selection and evaluation.
61
+
62
+ # 3 PickScore
63
+
64
+ One valuable outcome from collecting a large, natural dataset of user preferences is that we can use it to train a function that scores the quality of a generated image given a prompt. We train the PickScore scoring function over Pick-a-Pic by combining a CLIP-style model with a variant of
65
+
66
+ InstructGPT’s reward model objective [10]. PickScore is able to predict user preferences in held-out Pick-a-Pic prompts better than any other publicly-available scoring function, surpassing even expert human annotators (Section 4). Such a scoring function can be of value for various scenarios, such as performing model evaluation (Section 5), increasing the quality of generated images via ranking (Section 6), building better large-scale datasets to improve text-to-image models [14], and improving text-to-image models through weak supervision (e.g. RLHF).
67
+
68
+ Model PickScore follows the architecture of CLIP [12]; given a prompt $x$ and an image $y$ , our scoring function $s$ computes a real number by representing $x$ using a transformer text encoder and $y$ using a transformer image encoder as $d$ -dimensional vectors, and returning their inner product:
69
+
70
+ $$
71
+ s ( x , y ) = E _ { \mathrm { t x t } } ( x ) \cdot E _ { \mathrm { i m g } } ( y ) \cdot T
72
+ $$
73
+
74
+ Where $T$ is the learned scalar temperature parameter of CLIP.
75
+
76
+ Objective The input for our objective includes a scoring function $s$ , a prompt $x$ , two images $y _ { 1 } , y _ { 2 }$ , and a preference distribution vector $p$ , which captures the user’s preference over the two images. Specifically, $p$ takes a value of $[ 1 , 0 ]$ if $y _ { 1 }$ is preferred, $[ 0 , 1 ]$ if $y _ { 2 }$ is preferred, or [0.5, 0.5] for ties. Given this input, the objective optimizes the scoring function’s parameters by minimizing the KL-divergence between the preference $p$ and the softmax-normalized scores of $y _ { 1 }$ and $y _ { 2 }$ :
77
+
78
+ $$
79
+ \hat { p } _ { i } = \frac { \exp s ( x , y _ { i } ) } { \sum _ { j = 1 } ^ { 2 } \exp s ( x , y _ { j } ) }
80
+ $$
81
+
82
+ $$
83
+ { L _ { \mathrm { p r e f } } = \sum _ { i = 1 } ^ { 2 } p _ { i } \left( \log p _ { i } - \log \hat { p } _ { i } \right) }
84
+ $$
85
+
86
+ Since many examples can originate from the same prompt, we mitigate the risk of overfitting to a small set of prompts by applying a weighted average when reducing the loss across examples in the batch. Specifically, we weigh each example in the batch, with an inverse proportion to its prompt frequency in the dataset. This objective is analogous to InstructGPT’s reward model objective [10]. We also experiment with incorporating in-batch negatives into the objective, but find that this yields a less accurate scoring function (see Appendix).
87
+
88
+ Training We finetune CLIP-H [7] using our framework8 on the Pick-a-Pic training set. We train the model for 4,000 steps, with a learning rate of 3e-6, a total batch size of 128, and a warmup period of 500 steps, which follows a linearly decaying learning rate; the experiment is completed in less than an hour with 8 A100 GPUs. We did not perform hyperparameter search, which might further improve results. For model selection, we evaluate the model’s accuracy on the validation set (without the option for a tie) in intervals of 100 steps, and keep the best-performing checkpoint.
89
+
90
+ # 4 Preference Prediction
91
+
92
+ We first evaluate PickScore on the task it was trained to do: predict human preferences. We find that PickScore outperforms all other baselines, including expert human annotators.
93
+
94
+ Metric To evaluate the ability of models to predict human preferences, we use an adapted accuracy metric that accounts for the possibility of a tie. Our metric assigns one point to the model for predicting the same label as the user, half a point if either label or prediction is a tie (but not both), and zero otherwise.
95
+
96
+ Tie Threshold Selection Utilizing the notation specified in Section 3, each model requires a tie threshold probability $t$ to predict a tied outcome when $| \hat { p } _ { 1 } - \hat { p } _ { 2 } | < t$ . To achieve this, we evaluate each model on the validation set using various tie threshold probabilities and subsequently determine the most optimal tie threshold for each model. For human experts, we do not perform tie selection and explicitly allow them to select a tie.
97
+
98
+ ![](images/9f2a5b680227fc5555664385601d9d911f6c233975c5110318349257d8bc1246.jpg)
99
+ Figure 4: Disagreement between CLIP-H (left) and PickScore (right) on the Pick-a-Pic validation set. We add green borders around images that humans preferred.
100
+ Table 1: Quantitative results on Pick-a-Pic.
101
+ (a) Accuracy across different tie thresholds on the Pick-a-Pic validation set
102
+
103
+ ![](images/e474fbe1c1382557c67a3e7a78313cb58d48d0b60f497c689608db2e1fdf5502.jpg)
104
+
105
+ <table><tr><td>Model</td><td>Accuracy</td></tr><tr><td>Random Human Expert</td><td>56.8 68.0</td></tr><tr><td>Aesthetics [14]</td><td>56.8</td></tr><tr><td>CLIP-H[7]</td><td>60.8</td></tr><tr><td>ImageReward [18]</td><td>61.1</td></tr><tr><td>HPS [17]</td><td>66.7</td></tr><tr><td>PickScore (Ours)</td><td>70.5</td></tr></table>
106
+
107
+ (b) Performance on the Pick-a-Pic test set.
108
+
109
+ Baselines We compare our model with CLIP-H [7], an aesthetics predictor [14] built on top of CLIP-L [12], a random classifier, and human experts.9 For completeness, we also compare our results with models from concurrent work, namely, HPS [17] and ImageReward [18].
110
+
111
+ Results First, we compare the models’ performance on the validation set across different tie thresholds. Figure 1a shows that PickScore outperforms the baselines across almost all thresholds, and achieves the highest global score by a wide margin. After selecting the best-performing tie threshold for each model, we use the threshold to evaluate the different models on the test set.
112
+
113
+ Table 1b shows that the aesthetics score (56.8) and CLIP-H (60.8) perform closer to a random chance baseline (56.8), while PickScore $( 7 0 . 5 \pm 0 . 1 4 2 ) ^ { 1 0 }$ achieves superhuman performance, as it even outperforms human experts (68.0). It is important to emphasize a core difference between real users that produce the ground truth labels and annotators used to evaluate human performance. The users that produce the ground truth are actual text-to-image users, which have an idea (which may be incomplete) for an image, and invent a prompt (which may lack details) with hope that the resulting image will match their preferences. In contrast, annotators that are used to measure human performance are oblivious to the original user’s context, idea, and motivation. Therefore, superhuman performance on this task means that the model is able to outperform a human annotator that is oblivious to the original user’s context, idea, and motivation. The superhuman performance of PickScore showcases the importance of using real users as ground truth rather than expert annotators when collecting human preferences. Moreover, the relatively modest human performance (68.0) on the task, when compared to a random baseline (56.8), shows that predicting human preferences in text-to-image generation is a difficult task for human annotators.
114
+
115
+ For completeness, we also include the results of concurrent work from HPS [17], which scores 66.7, and ImageReward [18], which scores 61.1; PickScore outperforms both. To further illustrate the differences between CLIP-H and PickScore, we showcase examples of disagreement from the Pick-a-Pic validation set in Figure 4. We notice that PickScore often chooses more aesthetically pleasing images than CLIP-H; at times, at the cost of faithfulness to the prompt.
116
+
117
+ ![](images/99cadb8ca71029811819199799e68e1edea3c264eebdc59f89766d61f322760b.jpg)
118
+ Figure 5: Images generated using the same seed and model, but using different classifier-free guidance (CFG) scales. Even though high guidance scales lead to worse FID, humans usually find them more pleasing than low guidance scales.
119
+
120
+ ![](images/9bb28f42655114880fc91f20aa4cbafa0524ce03842af7ee4cfe0777b4d278be.jpg)
121
+ Figure 6: Correlation between the win ratio of different models according to FID and PickScore to human experts on the MS-COCO validation set.
122
+
123
+ ![](images/10cdad832dac55d51a480b5f014fefed1ddf740d9da2bc0c3e6acb35962baf89.jpg)
124
+ Figure 7: Correlation between Elo ratings of real users and Elo ratings by CLIP-H, ImageReward [18], HPS [17], and PickScore.
125
+
126
+ # 5 Model Evaluation
127
+
128
+ Despite significant progress in the generative capabilities of text-to-image models, the standard and most popular prompt dataset has remained the Microsoft Common Objects in Context dataset (MS-COCO) [9]. Similarly, the Fréchet Inception Distance (FID) [5] is still the main metric used for model evaluation. In this section, we explain why we recommend researchers to evaluate their models using prompts from Pick-a-Pic rather than (or at least alongside) MS-COCO, and show that when evaluating state-of-the-art text-to-image models, PickScore is more aligned with human judgments than other automatic evaluation metrics.
129
+
130
+ Model Evaluation Prompts The prompts contained in the MS-COCO dataset are captions of photographs taken by amateur photographers, depicting objects and humans in everyday settings. While certain captions within this dataset may pose a challenge to text-to-image models, it is evident that the scope of interest for text-to-image users extends beyond commonplace objects and humans. Moreover, the main use-case of image generation is arguably to generate fiction, which cannot be captured by camera. By construction, Pick-a-Pic’s prompts are sampled from real users, and thus better represent the natural distribution of text-to-image intents. We therefore strongly advocate that the research community employ prompts from Pick-a-Pic when assessing the performance of text-to-image models.
131
+
132
+ FID The FID metric [5] gauges the degree of resemblance between a set of generated images and a set of authentic images, at the set level. To do so, it first embeds the real and generated images into the feature space of an Inception net [15], and then estimates the mean and covariance of both sets of images and calculates their similarity. FID is thus geared towards measuring the realism of a set of images, but is oblivious to the prompts. In contrast, PickScore provides a per-instance score, and is directly conditioned on the prompt. We thus hypothesize that PickScore will correlate better with human judgements of generation quality.
133
+
134
+ To empirically test our hypothesis with the most “convenient” settings for the FID metric, we select 100 random captions from MS-COCO validation split. For each caption, we generate images from 9 different models based on the same set of prompts, and ask human experts to rank the 9 generated images (with ties), inducing pairwise preferences. Specifically, we use Stable Diffusion 1.5, Stable Diffusion 2.1, and Dreamlike Photoreal 2.0 combined with three different classifier-free guidance scales (3, 6, and 9). We then repeat the labeling process (over the same images) using FID, and PickScore instead of humans to determine preferences. Since FID does not operate on a per-example base, when “labeling” with FID, we simply choose the model that has a lower (better) FID score on MS-COCO.
135
+
136
+ Figure 6 shows the correlation between model win rates induced by human rankings (horizontal) and model win rates induced by each automatic scoring function. PickScore exhibits a stronger correlation (0.917) with human raters on MS-COCO captions than FID (-0.900), which surprisingly, exhibits a strong negative correlation. As FID is oblivious to the prompt, one would expect zero correlation, and not a strong negative correlation. We hypothesize that this is related to the classifier-free guidance scale hyperparameter – larger scales tend to produce more vivid images (which humans typically prefer), but differ from the distribution of ground truth images in MS-COCO, yielding worse (higher) FID scores. Figure 5 visualizes these differences by presenting pairs of images generated with the same random seed but with different classifier-free guidance (CFG) scales.
137
+
138
+ Other Evaluation Metrics When comparing with evaluation metrics that do not assume a set of ground truth images, we are able to use a more reliable evaluation procedure. In this evaluation procedure, we consider real user preferences rather than human annotators, as well as more models (i.e. more data points). Specifically, we take all the 14,000 collected preferences that correspond to prompts from the Pick-a-Pic test set. This set of examples contains images generated by 45 different models – four different backbone models, each with different guidance scales. We then use these real user preferences to calculate Elo ratings [4] for the different models. Afterward, we repeat the process while replacing the real user preferences with CLIP-H [7], and PickScore predictions. Similarly to Section 4, we also compare against the concurrent work from ImageReward[18] and HPS [17]. Since the Elo rating system is iterative by nature, we repeat the process 50 times. Each time we randomly shuffle the order of examples, and calculate the correlation with human ratings. Finally, for each metric, we output the mean and standard deviation of its 50 corresponding correlations. Figure 7 displays the correlation between real users’ Elo ratings with the different metrics’ rating, showing that PickScore exhibits a stronger correlation $( 0 . 7 9 0 \pm 0 . 0 5 4 )$ with real users than all other automatic metrics, namely CLIP-H $( 0 . 3 1 3 \pm 0 . 0 7 5 )$ , ImageReward $( 0 . 4 9 2 \pm 0 . 0 8 6 )$ , and HPS $( 0 . 6 7 0 \pm 0 . 0 7 1 )$ ).
139
+
140
+ # 6 Text-to-Image Ranking
141
+
142
+ Another possible application for scoring functions is improving the performance of generations made by text-to-image models through ranking: generate a sample of images, and select the one with the highest score. To test this approach, we generate one hundred images for each prompt of the one hundred prompts we take from the Pick-a-Pic test set. We generate the images with Dreamlike Photoreal 2.0, using a classifier-free guidance scale of 7.5, and to increase image diversity, we use 5 initial random noises and 20 different prompt templates. These templates include the null template “[prompt]” and other templates like “breathtaking [prompt]. award-winning, professional, highly detailed”. From each set of 100 generated images, we select the best one according to PickScore, CLIP-H, the aesthetics score, or randomly; in addition, we randomly select one image from the null template for control. We then ask expert human annotators to compare PickScore’s chosen image to each of the other functions’ choices, and decide which one they prefer.
143
+
144
+ Table 2 shows that PickScore consistently selects more preferable images than the baselines. By manually analyzing some examples, we find that PickScore typically selects images that are both more aesthetic and better aligned with the prompt. We also measure this explicitly by using the aesthetic scoring function instead of a human rater when comparing PickScore’s choice to CLIP-H’s, and find that for $6 8 . 5 \%$ of the prompts, PickScore selects an image with a higher aesthetic score. Likewise, when comparing PickScore to the aesthetic scorer, $9 0 . 5 \%$ of PickScore’s choices have a higher CLIP-H text-alignment score than the images chosen by the aesthetic scorer. Figure 8 visualizes the benefits of selecting images with PickScore.
145
+
146
+ Table 2: Percentage of instances where humans prefer PickScore’s choice over another scoring function’s choice when selecting one image out of 100.
147
+
148
+ <table><tr><td>Comparison</td><td>Win Rate</td></tr><tr><td>PickScore vs Random Seed + Null Template</td><td>71.4</td></tr><tr><td>+Random Template</td><td>82.0</td></tr><tr><td>PickScore Vs Aesthetics [14]</td><td>85.1</td></tr><tr><td>PickScore vs CLIP-H [7]</td><td>71.3</td></tr></table>
149
+
150
+ ![](images/57cf2bd40521c1878b141b39dba81f58d1ce5251af5484457054a70b48316035.jpg)
151
+ Figure 8: Comparing the image from the vanilla text-to-image model (left) with the image selected by PickScore from a set of 100 generations (right).
152
+
153
+ # 7 Related Work
154
+
155
+ Collecting and learning from human preferences is an active area of research in natural language processing (NLP) [3, 1, 10]. However, in the domain of text-to-image generation, related research questions have received little attention. One notable work that focuses on collecting human judgments in text-to-image generation is the Simulacra Aesthetic Captions (SAC) dataset [11]. This dataset contains almost 200,000 human ratings of generated images. However, unlike Pick-a-Pic which focuses on general user preferences, and allows users to compare between generated images, the human raters of SAC provide an absolute score for the aesthetic quality of the generated images.
156
+
157
+ There has been some concurrent work that involves collection and learning from human preferences that we describe below. Lee et al. [8] consider three simple categories of challenges (count, color, and background), enumerating through templates (e.g. “[number] dogs”) to synthetically create prompts. Then, they instruct crowd workers to choose if a generated image is good or bad and use the collected 30,000 examples to train a scoring function. In contrast, Pick-a-Pick allows real users to write any prompts they choose, and provide pairwise comparisons between images that yield more than 500,000 examples.
158
+
159
+ ImageReward [18] selects prompts and images from the DiffusionDB dataset [16], and collects for them image preference ratings via crowd workers. Since they employ crowd workers that lack the intrinsic motivation to select images that they prefer, the authors define criteria to assess the quality of generated images and instruct crowd workers to follow these criteria when ranking images. They use this strategy to collect 136,892 examples which originate from 8,878 prompts. Importantly, they have not publicly released this dataset. For completeness, we tested ImageReward on the Pick-a-Pic dataset and confirmed that PickScore outperforms it.
160
+
161
+ Another concurrent work from Wu et al. [17] collects a dataset of human judgments by scraping about 25,000 human ratings (which include about 100,000 images) from the Discord channel of StabilityAI. Similarly to us, they use an objective analogous to that of InstructGPT to train a scoring function that they name Human Preference Score (HPS). As with ImageReward, we evaluated HPS on Pick-a-Pic and saw that PickScore achieves better performance.
162
+
163
+ The observed superior performance of PickScore over the concurrent work from both HPS and ImageReward on the Pick-a-Pic dataset could be attributed to several factors. For example, differences in implementation (e.g., model size, backbone, hyperparameters), differences in the scales of data, or variations in the distribution of data. Notably, Pick-a-Pic is more than five times larger than the data used to train HPS and ImageReward. Furthermore, ImageReward collects judgments from crowd workers, which may lead to significant differences in data distribution. In contrast, HPS scrapes ratings from the StabilityAI discord channel for real text-to-image users but may be more aligned with this more specific distribution of text-to-image users. We leave Isolating and identifying the specific effects of these factors for future work.
164
+
165
+ # 8 Limitations and Broader Impact
166
+
167
+ It is important to acknowledge that despite our efforts to ensure data quality (see section 2), some images and prompts may contain NSFW content that could potentially bias the data, and some users may have made judgments without due care. Moreover, the preferences of users may include biases that may be reflected in the collected data. These limitations may affect the overall quality and reliability of the data collected and should be taken into consideration when considering the broader impact of the dataset. Nonetheless, we believe that the advantages of collecting data from intrinsically-motivated users and publicly releasing it will enable the text-to-image community to better align text-to-image models with human preferences.
168
+
169
+ # 9 Conclusions
170
+
171
+ We build a web application that serves text-to-image users and (willingly) collects their preferences. We use the collected data and present the Pick-a-Pic dataset: an open dataset of over half-a-million examples of text-to-image prompts, generated images, and user-labeled preferences. The quantity and quality of the data enables us to train PickScore, a state-of-the-art text-image scoring function, which achieves superhuman performance when predicting user preferences. PickScore aligns better with human judgements than any other publicly-available automatic metric, and together with Pick-a-Pic’s natural distribution prompts, enables much more relevant text-to-image model evaluation than existing evaluation standards, such as FID over MS-COCO. Finally, we demonstrate the effectiveness of using our scoring function for selecting images in improving the quality of text-to-image models. There are still many opportunities for building upon Pick-a-Pic and PickScore, such as RLHF and other alignment approaches, and we are excited to see how the research community will utilize this work in the near future.
172
+
173
+ # References
174
+
175
+ [1] Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, T. J. Henighan, Nicholas Joseph, Saurav Kadavath, John Kernion, Tom Conerly, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Tristan Hume, Scott Johnston, Shauna Kravec, Liane Lovitt, Neel Nanda, Catherine Olsson, Dario Amodei, Tom B. Brown, Jack Clark, Sam McCandlish, Christopher Olah, Benjamin Mann, and Jared Kaplan. Training a helpful and harmless assistant with reinforcement learning from human feedback. ArXiv, abs/2204.05862, 2022.
176
+ [2] Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollár, and C. Lawrence Zitnick. Microsoft coco captions: Data collection and evaluation server. ArXiv, abs/1504.00325, 2015.
177
+ [3] Paul Francis Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. ArXiv, abs/1706.03741, 2017.
178
+ [4] Arpad E. Elo. The rating of chessplayers, past and present. 1978.
179
+
180
+ [5] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In NIPS, 2017.
181
+
182
+ [6] Jonathan Ho. Classifier-free diffusion guidance. ArXiv, abs/2207.12598, 2022. [7] Gabriel Ilharco, Mitchell Wortsman, Ross Wightman, Cade Gordon, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip, July 2021. If you use this software, please cite it as below. [8] Kimin Lee, Hao Liu, Moonkyung Ryu, Olivia Watkins, Yuqing Du, Craig Boutilier, P. Abbeel, Mohammad Ghavamzadeh, and Shixiang Shane Gu. Aligning text-to-image models using human feedback. ArXiv, abs/2302.12192, 2023. [9] Tsung-Yi Lin, Michael Maire, Serge J. Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C. Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, 2014.
183
+ [10] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke E. Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Francis Christiano, Jan Leike, and Ryan J. Lowe. Training language models to follow instructions with human feedback. ArXiv, abs/2203.02155, 2022.
184
+ [11] John David Pressman, Katherine Crowson, and Simulacra Captions Contributors. Simulacra aesthetic captions. Technical Report Version 1.0, Stability AI, 2022. url https://github.com/JD-P/simulacraaesthetic-captions .
185
+ [12] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, 2021.
186
+ [13] Robin Rombach, A. Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 10674–10685, 2021.
187
+ [14] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade W Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, Patrick Schramowski, Srivatsa R Kundurthy, Katherine Crowson, Ludwig Schmidt, Robert Kaczmarczyk, and Jenia Jitsev. LAION-5b: An open large-scale dataset for training next generation image-text models. In Thirty-sixth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2022.
188
+ [15] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2818–2826, 2015.
189
+ [16] Zijie J. Wang, Evan Montoya, David Munechika, Haoyang Yang, Benjamin Hoover, and Duen Horng Chau. Diffusiondb: A large-scale prompt gallery dataset for text-to-image generative models. ArXiv, abs/2210.14896, 2022.
190
+ [17] Xiaoshi Wu, Keqiang Sun, Feng Zhu, Rui Zhao, and Hongsheng Li. Better aligning text-to-image models with human preference. ArXiv, abs/2303.14420, 2023.
191
+ [18] Jiazheng Xu, Xiao Liu, Yuchen Wu, Yuxuan Tong, Qinkai Li, Ming Ding, Jie Tang, and Yuxiao Dong. Imagereward: Learning and evaluating human preferences for text-to-image generation. ArXiv, abs/2304.05977, 2023.
192
+
193
+ # Appendix
194
+
195
+ # Comparing Pick-a-Pic Prompts with MS-COCO Captions
196
+
197
+ To illustrate the difference between MS-COCO captions and Pick-a-Pic prompts we show prompts from each dataset.
198
+
199
+ Pick-a-Pic – “forest with ruins, photo”, “A panda bear as a mad scientist”, “product photo of a sneakers”, “photo of a bicycle, detailed, 8k uhd, dslr, high quality, film grain, Fujifilm XT3”, “female portrait photo”, “Alexander the great, cover art, colorful”, “A galactic eldritch squid towering over the planet Earth, stars, galaxies and nebulas in the background...”, “Portrait of a giant, fluffy, ninja teddy bear”, “insanely detailed portrait, darth vader, shiny, extremely intricate, high res, 8k, award winning”, “Giant ice cream cone melting and creating a river through a city”.
200
+
201
+ MS-COCO – “A man with a red helmet on a small moped on a dirt road.”, “A woman wearing a net on her head cutting a cake.”, “there is a woman that is cutting a white cake”, “a little boy wearing headphones and looking at a computer monitor”, “A young girl is preparing to blow out her candle.”, “A commercial stainless kitchen with a pot of food cooking.”, “Two men that are standing in a kitchen.”, “A man riding a bike past a train traveling along tracks.”, “The pantry door of the small kitchen is closed.”, “A man is doing a trick on a skateboard”.
202
+
203
+ # Training a Scoring Function
204
+
205
+ We further explored an alternative loss function that is closer to CLIP’s original objective. In this loss function, we also incorporate the remaining examples in the batch as in-batch negatives. To elaborate, considering the notation established in section 3 and $y _ { 1 } ^ { k } , y _ { 2 } ^ { k }$ denoting the images corresponding to the $k$ -th example in the batch, we formulate $\hat { p } ^ { k }$ as follows:
206
+
207
+ $$
208
+ \hat { p } _ { i } ^ { k } = \frac { \exp { s ( x , y _ { i } ) } } { \sum _ { k } \sum _ { j = 1 } ^ { 2 } \exp { s ( x , y _ { j } ^ { k } ) } }
209
+ $$
210
+
211
+ We anticipated that this objective function would maintain the general capabilities of CLIP with minimal loss in performance. However, our findings demonstrated that PickScore significantly outperforms this objective function, as the latter only produced a scoring function that achieves an accuracy of 65.2 on the Pick-a-Pic test set.
md/dev/GLA4ablO3M/GLA4ablO3M.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/K10zWxlEGI/K10zWxlEGI.md ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Expressive dynamics models with nonlinear injective readouts enable reliable recovery of latent features from neural activity
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 The advent of large-scale neural recordings has enabled new approaches that
11
+ 2 aim to discover the computational mechanisms of neural circuits by understand
12
+ 3 ing the rules that govern how their state evolves over time. While these neural
13
+ 4 dynamics cannot be directly measured, they can typically be approximated by
14
+ 5 low-dimensional models in a latent space. How these models represent the map
15
+ 6 ping from latent space to neural space can affect the interpretability of the latent
16
+ 7 representation. Typical choices for this mapping (e.g., linear layer or MLP) lack the
17
+ 8 property of injectivity, meaning that changes in latent state may have no effect on
18
+ 9 neural activity. During training, non-injective readouts incentivize the invention of
19
+ 10 dynamics that misrepresent the underlying system and the computation it performs.
20
+ 11 Combining our injective Flow readout with prior work on interpretable latent dy
21
+ 12 namics models, we created the Ordinary Differential equations autoencoder with
22
+ 13 Injective Nonlinear readout (ODIN), which learns to capture latent dynamical
23
+ 14 systems that are nonlinearly embedded into observed neural firing rates via an
24
+ 15 approximately injective nonlinear mapping. We show that ODIN can recover non
25
+ 16 linearly embedded systems from simulated neural activity, even when the nature of
26
+ 17 the system and embedding are unknown. Additionally, we show that ODIN enables
27
+ 18 the unsupervised recovery of underlying dynamical features (e.g., fixed-points) and
28
+ 19 embedding geometry. When applied to biological neural recordings, ODIN can
29
+ 20 reconstruct neural activity with comparable accuracy to previous state-of-the-art
30
+ 21 methods while using substantially fewer latent dimensions. Overall, ODIN’s accu
31
+ 22 racy in recovering ground-truth latent features and ability to accurately reconstruct
32
+ 23 neural activity with low dimensionality make it a promising method for distilling
33
+ 24 interpretable dynamics that can help explain neural computation.
34
+
35
+ # 25 1 Introduction
36
+
37
+ 26 Recent evidence has shown that when artificial recurrent neural networks are trained to perform
38
+ 27 tasks, the rules that govern how the internal activity evolves over time (i.e., the network dynamics)
39
+ 28 can provide insight into how the network performs the underlying computation [1–4]. Given the
40
+ 29 conceptual similarities between artificial neural networks and biological neural circuits, it may be
41
+ 30 possible to apply these same dynamical analyses to brain activity to gain insight into how neural
42
+ circuits perform complex sensory, cognitive, and motor processes [5–7]. However, unlike in artificial
43
+ 32 networks, we cannot easily interrogate the dynamics of biological neural circuits and must instead
44
+ 33 estimate them from observed neural activity.
45
+ 34 Fortunately, advances in recording technology have dramatically increased the number of neurons
46
+ 35 that can be simultaneously recorded, providing ample data for novel population-level analyses of
47
+ 36 neural activity [8–10]. In these datasets, the activity of hundreds or thousands of neurons can often
48
+ 37 be captured by relatively low-dimensional subspaces [11], orders-of-magnitude smaller than the total
49
+ 38 number of neurons. Neural activity in these latent spaces seems to evolve according to consistent sets
50
+ 39 of rules (i.e., latent dynamics) [12, 6]. Assuming no external inputs, these rules can be expressed
51
+ 40 mathematically as:
52
+
53
+ $$
54
+ \begin{array} { r } { \mathbf { z } _ { t + 1 } = \mathbf { z } _ { t } + f ( \mathbf { z } _ { t } ) } \\ { \mathbf { y } _ { t } = \exp { g ( \mathbf { z } _ { t } ) } } \\ { \mathbf { x } _ { t } \sim \mathrm { P o i s s o n } ( \mathbf { y } _ { t } ) } \end{array}
55
+ $$
56
+
57
+ 41 where $\mathbf { z } _ { t } \in \mathbb { R } ^ { D }$ represents the latent state at time $t$ , $f ( \cdot ) : \mathbb { R } ^ { D } \mathbb { R } ^ { D }$ is the vector field governing the
58
+ 42 dynamical system, $\mathbf { y } _ { t } \in \mathbb { R } ^ { N }$ denotes the firing rates of the $N$ neurons, $g ( \cdot ) : \mathbb { R } ^ { D } \to \mathbb { R } ^ { \breve { N } }$ maps latent
59
+ 43 activity into log-firing rates, and $\mathbf { x } _ { t } \in \mathbb { R } ^ { N }$ denotes the observed spike counts at time $t$ , assuming the
60
+ 44 spiking activity follows a Poisson distribution with time-varying rates given at each moment $t$ by $\mathbf { y } _ { t }$
61
+ 45 Unfortunately, any latent system can be equivalently described by many combinations of dynamics $f$
62
+ 46 and embeddings $g$ , which makes the search for a unique latent system futile. However, versions of a
63
+ 47 latent system’s dynamics $f$ and embedding $g$ that are less complex and use fewer latent dimensions
64
+ 48 can be much easier to interpret than alternative representations that are more complex and/or higher
65
+ 49 dimensional. Models of latent dynamics that can discover simple and low-dimensional representations
66
+ 50 will make it easier to link latent dynamics to neural computation.
67
+ 51 A popular approach to estimate neural dynamics [13–15] is to use neural population dynamics models
68
+ 52 (NPDMs), which model neural activity as a latent dynamical system embedded into neural activity.
69
+ 53 We refer to the components of an NPDM that learn the dynamics and embedding as the generator $\hat { f }$
70
+ 54 and the readout $\hat { g }$ , respectively. When modeling neural activity, the generator and readout are jointly
71
+ 55 trained to infer firing rates $\hat { \mathbf { y } }$ that maximize the likelihood of the observed neural activity $\mathbf { x }$ .
72
+ 56 Using NPDMs to estimate underlying dynamics and embedding implicitly assumes that good recon
73
+ 57 struction performance (i.e., $\hat { x } \approx x$ ) implies interpretable estimates of the underlying system (i.e.,
74
+ 58 $\approx z , { \hat { f } } \approx f , { \hat { g } } \approx g )$ . However, recent work has shown that when the state dimensionality of
75
+ 59 the generator $\hat { D }$ is larger than a system’s latent dimensionality $D$ , high reconstruction performance
76
+ 60 may actually correspond to estimates of the latent system that are overly complex or misleading
77
+ 61 and therefore harder to interpret [15]. Thus at present, reconstruction performance is seemingly an
78
+ 62 unreliable indicator for the interpretability of the learned dynamics.
79
+ 63 This vulnerability to learning overly complex latent features might come from the fact that, in general,
80
+ 64 changes in the latent state are not obligated to have an effect on predicted neural activity. Thus,
81
+ 65 NPDMs can be rewarded for inventing latent activity that boosts reconstruction performance, even if
82
+ 66 that latent activity has no direct correspondence to the neural activity. A potential solution is to make
83
+ 67 the readout $\hat { g }$ injective, which obligates all latent activity to affect neural reconstruction. This would
84
+ 68 penalize any latent activity that is not reflected in the observed neural activity and puts pressure on
85
+ 69 the generator $\hat { f }$ and readout $\hat { g }$ to learn a more interpretable (i.e., simpler and lower dimensional)
86
+ 70 representation of the underlying system.
87
+ 71 In addition, most previously used readouts $\hat { g }$ were not expressive enough to model diverse mappings
88
+ 72 from latent space to neural space, assuming the embedding $g$ to be a relatively simple (often linear)
89
+ 73 transformation (though there are exceptions [16–18]). Capturing nonlinear embeddings is important
90
+ 74 because neural activity often lives on a lower-dimensional manifold that is nonlinearly embedded
91
+ 75 into the higher-dimensional neural space [7]. Therefore, assumptions of linearity are likely to prevent
92
+ 76 NPDMs from capturing dynamics in their simplest and lowest-dimensional form, making them less
93
+ 77 interpretable than the latent features learned by NPDMs that can approximate these nonlinearities.
94
+ 78 To address these challenges, we propose a novel architecture called the Ordinary Differential equa
95
+ 79 tion autoencoder with Injective Nonlinear readout (ODIN), which implements $\hat { f }$ using a Neural
96
+ 80 ODE (NODE [19]) and $\hat { g }$ using a network inspired by invertible ResNets [20–22, 19, 23]. ODIN
97
+ 81 approximates an injective nonlinear mapping between latent states and neural activity, obligating all
98
+ 82 latent state variance to appear in the predicted neural activity and penalizing the model for inventing
99
+ 83 excessively complex or high-dimensional dynamics. On synthetic data, ODIN learns representations
100
+ 84 of the latent system that are more interpretable, with simpler and lower-dimensional latent activity and
101
+ 85 dynamical features (e.g., fixed-points) than alternative readouts. ODIN’s interpretability is also more
102
+ 86 robust to overestimates of latent dimensionality and can recover the nonlinear embedding of synthetic
103
+ 87 data that evolves on a simulated manifold. When applied to neural activity from a monkey performing
104
+ 88 a reaching task with obstacles, ODIN reconstructs neural activity comparably to state-of-the-art
105
+ 89 recurrent neural network (RNN)-based models while requiring far fewer latent state dimensions.
106
+ 90 In summary, ODIN estimates interpretable latent features from synthetic data and can reconstruct
107
+ 91 biological neural recordings with high accuracy, making it a promising tool for understanding how
108
+ 92 the brain performs computation.
109
+
110
+ # 2 Related Work
111
+
112
+ 94 Many previous models have attempted to understand neural activity through the lens of neural
113
+ 95 dynamics. Early efforts limited model complexity by constraining both $\hat { f }$ and $\hat { g }$ to be linear [24–26].
114
+ 96 While these models were relatively straightforward to analyze, they often failed to adequately explain
115
+ 97 neural activity patterns [27].
116
+ 98 Other approaches increased the expressiveness of the modeled dynamics $\hat { f }$ . RNNs can learn to
117
+ 99 approximate complex nonlinear dynamics, and have been shown to substantially outperform linear
118
+ 100 dynamics models in reconstructing neural activity [27]. Unfortunately, RNNs implicitly couple the
119
+ 101 capacity of the model to the latent state dimensionality, meaning their ability to model complex
120
+ 102 dynamics relies on having a high-dimensional latent state. In contrast, NODEs can model arbitrarily
121
+ 103 complex dynamics of embedded dynamical systems at the dimensionality of the system [19, 15].
122
+ 104 On synthetic data, NODEs have been shown to recover dynamics more accurately than RNN
123
+ 105 based methods [28, 15]. In contrast to our approach, previous NODE-based models used a linear
124
+ 106 readout $\hat { g }$ that lacks injectivity. This can make the accuracy of estimated latent activity vulnerable
125
+ 107 to overestimates of the latent dimensionality (i.e., when $\dot { \hat { D } } > D _ { \ast } ^ { \ast }$ ) and/or fail to capture potential
126
+ 108 nonlinearities in the embedding $g$ .
127
+ 109 Early efforts to allow greater flexibility in $\hat { g }$ preserved linearity in $\hat { f }$ , using feed-forward neural
128
+ 110 networks to nonlinearly embed linear dynamical systems in high-dimensional neural firing rates
129
+ 111 [16]. More recently, models have used Gaussian Processes to approximate nonlinear mappings
130
+ 112 from latent state to neural firing with tuning curves [17]. Other models have combined nonlinear
131
+ 113 dynamics models and nonlinear embeddings for applications in behavioral tracking [29] and neural
132
+ 114 reconstruction [18]. Additional approaches extend these methods to incorporate alternative noise
133
+ 115 models that may better reflect the underlying firing properties of neurons [16, 30]. While nonlinear,
134
+ 116 the readouts of these models lacked injectivity in their mapping from latent activity to neural activity.
135
+ 117 Many alternative models seek to capture interpretable latent features of a system from observations.
136
+ 118 One popular approach uses a sparsity penalty on a high-dimensional basis set to derive a sparse
137
+ 119 symbolic estimate of the governing equations for the system [31]. However, it is unclear whether
138
+ 120 such sparse symbolic representation is necessarily a benefit when modeling dynamics in the brain.
139
+ 121 Another recent model uses contrastive loss and auxiliary behavioral variables to learn low-dimensional
140
+ 122 representations of latent activity [32]. This approach does not have an explicit dynamics model,
141
+ 123 however, so is not amenable to the dynamical analyses performed in this manuscript.
142
+ 124 Normalizing flows – a type of invertible neural network – have recently become a staple for generative
143
+ 125 modeling and density estimation [20, 23]. Some latent variable models have used invertible networks
144
+ 126 to approximate the mapping from the latent space to neural activity [33] or for generative models of
145
+ 127 visual cortex activity [34]. To allow this mapping to change dimensionality between the latent space
146
+ 128 and neural activity, some of these models used a zero-padding procedure similar to the padding used
147
+ 129 in this manuscript (see Section 3.3.1), which makes the transformation injective rather than invertible
148
+ 130 [33, 23]. However, these previous approaches did not have explicit dynamics models, making our
149
+ 131 study, to our knowledge, the first to test whether injective readouts can improve the interpretability of
150
+ 132 neural population dynamics models.
151
+
152
+ # 3 Methods
153
+
154
+ # 3.1 Synthetic Neural Data
155
+
156
+ To determine whether different models can distill an interpretable latent system from observed population activity, we first used reference datasets that were generated using simple ground-truth dynamics $f$ and embedding $g$ . Our synthetic test cases emulate the empirical properties of neural systems, specifically low-dimensional latent dynamics observed through noisy spiking activity [13, 35– 37]. We sampled latent trajectories from the Arneodo system ( $f$ , $D = 3$ ) and nonlinearly embedded these trajectories into neural activity via an embedding $g$ . We consider models that can recover the dynamics $f$ and embedding $g$ used to generate these data as providing an interpretable description of
157
+
158
+ ![](images/eab634284f324d8289edcca3712cdf4c394d49ced98bd8c14c03b34f7b694c84.jpg)
159
+ Figure 1: A) Synthetic neural data generation (left to right). Trajectories from the Arneodo system are projected onto random encoding vectors to compute activations at each timepoint. A scaled sigmoid nonlinearity is applied to convert the activations into firing rates. B) Zero-padded latent dynamics (green) are reversibly warped into higher-dimensional neural activity space (blue). C) The Flow readout maps from latent space to neural space by applying a sequence of $K$ small updates (parameterized by an MLP, bottom). Reverse pass maps from neural space to latent space and is implemented by serial subtraction of updates from the same MLP.
160
+
161
+ 142 the latent system and its relation to the neural activity. Additional detail on data generation, models,
162
+ 143 and metrics can be found in the Supplementary Material.
163
+ 144 We generated activations for $N$ neurons $N = 1 2$ ) by projecting the simulated latent trajectories $\mathbf { Z }$
164
+ 145 through a $3 \times N$ matrix whose columns were random encoding vectors with elements sampled from a
165
+ 146 uniform distribution $U [ - 0 . 5 , 0 . 5 ]$ (Fig. 1A, left). We standardized these activations to have zero mean
166
+ 147 and unit variance and applied a different scaled sigmoid function to each neuron, yielding a matrix of
167
+ 148 non-negative time-varying firing rates $\mathbf { Y }$ . The scaling of each sigmoid function was evenly spaced on
168
+ 149 a logarithmic scale between $1 0 ^ { \overline { { 0 . 2 } } }$ and 10. This process created a diverse set of activation functions
169
+ 150 ranging from quasi-linear to nearly step-function-like behavior (Fig. 1A, Activation Functions).
170
+ 151 We simulated spiking activity $\mathbf { X }$ by sampling from inhomogeneous Poisson processes with time
171
+ 152 varying rate parameters equal to the firing rate $\mathbf { Y }$ of the simulated neurons (Fig. 1A, right). We
172
+ 153 randomly split 70-point segments of these trials into training and validation datasets (training and
173
+ 154 validation proportions were 0.8 and 0.2, respectively).
174
+
175
+ # 3.2 Biological Neural Data
176
+
177
+ We evaluated how well our model could reconstruct biological neural activity on a well-characterized dataset [38] included in the Neural Latents Benchmark (NLB) [27]. This dataset is composed of single-unit recordings from primary and pre-motor cortices of a monkey performing a visually-guided reaching task with obstacles, referred to as the Maze task. Trials were trimmed to the window [-250, 350] ms relative to movement onset, and spiking activity was binned at $2 0 ~ \mathrm { m s }$ . To compare the reconstruction performance of our model directly against the benchmark, we split the neural activity into held-in and held-out neurons, comprising 137 and 35 neurons, respectively, using the same sets of neurons as were used to assess models for the NLB leaderboard.
178
+
179
+ # 3.3 Model Architecture
180
+
181
+ We used three sequential autoencoder (SAE) variants in this study, with the main difference being the choice of readout module, ${ \hat { g } } ( \cdot )$ . In brief, a sequence of binned spike counts $\mathbf { x } _ { \mathrm { 1 : } T }$ was passed through a bidirectional GRU encoder, whose final hidden states were converted to an initial condition $\hat { \mathbf { z } } _ { 0 }$ via a mapping $\phi ( \cdot )$ . A modified NODE generator unrolled the initial condition into time-varying latent states $\hat { \mathbf { z } } _ { 1 : T }$ . These were subsequently mapped to inferred rates via the readout ${ \hat { g } } ( \cdot ) \in$ {Linear, MLP, Flow $\}$ . All models were trained for a fixed number of epochs to infer firing rates $\hat { \mathbf { y } } _ { 1 : T }$ that minimize the negative Poisson log-likelihood of the observed spikes $\mathbf { x } _ { 1 : T }$ .
182
+
183
+ $$
184
+ \begin{array} { r l } & { \mathbf { h } _ { T } = \left[ \mathbf { h } _ { f w d } \middle | \mathbf { h } _ { b w d } \right] = \mathrm { B i G R U } ( \mathbf { x } _ { 1 : T } ) } \\ & { \qquad \hat { \mathbf { z } } _ { 0 } = \phi ( \mathbf { h } _ { T } ) } \\ & { \qquad \hat { \mathbf { z } } _ { t + 1 } = \hat { \mathbf { z } } _ { t } + \boldsymbol { \alpha } \cdot \mathbf { M } \mathbf { L } \mathbf { P } ( \hat { \mathbf { z } } _ { t } ) } \\ & { \qquad \hat { \mathbf { y } } _ { t } = \exp \hat { g } ( \hat { \mathbf { z } } _ { t } ) } \end{array}
185
+ $$
186
+
187
+ 172 For models with Linear and MLP readouts, $\phi ( \cdot )$ was a linear map to $\mathbb { R } ^ { \hat { D } }$ . For models with Flow
188
+ 173 readouts, $\phi ( \cdot )$ was a linear map to $\mathbb { R } ^ { N }$ followed by the reverse pass of the Flow (see Section 3.3.1).
189
+ 174 We unrolled the NODE using Euler’s method with a fixed step size equal to the bin width and trained
190
+ 175 using standard backpropagation for efficiency. A scaling factor $( \alpha = 0 . 1$ ) was applied to the output
191
+ 176 of the NODE’s MLP to stabilize the dynamics during early training. Readouts were implemented as
192
+ 177 either a single linear layer (Linear), an MLP with two 150-unit ReLU hidden layers (MLP), or a Flow
193
+ 178 readout (Flow) which contains an MLP with two 150-unit ReLU hidden layers. We refer to these
194
+ 179 three models as Linear-NODE, MLP-NODE, and ODIN, respectively.
195
+
196
+ # 3.3.1 Flow Readout
197
+
198
+ 181 The Flow readout resembles a simplified invertible ResNet [23]. Flow learns a vector field that can
199
+ 182 reversibly transform data between latent and neural representations (Figure 1B). The Flow readout
200
+ 183 has three steps: first, we increase the dimensionality of the latent activity $\mathbf { z } _ { t }$ to match that of the
201
+ 184 neural activity by padding the latent state with zeros. This corresponds to an initial estimate of
202
+ 185 the log-firing rates, $\log \hat { \mathbf { y } } _ { t , 0 }$ . Note that zero-padding makes our mapping injective rather than fully
203
+ 186 invertible (see [33, 23]). The Flow network then uses an MLP to iteratively refine $\log \hat { \mathbf y } _ { t , k }$ over $K$
204
+ 187 steps $K = 2 0$ ) after which we apply an exponential to produce the final firing rate predictions, $\hat { \mathbf { y } } _ { t }$ .
205
+ 188 A scaling factor $( \beta = 0 . 1 $ ) was applied to the output of the Flow’s MLP to stabilize the dynamics
206
+ 189 during early training.
207
+
208
+ $$
209
+ \begin{array} { c } { \log \hat { { \mathbf { y } } } _ { t , 0 } = [ \hat { { \mathbf { z } } } _ { t } | \mathbf { 0 } ] ^ { T } } \\ { \log \hat { { \mathbf { y } } } _ { t , k + 1 } = \log \hat { { \mathbf { y } } } _ { t , k } + \beta \cdot \operatorname { M L P } ( \log \hat { { \mathbf { y } } } _ { t , k } ) } \\ { \hat { g } \left( \hat { { \mathbf { z } } } _ { t } \right) = \log \hat { { \mathbf { y } } } _ { t , K } = \log \hat { { \mathbf { y } } } _ { t } } \end{array}
210
+ $$
211
+
212
+ 190 We also use the approximate inverse of the Flow to transform the output of the encoders to initial
213
+ 191 conditions in the latent space via $\phi ( \cdot )$ . We approximate the inverse using a simplified version of
214
+ 192 the fixed-point iteration procedure described in [23]. Our method subtracts the output of the MLP
215
+ 193 from the state rather than adding it as in the forward mode (Fig 1C). From here, we trim the excess
216
+ 194 dimensions to recover $\hat { z } \in \mathbb { R } ^ { \hat { D } }$ (in effect, removing the zero-padding dimensions).
217
+
218
+ $$
219
+ \begin{array} { r l } & { \log \hat { \mathbf { y } } _ { t , k - 1 } = \log \hat { \mathbf { y } } _ { t , k } - \boldsymbol { \beta } \cdot \mathbf { M } \mathbf { L } \mathbf { P } ( \log \hat { \mathbf { y } } _ { t , k } ) } \\ & { \hat { \boldsymbol { g } } ^ { - 1 } \left( \log \hat { \mathbf { y } } _ { t } \right) = [ \log \hat { y } _ { t , 0 , 1 } , \dots , \log \hat { y } _ { t , 0 , \hat { D } } ] ^ { T } = \hat { \mathbf { z } } _ { t } } \end{array}
220
+ $$
221
+
222
+ 195 The Flow mapping is only guaranteed to be injective if changes in the output of the MLP are
223
+ 196 sufficiently small relative to changes in the input (i.e., Lipschitz constants for the MLP that is
224
+ 197 strictly less than 1) [23]. The model can be made fully injective by either restricting the weights
225
+ 198 of the MLP (e.g., spectral norm [39]), or using a variable step-size ODE solver that can prevent
226
+ 199 crossing trajectories (e.g., continuous normalizing flows [19]. In practice, we found that using a
227
+ 200 moderate number of steps allows Flow to preserve approximate injectivity of the readout at all tested
228
+ 201 dimensionalities (Supp. Fig. 1).
229
+
230
+ # 3.4 Metrics and characterization of dynamics
231
+
232
+ 203 All metrics were evaluated on validation data. Reconstruction performance for the synthetic data was
233
+ 204 assessed using two key metrics. The first, spike negative log-likelihood (Spike NLL), was defined
234
+ 205 as the Poisson NLL employed during model training. The second, Rate $\dot { R } ^ { \hat { 2 } }$ , was the coefficient of
235
+ 206 determination between the inferred and true firing rates, averaged across neurons. We used Spike
236
+ 207 NLL to assess how well the inferred rates explain the spiking activity, while Rate $R ^ { 2 }$ reflects the
237
+ 208 model’s ability to find the true firing rates. These metrics quantify how well the model captures
238
+ 209 the embedded system’s dynamics (i.e., that $\hat { f }$ captures the system described by $f$ ), but give no
239
+ 210 indication of the interpretability of the learned latent representation (i.e., that the learned $\hat { f }$ is simple
240
+ 211 and low-dimensional).
241
+ 212 To assess the interpretability of the latent activity inferred by the model $\hat { z }$ , we used a previously
242
+ 213 published metric called the State $R ^ { 2 }$ [15]. State $R ^ { 2 }$ is defined as the coefficient of determination $( R ^ { 2 } )$
243
+ 214 of a linear regression from simulated latent trajectories $z$ to the inferred latent trajectories $\hat { z }$ . State $R ^ { 2 }$
244
+ 215 will be low if the inferred latent trajectories contain features that cannot be explained by an affine
245
+ 216 transformation of the true latent trajectories. We use this to assess the degree to which models can
246
+ 217 preserve the simplicity and low dimensionality of the embedded dynamics, thereby maintaining an
247
+ 218 interpretable latent representation. Together, high Rate $R ^ { 2 }$ and State $R ^ { 2 }$ indicate that the modeled
248
+ 219 latent activity reflects the simulated latent dynamics without inventing extra features that make the
249
+ 220 model harder to interpret (i.e., $\hat { z } \approx z$ ).
250
+ 221 As a direct comparison of the estimated dynamics $\hat { f }$ to the simulated dynamics $f$ , we extracted
251
+ 222 the fixed-point (FP) structure from our trained models and compared it to the FP structure of the
252
+ 223 underlying system. We used previously published FP-finding techniques [40] to identify regions of
253
+ 224 the generator’s dynamics where the magnitude of the vector field was close to zero, calling this set of
254
+ 225 locations the putative FPs. We linearized the dynamics around the FPs and computed the eigenvalues
255
+ 226 of the Jacobian of $\hat { f }$ to characterize each FP. Capturing FP location and character gives an indication
256
+ 227 of how closely the estimated dynamics resemble the simulated dynamics (i.e., $\hat { f } \approx f .$ ).
257
+ 228 To determine how well our embedding $\hat { g }$ captures the simulated embedding $g$ , we projected the
258
+ 229 encoding vectors used to generate the synthetic neural activity from the ground-truth system into our
259
+ 230 model’s latent space using the same affine transformation from ground-truth latent activity to inferred
260
+ 231 latent activity as was used to compute State $R ^ { 2 }$ . We projected the inferred latent activity onto each
261
+ 232 neuron’s affine-transformed encoding vector to find the predicted activation of each synthetic neuron.
262
+ 233 We then related the predicted firing rates of each neuron to its corresponding activations to derive
263
+ 234 an estimate of each neuron’s activation function. Because the inferred latent activity is arbitrarily
264
+ 235 scaled/translated relative to the true latent activity, we fit an affine transformation from the predicted
265
+ 236 activation function to the ground-truth activation function. The coefficient of determination $R ^ { 2 }$ of
266
+ 237 this fit quantifies how well our models were able to recover the synthetic warping applied to each
267
+ 238 neuron (i.e., $\hat { g } \approx g ,$ ).
268
+ 39 For the biological neural data, we measured model performance using two metrics from the Neural
269
+ 40 Latents Benchmark (NLB) [27], co-smoothing bits-per-spike (co-bps) and velocity decoding perfor
270
+ 41 mance on predicted firing rates $( \mathrm { V e l } R ^ { 2 } )$ . co-bps quantifies how well the model predicts the spiking of
271
+ 42 the held-out neurons, while Vel $R ^ { 2 }$ quantifies how well the denoised rates can predict the monkey’s
272
+ 43 hand velocity during the reach. We compare these metrics to models from the NLB leaderboard. Of
273
+ 44 note, models submitted to NLB are assessed by their performance on a hidden test set, while our
274
+ 45 model performance is computed on the validation data.
275
+
276
+ ![](images/4743073dde04bdb3113d5ce870ac0ca0526123e0b64702df1ef45b7313d71489.jpg)
277
+ Figure 2: Flow-NODE (ODIN) recovers latent activity more accurately than alternative models and is robust to overestimates of latent dimensionality. A) Diagram of model readouts tested, including Linear (green), Flow (red), MLP (orange). B) Inferred latent activity of representative model at each state dimensionality $\hat { D }$ . True latent activity (affine-transformed to overlay inferred latent activity) shown in light blue. C) All: Model metrics as a function of $\hat { D }$ . Shaded areas represent one standard deviation around the mean. Dashed vertical line indicates $\hat { D } = 3$ Top: Spike NLL, Middle: Rate $R ^ { 2 }$ , Bottom: State $R ^ { 2 }$ .
278
+
279
+ # 4 Results
280
+
281
+ # 4.1 Finding interpretable latent activity across state dimensionalities with ODIN
282
+
283
+ We began by training Linear-, MLP-, and Flow-NODEs (i.e., ODIN) (Fig 2A) to reconstruct synthetic neural activity from the Arneodo system [41] and compared reconstruction performance (i.e. Spike NLL and Rate $R ^ { 2 }$ ) and latent recovery (i.e. State $R ^ { 2 }$ ) as functions of the dimensionality $\hat { D }$ of the state space. We trained 5 different random seeds for each of the 3 model types and 5 state dimensionalities (75 total models, model hyperparameters in Supp. Table 1). First, we observed that the Linear-NODE learned latent states that did not closely resemble the simulated latent activity, with all tested dimensionalities performing worse than either the Flow or the MLP readout at $\hat { D } = \hat { 3 }$ (Fig 2B,C, mean State $R ^ { 2 } = 0 . { \dot { 7 } } 0$ for Linear vs. 0.89, 0.93 for MLP, Flow respectively). We also found that Linear-NODE required many more dimensions to reach the peak reconstruction performance (Fig 2C, Rate $R ^ { 2 }$ ). These results demonstrate that models that are unable to account for nonlinear embeddings are vulnerable to learning more complex and higher dimensional dynamics than those learned by models with nonlinear readouts.
284
+
285
+ ![](images/8e84513312f8a476088dda91ed20fa266a0a975070fd466e3887de0debc32baf.jpg)
286
+ Figure 3: Flow-NODE (ODIN) recovers fixed-point properties accurately at the correct dimensionality. A,B) Representative latent activity and fixed-points from the true (blue, ◦), ODIN (red, $\times )$ ), and Linear (green, $+$ ) systems. Each fixed point is labeled with reference to C. C) Plots of the real vs. imaginary part of the eigenvalues of the Jacobian evaluated at each fixed point. Unit circle in the complex plane (black curve) shows boundary between attractive and repulsive behavior (the attractive and repulsive sides of the boundary are indicated by inset).
287
+
288
+ Next, we compared ODIN to MLP-NODE and found that at the correct dimensionality $\hat { D } = 3 \AA$ ), these models had similar performance for both reconstruction and latent recovery. However, we found that as the dimensionality increased beyond the true dimensionality $\hat { D } > 3 )$ , the latent recovery of the MLP-NODE degraded rapidly while ODIN’s latent recovery remained high $\mathrm { F i g 2 C }$ , as $\hat { D } > 3$ ). This result provides evidence that readouts that lack injectivity (like MLPs) tend to learn misleading latent activity that can make their representations less interpretable when the true dimensionality $\hat { D }$ is unknown.
289
+
290
+ # 4.2 Recovering fixed-point structure with ODIN
291
+
292
+ A common method to compare how well dynamics models capture the underlying dynamics from synthetic data is to examine the character and structure of the inferred fixed-points (FPs) to the FPs of the ground-truth system[15]. At a high-level, FPs enable a concise description of the dynamics in a small region of state-space around the FP, and can collectively provide a qualitative picture of the overall dynamical landscape. To obtain a set of candidate FPs, we searched the latent space for points at which the magnitude of the vector field $\| \hat { f } \|$ is minimized (as in [1, 40]). We computed the eigenvalues (λs) of the Jacobian of $\hat { f }$ at each FP location. The real and imaginary components of these eigenvalues identify each FP as attractive, repulsive, etc.
293
+
294
+ We found that 3D ODIN models and 3D Linear-NODEs were both able to recover three fixed-points that generally matched the location of the three fixed points of the Arneodo system (Fig 3A), However, while ODIN was also able to capture the eigenspectra of all three FPs (Fig. 3B, red $\times ,$ ), the LinearNODE failed to capture the rotational dynamics of the central FP (Fig 3B, middle column, green $+$ ). 280 Both models were able to approximately recover the eigenspectra of outermost FPs of the system 281 (Fig. 3B, left, right columns). We found that the MLP-NODE was also able to find FPs with similar 282 accuracy to ODIN at 3D. These results show that the inability to model the nonlinear embedding can 283 lead to impoverished estimates of the underlying dynamics $\hat { f }$ .
295
+
296
+ # 4.3 Recovering simulated activation functions with ODIN
297
+
298
+ While obtaining interpretable dynamics is our primary goal, models that allow unsupervised recovery of the embedding geometry may provide additional insight about the computations performed by the neural system [42, 7]. For this section, we considered a representative model from each readout class with the correct number of latent dimensions $\simeq 3$ ). We performed an affine transformation from the ground truth encoding vectors into the modeled latent space and computed the projection of the modeled latent activity onto the affine-transformed encoding vectors (Fig 4A). From this projection, we derived an estimate of the activation function for each neuron, and compared this estimate to the ground-truth activation function.
299
+
300
+ We found, as expected, that the linear readout was unable to approximate the sigmoidal activation function of individual neurons (Fig 4B, green). On the other hand, both ODIN and MLP-NODE were able to capture activation functions ranging from nearly linear to step function-like in nature (Fig 4B, red, orange). Across all simulated neurons, we found that ODIN more accurately estimated the activation function of individual neurons compared to both Linear- and MLP-NODEs (Fig 4C), suggesting that the injectivity of the Flow readout allows more accurate estimation of nonlinear embeddings.
301
+
302
+ # 4.4 Modeling motor cortical activity with ODIN
303
+
304
+ To validate ODIN’s ability to fit neural activity from a biological neural circuit, we applied ODIN to the Maze dataset from the Neural Latents Benchmark, composed of recordings from the motor and pre-motor cortices of a monkey performing a reaching task (Fig. 5A). After performing hyperparameter sweeps across regularization parameters and network size (Supp. Table 2), we trained a set of ODIN and Linear-NODE models to reconstruct the neural activity with a range of state dimensionalities $\hat { D }$ . We visualized the top 3 PCs of the condition-averaged latent trajectories and predicted single-neuron firing rates for example models
305
+
306
+ ![](images/c2ee88f6bfd9413016df78193115d4b017b81459f7afc2ecca260f8bbc0ec2b2.jpg)
307
+ Figure 4: Flow-NODE (ODIN) can recover nonlinear activation functions of neurons. A) True encoding vectors (numbered lines over true latent activity (blue)) were affine-transformed into a representative model’s latent space. B) Inferred activation function for two example neurons (columns), color coded by readout type (Linear $=$ green, ${ \bf M L P = }$ orange, Flow $=$ red, True $=$ black). Plots show the predicted firing rate vs. the activation of the selected neuron. C) Comparison of the $R ^ { 2 }$ values of the fits from B across model types. Left: Flow vs. MLP. Right: Flow vs. Linear
308
+
309
+ from each readout type. We found no visually obvious differences in the inferred latent trajectories 2 (Fig. 5B), but when we computed condition-averaged peri-stimulus time histograms (PSTHs) of 23 single neuron firing rates, we found that ODIN typically produced firing rate estimates that more 24 closely resembled the empirical PSTHs than those from the Linear-NODE (Fig. 5C).
310
+
311
+ 325 Without access to a ground truth dynamics $f$ and embedding $g$ that generated these biological data, the
312
+ 326 dimensionality required to reconstruct the neural activity was our primary measure of interpretability.
313
+ 327 We computed co-bps –a measure of reconstruction performance on held-out neurons– for each model
314
+ 328 and found that 10D ODIN models substantially outperformed Linear-NODE models, even when the
315
+ 329 Linear-NODE had more than twice as many dimensions (10D ODIN: 0.333, vs 25D Linear: 0.287).
316
+ 330 This suggests that ODIN’s injective non-linear readout is effective at reducing the required latent
317
+ 331 state dimensionality to capture the data relative to a simple linear readout.
318
+ 332 We also compared ODIN to other models on the NLB leaderboard for this dataset [27, 43]. The best
319
+ 333 reported AutoLFADS model (a RNN-based variational SAE with $\hat { D } = 1 0 0 \mathrm { \Omega }$ ) had only modestly higher
320
+ 334 co-bps than the 10D ODIN (0.333 vs 0.355) [44]. These results suggest that ODIN is effective at
321
+ 335 reducing the required dimensionality for neural reconstruction, which may provide more interpretable
322
+ 336 latent representations than alternative models.
323
+
324
+ ![](images/d6b71f1c41ed60018e80ad2e0613428829e811e323b55ab29ea3873f788303dc.jpg)
325
+ Figure 5: ODIN can reconstruct cortical activity with low-dimensional dynamics A) Top: Schematic of task [38] Bottom: example hand trajectories and condition-averaged firing rates aligned to move onset. B) Example condition-averaged latent activity from ODIN and Linear-NODE models applied to neural activity recorded during the Maze task. C) Example single-neuron peri-stimulus time histograms for ODIN and Linear-NODE models across conditions. D) Effects of latent state dimensionality $\hat { D }$ on reconstruction (top, co-bps) and decoding (bottom, Vel $R ^ { 2 }$ ) performance. Plot shows mean (point) and standard deviation (shading) of 5 randomly initialized models at each $\hat { D }$ . Horizontal lines represent NLB performance by AutoLFADS (black) and GFPA (grey) [27].
326
+
327
+ # 5 Discussion
328
+
329
+ Dynamics models have had great success in reproducing neural activity patterns and relating brain activity to behavior [45, 27, 46]. However, it has been difficult to use these models to investigate neural computation directly. If neural population models could be trusted to find interpretable representations of latent dynamics, then recent techniques that can uncover computation in artificial networks could help to explain computations in the brain [1, 40, 47]. In this work, we created a new model called ODIN that can overcome major barriers to learning interpretable latent dynamical systems. By combining Neural ODE generators and approximately injective nonlinear readouts, ODIN offers significant advantages over the prior state-of-the-art, including lower latent dimensionality, simpler latent activity that is robust to the choice of latent dimensionality, and the ability to model arbitrary nonlinear activation functions.
330
+
331
+ 348 Circuits in the brain are densely interconnected, and so a primary limitation of this work is that
332
+ 349 ODIN is not yet able to account for inputs to the system that may be coming from areas that are not
333
+ 350 directly modeled. Thus ODIN is currently only able to model the dynamics of a given population of
334
+ 351 neurons as an autonomous system. Inferring inputs is difficult due to ambiguity in the role of inputs
335
+ 352 compared to internal dynamics for driving the state of the system. While some RNN-based models
336
+ 353 have methods for input inference [45], more work is needed to develop solutions for NODE-based
337
+ 354 models. Injective readouts are an important step towards addressing the fundamental difficulties of
338
+ 355 input inference, as models without injective readouts can be incentivized to imagine latent features
339
+ 356 that are actually the result of inputs.
340
+ 357 Interpretable dynamics derived from neural population recordings could answer critical scientific
341
+ 358 questions about the brain and help improve brain-machine interface technology. A potential negative
342
+ 359 consequence is that human neural interfaces combined with an understanding of neural computation
343
+ 360 might make it possible and profitable to develop strategies that are effective at influencing behavior.
344
+ 361 Future researchers should focus on applications of this research that are scientific and medical rather
345
+ 362 than commercial or political.
346
+ 363 References
347
+ 364 [1] David Sussillo and Omri Barak. Opening the black box: low-dimensional dynamics in high
348
+ 365 dimensional recurrent neural networks. Neural Computation, 25(3):626–649, March 2013.
349
+ 366 ISSN 1530-888X. doi: 10.1162/NECO_a_00409.
350
+ 367 [2] Valerio Mante, David Sussillo, Krishna Shenoy, and William Newsome. Context-dependent
351
+ 368 computation by recurrent dynamics in prefrontal cortex. Nature, 503:78–84, November 2013.
352
+ 369 doi: 10.1038/nature12742.
353
+ 370 [3] Evan D. Remington, Devika Narain, Eghbal A. Hosseini, and Mehrdad Jazayeri. Flexible
354
+ 371 Sensorimotor Computations through Rapid Reconfiguration of Cortical Dynamics. Neuron, 98
355
+ 372 (5):1005–1019.e5, June 2018. ISSN 1097-4199. doi: 10.1016/j.neuron.2018.05.020.
356
+ 73 [4] Niru Maheswaranathan, Alex Williams, Matthew Golub, Surya Ganguli, and David Sus
357
+ 374 sillo. Reverse engineering recurrent networks for sentiment classification reveals line at
358
+ 375 tractor dynamics. In Advances in Neural Information Processing Systems, volume 32. Cur
359
+ 376 ran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/hash/
360
+ 377 d921c3c762b1522c475ac8fc0811bb0f-Abstract.html.
361
+ 378 [5] Saurabh Vyas, Matthew D. Golub, David Sussillo, and Krishna V. Shenoy. Computation
362
+ 379 Through Neural Population Dynamics. Annual Review of Neuroscience, 43(1):249–275,
363
+ 380 2020. doi: 10.1146/annurev-neuro-092619-094115. URL https://doi.org/10.1146/
364
+ 381 annurev-neuro-092619-094115. _eprint: https://doi.org/10.1146/annurev-neuro-092619-
365
+ 382 094115.
366
+ 383 [6] Krishna V. Shenoy, Maneesh Sahani, and Mark M. Churchland. Cortical control of arm
367
+ 384 movements: a dynamical systems perspective. Annual Review of Neuroscience, 36:337–359,
368
+ 385 July 2013. ISSN 1545-4126. doi: 10.1146/annurev-neuro-062111-150509.
369
+ 386 [7] Mehrdad Jazayeri and Srdjan Ostojic. Interpreting neural computations by examining intrinsic
370
+ 387 and embedding dimensionality of neural activity. Technical Report arXiv:2107.04084, arXiv,
371
+ 388 August 2021. URL http://arxiv.org/abs/2107.04084. arXiv:2107.04084 [q-bio] type:
372
+ 389 article.
373
+ 390 [8] Ian H. Stevenson and Konrad P. Kording. How advances in neural recording affect data analysis.
374
+ 391 Nature Neuroscience, 14(2):139–142, February 2011. ISSN 1546-1726. doi: 10.1038/nn.2731.
375
+ 392 [9] Nicholas A Steinmetz, Cagatay Aydin, Anna Lebedeva, Michael Okun, Marius Pachitariu,
376
+ 393 Marius Bauza, Maxime Beau, Jai Bhagat, Claudia Böhm, Martijn Broux, Susu Chen, Jennifer
377
+ 394 Colonell, Richard J Gardner, Bill Karsh, Fabian Kloosterman, Dimitar Kostadinov, Carolina
378
+ 395 Mora-Lopez, John O’Callaghan, Junchol Park, Jan Putzeys, Britton Sauerbrei, Rik J J van
379
+ 396 Daal, Abraham Z Vollan, Shiwei Wang, Marleen Welkenhuysen, Zhiwen Ye, Joshua T Dudman,
380
+ 397 Barundeb Dutta, Adam W Hantman, Kenneth D Harris, Albert K Lee, Edvard I Moser, John
381
+ 398 O’Keefe, Alfonso Renart, Karel Svoboda, Michael Häusser, Sebastian Haesler, Matteo Caran
382
+ 399 dini, and Timothy D Harris. Neuropixels 2.0: A miniaturized high-density probe for stable,
383
+ 400 long-term brain recordings. Science, 372(6539), April 2021.
384
+ 401 [10] Jeffrey Demas, Jason Manley, Frank Tejera, Kevin Barber, Hyewon Kim, Francisca Martínez
385
+ 402 Traub, Brandon Chen, and Alipasha Vaziri. High-speed, cortex-wide volumetric recording
386
+ 403 of neuroactivity at cellular resolution using light beads microscopy. Nature Methods, 18(9):
387
+ 404 1103–1111, September 2021. ISSN 1548-7105. doi: 10.1038/s41592-021-01239-8. URL
388
+ 405 https://www.nature.com/articles/s41592-021-01239-8. Number: 9 Publisher: Na
389
+ 406 ture Publishing Group.
390
+ 407 [11] Peiran Gao and Surya Ganguli. On simplicity and complexity in the brave new world of
391
+ 408 large-scale neuroscience. Current Opinion in Neurobiology, 32:148–155, June 2015. ISSN
392
+ 409 0959-4388. doi: 10.1016/J.CONB.2015.04.003. URL https://www.sciencedirect.com/
393
+ 10 science/article/pii/S0959438815000768. Publisher: Elsevier Current Trends.
394
+ 11 [12] Lea Duncker and Maneesh Sahani. Dynamics on the manifold: Identifying computational
395
+ 12 dynamical activity from neural population recordings. Current Opinion in Neurobiology, 70:
396
+ 413 163–170, October 2021. ISSN 0959-4388. doi: 10.1016/j.conb.2021.10.014. URL https:
397
+ 14 //www.sciencedirect.com/science/article/pii/S0959438821001264.
398
+
399
+ [13] David Sussillo, Rafal Jozefowicz, L. F. Abbott, and Chethan Pandarinath. LFADS - Latent Factor Analysis via Dynamical Systems. Technical Report arXiv:1608.06315, arXiv, August 2016. URL http://arxiv.org/abs/1608.06315. arXiv:1608.06315 [cs, q-bio, stat] type: article.
400
+ [14] Marine Schimel, Ta-Chu Kao, Kristopher T. Jensen, and Guillaume Hennequin. iLQR-VAE : control-based learning of input-driven dynamics with applications to neural data. Technical report, bioRxiv, October 2021. URL https://www.biorxiv.org/content/10.1101/2021. 10.07.463540v1. Section: New Results Type: article.
401
+ [15] Andrew R. Sedler, Christopher Versteeg, and Chethan Pandarinath. Expressive architectures enhance interpretability of dynamics-based neural population models, February 2023. URL http://arxiv.org/abs/2212.03771. arXiv:2212.03771 [cs, q-bio].
402
+ [16] Yuanjun Gao, Evan Archer, Liam Paninski, and John P. Cunningham. Linear dynamical neural population models through nonlinear embeddings. Technical Report arXiv:1605.08454, arXiv, October 2016. URL http://arxiv.org/abs/1605.08454. arXiv:1605.08454 [q-bio, stat] type: article.
403
+ [17] Anqi Wu, Nicholas A. Roy, Stephen Keeley, and Jonathan W Pillow. Gaussian process based nonlinear latent structure discovery in multivariate spike train data. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://papers.nips.cc/paper_files/paper/2017/hash/ b3b4d2dbedc99fe843fd3dedb02f086f-Abstract.html.
404
+ [18] Yuan Zhao and Il Memming Park. Variational Online Learning of Neural Dynamics. Frontiers in Computational Neuroscience, 14, 2020. ISSN 1662-5188. URL https://www.frontiersin. org/article/10.3389/fncom.2020.00071.
405
+ [19] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural Ordinary Differential Equations. Technical Report arXiv:1806.07366, arXiv, December 2019. URL http://arxiv.org/abs/1806.07366. arXiv:1806.07366 [cs, stat] type: article.
406
+ [20] Laurent Dinh, David Krueger, and Yoshua Bengio. Nice: Non-linear independent components estimation. arXiv preprint arXiv:1410.8516, 2014.
407
+ [21] Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. Advances in neural information processing systems, 31, 2018.
408
+ [22] Lynton Ardizzone, Jakob Kruse, Sebastian Wirkert, Daniel Rahner, Eric W. Pellegrini, Ralf S. Klessen, Lena Maier-Hein, Carsten Rother, and Ullrich Köthe. Analyzing Inverse Problems with Invertible Neural Networks. Technical Report arXiv:1808.04730, arXiv, February 2019. URL http://arxiv.org/abs/1808.04730. arXiv:1808.04730 [cs, stat] type: article.
409
+ [23] Jens Behrmann, Will Grathwohl, Ricky T. Q. Chen, David Duvenaud, and Joern-Henrik Jacobsen. Invertible Residual Networks. In Proceedings of the 36th International Conference on Machine Learning, pages 573–582. PMLR, May 2019. URL https://proceedings.mlr. press/v97/behrmann19a.html. ISSN: 2640-3498.
410
+ [24] Jakob H Macke, Lars Buesing, John P Cunningham, Byron M Yu, Krishna V Shenoy, and Maneesh Sahani. Empirical models of spiking in neural populations. In Advances in Neural Information Processing Systems, volume 24. Curran Associates, Inc., 2011. URL https://papers. nips.cc/paper/2011/hash/7143d7fbadfa4693b9eec507d9d37443-Abstract.html.
411
+ [25] Evan Archer, Il Memming Park, Lars Buesing, John Cunningham, and Liam Paninski. Black box variational inference for state space models, November 2015. URL http://arxiv.org/ abs/1511.07367. arXiv:1511.07367 [stat].
412
+ [26] David Pfau, Eftychios A Pnevmatikakis, and Liam Paninski. Robust learning of low-dimensional dynamics from large neural ensembles. In Advances in Neural Information Processing Systems, volume 26. Curran Associates, Inc., 2013. URL https://papers.nips.cc/paper_files/ paper/2013/hash/47a658229eb2368a99f1d032c8848542-Abstract.html.
413
+
414
+ 464 [27] Felix Pei, Joel Ye, David Zoltowski, Anqi Wu, Raeed H. Chowdhury, Hansem Sohn, Joseph E.
415
+ 465 O’Doherty, Krishna V. Shenoy, Matthew T. Kaufman, Mark Churchland, Mehrdad Jazayeri,
416
+ 466 Lee E. Miller, Jonathan Pillow, Il Memming Park, Eva L. Dyer, and Chethan Pandarinath.
417
+ 467 Neural Latents Benchmark ’21: Evaluating latent variable models of neural population activity.
418
+ 468 Technical Report arXiv:2109.04463, arXiv, January 2022. URL http://arxiv.org/abs/
419
+ 469 2109.04463. arXiv:2109.04463 [cs, q-bio] type: article.
420
+ 470 [28] Timothy D Kim, Thomas Z Luo, Jonathan W Pillow, and Carlos Brody. Inferring latent
421
+ 471 dynamics underlying neural population activity via neural differential equations. In International
422
+ 472 Conference on Machine Learning, pages 5551–5561. PMLR, 2021.
423
+ 473 [29] Matthew J. Johnson, David Duvenaud, Alexander B. Wiltschko, Sandeep R. Datta, and Ryan P.
424
+ 474 Adams. Composing graphical models with neural networks for structured representations and
425
+ 475 fast inference, July 2017. URL http://arxiv.org/abs/1603.06277. arXiv:1603.06277
426
+ 476 [stat].
427
+ 477 [30] Ian H. Stevenson. Flexible models for spike count data with both over- and under- dispersion.
428
+ 478 Journal of Computational Neuroscience, 41(1):29–43, August 2016. ISSN 1573-6873. doi:
429
+ 479 10.1007/s10827-016-0603-y. URL https://doi.org/10.1007/s10827-016-0603-y.
430
+ 480 [31] Steven L Brunton, Joshua L Proctor, and J Nathan Kutz. Discovering governing equations
431
+ 481 from data by sparse identification of nonlinear dynamical systems. Proceedings of the national
432
+ 482 academy of sciences, 113(15):3932–3937, 2016.
433
+ 483 [32] Steffen Schneider, Jin Hwa Lee, and Mackenzie Weygandt Mathis. Learnable latent embeddings
434
+ 484 for joint behavioural and neural analysis. Nature, 617(7960):360–368, May 2023. ISSN 1476-
435
+ 485 4687. doi: 10.1038/s41586-023-06031-6. URL https://www.nature.com/articles/
436
+ 486 s41586-023-06031-6. Number: 7960 Publisher: Nature Publishing Group.
437
+ 487 [33] Ding Zhou and Xue-Xin Wei. Learning identifiable and interpretable latent models of high
438
+ 488 dimensional neural activity using pi-VAE, November 2020. URL http://arxiv.org/abs/
439
+ 489 2011.04798. arXiv:2011.04798 [cs, q-bio, stat].
440
+ 490 [34] Mohammad Bashiri, Edgar Walker, Konstantin-Klemens Lurz, Akshay Jagadish, Taliah
441
+ 491 Muhammad, Zhiwei Ding, Zhuokun Ding, Andreas Tolias, and Fabian Sinz. A flow-based
442
+ 492 latent state generative model of neural population responses to natural images. In Ad
443
+ 493 vances in Neural Information Processing Systems, volume 34, pages 15801–15815. Cur
444
+ 494 ran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper/2021/hash/
445
+ 495 84a529a92de322be42dd3365afd54f91-Abstract.html.
446
+ 496 [35] Jimmy T. H. Smith, Scott W. Linderman, and David Sussillo. Reverse engineering recur
447
+ 497 rent neural networks with Jacobian switching linear dynamical systems. Technical Report
448
+ 498 arXiv:2111.01256, arXiv, November 2021. URL http://arxiv.org/abs/2111.01256.
449
+ 499 arXiv:2111.01256 [cs] type: article.
450
+ 500 [36] Cole Hurwitz, Akash Srivastava, Kai Xu, Justin Jude, Matthew Perich, Lee Miller,
451
+ 501 and Matthias Hennig. Targeted Neural Dynamical Modeling. In Advances in Neu
452
+ 502 ral Information Processing Systems, volume 34, pages 29379–29392. Curran Asso
453
+ 503 ciates, Inc., 2021. URL https://papers.nips.cc/paper_files/paper/2021/hash/
454
+ 504 f5cfbc876972bd0d031c8abc37344c28-Abstract.html.
455
+ 505 [37] Kristopher Jensen, Ta-Chu Kao, Jasmine Stone, and Guillaume Hennequin. Scalable
456
+ 506 Bayesian GPFA with automatic relevance determination and discrete noise models. In Ad
457
+ 507 vances in Neural Information Processing Systems, volume 34, pages 10613–10626. Cur
458
+ 508 ran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper/2021/hash/
459
+ 509 58238e9ae2dd305d79c2ebc8c1883422-Abstract.html.
460
+ 510 [38] Mark M. Churchland, John P. Cunningham, Matthew T. Kaufman, Stephen I. Ryu, and Krishna V.
461
+ 511 Shenoy. Cortical preparatory activity: representation of movement or first cog in a dynamical
462
+ 512 machine? Neuron, 68(3):387–400, November 2010. ISSN 1097-4199. doi: 10.1016/j.neuron.
463
+ 513 2010.09.015.
464
+ 514 [39] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral Normaliza
465
+ 515 tion for Generative Adversarial Networks, February 2018. URL http://arxiv.org/abs/
466
+ 516 1802.05957. arXiv:1802.05957 [cs, stat].
467
+ 517 [40] Matthew D. Golub and David Sussillo. Fixedpointfinder: A tensorflow toolbox for identifying
468
+ 518 and characterizing fixed points in recurrent neural networks. Journal of Open Source Software,
469
+ 519 3(31):1003, 2018. doi: 10.21105/joss.01003. URL https://doi.org/10.21105/joss.
470
+ 520 01003.
471
+ 521 [41] A Arneodo, P Coullet, and C Tresser. Occurence of strange attractors in three-dimensional
472
+ 522 Volterra equations. Physics Letters A, 79(4):259–263, October 1980. ISSN 0375-9601.
473
+ 523 doi: 10.1016/0375-9601(80)90342-4. URL https://www.sciencedirect.com/science/
474
+ 524 article/pii/0375960180903424.
475
+ 525 [42] Richard J. Gardner, Erik Hermansen, Marius Pachitariu, Yoram Burak, Nils A. Baas, Ben
476
+ 526 jamin A. Dunn, May-Britt Moser, and Edvard I. Moser. Toroidal topology of population activity
477
+ 527 in grid cells. Technical report, bioRxiv, February 2021. URL https://www.biorxiv.org/
478
+ 528 content/10.1101/2021.02.25.432776v1. Section: New Results Type: article.
479
+ 529 [43] EvalAI: Neural Latents Benchmark ’21 - MC Maze 20ms. URL https://eval.ai/web/
480
+ 530 challenges/challenge-page/1256/leaderboard/3183.
481
+ 531 [44] Mohammad Reza Keshtkaran, Andrew R. Sedler, Raeed H. Chowdhury, Raghav Tandon,
482
+ 532 Diya Basrai, Sarah L. Nguyen, Hansem Sohn, Mehrdad Jazayeri, Lee E. Miller, and Chethan
483
+ 533 Pandarinath. A large-scale neural network training framework for generalized estimation
484
+ 534 of single-trial population dynamics. Nature Methods, 19(12):1572–1577, December 2022.
485
+ 535 ISSN 1548-7105. doi: 10.1038/s41592-022-01675-0. URL https://www.nature.com/
486
+ 536 articles/s41592-022-01675-0. Number: 12 Publisher: Nature Publishing Group.
487
+ 537 [45] Chethan Pandarinath, Daniel J. O’Shea, Jasmine Collins, Rafal Jozefowicz, Sergey D. Stavisky,
488
+ 538 Jonathan C. Kao, Eric M. Trautmann, Matthew T. Kaufman, Stephen I. Ryu, Leigh R. Hochberg,
489
+ 539 Jaimie M. Henderson, Krishna V. Shenoy, L. F. Abbott, and David Sussillo. Inferring single-trial
490
+ 540 neural population dynamics using sequential auto-encoders. Nature Methods, 15(10):805–815,
491
+ 541 October 2018. ISSN 1548-7105. doi: 10.1038/s41592-018-0109-9. URL https://www.
492
+ 542 nature.com/articles/s41592-018-0109-9. Number: 10 Publisher: Nature Publishing
493
+ 543 Group.
494
+ 544 [46] Jimmy T. H. Smith, Andrew Warrington, and Scott W. Linderman. Simplified State Space
495
+ 545 Layers for Sequence Modeling, March 2023. URL http://arxiv.org/abs/2208.04933.
496
+ 546 arXiv:2208.04933 [cs].
497
+ 547 [47] Laura Driscoll, Krishna Shenoy, and David Sussillo. Flexible multitask computation in recur
498
+ 548 rent networks utilizes shared dynamical motifs, August 2022. URL https://www.biorxiv.
499
+ 549 org/content/10.1101/2022.08.15.503870v1. Pages: 2022.08.15.503870 Section: New
500
+ 550 Results.
501
+
502
+ 1. For all authors...
503
+
504
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? Yes, we ensured that the abstract was supported by the main body of the article
505
+ (b) Did you describe the limitations of your work? Yes, we included a section in the discussion where we describe where our work is currently limited, and offer suggestions for ways to extend the work to address these limitations
506
+ (c) Did you discuss any potential negative societal impacts of your work? We’ve included a short description of how this work might adversely impact societal health in the Broader Impacts section
507
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? Yes, we’ve read the ethical review guidelines and confirmed that our paper meets their standards
508
+
509
+ 2. If you are including theoretical results...
510
+
511
+ (a) Did you state the full set of assumptions of all theoretical results? (b) Did you include complete proofs of all theoretical results?
512
+
513
+ 3. If you ran experiments...
514
+
515
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? We plan to include these components in the supplementary pdf for final submission
516
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? We’ve included these details, split between the main text and the supplement, depending on their relative importance
517
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? Yes, we’ve included error bars on relevant plots
518
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? Yes, we’ve included the details of our internal cluster in the supplementary materials
519
+
520
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
521
+
522
+ (a) If your work uses existing assets, did you cite the creators? Yes, we credit these assets in the supplementary materials
523
+ (b) Did you mention the license of the assets? We plan to include the license of each asset in the supplement
524
+ (c) Did you include any new assets either in the supplemental material or as a URL? Yes, we plan to include our code and data-generation in the final submission
525
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
526
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
527
+
528
+ 5. If you used crowdsourcing or conducted research with human subjects...
529
+
530
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
531
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
532
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
md/dev/K48UYo0glaJ/K48UYo0glaJ.md ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Theseus: A Library for Differentiable Nonlinear Optimization
2
+
3
+ Luis Pineda1, Taosha Fan1, Maurizio Monge2, Shobha Venkataraman1, Paloma Sodhi1, Ricky T. Q. Chen1, Joseph Ortiz1, Daniel DeTone2, Austin Wang1, Stuart Anderson1, Jing Dong2, Brandon Amos1, Mustafa Mukadam1
4
+
5
+ 1Meta AI, 2Reality Labs Research
6
+
7
+ # Abstract
8
+
9
+ We present Theseus, an efficient application-agnostic open source library for differentiable nonlinear least squares (DNLS) optimization built on PyTorch, providing a common framework for end-to-end structured learning in robotics and vision. Existing DNLS implementations are application specific and do not always incorporate many ingredients important for efficiency. Theseus is application-agnostic, as we illustrate with several example applications that are built using the same underlying differentiable components, such as second-order optimizers, standard costs functions, and Lie groups. For efficiency, Theseus incorporates support for sparse solvers, automatic vectorization, batching, GPU acceleration, and gradient computation with implicit differentiation and direct loss minimization. We do extensive performance evaluation in a set of applications, demonstrating significant efficiency gains and better scalability when these features are incorporated. Project page: https://sites.google.com/view/theseus-ai/
10
+
11
+ # 1 Introduction
12
+
13
+ Reconciling traditional approaches with deep learning to leverage their complementary strengths is a common thread in a large body of recent work in robotics. In particular, an emerging trend is to differentiate through nonlinear least squares (NLS) [1] which is a second-order optimization formulation at the heart of many problems in robotics [2–7] and vision [8–13]. Optimization layers as inductive priors in neural models have been explored in machine learning with convex optimization [14, 15] and in meta learning with gradient descent [16, 17] based first-order optimization.
14
+
15
+ Differentiable nonlinear least squares (DNLS) provides a general scheme to encode inductive priors, as the objective function can be partly parameterized by neural models and partly with engineered domain-specific differentiable models. Here, as illustrated in Fig. 1, input tensors define a sum of weighted squares objective function and output tensors are minima of that objective. Such implicit layers [18] are in contrast to typical (explicit) layers that take input tensors through a linear transformation and some element-wise nonlinear activation function.
16
+
17
+ ![](images/f32571828e106eb15cfc6d5807fd15ee3907f8a37214f72613464968ff0d3eb6.jpg)
18
+ Figure 1: Theseus enables building custom, efficient DNLS layers that support end-to-end structured learning.
19
+
20
+ 36th Conference on Neural Information Processing Systems (NeurIPS 2022).
21
+
22
+ The ability to compute gradients end-to-end is retained by differentiating through the optimizer which allows neural models to train on the final task loss, while also taking advantage of priors captured by the optimizer. The flexibility of such a scheme has led to promising state-of-the-art results in a wide range of applications such as structure from motion [19], motion planning [20], SLAM [21, 22], bundle adjustment [23], state estimation [24, 25], image alignment [26] with other applications like manipulation and tactile sensing [27, 28], control [29], human pose tracking [30, 31] to be explored. However, existing implementations from above are application specific, common underlying tools like optimizers get reimplemented, and features like sparse solvers, batching, and GPU support that impact efficiency are not always included. This has led to a fragmented literature where it is difficult to start work on new ideas or to build on the progress of prior work.
23
+
24
+ To address this gap, we present Theseus, an open source library for differentiable nonlinear least squares optimization built on PyTorch. Theseus provides an efficient application-agnostic interface that consolidates recent efforts and catalyzes future progress in the domain of structured end-to-end learning for robotics and vision. Our contributions are summarized below.
25
+
26
+ Application agnostic interface. Our implementation provides an easy to use interface to build custom optimization layers and plug them into any neural architecture. (i) The layer can be constructed from a set of available second-order optimizers like Gauss-Newton, Levenberg–Marquardt (with adaptive damping) and Dogleg, and a nonlinear least squares objective. (ii) The objective can be constructed with learnable or hand-specified cost functions, either by applying one of many common costs already provided in the library, or by building custom costs in-place with support for automatic differentiation through PyTorch [32]. (iii) We also provide differentiable Lie groups for representing 2D/3D positions and rotations [33], and differentiable kinematics wrapping over an existing library [34] for representing robot models. More details are described in Sec. 3.
27
+
28
+ Efficiency based design. Efficiency is a central design consideration and we make several advancements in improving computation times and memory consumption. (i) As common in prior work, an optimizer implementation using PyTorch’s native linear solver would use a dense representation for solving the linear system within the nonlinear optimization. In practice, these optimization problems often have a considerable amount of sparsity that can be exploited [35–38]. In Theseus, we implement sparse linear solvers that are differentiable end-to-end and make them efficient with custom CPU and CUDA backends to support batching and GPU acceleration. (ii) Beyond sparse solvers, we extend batching and GPU support to all features in the library and add automatic vectorization of cost functions and other operations to significantly boost efficiency. (iii) Finally, we introduce implicit differentiation [39] and direct loss minimization [40, 41], which have been previously applied to only first order optimizers like gradient descent and convex optimization, to a new class of second-order optimizers. This goes beyond prior work with nonlinear least squares that currently only support differentiation with standard unrolling, which is known to have challenges with compute, memory, and vanishing gradients. More details are described in Sec. 4.
29
+
30
+ Highlights of results. Together, the application-agnostic features let users easily set up a variety of problems like pose graph optimization, tactile state estimation, bundle adjustment, motion planning, and homography estimation, all of which are included as examples in the open source code and described in Sec. 3.1. In evaluations, we find that on a standard GPU, Theseus with a sparse solver is much faster and requires significantly less memory than a dense solver, and when solving a batch of large problems the forward pass of Theseus is up to $2 0 \mathrm { x }$ faster than state-of-the-art $\mathrm { C } { + } { + }$ based solver Ceres that has limited GPU support and does not support batching and end-to-end learning. We also compare all backward modes to find that with increasing number of optimization iterations, compute and memory increases linearly for unrolling and stays constant for implicit differentiation, while the latter also provides better gradients. More details are described in Sec. 5.
31
+
32
+ # 2 Background and related work
33
+
34
+ Nonlinear least squares (NLS) is an optimization problem [1] that finds optimization variables $\theta$
35
+
36
+ $$
37
+ \theta ^ { \star } = \operatorname * { a r g m i n } _ { \theta } S ( \theta ) , \qquad S ( \theta ) = \frac { 1 } { 2 } \sum _ { i } | | r _ { i } ( \theta ^ { i } ) | | ^ { 2 } = \frac { 1 } { 2 } \sum _ { i } | | w _ { i } c _ { i } ( \theta ^ { i } ) | | ^ { 2 }
38
+ $$
39
+
40
+ where the objective $S ( \theta )$ is a sum of squared vector-valued residual terms $r _ { i }$ , each a function of $\theta ^ { i } \subset \theta$ that are (non-disjoint) subsets of the optimization variables $\theta = \{ \theta _ { j } \}$ . Any variable $\theta _ { j }$ is a manifold object; for example, a Euclidean vector or a matrix Lie group. For flexibility, we represent a residual $\dot { r _ { i } } ( \theta ^ { i } ) = w _ { i } c _ { i } ( \bar { \theta } ^ { i } )$ as a product of a matrix weight $w _ { i }$ and vector cost $c _ { i }$ . Robotics and vision have used this general optimization formulation to tackle many applications [3, 4]. For example, costs capture sensor measurement errors and physical constraints to optimize camera, robot, object, or human poses in estimation and tracking problems like simultaneous localization and mapping (SLAM) [42], structure from motion [13], bundle adjustment [8], visual inertial odometry [2], articulated tracking [12], contact odometry in legged locomotion [27], 3D pose and shape reconstruction of humans [30, 31] or objects [10]. Similarly, costs can also capture constraints and desired future goals to find robot states or actions in motion planning [5], dynamics [6], and control [29] problems.
41
+
42
+ Solving NLS. Problems represented by Eq. (1) are solved by iteratively linearizing the nonlinear objective around the current variables to get the linear system $\begin{array} { r } { ( \sum _ { i } J _ { i } ^ { \top } J _ { i } ) \delta \theta = ( \bar { \sum _ { i } } J _ { i } ^ { \top } r _ { i } ) } \end{array}$ , then solving the linear system to find the update $\delta \theta$ , and finally updating the variables $\theta \theta - \delta \theta$ , until convergence. Note that in the update the minus operation is more generally a retraction mapping for non-Euclidean variables. In the linear system, $\bar { J } _ { i } = [ \partial r _ { i } / \partial \theta ^ { i } ]$ are the Jacobians of residuals with respect to the variables and the iterative method above, called Gauss-Newton (GN), is a nonlinear optimizer that is (approximately) second-order, since $\begin{array} { r } { \dot { H } = ( \sum _ { i } J _ { i } ^ { \top } J _ { i } ) } \end{array}$ represents the approximate Hessian. To improve robustness and convergence, variations like Levenberg–Marquardt (LM) damp the linear system, while others use a trust region and adjust step size for the update with line search (e.g., Dogleg). Please refer to [1, 43] for an in-depth exploration. In most applications discussed above the objective structure gives rise to a sparse Hessian, since not all costs depend on all variables. Several general purpose frameworks [35–38] have been built that leverage this sparsity property to efficiently solve the sparse linear system in every iteration of the nonlinear optimization. While these frameworks were not built for deep learning, they are highly efficient and performant on CPU.
43
+
44
+ NLS with learning. Data driven learning has been explored to address challenges in hand crafting costs or features for costs, finding weights to balance different costs, or to find initializations that lead to better convergence. Some examples include, learning object shape code [44] or environment depth code [45] for SLAM [46], learning motion priors for planning to manipulate articulated objects [47], learning relative pose from tactile images to estimate object state during pushing [28], and semantic 2D segmentation fused in 3D mesh for semantic SLAM [7]. These approaches only train features on a surrogate or intermediate loss and then apply optimization at inference where the true downstream task loss is available but not utilized. To take full advantage of end-to-end learning, latest approaches thus are redesigning the optimization to be differentiable.
45
+
46
+ Differentiable NLS (DNLS) solves the optimization in Eq. (1) and also provides gradients of the solution $\theta ^ { \star }$ with respect to any upstream neural model parameters $\phi$ that parameterize the objective $S ( \theta ; \phi )$ and in turn any costs $\boxed { c _ { i } ( \theta ^ { i } ; \phi ) }$ , weights $w _ { i } ( \phi )$ , or initialization for variables $\theta _ { i n i t } ( \phi )$ . The goal is to learn these parameters $\phi$ end-to-end with a downstream learning objective $L$ defined as a function of $\theta ^ { \star }$ . This results in a bilevel optimization setup as shown in Fig. 1
47
+
48
+ $$
49
+ \theta ^ { \star } ( \phi ) = \operatorname * { a r g m i n } _ { \theta } S ( \theta ; \phi ) , \qquad \mathrm { o u t e r ~ l o o p : ~ } \phi ^ { \star } = \operatorname * { a r g m i n } _ { \phi } L ( \theta ^ { \star } ( \phi ) )
50
+ $$
51
+
52
+ where the inner loop is DNLS and the outer loop is gradient descent class of optimization that is standard in deep learning. The outer loop performs update $\phi \phi + \delta \phi$ by computing $\delta \phi$ using gradients ${ \partial \theta ^ { \star } } / { \bar { \partial } \phi }$ through inner loop DNLS. Note that more generally the learning objective i.e. outer loss $L$ can also depend on other quantities like neural model parameters downstream of $\theta ^ { * }$ , but we omit them here for clarity.
53
+
54
+ Recent works with DNLS have outperformed optimization only or learning only methods by combining the strengths of classical methods with deep learning. For example, learning features for costs to represent depth in bundle adjustment [23] and monocular stereo [48] where an initialization network also learns to predict depth and pose, learning cost weights like motion model weights in video to depth estimation [19], obstacle avoidance weights in 2D motion planning from occupancy images [20], learning robust loss weights in image alignment [26] and state-of-the-art dense SLAM [22], and confidence weights for feature matching to optimize camera pose [49]. Other works, backpropagate reconstruction error to sensor model in a SLAM system [21], solve large scale bundle adjustment on a GPU [50], and learn sensor and dynamics models for 2D visual object tracking and visual odometry [24]. These implementations however, are application specific which has led to repeated work in building DNLS where features like learnable costs and weights, Lie groups, and kinematics are not always present. Additionally, features that have a significant impact on performance, like sparsity and vectorization of costs are only considered by some [24, 50, 51] or in the case of implicit differentiation for NLS optimization, have not yet been explored.
55
+
56
+ # 3 Application agnostic interface
57
+
58
+ Given the lack of a common and efficient framework for DNLS an important goal of Theseus is to provide an application-agnostic interface. In this section, we describe how we enable this with an easy-to-use core API, standard cost functions, and features like Lie groups and kinematics, and illustrate several examples using this interface. We discuss design for efficiency in the next section.
59
+
60
+ ![](images/4adcd5b9bfba8d359b492ca749686c0e143e3f7523ae53c2ee192ad37fecb287.jpg)
61
+
62
+ The core API lets users focus on describing the DNLS problem and their interaction with the outer loss $L$ and parameters $\phi$ within any broader PyTorch model, while the solution and differentiation are seamlessly taken care of under-the-hood. The basic components of the core API are described below with the help of a simple example in Listing 1 (see App. B for more details on the example):
63
+
64
+ ��� Variable: refers to either optimization variables, $\theta$ , or auxiliary variables (those constant with respect to $S$ , e.g., parameters $\phi$ or data tensors), which are named wrappers of torch batched tensors stored in Variable.tensor (lines 3-5).
65
+ • CostFunction: defines costs $c _ { i }$ (lines 12-14) and are also responsible for declaring which of its variables are optimization and which are auxiliary (lines 8-9),
66
+ • CostWeight: defines weights $w _ { i }$ associated with cost $c _ { i }$ (line 14).
67
+ • Objective: defines $S ( \theta ; \phi )$ , and thus the structure of an optimization problem (lines 11, 15) by holding all cost functions and weights, and their associated variables. These are implicitly obtained when a CostFunction is added to the Objective, and Variable names are used to infer which are shared by one or more CostFunction.
68
+ • Optimizer: is the inner loop optimization algorithm (e.g. Gauss-Newton) that finds the solution $\theta ^ { \star }$ given objective $S$ (line 16).
69
+ • TheseusLayer: encapsulates Optimizer and Objective, and serves as the interface between the DNLS block and other torch modules upstream or downstream (line 16).
70
+
71
+ The interface between the inner loop optimization and the outer loop’s parameters and loss occurs via TheseusLayer.forward (lines 21-23). This receives as input a dictionary mapping variable names to torch tensors, which Theseus then uses to populate the corresponding Variable with the tensor mapped to its name. With the input dictionary users can provide initial values for the optimization variables, data tensors, or current values for parameters $\phi$ before running the inner loop optimization. The output of forward is another dictionary that maps variable names to tensors with their optimal values found in the inner loop (lines 21, 24); auxiliary variables are not modified during the forward pass. The output tensors can then be combined with other torch modules downstream to compute $L$ while maintaining the full differentiable computation graph (lines 24-26).
72
+
73
+ We currently provide Gauss-Newton, Levenberg–Marquardt (with adaptive damping), and Dogleg as nonlinear Optimizer for the inner loop, with the ability to easily add support for more optimizers in the future. Listing 1 uses AutoDiffCostFunction to construct an in-place CostFunction (line 12) which allows automatically calculating Jacobians $J _ { i }$ with PyTorch (see App. C). Beyond this, in the library we include standard cost functions with analytical Jacobians broadly used in many applications, like Gaussian measurements, reprojection error, relative pose measurement, motion models, and collision costs. We also include a variety of robust loss functions, useful for example in handling outliers [52], which can be easily integrated with CostFunction. Next we describe support for Lie groups and kinematics.
74
+
75
+ Differentiable Lie groups. Lie groups are widely used in robotics and vision to represent 2D/3D positions and rotations [33]. Due to their non-Euclidean geometry, it is difficult to apply them to deep learning, which primarily operates with Euclidean tensors, but recently there is growing interest in making them compatible [24, 53–57]. LieTorch [54] generalizes automatic differentiation on the Lie group tangent space through local parameterization around the identity, but the implementation is complex since every operation requires a custom kernel. In contrast, Theseus computes common Lie group operators, e.g., the exponential and logarithm map, inverse, composition, etc., in closed form, and provides their corresponding analytical derivatives on the tangent space. Following [58], we also implement a projection operator that allows us to project gradients computed by PyTorch’s autodiff to the tangent space and use them to easily compute Jacobians and update Lie group variables correctly; a similar strategy has also been implemented in [59]. Additionally, our Lie group implementation includes a heuristic extension that allows using any of PyTorch’s first-order optimizers on nonEuclidean manifolds with minimal code changes. All of these make it easy and straightforward to run optimization and train neural networks with Lie groups variables. More details in App. D.
76
+
77
+ Differentiable kinematics. Many problems such as motion planning or state estimation on high degree of freedom robots like arms or mobile manipulators, involve computation of robot kinematics for collision avoidance or computing distance of end effector to goal. Theseus provides a differentiable implementation of forward kinematics by wrapping over Differentiable Robot Model [34], which builds a differentiable kinematics function from a standard robot model file. Gradients are computed through autodiff, while we also provide a more efficient, analytical manipulator Jacobian. This module can be used within any CostFunction in Theseus.
78
+
79
+ # 3.1 Example applications
80
+
81
+ To illustrate the versatility of Theseus, we include a number of example DNLS applications below with more details in App. E. Crucially, to implement these with Theseus, most of the effort is only in defining application-specific components such as data management, neural models, or custom CostFunction. With these defined, putting the full DNLS block together is a few lines of code to setup a TheseusLayer and an outer loop, similar to the simple example in Listing 1.
82
+
83
+ Pose graph optimization (PGO) estimates poses from their noisy relative measurements [60]. With DNLS we learn the radius of a Welsh robust cost function for outlier rejection, using the difference between estimated and ground truth poses as the outer loss on a synthetic dataset.
84
+
85
+ Tactile state estimation follows [28], which estimates 2D poses of an object pushed by a robot hand with an image-based tactile sensor [61]. A neural network that predicts relative pose between hand and object from tactile images is learned end-to-end through the TheseusLayer.
86
+
87
+ Bundle adjustment is the problem of optimizing a 3D reconstruction formed by a set of camera images and a set of landmarks observed and matched across the images [62]. We learn the radius of a soft-kernel that penalizes outlier observations, using the average frame pose error as outer loss.
88
+
89
+ Motion planning considers a differentiable version of the GPMP2 planning algorithm, inspired by [20], where the outer loss tries to match expert demonstrations. Here we learn a model for initializing optimization variables, and we include the inner loop objective as a term in the outer loss.
90
+
91
+ Homography estimation. Homography is a linear transformation between corresponding points in two images and can be solved by minimising a dense photometric loss. Robustness to lighting and viewpoint change can be improved with a feature-metric loss based on CNN features [63–68]. In our outer loop, we train a CNN to produce robust features for image alignment.
92
+
93
+ # 4 Efficiency based design
94
+
95
+ Theseus enables several different applications with a general interface. Compute and memory efficiency are central to making its usage practical. Next, we explain design considerations to support batching and vectorization, sparsity, and backward modes for differentiation, which we demonstrate boost performance in the evaluations section.
96
+
97
+ # 4.1 Batching and vectorization
98
+
99
+ Parallel processing is important to improve computational efficiency in machine learning and optimization. In Theseus, we enable two levels of parallelization. First, Theseus natively supports solving a batch of DNLS in parallel, thus fitting seamlessly in the PyTorch framework, where training and inferences on batches is the standard. Second, inspired by DeepLM [50], and noting that lots of the operations such as costs, gradients/Jacobian computation, and variable
100
+
101
+ ![](images/15fbb0913b91156eb3a69e3af4fdd5d459dc9750a0150f6fea435a8603a80e2f.jpg)
102
+ Figure 2: Speedup with automatic vectorization on PGO. Black dotted line is without vectorization.
103
+
104
+ updates only differ from each other in terms of the input data, we make use of the single-instructionmultiple-data (SIMD) protocol by automatically detecting and vectorizing operations of the same type, significantly reducing computation overhead. Using the PGO example, Fig. 2 shows that Theseus achieves significant speedup with automatic vectorization both for forward and backward pass. Note that there is an application-dependent trade-off between memory and speed; here the memory use increases by up to $\sim 8 2 \%$ for forward and $\sim 5 5 \%$ for backward.
105
+
106
+ # 4.2 Handling sparsity with linear solvers beyond PyTorch
107
+
108
+ Solving NLS requires solving a sequence of linear systems to obtain descent directions. As discussed in Sec. 2, these systems are generally sparse and can be solved much more efficiently if not treated as dense. Theseus includes differentiable sparse solvers that take advantage of the sparsity, complementing PyTorch’s native dense solvers. Importantly, Theseus seamlessly takes care of assembling the cost functions and variables in the objective into sparse data structures that our linear solvers can consume, without any extra burden on the user. Currently, we provide three sparse solvers: (i) a CPU-based solver that relies on CHOLMOD [69], (ii) cudaLU, which is based on the cuSolverRF package that is part of Nvidia’s cuSolver library provided with CUDA, and (iii) BaSpaCho, our novel batched sparse Cholesky solver with GPU support. As a bonus feature, we provide access to these solvers as standalone PyTorch functions, so they can be used to solve sparse matrices arising outside of NLS or DNLS optimization.
109
+
110
+ CHOLMOD-based solver. CHOLMOD [69] achieves state-of-the-art performance on computation of the Cholesky decomposition of sparse matrices. It exploits parallelism by grouping sparse entries to take advantage of high-performance multi-threaded dense matrix operations in BLAS/LAPACK libraries. CHOLMOD has some limited support for GPU for some of its operations, but the algorithm is strongly CPU-based, and the user is expected to provide matrix data on the CPU. One convenient feature is computing the symbolic analysis of a sparse matrix pattern as a separate step and creating a symbolic decomposition object that can be used for all subsequent factorizations. We also take advantage of builtin functionality for sparse multiplication and only provide the Jacobian matrix $J$ to solve for the Hessian $H = j ^ { \top } J$ . Two limitations of the library with respect to Theseus are, first, the lack of proper GPU support, which forces us to provide matrix data on the CPU, and, second, the lack of batching, which requires us to loop to solve every problem in the batch independently. On the other hand, since it runs on CPU, it has less memory restrictions than GPU-based solvers (see Sec. 5.1).
111
+
112
+ cudaLU solver. cuSolverRF is designed to accelerate the solution of sets of linear systems by fast LU refactorization when given new coefficients for the same sparsity pattern. To take advantage of this, we implemented custom CUDA kernels for batched sparse matrix-matrix and matrix-vector products, and for solving a batch of sparse linear systems using LU factorization from cuSolverRF. Although this solver leads to a substantial performance boost over PyTorch’s dense solver (see Sec. 5.1), the closed-source nature of cuSOLVER results in some challenges and limitations: (i) cuSolverRF does not support separate symbolic decomposition and numeric contexts, so it’s not possible to use the same symbolic decomposition to hold in memory separate factors. Since this is necessary in Theseus for unrolling of the inner loop, we work around this limitation by creating a pool of contexts, and we use the least recently used context for factorization. As a consequence, the number of contexts must be set according to the number of iterations that need to be unrolled; (ii) The batch size is fixed once a context is created. Since recreating the contexts is an expensive operation, it means that the batch size has to be constant over the course of outer loop optimization; (iii) It relies on LU factorization, which for symmetric matrices (the case of Theseus) is less efficient than using Cholesky decomposition.
113
+
114
+ BaSpaCho solver. Batched Sparse Cholesky (BaSpaCho) is a novel open-source sparse Cholesky solver designed for Theseus with support for batching (https://github.com/facebookresearch/ baspacho). BaSpaCho implements the supernodal Cholesky algorithm [70] to achieve state-of-the art performance by exploiting dense operations via BLAS/cuBLAS. This is achieved by building an elimination tree and then clustering column blocks with similar sparsity patterns. These blocks form nodes of the elimination tree and allow dense operations. In BaSpaCho, the dense operations are dispatched to BLAS (on CPU) or cuBLAS (on GPU), with additional support added on top for batching matrix operations with the same sparsity patterns. In problems with very sparse matrices, like bundle adjustment [8], the supernodal algorithm employed in state-of-the-art solvers [37] is unable to eliminate columns of parameter blocks simultaneously. Thus, past work has resorted to the Schur complement trick [71] to send a reduced problem to the sparse solver. However, this logic adds extra complexity to the nonlinear optimization, while essentially duplicating the work of the (mathematically equivalent) Cholesky decomposition. In BaSpaCho, we instead complement the supernodal algorithm with sparse elimination that removes the need to externally handle Schur complement as a workaround to the limitation of the supernodal algorithm. More details are described in App. F.
115
+
116
+ Backward for custom linear solvers. Obtaining derivatives of the linear system solve with respect to the parameters is a crucial operation for DNLS. In particular, we consider optimizing the parameters $A$ and $b$ of a linear system $y = A ^ { - 1 } b$ to minimize a downstream function $f ( y )$ . The derivatives of the loss with respect to the parameters of the linear system can be obtained with implicit differentiation, $\begin{array} { r } { \frac { \partial f } { \partial b } = A ^ { - 1 } \frac { \partial \mathbf { \bar { f } } } { \partial y } } \end{array}$ and $\begin{array} { r } { \frac { \partial f } { \partial A } = - A ^ { - 1 } \frac { \partial f } { \partial y } y ^ { \top } } \end{array}$ 1 @f@y y>, as done in Barron and Poole [72]. In Theseus, we implement this by connecting the Python interface of our sparse solvers with PyTorch’s autograd.Function classes that implement the gradients above in their backward methods. This connects the computation graph between the downstream function and any upstream parameters that modify the system via auxiliary variables or values for optimization variables. Furthermore, since the gradients require solving linear systems that use the same matrix as the forward pass, our backward pass can cache factorizations, resulting in it being significantly faster than the forward pass (see Fig. 3).
117
+
118
+ # 4.3 Backward modes for DNLS
119
+
120
+ The parameters $\phi$ upstream of DNLS can be learned end-to-end through the solution $\theta ^ { \star } ( \phi )$ by using the adjoint derivatives ${ { \partial \theta ^ { \star } ( \phi ) } / { \partial \phi } }$ . We include four methods for computing them in Theseus.
121
+
122
+ Unrolling is the standard way in which past work in DNLS has computed the adjoint derivatives. This is often referred to as backpropagation through time or unrolled optimization and is explored in [16, 20, 73–82]. In practice, often only a few steps of unrolling are performed due to challenges with compute, memory, and vanishing gradients.
123
+
124
+ Truncated differentiation. Aside from unrolling a few steps, another way of approximating the derivatives is to use truncated backpropagation through time (TBPTT) [83, 84]. Truncation unfortunately results in biased derivatives and many works [85–89] seek to further theoretically understand the properties of TBPTT, including the bias of the estimator and how to unbias it.
125
+
126
+ Implicit differentiation. If $\theta ^ { \star }$ can be computed exactly, then the implicit function theorem provides a way of computing the adjoint derivatives, as done in related work in convex optimization and first-order gradient descent methods [14, 15, 90–95]. We apply the implicit function theorem from Dontchev and Rockafellar [39, Theorem 1B.1] (see App. H) to Eq. (2) to perform implicit differentiation on a new class of second-order NLS optimization. This first requires that we transform Eq. (2) into an implicit function that finds the roots. We do this via the first-order optimality condition, resulting in $\bar { g } ( \theta ; \phi ) : = \nabla _ { \theta } S ( \theta ; \phi )$ . Finding $\Theta ^ { \star } ( \phi ) : = \{ \theta \mid g ( \theta ; \phi ) = 0 \}$ corresponds to solving Eq. (2). Under mild assumptions, the theorem above gives the adjoint derivative at $\bar { \phi }$
127
+
128
+ $$
129
+ \mathrm { D } _ { \phi } \theta ^ { \star } ( \bar { \phi } ) = - \mathrm { D } _ { \theta } ^ { - 1 } g ( \theta ^ { \star } ( \bar { \phi } ) ; \bar { \phi } ) \mathrm { D } _ { \phi } g ( \theta ^ { \star } ( \bar { \phi } ) ; \bar { \phi } ) .
130
+ $$
131
+
132
+ As Theseus internally uses a (Gauss-)Newton solver, the following proposition provided in App. H shows how we can compute Eq. (3) by differentiating a single Newton step at an optimal solution.
133
+
134
+ Proposition 1. The implicit derivative (Eq. (3)) can be computed by differentiating a Newton step $\bar { h ( \theta ; \phi ) } : = \theta - [ \nabla _ { \theta } ^ { 2 } S ( \hat { \theta } ; \phi ) ] _ { \mathrm { { s t o p } } } ^ { - 1 } \nabla _ { \theta } S ( \theta ; \phi )$ at an optimal $\theta ^ { \star }$ , where $[ \cdot ] _ { \mathrm { s t o p } }$ zeros the derivative.
135
+
136
+ ![](images/34be76bb347a8d76fcfa01017b987d15fb2306443580a73d8087400d22648ccd.jpg)
137
+ Figure 3: Forward/backward times of Theseus with sparse and dense solvers on different PGO problem scales.
138
+
139
+ Direct loss minimization. Suppose we have an outer loss as in Eq. (2). The direct loss minimization (DLM) approach uses this loss to augment the inner-loop optimization problem in order to define a finite difference scheme that approaches the true gradient $\begin{array} { r } { \nabla _ { \phi } L = \operatorname* { l i m } _ { \varepsilon \to 0 } g _ { \mathrm { D L M } } ^ { \varepsilon } } \end{array}$ , where $g _ { \mathrm { D L M } } ^ { \varepsilon } \triangleq$ $\begin{array} { r } { \frac { 1 } { \varepsilon } \{ \frac { \partial } { \partial \phi } S ( \theta ^ { * } ; \phi ) - \frac { \partial } { \partial \phi } S ( \theta _ { \mathrm { d i r e c t } } ; \phi ) \} } \end{array}$ ! . This was used in prior works that solve optimization problems on structured discrete domains [40, 41, 96, 97], but has so far not seen much use in structured continuous settings. We modify the original DLM formulation to better suit its implementation within Theseus
140
+
141
+ $$
142
+ \begin{array} { r l } { \theta ^ { \star } = \underset { \hat { \theta } } { \arg \operatorname* { m i n } } S ( \hat { \theta } ; \phi ) , \quad } & { \theta _ { \mathrm { d i r e c t } } = \underset { \hat { \theta } } { \arg \operatorname* { m i n } } S ( \hat { \theta } ; \phi ) + \left\| \varepsilon \hat { \theta } - \frac { 1 } { 2 } \nabla _ { \theta } L ( \theta ^ { * } ) \right\| ^ { 2 } . } \end{array}
143
+ $$
144
+
145
+ This is different from the original formulation in two ways: (i) we only assume access to the gradient vector $\nabla _ { { \boldsymbol { \theta } } } L ( { \boldsymbol { \theta } } ^ { * } )$ , which helps formulate DLM as an algorithm for computing vector-Jacobian products, and (ii) we add a small regularization term to ensure the modified objective for $\theta _ { \mathrm { d i r e c t } }$ is a sum-of-squares without affecting the limit as $\varepsilon \to 0$ . See App. H for more details.
146
+
147
+ # 5 Evaluation
148
+
149
+ We evaluate the performance of Theseus under different settings with PGO and tactile state estimation applications from Sec. 3.1. PGO allows us to easily control the problem scales for performance evaluation; in Sec. 5.1 we profile time and memory consumption of Theseus in an end-to-end setup and in Sec. 5.2 we evaluate timings of Theseus as a stand-alone NLS optimizer and compare with state-of-the-art Ceres [37]. The tactile state estimation application involves a more complex outer loop model that is useful for comparing all different backward modes, which we present in Sec. 5.3.
150
+
151
+ # 5.1 Profiling forward and backward pass of Theseus for DNLS
152
+
153
+ We study the performance of Theseus for DNLS on the PGO problem [60] with the synthetic Cube dataset, as described in App. E. We run 10 inner loop iterations and 20 outer loop epochs, and use implicit differentiation to compute gradients of the inner NLS optimization. For these experiments we used an Nvidia V100 GPU with 32GBs of memory for all Python computation, and Intel Xeon 2.2GHz CPU with 20 threads for the CPU-based CHOLMOD linear solver. We evaluate performance using our sparse solvers in Theseus and using PyTorch’s Cholesky dense solver.
154
+
155
+ Fig. 3 shows the average time of a full forward and backward pass for a given batch size, taken by Theseus with different solvers (cudaLU, CHOLMOD, BaSpaCho and dense), for different problem scales (number of poses and batch size). The two left plots show time as a function of number of poses for a batch size of 128, while the two right plots show time as a function of batch size for 2048 poses. We find that dense does not scale well with poses or batch size. For a batch size of 128, the largest problem that it can solve before running out of GPU memory has 256 poses (left two plots). With 2048 poses, dense is unable to solve the problem regardless of batch size (right two plots). On the other hand with a batch size of 128, our solvers BaSpaCho scale to 2048 poses and cudaLU scale to 4096 poses. CHOLMOD can solve problems even larger, since the linear system is solved on CPU and we have successfully tested up to 8192 poses and batch size 256 (see App. G), for a total of 22GBs of GPU usage for residuals and Jacobian blocks computation.
156
+
157
+ In addition to being more memory efficient, running times of our sparse solvers are also smaller for large enough number of poses/batch size, especially for the backward pass. Even though dense’s total time for forward+backward is comparable to cudaLU and faster than CHOLMOD for smaller problems: e.g., 1.47s (dense) vs. 1.32s (cudaLU) and 2.82s (CHOLMOD) for batch size 128 and 64 poses, dense is significantly slower or out of memory for larger problems. For the largest problem that dense can solve (batch size 128 and 256 poses) its total time is already much slower than all others methods:
158
+
159
+ 20.81s (dense) vs. 10.96s (CHOLMOD), 2.86s (cudaLU), and 2.25s (BaSpaCho). Furthermore, BaSpaCho outperforms dense for any problem scale and is up to one order of magnitude faster, including for smaller batch sizes and number of poses (see App. G for more results and details). For the largest problem that we consider (batch size 256 and 2048 poses), the total times for our sparse solvers are 170.28s for cudaLU, 239.07s for CHOLMOD, and 57.67s for BaSpaCho.
160
+
161
+ # 5.2 Profiling Theseus as stand-alone NLS optimizer
162
+
163
+ DNLS typically involves solving numerous optimization problems each epoch where a fast NLS optimizer is essential. We compare Theseus as a stand-alone NLS optimizer with the state-of-the-art Ceres [37] library for solving a batch of PGO problems without any learning involved. We compare all solvers in terms of the total time required to perform 10 iterations on a set of 256 PGO problems. CPU/GPU configurations are same as before. For CHOLMOD, we also include a configuration that runs everything on CPU, including Jacobians and residual computation (labelled CHOLMOD-allcpu).
164
+
165
+ Fig. 4 shows speedup obtained by Theseus with batching, vectorization and sparse solvers, over Ceres as a function of increasing number of poses or batch size. We vary the number of poses for a fixed batch size of 256, and vary the batch size for a fixed number of poses of 2048. Although Ceres is faster than all of our solvers when the number of poses and batch size are small (for instance, Ceres is $2 5 \mathrm { x }$ faster with 256 poses and 16 batch size, see App. G), as these increase Theseus shows signif
166
+
167
+ ![](images/ea54f83cdfabe19990c310cda65475bf4791b5a3adff46b06d1784c65e347701.jpg)
168
+ Figure 4: Speedup of Theseus (forward pass) over Ceres (black dashed) on different PGO problem scales.
169
+
170
+ icant speedup by being able to solve larger batches of problems in parallel. For the largest setup that all our solvers can scale to (2048 poses, 256 batch size), BaSpaCho is ${ \sim } 2 3 \mathbf { x }$ faster than Ceres, and our other solvers are ${ \sim } 4 \mathbf { x }$ faster. CHOLMOD has a 6x speedup for its largest setting (4096 poses, 256 batch size).
171
+
172
+ Since typical use case of Theseus involves large batches and number of variables during end-to-end learning with DNLS, the speedups in this setting against a performant NLS solver highlights the significance of our efficiency-based design choices. See App. G for additional results of smaller fixed batch size and number of poses.
173
+
174
+ # 5.3 Backward modes analysis
175
+
176
+ We explore the trade-offs between our different backward modes using the tactile state estimation application in Sec. 3.1. The learnable components here include a neural network, and thus closely follow the type of applications that motivate Theseus. We compare the following backward modes: derivative unrolling (Unroll), implicit differentiation (Implicit), truncated differentiation (Trunc), and direct loss minimization (DLM); for Trunc we include results when truncating 5 and 10 steps. We compare all modes along 3 axis of performance: validation loss after 100 epochs (outer loop), run time during training, and peak GPU memory consumption of TheseusLayer. For these experiments we used Quadro GP100 GPUs with 16GB of memory. For time and memory we present separate results for forward and backward pass, and all numbers are averaged over 700 (7 batches for 100 epochs). Below we discuss our main findings from this analysis, and more results and details can be found in App. H.
177
+
178
+ Fig. 5 shows average run times for all backward modes as a function of the maximum number of iterations in the inner loop optimization. We observe that the time used in the forward pass (Fig. 5, far left) increases roughly linearly for all modes, all having similar times except for Unroll, which is slower than other modes. On the other hand, we observe stark differences in the backward pass time (Fig. 5, center left), where Unroll is the only method that has a linear dependence on the number of inner loop iterations. All other methods have a constant footprint for computing derivatives, independent of the number of inner loop iterations. As expected, increasing the number of iterations through which we backprop (5 or 10 for Trunc, all iterations for Unroll) increases the time necessary for a backward pass $( \mathtt { I m p l i c i t } = \mathtt { D L M } < \mathtt { T r u n c - 5 } < \mathtt { T r u n c - 1 } \theta < < \mathtt { U n r o l 1 } )$ .
179
+
180
+ Figure 5 (center right) shows the average peak memory consumption of the backward modes. In this case, the trends observed for the backward pass memory consumption is similar to the trends in time. In particular, Unroll’s memory footprint increases linearly with the number of inner loop iterations, from $\mathrm { \sim 3 4 M B s }$ to $\sim \mathrm { 2 6 2 M B s }$ ; for all other methods the memory consumption remains constant. The best memory profiles in this example is obtained with Implicit and DLM backward modes, with $\sim \mathrm { 2 8 M B s }$ and $\sim \mathrm { 2 9 M B s }$ , respectively. These trends also hold for the forward pass memory consumption.
181
+
182
+ ![](images/76832a8958ee7b5e173871e737d1c489533f2a9e26449e6214b37904f103dae4.jpg)
183
+ Figure 5: Time and memory consumption of different backward modes in tactile state estimation.
184
+
185
+ Figure 5 also shows the validation losses obtained with all backward modes (far right). The best validation loss, after 100 epochs of training, is obtained using Implicit, followed by Trunc variants. We notice that both variants of Trunc keep improving with increasing number of inner loop iterations, and that Unroll and Implicit achieve the best results with 20 iterations. One exception is DLM, which doesn’t improve much with the number of iterations, but is also the best method when only 2 inner loop iterations are performed. As a point of caution, we stress that, unlike the timing and memory results, the relative training performance between different backward modes is likely to be application dependent, and is affected by hyperparameters such as the step size used for the inner loop optimizer (0.05 in this example), and the outer optimizer’s learning rate. Our experiments suggest that implicit differentiation is a good default to use for differentiable optimization, considering its low time/memory footprint, and potential for better end-to-end performance with proper hyperparameter tuning.
186
+
187
+ # 6 Discussion
188
+
189
+ Summary. Theseus provides nonlinear least squares as a differentiable layer and enables easily building and training end-to-end architectures for robotics and vision applications. We illustrate several example applications using the same application-agnostic interface and demonstrate significant improvements in performance with our efficiency-based design. Following how autodiff and GPU acceleration (among others) have led to the evolution of PyTorch in contrast to NumPy [98], we can similarly view sparsity and implicit differentiation on top of autodiff and GPU acceleration as the key ingredients that power Theseus, in contrast to solvers like Ceres that typically only support sparsity. When solving a batch of large problems the forward pass of Theseus is up to $2 0 \mathrm { x }$ faster than Ceres.
190
+
191
+ Limitations. Theseus currently has a few limitations. The nonlinear solvers we currently support apply constraints in a soft manner (i.e., using weighted costs). Hard constraints can be handled with methods like augmented Lagrangian or sequential quadratic programs [99, 100], and differentiating through them are active research topics. The current implementation of LM does not support damping to be learnable. Some limitations and trade-offs with the sparse linear solvers are discussed in Sec. 4.2, and with backward modes are discussed in App. H. Online learning applications may require frequently editing the objective and depending on the problem size there may be a nontrivial overhead that is not currently optimized as we explored only non-incremental settings in this work. Additional performance gains can be extracted by moving some of our Python implementation to $\mathrm { C } { + } { + }$ but we prioritized flexibility in evolving the API in the short-term. We do not yet support distributed training beyond what PyTorch natively supports. We will explore these features and optimizations in the future as the library continues to evolve.
192
+
193
+ # Acknowledgments and Disclosure of Funding
194
+
195
+ The authors would like to thank Dhruv Batra, Olivier Delalleau, Jessica Hodgins, and Mary Williamson for guidance and support on the project, Dhruv Batra and Sal Candido for feedback on early drafts of the paper, Franziska Meier for help with the differentiable robot model library, Paul-Edouard Sarlin for helpful discussion on the homography example, Horace He, Richard Zou and Samantha Andow for help with functorch [101] library, Terran Washington, Gopika Jhala and Chantal Mora for designing the Theseus logo, and Oliver Libaw, Christine Gibson, Orialis Valentin, Alyssa Newcomb and Eric Kaplan for help with the blog post. The authors also thank community members for contributions to the open source code. Work by PS and JO was done while at Meta AI.
196
+
197
+ References [1] Jorge Nocedal and Stephen Wright. Numerical optimization. Springer Science & Business Media, 2006. 1, 2, 3 [2] Christian Forster, Luca Carlone, Frank Dellaert, and Davide Scaramuzza. On-manifold preintegration for real-time visual–inertial odometry. IEEE Transactions on Robotics, 33(1): 1–21, 2016. 1, 3 [3] Frank Dellaert, Michael Kaess, et al. Factor graphs for robot perception. Foundations and Trends® in Robotics, 6(1-2):1–139, 2017. 3 [4] Timothy D. Barfoot. State estimation for robotics. State Estimation for Robotics, 2017. doi: 10.1017/9781316671528. 3 [5] Mustafa Mukadam, Jing Dong, Xinyan Yan, Frank Dellaert, and Byron Boots. Continuoustime gaussian process motion planning via probabilistic inference. The International Journal of Robotics Research, 37(11):1319–1340, 2018. 3, 22, 23 [6] Mandy Xie and Frank Dellaert. A unified method for solving inverse, forward, and hybrid manipulator dynamics using factor graphs. arXiv preprint arXiv:1911.10065, 2019. 3 [7] Antoni Rosinol, Marcus Abate, Yun Chang, and Luca Carlone. Kimera: an open-source library for real-time metric-semantic localization and mapping. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 1689–1696. IEEE, 2020. 1, 3 [8] Bill Triggs, Philip F McLauchlan, Richard I Hartley, and Andrew W Fitzgibbon. Bundle adjustment—a modern synthesis. In International workshop on vision algorithms, pages 298–372. Springer, 1999. 1, 3, 7, 22 [9] Hanna Pasula, Stuart Russell, Michael Ostland, and Yaacov Ritov. Tracking many objects with many sensors. In IJCAI, volume 99, pages 1160–1171. Citeseer, 1999.
198
+ [10] Richard Szeliski and Sing Bing Kang. Recovering 3d shape and motion from image streams using nonlinear least squares. Journal of Visual Communication and Image Representation, 5 (1):10–28, 1994. 3
199
+ [11] Aleksandr Segal, Dirk Haehnel, and Sebastian Thrun. Generalized-icp. In Robotics: science and systems, volume 2, page 435. Seattle, WA, 2009.
200
+ [12] Tanner Schmidt, Richard A Newcombe, and Dieter Fox. Dart: Dense articulated real-time tracking. In Robotics: Science and Systems, volume 2, pages 1–9. Berkeley, CA, 2014. 3
201
+ [13] Johannes L Schonberger and Jan-Michael Frahm. Structure-from-motion revisited. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4104–4113, 2016. 1, 3
202
+ [14] Brandon Amos and J Zico Kolter. Optnet: Differentiable optimization as a layer in neural networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 136–145. JMLR. org, 2017. 1, 7
203
+ [15] Akshay Agrawal, Brandon Amos, Shane Barratt, Stephen Boyd, Steven Diamond, and J Zico Kolter. Differentiable convex optimization layers. In Advances in Neural Information Processing Systems, pages 9558–9570, 2019. 1, 7
204
+ [16] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International conference on machine learning, pages 1126– 1135. PMLR, 2017. 1, 7
205
+ [17] Edward Grefenstette, Brandon Amos, Denis Yarats, Phu Mon Htut, Artem Molchanov, Franziska Meier, Douwe Kiela, Kyunghyun Cho, and Soumith Chintala. Generalized inner loop meta-learning. arXiv preprint arXiv:1910.01727, 2019. 1
206
+
207
+ [18] David Duvenaud, Zico Kolter, and Matthew Johnson. Deep Implicit Layers: Neural ODEs, Equilibrium Models, and Differentiable Optimization. http://implicit-layers-tutorial. org/, 2020. 1
208
+
209
+ [19] Zachary Teed and Jia Deng. Deepv2d: Video to depth with differentiable structure from motion. arXiv preprint arXiv:1812.04605, 2018. 2, 3
210
+
211
+ [20] Mohak Bhardwaj, Byron Boots, and Mustafa Mukadam. Differentiable gaussian process motion planning. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 10598–10604. IEEE, 2020. 2, 3, 5, 7, 22
212
+
213
+ [21] Krishna Murthy Jatavallabhula, Ganesh Iyer, and Liam Paull. $\nabla$ slam: Dense slam meets automatic differentiation. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 2130–2137. IEEE, 2020. 2, 3
214
+
215
+ [22] Zachary Teed and Jia Deng. Droid-slam: Deep visual slam for monocular, stereo, and rgb-d cameras. Advances in Neural Information Processing Systems, 34, 2021. 2, 3
216
+
217
+ [23] Chengzhou Tang and Ping Tan. BA-Net: Dense bundle adjustment networks. 7th International Conference on Learning Representations, ICLR 2019, 2019. 2, 3
218
+
219
+ [24] Brent Yi, Michelle A Lee, Alina Kloss, Roberto Martín-Martín, and Jeannette Bohg. Differentiable factor graph optimization for learning smoothers. In 2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 1339–1345. IEEE, 2021. 2, 3, 5 [25] Hansheng Chen, Pichao Wang, Fan Wang, Wei Tian, Lu Xiong, and Hao Li. Epro-pnp: Generalized end-to-end probabilistic perspective-n-points for monocular object pose estimation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2781–2790, 2022. 2
220
+
221
+ [26] Zhaoyang Lv, Frank Dellaert, James M Rehg, and Andreas Geiger. Taking a deeper look at the inverse compositional algorithm. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4581–4590, 2019. 2, 3
222
+
223
+ [27] Ross Hartley, Maani Ghaffari Jadidi, Lu Gan, Jiunn-Kai Huang, Jessy W Grizzle, and Ryan M Eustice. Hybrid contact preintegration for visual-inertial-contact state estimation using factor graphs. In 2018 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 3783–3790. IEEE, 2018. 2, 3
224
+
225
+ [28] Paloma Sodhi, Michael Kaess, Mustafa Mukadam, and Stuart Anderson. Learning tactile models for factor graph-based estimation. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pages 13686–13692. IEEE, 2021. 2, 3, 5, 21, 22
226
+
227
+ [29] Markus Giftthaler, Michael Neunert, Markus Stäuble, Jonas Buchli, and Moritz Diehl. A family of iterative gauss-newton shooting methods for nonlinear optimal control. In 2018 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 1–9. IEEE, 2018. 2, 3
228
+
229
+ [30] Federica Bogo, Angjoo Kanazawa, Christoph Lassner, Peter Gehler, Javier Romero, and Michael J Black. Keep it smpl: Automatic estimation of 3d human pose and shape from a single image. In European conference on computer vision, pages 561–578. Springer, 2016. 2, 3
230
+
231
+ [31] Taosha Fan, Kalyan Vasudev Alwala, Donglai Xiang, Weipeng Xu, Todd Murphey, and Mustafa Mukadam. Revitalizing optimization for 3d human pose and shape estimation: A sparse constrained formulation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 11457–11466, 2021. 2, 3
232
+
233
+ [32] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32:8026–8037, 2019. 2
234
+
235
+ [33] Joan Solà, Jeremie Deray, and Dinesh Atchuthan. A micro Lie theory for state estimation in robotics. arXiv, pages 1–17, 2018. URL http://arxiv.org/abs/1812.01537. 2, 5
236
+
237
+ [34] Franziska Meier, Austin Wang, Giovanni Sutanto, Yixin Lin, and Paarth Shah. Differentiable and learnable robot models. arXiv preprint arXiv:2202.11217, 2022. 2, 5
238
+
239
+ [35] Giorgio Grisetti, Rainer Kümmerle, Hauke Strasdat, and Kurt Konolige. g2o: A general framework for (hyper) graph optimization. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pages 9–13, 2011. 2, 3, 21
240
+
241
+ [36] Frank Dellaert. Factor graphs and gtsam: A hands-on introduction. Technical report, Georgia Institute of Technology, 2012.
242
+
243
+ [37] Sameer Agarwal and Keir Mierle. Ceres solver: Tutorial & reference. Google Inc, 2(72):8, 2012. 7, 8, 9, 21
244
+
245
+ [38] Jing Dong and Zhaoyang Lv. miniSAM: A flexible factor graph non-linear least squares optimization framework. CoRR, abs/1909.00903, 2019. URL http://arxiv.org/abs/1909. 00903. 2, 3
246
+
247
+ [39] Asen L Dontchev and R Tyrrell Rockafellar. Implicit functions and solution mappings, volume 543. Springer, 2009. 2, 7, 26
248
+
249
+ [40] Tamir Hazan, Joseph Keshet, and David McAllester. Direct loss minimization for structured prediction. Advances in neural information processing systems, 23, 2010. 2, 8
250
+
251
+ [41] Yang Song, Alexander Schwing, Raquel Urtasun, et al. Training deep neural networks via direct loss minimization. In International conference on machine learning, pages 2169–2177. PMLR, 2016. 2, 8, 27
252
+
253
+ [42] Frank Dellaert and Michael Kaess. Square root sam: Simultaneous localization and mapping via square root information smoothing. The International Journal of Robotics Research, 25 (12):1181–1203, 2006. 3
254
+
255
+ [43] Carl T Kelley. Iterative methods for optimization. SIAM, 1999. 3 [44] Edgar Sucar, Kentaro Wada, and Andrew Davison. NodeSLAM: Neural Object Descriptors for Multi-View Shape Reconstruction. Proceedings - 2020 International Conference on 3D Vision, 3DV 2020, pages 949–958, 2020. doi: 10.1109/3DV50981.2020.00105. 3
256
+
257
+ [45] Michael Bloesch, Jan Czarnowski, Ronald Clark, Stefan Leutenegger, and Andrew J Davison. Codeslam—learning a compact, optimisable representation for dense visual slam. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2560–2568, 2018. 3
258
+
259
+ [46] Jan Czarnowski, Tristan Laidlow, Ronald Clark, and Andrew J. Davison. DeepFactors: RealTime Probabilistic Dense Monocular SLAM. IEEE Robotics and Automation Letters, 5(2): 721–728, 2020. doi: 10.1109/LRA.2020.2965415. 3
260
+
261
+ [47] Muhammad Asif Rana, Mustafa Mukadam, Seyed Reza Ahmadzadeh, Sonia Chernova, and Byron Boots. Towards robust skill generalization: Unifying learning from demonstration and motion planning. In Conference on Robot Learning, pages 109–118. PMLR, 2017. 3
262
+
263
+ [48] Ronald Clark, Michael Bloesch, Jan Czarnowski, Stefan Leutenegger, and Andrew J Davison. Ls-net: Learning to solve nonlinear least squares for monocular stereo. arXiv preprint arXiv:1809.02966, 2018. 3
264
+
265
+ [49] Barbara Roessle and Matthias Nießner. End2end multi-view feature matching using differentiable pose optimization. arXiv preprint arXiv:2205.01694, 2022. 3
266
+
267
+ [50] Jingwei Huang, Shan Huang, and Mingwei Sun. Deeplm: Large-scale nonlinear least squares on deep learning frameworks using stochastic domain decomposition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10308–10317, 2021. 3, 6
268
+
269
+ [52] Jonathan T Barron. A general and adaptive robust loss function. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4331–4339, 2019. 5
270
+
271
+ [53] Valentin Peretroukhin, Matthew Giamou, David M Rosen, W Nicholas Greene, Nicholas Roy, and Jonathan Kelly. A smooth representation of belief over so (3) for deep rotation learning with uncertainty. Robotics: Science and Systems, 2020. 5
272
+
273
+ [54] Zachary Teed and Jia Deng. Tangent Space Backpropagation for 3D Transformation Groups. Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, pages 10333–10342, 2021. doi: 10.1109/CVPR46437.2021.01020. URL http: //arxiv.org/abs/2103.12032. 5
274
+
275
+ [55] Yi Zhou, Connelly Barnes, Jingwan Lu, Jimei Yang, and Hao Li. On the continuity of rotation representations in neural networks. Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2019-June:5738–5746, 2019. doi: 10.1109/CVPR.2019.00589.
276
+
277
+ [56] Congyue Deng, Or Litany, Yueqi Duan, Adrien Poulenard, Andrea Tagliasacchi, and Leonidas J Guibas. Vector neurons: A general framework for so (3)-equivariant networks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 12200–12209, 2021.
278
+
279
+ [57] Philippe Hansen-Estruch, Wenling Shang, Lerrel Pinto, Pieter Abbeel, and Stas Tiomkin. Gem: Group enhanced model for learning dynamical control systems. arXiv preprint arXiv:2104.02844, 2021. 5
280
+
281
+ [58] P-A Absil, Robert Mahony, and Rodolphe Sepulchre. Optimization algorithms on matrix manifolds. Princeton University Press, 2009. 5, 20, 21
282
+
283
+ [59] Brent Yi. jaxlie. https://github.com/brentyi/jaxlie, 2021. 5 [60] D.M. Rosen, L. Carlone, A.S. Bandeira, and J.J. Leonard. SE-Sync: A certifiably correct algorithm for synchronization over the special Euclidean group. Intl. J. of Robotics Research, 38(2–3):95–125, March 2019. 5, 8, 21
284
+
285
+ [61] Mike Lambeta, Po-Wei Chou, Stephen Tian, Brian Yang, Benjamin Maloon, Victoria Rose Most, Dave Stroud, Raymond Santos, Ahmad Byagowi, Gregg Kammerer, et al. Digit: A novel design for a low-cost compact high-resolution tactile sensor with application to in-hand manipulation. IEEE Robotics and Automation Letters, 5(3):3838–3845, 2020. 5, 21
286
+
287
+ [62] Sameer Agarwal, Noah Snavely, Steven M Seitz, and Richard Szeliski. Bundle adjustment in the large. In European conference on computer vision, pages 29–42. Springer, 2010. 5, 22 [63] Jan Czarnowski, Stefan Leutenegger, and Andrew J. Davison. Semantic texture for robust dense tracking. In Proceedings of the IEEE International Conference on Computer Vision (ICCV) Workshops, Oct 2017. 5, 23
288
+
289
+ [64] Jing Dong, Byron Boots, Frank Dellaert, Ranveer Chandra, and Sudipta Sinha. Learning to align images using weak geometric supervision. In 2018 International Conference on 3D Vision (3DV), pages 700–709. IEEE, 2018.
290
+
291
+ [65] Chengzhou Tang and Ping Tan. BA-Net: Dense Bundle Adjustment Network. In ICLR, 2019.
292
+
293
+ [66] Paul-Edouard Sarlin, Ajaykumar Unagar, Måns Larsson, Hugo Germain, Carl Toft, Viktor Larsson, Marc Pollefeys, Vincent Lepetit, Lars Hammarstrand, Fredrik Kahl, and Torsten Sattler. Back to the Feature: Learning robust camera localization from pixels to pose. In CVPR, 2021. URL https://arxiv.org/abs/2103.09213.
294
+
295
+ [67] Zhaoyang Lv, Frank Dellaert, James Rehg, and Andreas Geiger. Taking a deeper look at the inverse compositional algorithm. In CVPR, 2019.
296
+
297
+ [68] Chaoyang Wang, Hamed Kiani Galoogahi, Chen-Hsuan Lin, and Simon Lucey. Deep-lk for efficient adaptive object tracking. 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 627–634, 2018. 5
298
+ [69] Yanqing Chen, Timothy A Davis, William W Hager, and Sivasankaran Rajamanickam. Algorithm 887: Cholmod, supernodal sparse cholesky factorization and update/downdate. ACM Transactions on Mathematical Software (TOMS), 35(3):1–14, 2008. 6
299
+ [70] Esmond $\mathrm { N g }$ and Barry W Peyton. A supernodal cholesky factorization algorithm for sharedmemory multiprocessors. SIAM Journal on scientific computing, 14(4):761–769, 1993. 7, 23
300
+ [71] Fuzhen Zhang. The Schur complement and its applications, volume 4. Springer Science & Business Media, 2006. 7
301
+ [72] Jonathan T Barron and Ben Poole. The fast bilateral solver. In European conference on computer vision, pages 617–632. Springer, 2016. 7
302
+ [73] Barak A Pearlmutter and Jeffrey Mark Siskind. Reverse-mode ad in a functional framework: Lambda the ultimate backpropagator. ACM Transactions on Programming Languages and Systems (TOPLAS), 30(2):1–36, 2008. 7
303
+ [74] Chongjie Zhang and Victor Lesser. Multi-agent learning with policy prediction. In Twentyfourth AAAI conference on artificial intelligence, 2010.
304
+ [75] Dougal Maclaurin, David Duvenaud, and Ryan Adams. Gradient-based hyperparameter optimization through reversible learning. In International conference on machine learning, pages 2113–2122. PMLR, 2015.
305
+ [76] David Belanger and Andrew McCallum. Structured prediction energy networks. In International Conference on Machine Learning, pages 983–992, 2016.
306
+ [77] Luke Metz, Ben Poole, David Pfau, and Jascha Sohl-Dickstein. Unrolled generative adversarial networks. CoRR, abs/1611.02163, 2016. URL http://arxiv.org/abs/1611.02163.
307
+ [78] Tian Han, Yang Lu, Song-Chun Zhu, and Ying Nian Wu. Alternating back-propagation for generator network. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 31, 2017.
308
+ [79] David Belanger, Bishan Yang, and Andrew McCallum. End-to-end learning for structured prediction energy networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 429–439. JMLR. org, 2017.
309
+ [80] David Belanger. Deep energy-based models for structured prediction. PhD thesis, University of Massachusetts Amherst, 2017.
310
+ [81] Jakob N Foerster, Richard Y Chen, Maruan Al-Shedivat, Shimon Whiteson, Pieter Abbeel, and Igor Mordatch. Learning with opponent-learning awareness. arXiv preprint arXiv:1709.04326, 2017.
311
+ [82] Vishal Monga, Yuelong Li, and Yonina C Eldar. Algorithm unrolling: Interpretable, efficient deep learning for signal and image processing. IEEE Signal Processing Magazine, 38(2): 18–44, 2021. 7
312
+ [83] Paul J Werbos. Backpropagation through time: what it does and how to do it. Proceedings of the IEEE, 78(10):1550–1560, 1990. 7
313
+ [84] Herbert Jaeger. Tutorial on training recurrent neural networks, covering BPPT, RTRL, EKF and the" echo state network" approach, volume 5. GMD-Forschungszentrum Informationstechnik Bonn, 2002. 7
314
+ [85] Corentin Tallec and Yann Ollivier. Unbiasing truncated backpropagation through time. arXiv preprint arXiv:1705.08209, 2017. 7
315
+
316
+ [86] Yuhuai Wu, Mengye Ren, Renjie Liao, and Roger Grosse. Understanding short-horizon bias in stochastic meta-optimization. arXiv preprint arXiv:1803.02021, 2018.
317
+
318
+ [87] Renjie Liao, Yuwen Xiong, Ethan Fetaya, Lisa Zhang, KiJung Yoon, Xaq Pitkow, Raquel Urtasun, and Richard Zemel. Reviving and improving recurrent back-propagation. In International Conference on Machine Learning, pages 3082–3091. PMLR, 2018.
319
+
320
+ [88] Amirreza Shaban, Ching-An Cheng, Nathan Hatch, and Byron Boots. Truncated backpropagation for bilevel optimization. In The 22nd International Conference on Artificial Intelligence and Statistics, pages 1723–1732. PMLR, 2019.
321
+
322
+ [89] Paul Vicol, Luke Metz, and Jascha Sohl-Dickstein. Unbiased gradient estimation in unrolled computation graphs with persistent evolution strategies. In International Conference on Machine Learning, pages 10553–10563. PMLR, 2021. 7
323
+
324
+ [90] Brandon Amos. Differentiable Optimization-Based Modeling for Machine Learning. PhD thesis, Carnegie Mellon University, May 2019. 7
325
+
326
+ [91] Justin Domke. Generic methods for optimization-based modeling. In Artificial Intelligence and Statistics, pages 318–326. PMLR, 2012.
327
+
328
+ [92] Stephen Gould, Basura Fernando, Anoop Cherian, Peter Anderson, Rodrigo Santa Cruz, and Edison Guo. On differentiating parameterized argmin and argmax problems with application to bi-level optimization. arXiv preprint arXiv:1607.05447, 2016.
329
+
330
+ [93] Jonathan Lorraine, Paul Vicol, and David Duvenaud. Optimizing millions of hyperparameters by implicit differentiation. In International Conference on Artificial Intelligence and Statistics, pages 1540–1552. PMLR, 2020.
331
+
332
+ [94] Mathieu Blondel, Quentin Berthet, Marco Cuturi, Roy Frostig, Stephan Hoyer, Felipe LlinaresLópez, Fabian Pedregosa, and Jean-Philippe Vert. Efficient and modular implicit differentiation. arXiv preprint arXiv:2105.15183, 2021.
333
+
334
+ [95] Matan Atzmon, Niv Haim, Lior Yariv, Ofer Israelov, Haggai Maron, and Yaron Lipman. Controlling neural level sets. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché- Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/ 2019/file/b20bb95ab626d93fd976af958fbc61ba-Paper.pdf. 7
335
+
336
+ [96] Marin Vlastelica, Anselm Paulus, Vít Musil, Georg Martius, and Michal Rolínek. Differentiation of blackbox combinatorial solvers. arXiv preprint arXiv:1912.02175, 2019. 8
337
+
338
+ [97] Mathias Niepert, Pasquale Minervini, and Luca Franceschi. Implicit mle: Backpropagating through discrete exponential family distributions. Advances in Neural Information Processing Systems, 34, 2021. 8
339
+
340
+ [98] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, Robert Kern, Matti Picus, Stephan Hoyer, Marten H. van Kerkwijk, Matthew Brett, Allan Haldane, Jaime Fernández del Río, Mark Wiebe, Pearu Peterson, Pierre Gérard-Marchant, Kevin Sheppard, Tyler Reddy, Warren Weckesser, Hameer Abbasi, Christoph Gohlke, and Travis E. Oliphant. Array programming with NumPy. Nature, 585(7825):357–362, September 2020. doi: 10.1038/s41586-020-2649-2. URL https://doi.org/10.1038/s41586-020-2649-2. 10
341
+
342
+ [99] Paloma Sodhi, Sanjiban Choudhury, Joshua G. Mangelson, and Michael Kaess. ICS: Incremental Constrained Smoothing for State Estimation, 2020. 10
343
+
344
+ [100] André F.T. Martins, Mário A.T. Figueiredo, Pedro M.Q. Aguiar, Noah A. Smith, and Eric P. Xing. An augmented Lagrangian approach to constrained MAP inference. Proceedings of the 28th International Conference on Machine Learning, ICML 2011, pages 169–176, 2011. 10 [101] Richard Zou Horace He. functorch: Jax-like composable function transforms for pytorch. https://github.com/pytorch/functorch, 2021. 10, 19, 20
345
+
346
+ [102] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. 20
347
+
348
+ [103] Gregory S Chirikjian. Stochastic models, information theory, and Lie groups, volume 2: Analytic methods and modern applications, volume 2. Springer Science & Business Media, 2011. 20
349
+
350
+ [104] Taosha Fan, Hanlin Wang, Michael Rubenstein, and Todd Murphey. Cpl-slam: Efficient and certifiably correct planar graph-based slam using the complex number representation. IEEE Transactions on Robotics, 36(6):1719–1737, 2020. 21
351
+
352
+ [105] Taosha Fan and Todd Murphey. Majorization minimization methods for distributed pose graph optimization. arXiv preprint arXiv:2108.00083, 2021. 21
353
+
354
+ [106] Daniel Martinec and Tomas Pajdla. Robust rotation and translation estimation in multiview reconstruction. In 2007 IEEE Conference on Computer Vision and Pattern Recognition, pages 1–8. IEEE, 2007. 21
355
+
356
+ [107] Amit Singer and Yoel Shkolnisky. Three-dimensional structure determination from common lines in cryo-em by eigenvectors and semidefinite programming. SIAM journal on imaging sciences, 4(2):543–572, 2011. 21
357
+
358
+ [108] Mihai Cucuringu, Yaron Lipman, and Amit Singer. Sensor network localization by eigenvector synchronization over the euclidean group. ACM Transactions on Sensor Networks (TOSN), 8 (3):1–42, 2012. 21
359
+
360
+ [109] Luca Carlone, Roberto Tron, Kostas Daniilidis, and Frank Dellaert. Initialization techniques for 3d slam: A survey on rotation estimation and its use in pose graph optimization. In 2015 IEEE International Conference on Robotics and Automation (ICRA), pages 4597–4604, 2015. 21
361
+
362
+ [110] Jiaji Zhou, James A. Bagnell, and Matthew T. Mason. A fast stochastic contact model for planar pushing and grasping: Theory and experimental validation. In Nancy M. Amato, Siddhartha S. Srinivasa, Nora Ayanian, and Scott Kuindersma, editors, Robotics: Science and Systems XIII, Massachusetts Institute of Technology, Cambridge, Massachusetts, USA, July 12-16, 2017, 2017. doi: 10.15607/RSS.2017.XIII.040. URL http://www.roboticsproceedings.org/ rss13/p40.html. 22
363
+
364
+ [111] Paloma Sodhi, Eric Dexheimer, Mustafa Mukadam, Stuart Anderson, and Michael Kaess. Leo: Learning energy-based models in factor graph optimization. In Conference on Robot Learning, pages 234–244. PMLR, 2022. 22
365
+
366
+ [112] Bruce D. Lucas and Takeo Kanade. An iterative image registration technique with an application to stereo vision. In Proceedings of the 7th International Joint Conference on Artificial Intelligence - Volume 2, IJCAI’81, page 674–679, San Francisco, CA, USA, 1981. Morgan Kaufmann Publishers Inc. 23
367
+
368
+ [113] Simon Baker and Iain A. Matthews. Lucas-kanade 20 years on: A unifying framework. International Journal of Computer Vision, 56(3):221–255, 2004. URL https://doi.org/10. 1023/B:VISI.0000011205.11775.fd. 23
369
+
370
+ [114] Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. Deep image homography estimation. RSS 2016 Workshop: Limits and Potentials of Deep Learning in Robotics, 2016. URL http://arxiv.org/abs/1606.03798. 23
371
+
372
+ [115] Ulisse Dini. Analisi infinitesimale. Lithografia Gorani, 1878. 26
373
+
374
+ # Checklist
375
+
376
+ 1. For all authors...
377
+
378
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
379
+ (b) Did you describe the limitations of your work? [Yes]
380
+ (c) Did you discuss any potential negative societal impacts of your work? [No] We do not foresee any beyond what the field of differentiable optimization already have.
381
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
382
+
383
+ 2. If you are including theoretical results...
384
+
385
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
386
+
387
+ 3. If you ran experiments...
388
+
389
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
390
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
391
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
392
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
393
+
394
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
395
+
396
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
397
+ (b) Did you mention the license of the assets? [Yes]
398
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
399
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
400
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
401
+
402
+ 5. If you used crowdsourcing or conducted research with human subjects...
403
+
404
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
405
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
406
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/M2sNIiCC6C/M2sNIiCC6C.md ADDED
@@ -0,0 +1,564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SELF-SUPERVISED REGRESSION LEARNING USING DOMAIN KNOWLEDGE: APPLICATIONS TO IMPROVING SELF-SUPERVISED IMAGE DENOISING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Regression that predicts continuous quantity is a central part of applications using computational imaging and computer vision technologies. Yet, studying and understanding self-supervised learning for regression tasks – except for a particular regression task, image denoising – have lagged behind. This paper proposes a general self-supervised regression learning (SSRL) framework that enables learning regression neural networks with only input data (but without ground-truth target data), by using a designable operator that encapsulates domain knowledge of a specific application. The paper underlines the importance of domain knowledge by showing that under some mild conditions, the better designable operator is used, the proposed SSRL loss becomes closer to ordinary supervised learning loss. Numerical experiments for camera image denoising and low-dose computational tomography denoising demonstrate that proposed SSRL significantly improves the denoising quality over several existing self-supervised denoising methods.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep regression neural network (NN)-based methods that can accurately predict real- or complexvalued output have been rapidly gaining popularity in a wide range of computational imaging and computer vision applications including image denoising (Vincent et al., 2010; Xie et al., 2012; Zhang et al., 2017), image deblurring $\mathrm { { X u } }$ et al., 2014), image super-resolution (Dong et al., 2016; Kim et al., 2016), light-field reconstruction (Chun et al., 2020; Huang et al., 2020), object localization (Szegedy et al., 2013), end-to-end autonomous driving (Bojarski et al., 2016). Yet, they lack a general self-supervised learning framework.
12
+
13
+ In training a regression NN $f : \mathbb { R } ^ { N } \to \mathbb { R } ^ { M }$ , the most prevalent supervised learning approach minimizes the mean square error (MSE) between what $f$ predicts from an input $x \in \overline { { \mathbb { R } } } ^ { N }$ and a ground-truth target y ∈ RM :
14
+
15
+ $$
16
+ \operatorname* { m i n } _ { f } \mathbb { E } _ { x , y } { \| f ( x ) - y \| _ { 2 } ^ { 2 } } .
17
+ $$
18
+
19
+ Learning a denoising or refining NN uses (1) with $M = N$ – dubbed Noise2True – where $x$ is a corrupted image and $y$ is a clean (i.e., ground-truth) image. However, it is challenging or even impossible to collect many clean images $y$ in many practical applications, motivating research on self-supervised learning for image denoising (Ulyanov et al., 2018; Soltanayev & Chun, 2018; Krull et al., 2019; Batson $\&$ Royer, 2019; Laine et al., 2019; Moran et al., 2020; Quan et al., 2020; Xu et al., 2020; Hendriksen et al., 2020; Xie et al., 2020; Huang et al., 2021) – called self-supervised image denoising. To learn a denoiser $f$ with single noisy images, a popular self-supervised image denoising method, Noise2Self (Batson & Royer, 2019) (see also the concurrent work (Krull et al., 2019)), and its sophisticated relaxation, Noise2Same (Xie et al., 2020), study the following MSE minimization problem:
20
+
21
+ $$
22
+ \operatorname* { m i n } _ { f } \mathbb { E } _ { x } \| f ( x ) - x \| _ { 2 } ^ { 2 } .
23
+ $$
24
+
25
+ These methods use some partitioning schemes in (2) to avoid that its optimal solution is just the identity mapping $\mathcal { T }$ . Noise2Noise (Lehtinen et al., 2018) that learns a denoiser with pairs of two independent noisy images, is a pioneer work for self-supervised image denoising. Motivated by Noise2Noise, several self-supervised image denoising methods such as Noise2Inverse (Hendriksen et al., 2020), Neighbor2Neighbor (Huang et al., 2021), and (Soltanayev & Chun, 2018; Moran et al., 2020; Xu et al., 2020) emulate pairs of two independent noisy images, by applying partitioning or adding simulated noise to single noisy measurements. All the aforementioned methods have been developed based on some noise assumptions including pixel-wise independent noise (Krull et al., 2019; Xie et al., 2020; Huang et al., 2021) and zero-mean noise (Lehtinen et al., 2018; Batson & Royer, 2019; Xie et al., 2020). Yet, they lack design flexibility that might relax such noise assumptions and further improve the denoising performance of NNs. Some works estimate statistical parameters of noise, such as noise histogram (Krull et al., 2020) and parameters of Gaussian mixture noise model (Prakash et al., 2021).
26
+
27
+ This paper presents new insights on this topic. The paper proposes a general self-supervised learning framework for regression problems, which we refer to as self-supervised regression learning (SSRL). Proposed SSRL enables learning regression NNs with only input samples, by using a designable operator that can encapsulate domain knowledge of a specific application. Our main results show that under some mild conditions (e.g., in image denoising, statistical noise properties in $x _ { \mathrm { ~ } }$ ), the better desinable operator is used, the proposed SSRL loss becomes closer to ordinary supervised learning loss. In addition, a designable operator with good domain knowledge can relax noise assumptions of existing self-supervised denoising methods. Numerical experiments for camera image and low-dose computational tomography (CT) denoising with both simulated and real-world datasets – corrupted by only single noise realization – demonstrate that the proposed SSRL framework significantly improves denoising quality compared to several existing self-supervised denoising methods. Put together, our findings provide new insights into how using good domain knowledge can improve self-supervised denoising, underscoring the benefits of understanding application-specific knowledge in SSRL. (Section S.1 further elaborates the contributions of the paper.)
28
+
29
+ # 2 SSRL USING DOMAIN KNOWLEDGE
30
+
31
+ The proposed SSRL loss is given by
32
+
33
+ $$
34
+ \mathbb { E } _ { x } \Vert f ( x ) - g ( x ) \Vert _ { 2 } ^ { 2 } ,
35
+ $$
36
+
37
+ where $g : \mathbb { R } ^ { N } \to \mathbb { R } ^ { M }$ is a designable operator encapsulating domain knowledge of a specific application. We will incorporate some sophisticated setups in (3) such that $f$ obtained by minimizing (3) cannot merely be $g$ . Although related theorems (see later) hold for any $M$ , we mainly focus on practical image denoising applications with pseudo-target $g ( x ) \not \approx y$ .
38
+
39
+ # 2.1 MOTIVATION
40
+
41
+ This section empirically shows that understanding domain knowledge is important for designing $g$ in the proposed SSRL loss (3). The following camera image denoising examples demonstrate that well-designed $g$ with good domain knowledge improves the denoising performance of learned $f$ via (3).
42
+
43
+ Suppose that camera images are corrupted by salt-and-pepper noise. Consider two example setups for $g ( \cdot )$ , median filtering and BM3D denoiser (Makinen et al., 2020), denoted by ¨ median $( \cdot )$ and BM3D(·), respectively. Figure 1 compares the denoising performance of minimum $f ^ { \star }$ with the two aforementioned $g$ setups: $f ^ { \star }$ with median filtering significantly im
44
+
45
+ ![](images/956fd43252838c235cf56f6b3ea1a79a0f8c4adad823fe03d4aac54cd88fb989.jpg)
46
+ Figure 1: Error map comparisons of denoised images from (3) using $g ( x ) = { \mathrm { m e d i a n } } ( x )$ (left) and $g ( x ) \ = \ \mathsf { B M } 3 \mathsf { D } ( x )$ (right) (blue and yellow denote 0 and 50 absolute errors, respectively). Peak signal-to-noise ratio (PSNR) values are averaged.
47
+
48
+ proved that with BM3D denoiser. This is not surprising, as median filtering is widely known to be effective in reducing salt-and-pepper noise (Bovik, 2010, $\ S 3 . 2 )$ . This result emphasizes the importance of understanding domain knowledge of specific applications in proposed SSRL.
49
+
50
+ # 2.2 PRELIMINARIES
51
+
52
+ We first introduce the $\mathcal { I }$ -complement between two functions $f$ and $g$ :
53
+
54
+ Definition 1. For a given partition $\mathcal { I } = \{ J _ { 1 } , \ldots , J _ { B } \} ( | J _ { 1 } | + \ldots + | J _ { B } | = N )$ of the dimensions of input $\boldsymbol { x } \in \mathbb { R } ^ { N }$ , functions $f : \mathbb { R } ^ { N } \to \bar { \mathbb { R } ^ { M } }$ and $g : \mathbb { R } ^ { N } \to \mathbb { R } ^ { M }$ are called $\mathcal { I }$ -complementary, $i f$ $f ( x _ { J ^ { c } } )$ does not depend on $g ( x _ { J } )$ for all $J \in \mathcal { I }$ , where $J ^ { c }$ denotes the complement of $J$ , and $( \cdot ) _ { J }$ denotes a vector restricted to $J$ .
55
+
56
+ That is, $f$ and $g$ use information from outside and inside of $J$ to predict output and give pseudotarget, respectively. In denoiser learning (where $M \ = \ N )$ ), Definition 1 specializes to the $\mathcal { I }$ - invariance of $f$ (Batson & Royer, 2019), by setting $g = \mathcal { Z }$ . Incorporating Definition 1 into the SSRL loss (3) is a straightforward approach to avoid that optimal $f$ is just $g$ in (3). The proposed SSRL framework assumes the followings:
57
+
58
+ Assumption $^ { l }$ ) $x _ { J }$ and $x J c$ are conditionally independent given $y$ , i.e., $p ( x | y ) = p ( x _ { J } | y ) p ( x _ { J ^ { c } } | y )$ .
59
+ Assumption 2) $\mathbb { E } [ g ( x ) | y ] = y$ .
60
+ Assumption 3) $f$ and $g$ are (Borel-)measurable.
61
+
62
+ In denoiser learning, Assumption 1 holds if noise in each subset $J \in \mathcal { I }$ is conditionally independent from that in $J ^ { c }$ , given $y$ . Assumption 1 can be satisfied in general regression NN learning, by adding small randomized perturbations (independent of $y$ ) to either $J$ or $J ^ { c }$ , similar to Moran et al. (2020). Assumption 2 suggests a direction for designing $g$ : suppose that $x$ has non-zero-mean noise; one then can design $g$ to make noise zero-mean using the domain knowledge. Assumption 3 is satisfied if $f$ and $g$ are continuous. This condition is mild because many regression NNs $f$ are continuous – where their modules, convolution, matrix-vector multiplication, rectified linear unit activation, max pooling, etc. are continuous – and one can design $g$ with measurable or continuous function.
63
+
64
+ Finally, observe that the proposed SSRL loss (3) can be rewritten by
65
+
66
+ $$
67
+ \begin{array} { r } { \mathbb { E } _ { x } \| f ( x ) - g ( x ) \| _ { 2 } ^ { 2 } = \mathbb { E } _ { x , y } \| f ( x ) - y \| _ { 2 } ^ { 2 } + \| g ( x ) - y \| _ { 2 } ^ { 2 } - 2 \langle f ( x ) - y , g ( x ) - y \rangle . } \end{array}
68
+ $$
69
+
70
+ We aim to either remove or control the third term, incorporating the $\mathcal { I }$ -complement and/or Assumptions 1-3 introduced above.
71
+
72
+ # 2.3 SSRL USING DOMAIN KNOWLEDGE WITH $\mathcal { I }$ -COMPLEMENT
73
+
74
+ This section studies SSRL loss (3) minimization over $f$ that is $\mathcal { I }$ -complementary of $g$ . Our first main result shows that under Assumptions 1–3, the SSRL loss (3) with the $\mathcal { I }$ -complement is the sum of the ordinary supervised learning loss and variance of $g ( x ) - y$ , i.e., the third term in (4) vanishes.
75
+
76
+ Theorem 2. Under Assumptions 1–3, the SSRL loss (3) with the $\mathcal { I }$ -complement in Definition $^ { l }$ becomes
77
+
78
+ $$
79
+ \begin{array} { r } { \mathbb { E } _ { x } \| f ( x ) - g ( x ) \| _ { 2 } ^ { 2 } = \mathbb { E } _ { x , y } \| f ( x ) - y \| _ { 2 } ^ { 2 } + \| g ( x ) - y \| _ { 2 } ^ { 2 } . } \end{array}
80
+ $$
81
+
82
+ The following equality similarly holds for any $K \in \kappa$ : $\mathbb { E } _ { x } \| f ( x ) _ { K } - g ( x ) _ { K } \| _ { 2 } ^ { 2 } = \mathbb { E } _ { x , y } \| f ( x ) _ { K } -$ $y _ { K } \| _ { 2 } ^ { 2 } + \| g ( x ) _ { K } - y _ { K } \| _ { 2 } ^ { 2 }$ , where $\kappa$ is a partition of $\{ 1 , \dots , M \}$ , and $f ( \cdot ) _ { K }$ and $g ( \cdot ) _ { K }$ denote $f ( \cdot )$ and $g ( \cdot )$ restricted to $K$ , respectively. The optimal solution for (5) is given by
83
+
84
+ $$
85
+ \begin{array} { r } { f ^ { \star } ( x _ { J ^ { c } } ) = \mathbb { E } [ g ( x _ { J } ) | x _ { J ^ { c } } ] = \mathbb { E } [ y | x _ { J ^ { c } } ] . } \end{array}
86
+ $$
87
+
88
+ Proof. See Section A.1 in the appendix.
89
+
90
+ The result (6) suggests another direction for designing $g$ : we aim to design good $g$ that can make $g ( x _ { J } )$ close to $y$ . Using such $g$ , optimal solution of LHS in (6), $\mathbb { E } [ g ( x _ { J } ) | x _ { J ^ { c } } ]$ , becomes close to its supervision counterpart, $\mathbb { E } \lfloor y \vert x _ { J ^ { c } } \rfloor$ . Consequently, such $g$ reduces the second term $\mathbb { E } _ { x , y } \lVert g ( x ) - y \rVert _ { 2 } ^ { 2 }$ in RHS of (5), leading (3) closer to (1). If $g$ is ideal such that $g ( x _ { J } ) = y$ , the SSRL loss (3) becomes the usual supervised learning loss. In designing $g$ , domain knowledge of specific application is crucial. Domain knowledge includes noise properties in $x$ and pre-trained NN by existing self-supervised denoising, such as Noise2Self (Batson $\&$ Royer, 2019) and Noise2Noise (Lehtinen et al., 2018).
91
+
92
+ Specifically, the proposed SSRL loss using the $\mathcal { I }$ -complement is given by
93
+
94
+ $$
95
+ \mathcal { L } _ { \mathrm { i n d } } ( f ) \overset { \Delta } { = } \sum _ { J \in \mathcal { I } } \mathbb { E } _ { x } \Vert f ( x _ { J ^ { c } } ) - g ( x _ { J } ) \Vert _ { 2 } ^ { 2 } .
96
+ $$
97
+
98
+ ![](images/d58aa2ead765bf3a07f19a92bf12f2093a2d961269ffc483a94c4e62bec9bf93.jpg)
99
+ Figure 2: Proposed SSRL models using the $\mathcal { I }$ -complement in denoiser learning. Top: $f$ and $g$ use almost equal amount of information from input, i.e., $\vert J \vert \approx \vert J ^ { c } \vert$ , where $J$ and $J ^ { c }$ are complementary checkerboard masks. Bottom: $f$ and $g$ use unbalanced amount of information from input, specifically, $\left| J ^ { c } \right| \gg \left| J \right|$ .
100
+
101
+ Figure 2 illustrates (7) with complementary checkerboard masks $J ^ { c }$ and $J$ , where $f$ and $g$ use almost equal amount of information, and its variant, where $g$ uses much less information than $f$ . The variant computes MSE only on $J \in \mathcal { I }$ ; in this setup, it is challenging for $g$ to predict the entire image.
102
+
103
+ Relation to previous self-supervised denoising works. In denoiser learning, the proposed SSRL loss (3) with the $\mathcal { I }$ -complement of $f$ and $g = \mathcal { Z }$ specializes to (2) with the $\mathcal { I }$ -invariance of $f$ , i.e., Noise2Self. Noise2Inverse (Hendriksen et al., 2020) and Neighbor2Neighbor (Huang et al., 2021) that emulate pairs of two independent noisy images by partitioning single measurements (e.g., CT ray measurements with independent noise and corrupted images with pixel-wise independent noise) can be viewed as Noise2Self. Thus, SSRL loss (3) with the $\mathcal { I }$ -complement of $f$ and $g = \mathcal { T }$ specializes to the aforementioned Noise2Noise-motivated self-supervised denoising methods. (Noise2Noise also can be viewed by SSRL (3) with the setup above, by constructing $x$ with stacking two independent noisy images, where an image is corrupted by two independent noise realizations.)
104
+
105
+ # 2.4 SSRL USING DOMAIN KNOWLEDGE WITHOUT $\mathcal { I }$ -COMPLEMENT
106
+
107
+ This section studies the SSRL loss (3) without using the $\mathcal { I }$ -complement in Definition 1. Observe by (4) that $\begin{array} { r } { \mathbb { E } _ { x , y } \| f ( x ) - y \| _ { 2 } ^ { 2 } + \| g ( x , \ j ) - y \| _ { 2 } ^ { 2 } = \mathbb { E } _ { x } \| f ( x ) - g ( x , \ j ) \| _ { 2 } ^ { 2 } + 2 \mathbb { E } _ { x , y } \langle f ( x ) - f ( x , \ j ) \| _ { 2 } ^ { 2 } . } \end{array}$ $y , g ( x _ { J } ) - y \rangle$ . Inspired by Noise2Same (Xie et al., 2020), the second proposed SSRL approach is to minimize an approximation of the right hand side in this equation that does not assume that $f$ and $g$ are $\mathcal { I }$ -complementary. Our second main result finds an upper bound for the term $\mathbb { E } _ { x , y } \langle f ( x ) - y , g ( x _ { J } ) - y \rangle$ without relying on the $\mathcal { I }$ -complement (remind that this term vanishes if $f$ and $g$ are $\mathcal { I }$ -complementary; see Theorem 2).
108
+
109
+ Theorem 3. Assume that $\mathrm { V a r } ( g ( x _ { J } ) _ { m } | y ) \leq \sigma ^ { 2 }$ , ∀m. Under Assumptions 1–3, the following bound holds:
110
+
111
+ $$
112
+ \mathbb { E } _ { x , y } \langle f ( x ) - y , g ( x _ { J } ) - y \rangle \leq \sigma { \sqrt { M } } \cdot \left( \mathbb { E } _ { x } \| f ( x ) - f ( x _ { J ^ { c } } ) \| _ { 2 } ^ { 2 } \right) ^ { 1 / 2 } .
113
+ $$
114
+
115
+ The following bound similarly holds for any $K \in \kappa$ : $\mathbb { E } _ { x , y } \langle f ( x ) _ { K } - y _ { K } , g ( x _ { J } ) _ { K } - y _ { K } \rangle \le \sigma \sqrt { | K | }$ · $( \mathbb { E } _ { x } \| f ( x ) _ { K } - f ( x _ { J ^ { c } } ) _ { K } ) \| _ { 2 } ^ { 2 } ) ^ { 1 / 2 }$ , where $K$ and $\kappa$ are defined in Theorem 2.
116
+
117
+ Proof. See Section A.2 in the appendix.
118
+
119
+ Using Theorem 3, the proposed SSRL loss that does not rely on the $\mathcal { I }$ -complement is given by
120
+
121
+ $$
122
+ \mathcal { L } ( f ) \overset { \Delta } { = } \sum _ { J \in \mathcal { I } } \mathbb { E } _ { x } \| f ( x ) - g ( x _ { J } ) \| _ { 2 } ^ { 2 } + 2 \sigma \sqrt { M } \cdot \big ( \mathbb { E } _ { x } \| f ( x ) - f ( x _ { J ^ { c } } ) \| _ { 2 } ^ { 2 } \big ) ^ { 1 / 2 } ,
123
+ $$
124
+
125
+ where $\sigma$ is given in Theorem 3. Here, a regression NN $f$ can use information from the entire input $x$ , whereas $\operatorname { \mathcal { L } } _ { \mathrm { i n d } } ( f )$ in (7) uses only partial input $x J ^ { c }$ in $f$ . The intuition for designing $g$ in Section 2.3 similarly applies here. Our aim is to design good $g$ such that $g ( x _ { J } )$ is closer to $y$ , consequently leading (9) close to (1). Similar to the variant of $\operatorname { \mathcal { L } } _ { \mathrm { i n d } } ( f )$ (see Section 2.3), if the amount of information between two partitions $J$ and $J ^ { c }$ is unbalanced in denoiser learning, one can modify (9) to compute the MSE only on $J$ or $J ^ { c }$ in either both terms or the right term in (9). (These variants use the second result in Theorem 3.)
126
+
127
+ We conjecture that how well designed $g$ is, i.e., how close is pseudo-target $g ( x _ { J } )$ to ground-truth $y$ , is captured by $\sigma$ defined in Theorem 3. We support the conjecture with examples in Section A.3 of the appendix. Then, this “goodness” of $g$ balances the two terms in (9) via $\sigma$ . If $g$ is well-designed such that $g ( x _ { J } )$ is close to $y$ , i.e., $\sigma ^ { 2 }$ is small, then the SSRL loss (9) relies more on the first term with good pseudo-target. If $g$ is poorly-designed such that $\sigma ^ { 2 }$ is large, then (9) puts more weight more on the second term that can implicitly promote the $\mathcal { I }$ -invariance of $f$ .
128
+
129
+ Relation to previous self-supervised denoising work. The proposed SSRL loss (9) becomes the Noise2Same loss (Xie et al., 2020, Thm. 2), by replacing $g ( x _ { J } )$ with $x$ and adding randomness to $K = J$ in the second term. In practice, one can tune $\sigma$ in (9) without knowing its exact value, similar to Noise2Same. One might use the aforementioned conjectured behavior of (9) with expected performance of $g$ .
130
+
131
+ # 2.5 RELAXING NOISE ASSUMPTIONS OF EXISTING SELF-SUPERVISED DENOISING METHODS
132
+
133
+ This section explains how proposed SSRL (3) can relax noise assumptions of existing selfsupervised denoising methods. Noise assumptions of existing self-supervised denoising methods include additive white Gaussian noise (AWGN with known variance) (Soltanayev & Chun, 2018), pixel-wise independent noise (Krull et al., 2019; Xie et al., 2020; Huang et al., 2021), and zero-mean noise (Lehtinen et al., 2018; Quan et al., 2020) or more generally $\mathbb { E } [ x | y ] = y$ (Batson & Royer, 2019; Xie et al., 2020). Assumption 1 of proposed SSRL relaxes the AWGN and pixel-wise independent noise assumptions, and is identical to the first assumption of Noise2Self (Batson & Royer, 2019). Assumption 2 of proposed SSRL can relax the second assumption of Noise2Self, $\mathbb { E } [ x | y ] = y$ , that is also (implicitly) used in Noise2Same (Xie et al., 2020) and Noise2Noise (Lehtinen et al., 2018), by using a desinable function $g$ . For example, $x$ is corrupted by additive non-zero-mean noise $e$ that is independent of $y$ , i.e., $x = y + e$ , then one can design $g$ as follows: $\boldsymbol { g } ( \boldsymbol { x } ) = \boldsymbol { x } - \mathbb { E } [ \boldsymbol { e } ]$ , where $\mathbb { E } [ e ]$ can be estimated from calibration of imaging systems. The next section will explain how one can design $g$ using domain knowledge and select $g$ if domain knowledge is unavailable in image denoising.
134
+
135
+ # 3 EXAMPLES OF HOW TO DESIGN $g$ USING DOMAIN KNOWLEDGE, ANDEMPIRICAL-LOSS APPROACH FOR SELECTING $g$ IN IMAGE DENOISING
136
+
137
+ Understanding noise statistics or properties is the first step towards accurate image recovery in computational imaging. First, this section describes how to use domain knowledge for designing $g$ in two imaging applications with practical noise models: 1) camera image denoising in mixed Poisson– Gaussian–Bernoulli noise, 2) low-dose CT denoising. Both applications have complicated noise models or strong noise, where Assumptions 1–2 in Section 2.2 are not completely satisfied. Noisy images in the first application are corrupted by independent and identically distributed (i.i.d.) noise with non-zero mean. The noise in the second application is approximately zero-mean but it is likely non-i.i.d. In designing $g$ for each application, we will use the suggestions in Sections 2.2–2.3, investigating Assumptions 1–3. Second, we propose a $g$ -selection approach in image denoising that calculates some empirical measure related to (6) using only input training data.
138
+
139
+ The major noise sources in camera imaging (using charge coupled device) include object-dependent photoelectrons in image sensors, readout in camera electronics, and analog-to-digital converter and transmission errors that can be modeled by Poisson noise, AWGN, and Bernoulli (i.e., salt-andpepper) noise models (Snyder et al., 1993), (Bovik, 2010, p. 90). We use the following practical mixed Poisson–Gaussian–Bernoulli noise model (Snyder et al., 1993; Batson & Royer, 2019):
140
+
141
+ $$
142
+ x _ { n } = \Pi _ { [ 0 , 2 5 5 ] } ( \mathsf { B e r n o u l l i } _ { p } ( \mathsf { P o i s s o n } ( \lambda y _ { n } ) / \lambda + \epsilon _ { n } ) ) , \quad \epsilon \sim \mathcal { N } ( 0 , \sigma _ { \epsilon } ^ { 2 } I ) , \quad n = 1 , \hdots , N ,
143
+ $$
144
+
145
+ where $\Pi _ { [ 0 , 2 5 5 ] }$ performs 8-bit quantization and clips pixel values outside of [0, 255], Bernoulli substitutes a pixel value with either 0 or 255 with probability $p$ (0 and 255 are coined with equal probability), Poisson generates pixel intensity-dependent Poisson noise with gain parameter $\lambda$ , and $\epsilon$ is AWGN. Figure 3 (left) shows a noisy image corrupted by the mixed noise model (10). If an image $y$ is corrupted only by the mixed Poisson–Gaussian noise, ${ \dot { \mathbb { E } } } [ x | y ] = y$ in Assumption 2 can be satisfied $( \mathbb { E } [ \mathsf { P o i s s o n } ( \lambda y _ { n } ) / \lambda + \epsilon | y ] = y _ { n } , \forall n ) .$ . However, if Bernoulli noise is additionally considered as given in (10), the assumption $\mathbb { E } [ x | y ] = y$ will not be satisfied $( \mathbb { E } [ { \mathsf { B e r n o u l l i } } _ { p } ( y _ { n } ) | y ] = ( 1 - p ) y _ { n } + 1 2 7 . 5 p .$ , $\forall n$ ). The quantization-clipping operator $\Pi _ { [ 0 , 2 5 5 ] }$ also makes it hard to satisfy $\mathbb { E } [ x | y ] = y$ .
146
+
147
+ Following the suggestion based on Assumption 2 (see Section 2.2), we handcraft $g$ to “approximately” satisfy $\mathbb { E } [ g ( x ) | y ] ~ = ~ y$ with a simple operator. We interpret aforementioned Bernoulli noise and clipping artifact as salt-and-pepper noise. Median filtering is a computational efficient method that is effective in reducing salt-and-pepper and impulse noises (Bovik, 2010, $\ S 3 . 2 )$ . We design $g$ by applying weighted median filtering (Brownrigg, 1984) to a pixel with intensity either 0 or 255 at each color channel, aiming that this $g$ design “approximately” satisfy $\mathbb { E } [ g \bar { ( } x ) | y ] = y$ by suppressing the salt-and-pepper noise effects cased by $\Pi _ { [ 0 , 2 5 5 ] }$ and Bernoullip. (This is supported by empirical results in Section S.4.)
148
+
149
+ ![](images/c61ccb25de7db08c3cde623523889122a9e47f23a2077cdfe541a2e8dd4eacc2.jpg)
150
+ Figure 3: An input noisy image in camera image denoising in mixed noise (left) and low-dose CT (right). PSNR and root mean square error (RMSE) values were averaged across all test samples.
151
+
152
+ Assumption 1 is satisfied because the noise in (10) is i.i.d. and independent of $y$ . In Assumption 3, we conjecture that the above $g$ design is measurable (median operator is measurable under some conditions (Rustad, 2004)).
153
+
154
+ # 3.2 DESIGNING $g$ USING DOMAIN KNOWLEDGE: LOW-DOSE CT DENOISING
155
+
156
+ In $\mathbf { X }$ -ray CT (with a monoenergetic source), the pre-log measurement data is usually modeled by the Poisson model, i.e., Poisson $\bar { \{ \rho _ { 0 } \exp ( - [ A y ] _ { l } ) \} }$ , $l = 1 , \ldots , L$ , where $\rho _ { 0 }$ is the number of incident photons per ray, $A \in \mathbb { R } ^ { L \times N }$ is a CT projection system matrix, and $L$ is the number of measured rays. Using the quadratic approximation to the log-likelihood of a Poisson model, the post-log measurement $z \in \mathbb { R } ^ { L }$ given $y$ can be approximated as the following Gaussian model (Sauer & Bouman, 1993; Fessler, 2000): $z | y \sim { \bar { \mathcal { N } } } ( A y , C )$ , where $C \in \mathbb { R } ^ { L \times L }$ is a diagonal covariance matrix and its diagonal elements become more nonuniform in lower-dose CT. This model suggests that post-log measurement may be modeled by $z = A y + \varepsilon$ , where $\varepsilon \sim \mathcal { N } ( 0 , C )$ . The filtered back-projection (FBP) method (Kak & Slaney, 1988, $\ S 3$ ) performs computationally efficient CT reconstruction and has been widely used in commercial CT scanners (Pan et al., 2009). In low-dose CT, however, reconstructed image $x = F z$ suffers from strong noise and streak artifacts, where $\boldsymbol { F } \in \mathbb { R } ^ { N \times L }$ denotes a linear FBP operator, motivating research on learning denoising NNs. Figure 3 (right) shows a noisy FBP image in low-dose CT. Using the statistical results above, we model that a reconstructed image by $F$ is corrupted by an arbitrary additive noise $e$ :
157
+
158
+ $$
159
+ x = y + e , \quad e = ( F A - I ) y + F \varepsilon .
160
+ $$
161
+
162
+ Low-dose CT uses all projection rays similar to standard-dose CT (but with substantially reduced dose) where $F$ approximately inverts $A$ , i.e., $F A \approx I$ , so we conclude that under (11), $\mathbb { E } [ \bar { e } ] \approx 0$ and $\mathbb { E } [ x | y ] \approx y$ . (See empirical results in Section S.4 that support $\mathbb { E } [ e ] \approx 0$ .)
163
+
164
+ The above domain knowledge in low-dose CT indicates that handcrafting $g$ to have zero-mean $e$ to satisfy Assumption 2 can be redundant. Following the suggestion motivated by Theorem 2 (see Section 2.3), we set $g$ as a pre-trained denoiser by the existing self-supervised denoising methods (Batson & Royer, 2019; Hendriksen et al., 2020; Xie et al., 2020). Since such pre-trained $g$ will have some denoising capability and give better reference than $g = \mathcal { T }$ to (7) and (9) (see empirical results in Section S.4), we expect that proposed SSRL losses (7) and (9) improve the denoising quality over the aforementioned existing self-supervised denoising methods.
165
+
166
+ Assumption 1 is unlikely satisfied because in FBP images, neighboring noise components are likely to be correlated, i.e., $\begin{array} { r } { \dot { \mathrm { V a r } } ( e ) \approx F C F ^ { \top } } \end{array}$ using $F A \approx I$ and noise model (11). Assumption 3 is satisfied as we use the conventional denoisiong NN, DnCNN (Zhang et al., 2017) and (modified) U-Net (Ronneberger et al., 2015), that are a continuous function.
167
+
168
+ # 3.3 EMPIRICAL-LOSS APPROACH FOR SELECTING $g$ IF DOMAIN KNOWLEDGE UNAVAILABLE
169
+
170
+ If accurate domain knowledge of a specific application is unavailable, it would be challenging to explicitly design $g$ . In such cases in denoising, our general suggestion is to measure an existing selfsupervised denoising loss, an upper bound of $\| g ( x _ { J } ) - y \| _ { 2 } ^ { 2 }$ or its variant that measure the quality of $g$ , only with input training data. The lower quantity implies that $g$ is better and implicitly encapsulates better domain knowledge. In camera image denoising with the real-world dataset (Abdelhamed et al., 2018), the empirical measure of the Neighbor2Neighbor loss (Huang et al., $2 0 2 1 ) - \mathbb { E } \| g ( x _ { J } ) -$ $x _ { J ^ { c } } \| _ { 2 } ^ { 2 }$ – with setting $g$ as $\mathcal { T }$ and median filtering are 0.0052 and 0.0048, respectively. In low-dose CT denoising with the real-world dataset (Moen et al., 2021), the empirical measure of the Noise2Self loss (Batson & Royer, $2 0 1 9 ) - \mathbb { E } \| g ( x _ { J } ) _ { J ^ { c } } - x _ { J ^ { c } } \| _ { 2 } ^ { 2 }$ – with setting $g$ as $\mathcal { T }$ and pre-trained DnCNN by Noise2Self are 22044.5 and 17062.0 (in $\mathrm { H U ^ { 2 } }$ where HU stands for modified Hounsfield unit), respectively. We expect better SSRL performance with the selected $g$ designs over $\mathcal { T }$ .
171
+
172
+ # 4 EXPERIMENTAL RESULTS AND DISCUSSION
173
+
174
+ We evaluated proposed SSRL in two practical imaging applications in Section 3 with both simulated and real-world datasets. For these applications, we mainly focuses on comparisons with selfsupervised denoising methods using single noisy input samples, particularly when statistical noise parameters are unavailable. We compared the performances of the following methods: Noise2Self (Batson & Royer, 2019), Noise2Noise-motivated methods that emulate pairs of two independent noisy images – Neighbor2Neighbor (Huang et al., 2021) or Noise2Inverse (Hendriksen et al., 2020) – Noise2Same (Xie et al., 2020), and corresponding SSRL to each aforementioned method. We also included Noise2True (1) results as baseline. For $f$ or $g$ in all the methods, we used the conventional denoising NN architecture, DnCNN (Zhang et al., 2017) or modified U-Net used in Noise2Self. We include experiment setup, and image and numerical results for/from real-world datasets in Sec. A.4.
175
+
176
+ # 4.1 EXPERIMENTAL SETUP FOR SIMULATED DATASETS
177
+
178
+ Camera image denoising in mixed noise. We evaluated the proposed SSRL framework with three RGB camera image datasets, ImageNet ILSVRC 2012 Val (Russakovsky et al., 2015), BSD 300 (Martin et al., 2001), Set 5 (Bevilacqua et al., 2012). For training, we used the ImageNet ILSVRC 2012 Val dataset with 20,000 images; for tests, we used the BSD 300 and Set 5 datasets consisting of 300 and 5 images, respectively. We simulated noisy images with the following imaging parameters introduced in (10): $\lambda = 3 0$ , $\sigma _ { \epsilon } = 6 0$ , and $p = 0 . 2$ . We evaluated the denoising quality by the most conventional error metric in camera image denoising, PSNR and structural similarity index measure (SSIM). In Neighbor2Neighbor setup, we emulated two independent noisy images from single noisy images by random neighbor sub-sampling with $2 \times 2 \cdot$ -window (Huang et al., 2021).
179
+
180
+ Low-dose CT denoising. We evaluated the proposed SSRL framework with The 2016 Low Dose CT Grand Challenge data (McCollough, 2016). We selected 200 regular-dose chest images of size $N = 5 1 2 \times 5 1 2$ and the $3 \mathrm { m m }$ slice thickness from four patients. For training, we used 170 $( 8 5 \% )$ chest images from three patients; for tests, we used 30 $( 1 5 \% )$ chest images from the other patient. We simulated low-dose sinograms using the Poisson model with the selected regular-dose chest datasets. In particular, we simulated sinograms of size $L = 7 3 6 \times 1 1 5 2$ (‘detectors’ $\times$ ‘projection views’), with fan-beam geometry corresponding to a no-scatter monoenergetic source with $\rho _ { 0 } = 5 \times 1 0 ^ { 4 }$ . We used FBP (Kak & Slaney, 1988, §3) to reconstruct images with resolution $\mathrm { 0 . 6 9 m m \times 0 . 6 9 m m }$ . We evaluated the denoising quality by the most conventional error metric in CT application, RMSE in HU. In Noise2Inverse setup, we emulated two independent noisy images by partitioning single sinograms with odd and even views and applying FBP to two partitioned independent sinograms.
181
+
182
+ ![](images/fbfc5b3714c912198e76971f6c45878aaea68bd1d3c508ffa818c3c85382c5e8.jpg)
183
+ Figure 4: Comparisons of denoised images (left) via DnCNNs from different learning methods and their saturation error maps (right) in camera image denoising (blue and yellow denote 0 and 0.5 absolute error, respectively). PSNR & SSIM values were averaged across all BSD 300 test samples.
184
+
185
+ # 4.2 COMPARISONS BETWEEN DIFFERENT SELF-SUPERVISED DENOISING METHODS
186
+
187
+ Compare each existing self-supervised denoising method to its corresponding SSRL setup in Figures 4–5, and Figures S.1–S.4 and Tables S.1–S.3; see three comparison sets, each grouped by red box. For both applications, proposed SSRL achieves significantly better image denoising quality, i.e., closer to the Noise2True quality, compared to the existing methods, Noise2Self, Neighbor2Neighbor, Noise2Inverse, and Noise2Same, regardless of the regression NN architecture. We show DnCNN prediction uncertainty of all the methods in Figure S.5.
188
+
189
+ Camera image denoising in mixed noise (simulated data). Figures 4 and S.3 show that in all the three comparison sets, SSRL gives closer image quality, particularly color saturation, to Noise2True than existing methods, Noise2Self, Neighbor2Neighbor, and Noise2Same. Setting $g$ as weighted median filtering avoids bias in SSRL loss caused by salt-and-pepper noise. Yet, compared to Noise2True, denoised images obtained by proposed SSRL lack saturation and detail preservation. For saturation and detail preservation comparisons, see Figures 4, S.1 and S.3.
190
+
191
+ Comparing the three comparison sets in Figures 4 and S.3, and Tables S.1–S.2 shows that all the Noise2Self, Neighbor2Neighbor, and Noise2Self setups have comparable results in terms of PSNR values. The potential reason is that in this application, all the three setups similarly satisfy Assumptions 1–3 (see Section 2.2); in particular, Assumption 1 is well-satisfied by pixel-wise i.i.d. noise.
192
+
193
+ In this application, the zero-mean noise assumption of the existing self-supervised denoising methods is violated, whereas its counterpart in proposed SSRL, Assumption 2, is “approximately” satisfied by $g$ in Section 3.1. This suggests the importance of satisfying Assumption 2 with good $g$ .
194
+
195
+ Low-dose CT denoising (simulated data). In all the three comparison sets, SSRL better recovers low-contrast regions (e.g., soft tissues) and small details, and significantly reduces noise and artifacts throughout the image, over existing methods, Noise2Self, Noise2Inverse, and Noise2Same. See zoom-ins and circled small details in Figures 5 and S.4, and error images in Figure S.2, particularly in ‘Noise2Self vs. Propose SSRL in Noise2Self setup’ and ‘Noise2Same vs. Proposed SSRL in Noise2Same setup.’ The results might imply that simply setting $g$ as pre-trained NN by existing selfsupervised denoising methods works like a charm in SSRL. Proposed SSRL in the Noise2Inverse setup can provide images with image quality that is comparable to conventional FBP at 10 times higher dose (when $\rho _ { 0 } \stackrel { \mathbf { \Delta } } { = } 5 \times 1 0 ^ { 5 }$ , $\mathrm { R M S E } = 2 0 . 5 \ : \mathrm { H L }$ on average; see DnCNN results in Figure 5).
196
+
197
+ ![](images/319120f1abc4bbc507e34a918865fcc8036d9524038facd63ffcd5edb68b04ad.jpg)
198
+ Figure 5: Comparisons of denoised images via DnCNNs from different learning methods in lowdose CT (display window is [800, 1200] HU). RMSE values were averaged across all test samples.
199
+
200
+ Next, comparing Noise2Self and Noise2Same result sets to that of Noise2Inverse in Figures 5, S.2 and S.4, and Table S.3 shows that Noise2Inverse setup significantly improves the denoising quality, compared to Noise2Self and Noise2Same setups. We conjecture that violation of Assumption 1 – that is satisfied in the Noise2Inverse setup but unlikely to be satisfied in the Noise2Self and Noise2Same setups in this application – degrades the performance.
201
+
202
+ Camera image denoising and low-dose CT denoising with real-world datasets. Denoised image results in Figures A.2–A.3 and S.8–S.9 from the two real-world datasets (Abdelhamed et al., 2018; Moen et al., 2021) demonstrate that SSRL improves existing self-supervised denoising methods, particularly Neighbor2Neighbor, Noise2Self, and Noise2Same, without having their exact noise properties. The results well correspond to our expectation in Section 3.3.
203
+
204
+ # 5 CONCLUSION
205
+
206
+ It is important to develop SSRL that enables comparable prediction performances to supervised learning, because it is extremely challenging to collect many ground-truth target samples in many practical computational imaging and computer vision applications. The proposed SSRL framework bridges the gap between SSRL and supervised regression learning via domain knowledge of applications. To achieve closer prediction performance to supervised learning, SSRL uses domain knowledge to design a better pseudo-predictor $g$ such that $\bar { g ( x _ { J } ) }$ becomes closer to $y$ . For camera image denoising and low-dose CT denoising with both simulated and real-world datasets, SSRL achieves more accurate prediction compared to the existing self-supervised denoising methods (Batson & Royer, 2019; Huang et al., 2021; Hendriksen et al., 2020; Xie et al., 2020). Remark, however, that applying SSRL to other regressions problems may need careful investigations about $g$ based on their domain knowledge. Our future work is extending proposed SSRL to other machine learning problems such as teacher-student models (see Section S.7) and meta-learning. On the application side, our future work is applying SSRL to regression problems beyond image denoising.
207
+
208
+ # 6 REPRODUCIBILITY
209
+
210
+ Section 2.2 specifies all the theoretical assumptions. Section A.1 and Section A.2 in the appendix include the complete proofs of Theorem 2 and Theorem 3, respectively. Section S.2 in the supplement includes the complete implementation details including the hyperparameter selection strategies and the chosen hyperparameters. We included an anonymized zip file that includes test codes, test data, trained models, and instructions and codes that provide complete description of the data processing steps, as supplementary materials. We will make our codes (for data construction, training, and test) and trained models publicly available on GitHub if the paper is accepted.
211
+
212
+ # REFERENCES
213
+
214
+ Abdelrahman Abdelhamed, Stephen Lin, and Michael S. Brown. A high-quality denoising dataset for smartphone cameras. In Proc. IEEE CVPR, pp. 1692–1700, Salt Lake City, Utah, Jun. 2018.
215
+
216
+ Joshua Batson and Loic Royer. Noise2Self: Blind denoising by self-supervision. In Proc. ICML, pp. 524–533, Long Beach, CA, Jun. 2019.
217
+
218
+ Marco Bevilacqua, Aline Roumy, Christine Guillemot, and Marie Line Alberi-Morel. Lowcomplexity single-image super-resolution based on nonnegative neighbor embedding. In Proc. BMVC, pp. 135.1–135.10, Surrey, UK, Sep. 2012.
219
+
220
+ Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski, Bernhard Firner, Beat Flepp, Prasoon Goyal, Lawrence D Jackel, Mathew Monfort, Urs Muller, Jiakai Zhang, et al. End to end learning for self-driving cars. NIPS Deep Learning Symposium, Dec. 2016. arXiv:1604.07316.
221
+
222
+ Alan C Bovik. Handbook of image and video processing. Academic Press, Florida, 2010.
223
+
224
+ David RK Brownrigg. The weighted median filter. Commun. of the ACM, 27:807–818, 1984.
225
+
226
+ Il Yong Chun, Zhengyu Huang, Hongki Lim, and Jeffrey A Fessler. Momentum-Net: Fast and convergent iterative neural network for inverse problems. early access in IEEE Trans. Pattern Anal. Mach. Intell., 2020. doi: 10.1109/TPAMI.2020.3012955.
227
+
228
+ Chao Dong, Chen Change Loy, Kaiming He, and Xiaoou Tang. Image super-resolution using deep convolutional networks. IEEE Trans. Pattern Anal. Mach. Intell., 38(2):295–307, Feb. 2016.
229
+
230
+ Jeffrey A Fessler. Statistical image reconstruction methods for transmission tomography. In M Sonka and J Michael Fitzpatrick (eds.), Handbook of Medical Imaging, Volume 2. Medical Image Processing and Analysis, pp. 1–70. SPIE, Bellingham, WA, 2000.
231
+
232
+ Allard Adriaan Hendriksen, Daniel Maria Pelt, and K Joost Batenburg. Noise2Inverse: Self-¨ supervised deep convolutional denoising for tomography. IEEE Trans. Comput. Imag., 6:1320– 1335, Aug. 2020.
233
+
234
+ Tao Huang, Songjiang Li, Xu Jia, Huchuan Lu, and Jianzhuang Liu. Neighbor2Neighbor: Selfsupervised denoising from single noisy images. In Proc. IEEE/CVF CVPR, pp. 14781–14790, Virtual, Jun. 2021.
235
+
236
+ Zhengyu Huang, Jeffrey A Fessler, Theodore B Norris, and Il Yong Chun. Light-field reconstruction and depth estimation from focal stack images using convolutional neural networks. In Proc. IEEE ICASSP, pp. 8648–8652, Barcelona, Spain, May 2020.
237
+
238
+ A. C. Kak and M. Slaney. Principles of computerized tomographic imaging. IEEE Press, New York, NY, 1988.
239
+
240
+ Jiwon Kim, Kwon Jung Lee, and Kyoung Mu Lee. Accurate image super-resolution using very deep convolutional networks. In Proc. IEEE CVPR, Las Vegas, NV, Jun. 2016.
241
+
242
+ Alexander Krull, Tim-Oliver Buchholz, and Florian Jug. Noise2Void - Learning denoising from single noisy images. In Proc. IEEE/CVF CVPR, pp. 2129–2137, Long Beach, CA, Jun. 2019.
243
+
244
+ Alexander Krull, Toma´s Vi ˇ car, Mangal Prakash, Manan Lalit, and Florian Jug. Probabilistic ˇ noise2void: Unsupervised content-aware denoising. Frontiers in Computer Science, 2:5, 2020.
245
+
246
+ Samuli Laine, Jaakko Lehtinen, and Timo Aila. High-quality self-supervised deep image denoising. In Proc. NIPS, Vancouver, Canada, Dec. 2019.
247
+
248
+ Jaakko Lehtinen, Jacob Munkberg, Jon Hasselgren, Samuli Laine, Tero Karras, Miika Aittala, and Timo Aila. Noise2Noise: Learning image restoration without clean data. In Proc. ICML, pp. 2965–2974, Stockholm, Sweden, Jul. 2018.
249
+
250
+ Ymir Makinen, Lucio Azzari, and Alessandro Foi. Collaborative filtering of correlated noise: Ex- ¨ act transform-domain variance for improved shrinkage and patch matching. IEEE Trans. Image Process., 29:8339–8354, Aug. 2020.
251
+
252
+ D. Martin, C. Fowlkes, D. Tal, and J. Malik. A database of human segmented natural images and its application to evaluating segmentation algorithms and measuring ecological statistics. In Proc. IEEE ICCV, pp. 416–423, Vancouver, Canada, July 2001.
253
+
254
+ C. McCollough. TU-FG-207A-04: Overview of the low dose CT grand challenge. Med. Phys., 43 (6Part35):3759–3760, Jun. 2016.
255
+
256
+ Taylor R Moen, Baiyu Chen, David R Holmes III, Xinhui Duan, Zhicong Yu, Lifeng Yu, Shuai Leng, Joel G Fletcher, and Cynthia H McCollough. Low-dose CT image and projection dataset. Med. Phys., 48(2):902–911, Feb. 2021.
257
+
258
+ Nick Moran, Dan Schmidt, Yu Zhong, and Patrick Coady. Noisier2Noise: Learning to denoise from unpaired noisy data. In Proc. IEEE/CVF CVPR, pp. 12064–12072, Virtual, Jun. 2020.
259
+
260
+ Xiaochuan Pan, Emil Y Sidky, and Michael Vannier. Why do commercial CT scanners still employ traditional, filtered back-projection for image reconstruction? Inverse Probl., 25(12):123009, 2009.
261
+
262
+ Mangal Prakash, Alexander Krull, and Florian Jug. Fully unsupervised diversity denoising with convolutional variational autoencoders. In Proc. ICLR, Virtual, May. 2021.
263
+
264
+ Yuhui Quan, Mingqin Chen, Tongyao Pang, and Hui Ji. Self2Self with dropout: Learning selfsupervised denoising from single image. In Proc. IEEE/CVF CVPR, pp. 1890–1898, Virtual, Jun. 2020.
265
+
266
+ Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In Proc. Med. Image Computing and Computer Assist. Interven., pp. 234–241, Munich, Germany, Oct. 2015.
267
+
268
+ Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. Int. J. Comput. Vision, 115(3):211–252, 2015.
269
+
270
+ Alf B Rustad. The median in multidimensional spaces. Adv. App. Math., 33(2):366–396, Mar. 2004.
271
+
272
+ Ken Sauer and Charles Bouman. A local update strategy for iterative reconstruction from projections. IEEE Trans. Signal Process., 41(2):534–548, Feb. 1993.
273
+
274
+ Donald L. Snyder, Abed M. Hammoud, and Richard L. White. Image recovery from data acquired with a charge-coupled-device camera. J. Opt. Soc. Am. A, 10(5):1014–1023, May 1993.
275
+
276
+ Shakarim Soltanayev and Se Young Chun. Training deep learning based denoisers without ground truth data. In Proc. NIPS, volume 31, Montreal, Canada, Dec. 2018.
277
+
278
+ Christian Szegedy, Alexander Toshev, and Dumitru Erhan. Deep neural networks for object detection. 2, Dec. 2013.
279
+
280
+ Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Deep image prior. In Proc. IEEE/CVF CVPR, pp. 9446–9454, Salt Lake City, Utah, June 2018.
281
+
282
+ Pascal Vincent, Hugo Larochelle, Isabelle Lajoie, Yoshua Bengio, and Pierre-Antoine Manzagol. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. J. Mach. Learn. Res., 11(12):3371–3408, Dec. 2010.
283
+
284
+ Junyuan Xie, Linli Xu, and Enhong Chen. Image denoising and inpainting with deep neural networks. In Proc. NIPS, pp. 341–349, Lake Tahoe, NV, Dec. 2012.
285
+
286
+ Yaochen Xie, Zhengyang Wang, and Shuiwang Ji. Noise2Same: Optimizing a self-supervised bound for image denoising. In Proc. NIPS, volume 33, pp. 20320–20330, Vancouver, Canada, Dec. 2020.
287
+
288
+ Jun Xu, Yuan Huang, Li Liu, Fan Zhu, Xingsong Hou, and Ling Shao. Noisy-As-Clean: Learning unsupervised denoising from the corrupted image. IEEE Trans. Image Process., 29:9316–9329, Sep. 2020.
289
+
290
+ Li Xu, Jimmy SJ Ren, Ce Liu, and Jiaya Jia. Deep convolutional neural network for image deconvolution. In Proc. NIPS, pp. 1790–1798, Montreal, Canada, Dec. 2014.
291
+
292
+ Kai Zhang, Wangmeng Zuo, Yunjin Chen, Deyu Meng, and Lei Zhang. Beyond a Gaussian denoiser: Residual learning of deep CNN for image denoising. IEEE Trans. Image Process., 26(7):3142– 3155, Feb. 2017.
293
+
294
+ # APPENDIX
295
+
296
+ # A.1 PROOFS FOR THEOREM 2
297
+
298
+ Observe first that combining Assumptions 1 & 3 and the $\mathcal { I }$ -complement implies that $f ( x ) _ { m }$ and $g ( x ) _ { m }$ are conditionally independent, given $y$ , i.e.,
299
+
300
+ $$
301
+ f ( x _ { J ^ { c } } ) _ { m } | y \perp \perp g ( x _ { J } ) _ { m } | y , \quad \forall m .
302
+ $$
303
+
304
+ Using this result with Assumption 2 and reminding that the $\mathcal { I }$ -complement implies $\mathbb { E } _ { x } \Vert f ( x ) -$ $g ( x ) \bar { | | } _ { 2 } ^ { 2 } = \mathbb { E } _ { x } | | f ( x _ { J ^ { c } } ) - g ( x _ { J } ) | | _ { 2 } ^ { 2 }$ , we obtain the following result from (4):
305
+
306
+ $$
307
+ \mathbb { E } _ { x } \| f ( x _ { J ^ { c } } ) - g ( x _ { J } ) \| _ { 2 } ^ { 2 } = \mathbb { E } _ { x , y } \| f ( x _ { J ^ { c } } ) - y \| _ { 2 } ^ { 2 } + \| g ( x _ { J } ) - y \| _ { 2 } ^ { 2 }
308
+ $$
309
+
310
+ where the equality uses
311
+
312
+ $$
313
+ \begin{array} { r l } { { \mathbb { E } _ { x , y } \langle f ( x _ { J ^ { c } } ) - y , g ( x _ { J } ) - y \rangle = \mathbb { E } _ { y } \mathbb { E } _ { x | y } \langle f ( x _ { J ^ { c } } ) - y , g ( x _ { J } ) - y \rangle } } \\ & { = \sum _ { m } \mathbb { E } _ { y } \big ( \mathbb { E } _ { x | y } [ f ( x _ { J ^ { c } } ) _ { m } - y _ { m } ] \big ) \big ( \mathbb { E } _ { x | y } [ g ( x _ { J } ) _ { m } - y _ { m } ] \big ) } \\ & { = 0 } \end{array}
314
+ $$
315
+
316
+ in which the second equality uses the first result above and the third equality holds by Assumption 2.
317
+ This completes the proofs.
318
+
319
+ # A.2 PROOFS FOR THEOREM 3
320
+
321
+ We first obtain the following bound:
322
+
323
+ $$
324
+ \begin{array} { r l } & { \mathbb { E } _ { \rho \to \infty } \int \mathrm { d } \rho ( x , \rho ) \mathrm { d } x , } \\ & { = \mathbb { E } _ { \rho \to \infty } \frac { 1 } { \rho } \int _ { 0 } ^ { \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \frac { 1 } { \rho } \{ \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x - \mathrm { c o s } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x - \mathrm { c o s } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { = \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { \leq \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { \leq \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & { \leq \sum _ { \rho \geq \infty } \mathbb { E } _ { \rho \to \infty } \{ \mathrm { d } \rho ( x , \rho ) \mathrm { d } x \} \mathrm { d } \rho } \\ & \leq ( \frac { 1 } { \rho } \mathrm { d } x ) \mathrm { d } x \mathrm { d } \rho ( x , \rho ) \mathrm { d } \rho \end{array}
325
+ $$
326
+
327
+ where the second equality holds by Assumption 2, the third equality uses $\mathrm { C o v } ( X , Y \vert Z ) ~ =$ $\mathbb { E } [ X Y | Z ] - \mathbb { E } [ X | Z ] \mathbb { E } [ Y | Z ]$ where $X , Y$ , and $Z$ are random variables or vectors, the fifth equality holds because $f ( x _ { J ^ { c } } ) _ { m }$ does not correlate with $g ( x _ { J } ) _ { m }$ , ∀m (due to Assumptions 1 and 3), so subtracting $f ( x _ { J ^ { c } } ) _ { m }$ from $f ( x ) _ { m }$ does not change the covariance. Now, the first inequality uses the Pearson correlation coefficient bound, the second inequality uses the Jensen’s inequality√ √ $\mathbb { E } \sqrt { X } \le \sqrt { \mathbb { E } X }$ , the third inequality uses the Jensen’s inequality $\begin{array} { r } { \sum _ { m } \sqrt { a _ { m } } \leq \sqrt { M ^ { \prime } \sum _ { m } a _ { m } } } \end{array}$ for any $a \in \mathbb { R } ^ { M ^ { \prime } }$ , and the last inequality holds by the conditional variance bound specified in Theorem 3. We bound and rewrite the final result above and this completes the proof:
328
+
329
+ $$
330
+ \begin{array} { r l } & { \mathbb { E } _ { x , y } \langle f ( x ) - y , g ( x , \ j ) - y \rangle \leq \sigma \sqrt { M } \cdot \left( \displaystyle \sum _ { m = 1 } ^ { M } \mathbb { E } _ { y } \left[ \mathrm { V a r } ( f ( x ) _ { m } - f ( x , \ j _ { m } | y ) \right] \right) ^ { 1 / 2 } } \\ & { \quad \quad \quad \leq \sigma \sqrt { M } \cdot \left( \displaystyle \sum _ { m = 1 } ^ { M } \mathbb { E } _ { y } \left[ \mathbb { E } _ { x | y } \left[ f ( x ) _ { m } - f ( x , \ j _ { m } ) \right] ^ { 2 } \right] \right) ^ { 1 / 2 } } \\ & { \quad \quad \quad = \sigma \sqrt { M } \cdot \left( \displaystyle \sum _ { m = 1 } ^ { M } \mathbb { E } _ { x } \left[ f ( x ) _ { m } - f ( x , \ j _ { m } ) _ { m } \right] ^ { 2 } \right) ^ { 1 / 2 } , } \end{array}
331
+ $$
332
+
333
+ where the equality uses the filtration property of conditional expectation.
334
+
335
+ # A.3 EXAMPLES THAT SUPPORT CONJECTURED BEHAVIOR OF (9) WITH $\sigma$
336
+
337
+ The first example in general regression models the pseudo-target as follows: $g ( x _ { J } ) = y + e _ { 1 }$ , where $\boldsymbol { e } _ { 1 } \in \mathbb { R } ^ { \dot { \boldsymbol { M } } }$ is some arbitrarily additive noise independent of $y$ . This gives $\nabla \ a \mathbf { r } ( g ( x _ { J } ) _ { m } | y ) =$ $\mathrm { V a r } ( y _ { m } + ( e _ { 1 } ) _ { m } | y ) = \mathrm { V a r } ( e _ { 1 } ) _ { m } \stackrel { \cdot } { \leq } \sigma ^ { 2 }$ , $m = 1 , \ldots , M$ . Under this model, how close is $g ( x _ { J } )$ to $y$ is captured by $\sigma$ .
338
+
339
+ The second example in image denoising assumes that $x$ is corrupted by AWGN $e _ { 2 } \in \mathbb { R } ^ { N }$ that is independent of $y$ . Setting $g$ as a linear mapping $G \in \mathbb { R } ^ { J \times N }$ gives $\mathrm { \bar { V a r } } ( g ( x _ { J } ) _ { n } | y ) = \mathrm { V a r } ( ( G y _ { J } ) _ { n } +$ $( G ( e _ { 2 } ) _ { J } ) _ { n } | y ) = \mathrm { V a r } ( ( G ( e _ { 2 } ) _ { J } ) _ { n } ) \leq \sigma ^ { 2 }$ , $\forall n = 1 , \ldots , N$ . Under this model, how close is $g ( x _ { J } )$ to $y$ is captured by $\sigma$ .
340
+
341
+ # A.4 EXPERIMENTAL SETUP AND RESULTS FOR/FROM REAL-WORLD DATASETS
342
+
343
+ # A.4.1 EXPERIMENTAL SETUP FOR REAL-WORLD DATASETS
344
+
345
+ We also evaluated the proposed SSRL framework with real-world camera image and low-dose CT datasets, where we do not have their complete noise properties/statistics. We chose the publicly available SIDD sRGB Data (Abdelhamed et al., 2018) and Low Dose CT Image and Projection Data (Moen et al., 2021), where both the datasets include high-quality images or standard-dose FBP images so that one can run Noise2True experiments and obtain quantitative results. We used the DnCNN architecture for all experiments. For each experiment, we used the same implementation setup (such as hyperparameters and masking scheme) as that in the corresponding simulated data experiment. In particular, $g$ is median filter and pre-trained denoiser via existing self-supervised denoising methods in camera image denoising and low-dose CT denoising experiments, respectively.
346
+
347
+ Camera image denoising with SIDD sRGB Data. We used the SIDD sRGB training and validation datasets for training and tests, respectively. We chose the representative comparison setup, Neighbor2Neighbor, from the camera image denoising experiments using simulated data in Section 4.1.
348
+
349
+ Low-dose CT denoising with Low Dose CT Image and Projection Data. We followed the data construction setup in Section 4.1 that was used in simulated data experiments; we remark that chest CT scans in the Low Dose CT Image and Projection Data use the $1 \mathrm { m m }$ slice
350
+
351
+ ![](images/ad39d0d65b3e7dc1ff7f24361f1e8b442688b064cc5fb8ccd3a6bcdb6b3ef6e7.jpg)
352
+ Figure A.1: An input intrinsically-noisy image in camera image denoising (left) and low-dose CT (right). PSNR and RMSE values were averaged across all test samples.
353
+
354
+ thickness. We cannot run Noise2Inverse experiments because the Low Dose CT Image and Projection Data does not provide two independent half-view FBP images. We thus chose the other comparison setups, Noise2Self and Noise2Same.
355
+
356
+ # A.4.2 MAIN EXPERIMENTAL RESULTS FROM REAL-WORLD DATASETS
357
+
358
+ This section includes main experimental results such as denoised images and calculated performance measure, from the real-world datasets. Section S.3.2 in the supplement includes their supplementary results.
359
+
360
+ ![](images/2a0f24dd64a8ea2048304ad2f30ef3ae8f529172557fa0d7bfc775aba254e9ed.jpg)
361
+ Figure A.2: Comparisons of denoised images (top) via DnCNNs from different learning methods and their saturation error maps (bottom) in camera image denoising (blue and yellow denote 0 and 0.5 absolute errors, respectively). PSNR and SSIM values were averaged across all SIDD sRGB validation samples.
362
+
363
+ ![](images/20c7f390945cfb312b4fb6d7c37f244302cef3b4d75618691a898cae8cdfa209.jpg)
364
+ Figure A.3: Comparisons of denoised images via DnCNNs from different learning methods in lowdose CT (display window is [800, 1200] HU). RMSE values were averaged across all test samples.
365
+
366
+ # SELF-SUPERVISED REGRESSION LEARNING USING DOMAIN KNOWLEDGE: APPLICATIONS TO IMPROVING SELF-SUPERVISED IMAGE DENOISING (SUPPLEMENT)
367
+
368
+ Anonymous authors Paper under double-blind review
369
+
370
+ # S.1 DETAILED PAPER CONTRIBUTIONS
371
+
372
+ This section elaborates the contributions of the proposed SSRL framework:
373
+
374
+ 1. The paper applies the proposed SSRL generalization to several recent representative selfsupervised denoising methods, Noise2Self (Batson & Royer, 2019), Noise2Same (Xie et al., 2020), Noise2Noise (Lehtinen et al., 2018), Noise2Inverse (Hendriksen et al., 2020), and Neighbor2Neighbor (Huang et al., 2021). See Sections 2.3–2.4. With camera image and low-dose CT denoising experiments using both real and synthetic datasets, the paper demonstrates the outperforming performance of SSRL extensions over the aforementioned self-supervised denoising methods.
375
+
376
+ 2. Section 2.5 shows that designable pseudo-predictor $g$ in SSRL can relax noise assumptions of existing self-supervised denoising methods. In addition, Section 4.2 includes experiments studying how denoising performances change with satisfying noise assumption(s) (i.e., Assumptions 1–2).
377
+
378
+ 3. The paper explains how to incorporate domain knowledge into self-supervised denoising methods via $g$ and why more accurate domain knowledge can improve them. See examples in Sections 3.1–3.2. In addition, Section 3.3 proposes an empirical approach for selecting $g$ if domain knowledge of specific applications is unavailable.
379
+
380
+ 4. The proposed SSRL framework in Section 2 considers regression NN learning beyond denoiser learning, by using a desinable operator $g$ . The paper is the first step towards self-supervised learning in regression problems, by showing that the proposed framework extends well to image denoising problem.
381
+
382
+ # S.2 IMPLEMENTATION DETAILS, DATA AND CODE LICENSES, AND LIBRARY VERSIONS
383
+
384
+ This section describes implementation details, lists hyperparameters, and specifies license of datasets and codes used in this study.
385
+
386
+ # S.2.1 DATA AND CODE LICENCES, AND LIBRARY VERSIONS
387
+
388
+ The ImageNet ILSVRC 2012 Val and BSD 300 datasets have the Custom license (research, non-commercial), the Set 5 data has the Unknown license, and the SIDD sRGB Data (Abdelhamed et al., 2018) has the MIT license. We obtained The 2016 Low Dose CT Grand Challenge data (McCollough, 2016) from https://aapm.app.box.com/s/ eaw4jddb53keg1bptavvvd1sf4x3pe9h/file/856956352254, and Low Dose CT Image and Projection Data (Moen et al., 2021) from https://doi.org/10.7937/9npb-2637. The 2016 Low Dose CT Grand Challenge data and Low Dose CT Image and Projection Data have the Custom license and the patient information is fully redacted.
389
+
390
+ We implemented all the methods specified in Section 4 by modifying the Noise2Self code (Batson & Royer, 2019) (GitHub repository: https://github.com/czbiohub/noise2self with version Dec. 17, 2019) that is licensed under the MIT license. For all training and testing experiments, we used Pytorch 1.0.0 or 1.7.0 (Paszke et al., 2019) with the BSD-style license. For simulating low-dose FBP images, we used the Michigan image reconstruction toolbox (MIRT) (Fessler, 2016) of which license information is declared on its release page. For sinogram generation and FBP reconstruction, we used the “Gtomo2 dscmex.m” routine (updated on Dec. 10, 2006) and the “fbp2.m” routine (updated on Dec. 21, 2005), respectively.
391
+
392
+ # S.2.2 COMMON IMPLEMENTATION DETAILS IN BOTH APPLICATIONS
393
+
394
+ For all the existing self-supervised denoising methods specified in Section 4 and Noise2True, we finely tuned their hyperparameters, including the initial learning rate, learning rate decay parameters, minibatch size, number of DnCNN layers, and balancing parameter $\sigma$ (see, e.g., (9)), to achieve the best numerical results. We simply applied the chosen hyperparameter sets to corresponding SSRL setups. We applied the chosen learning rate decay parameters, minibatch size, and number of DnCNN layers in Noise2True experiments to all the self-supervised denoising methods.
395
+
396
+ For the existing self-supervised denoising methods, Noise2Self (Batson & Royer, 2019) and Noise2Same (Xie et al., 2020), we used their default masking setups. The Noise2Self default setup uses the deterministic masking scheme for each $J$ that equi-spacedly samples $6 . 2 5 \%$ of the number of pixels in each training image (i.e., a single pixel is selected in each $4 \times 4$ window). The Noise2Same default setup uses the saturated sampling scheme (Xie et al., 2020; Krull et al., 2019) for each $J$ that randomly samples $\approx 0 . 5 \%$ of the number of pixels in each training image (i.e., a single pixel is sampled in each $1 4 \times 1 4$ window). In training denoising NNs, both methods interpolate missing pixels in $x J c$ by applying weighted average to their 8 neighboring pixels, and use interpolated $x J ^ { c }$ as input to denoisers.
397
+
398
+ For the existing Noise2Noise-motivated methods that emulate pairs of two independent noisy images, Neighbor2Neighbor (Huang et al., 2021) and Noise2Inverse (Hendriksen et al., 2020), we calculated their loss with non-masked images as proposed.
399
+
400
+ We tested all trained regression NNs to non-masked images – rather than masked images with $J ^ { c } -$ as this setup gave higher denoising accuracy than prediction with masked images (Batson & Royer, 2019; Xie et al., 2020).
401
+
402
+ # S.2.3 IMPLEMENTATION DETAILS FOR EXPERIMENTS WITH SYNTHETIC CAMERA IMAGE DENOISING DATA
403
+
404
+ The common hyperparameters for all learning methods were defined as follows. (In this application, these gave good image denoising performance across all existing self-supervised denoising methods and Noise2True, since we rescaled or normalized training images; see details below.) We used the default 17-layer DnCNN (Zhang et al., 2017) and the modified U-Net used in Noise2Self (Batson & Royer, 2019), and trained all DnCNNs and U-Nets with the mini-batch version of Adam (Kingma & Ba, 2015). We selected the initial learning rate, the batch size, and the number of epochs as $8 \times 1 0 ^ { - 4 }$ , 8, and 190, respectively, and decayed the learning rates by a factor of 0.5 every 50,000 iterations. (For Neighbor2Neighbor (Huang et al., 2021), we set the batch size as 32, as it reduces training image size with $2 \times 2$ sub-sampling window.) We used the data augmentations in Noise2Same (Xie et al., 2020), i.e., random crops with size $2 5 6 \times 2 5 6$ , rotation and flipping. Except for Noise2Same, we rescaled all images to [0, 1], following (Batson & Royer, 2019; Huang et al., 2021). In Noise2Same experiments (including SSRL-Noise2Same), we normalized each image by subtracting its mean and dividing by its standard deviation at each channel, following (Xie et al., 2020).
405
+
406
+ For proposed SSRL in the Noise2Self and Noise2Same setups (referred to as SSRL-Noise2Self and SSRL-Noise2Same, respectively), we used the deterministic masking scheme in Figure 2(bottom) for each $J$ with ${ \approx } 1 1 . 1 \%$ and ${ \approx } 1 . 2 \%$ sampling ratio, respectively – i.e., a single pixel is selected in each $3 \times 3$ and $9 \times 9$ window, respectively. These setups gave more appealing results than the default masking parameters (i.e., $4 \times 4$ window in Noise2Self and $1 4 \times 1 4$ window in Noise2Same); compare Figure S.6 to corresponding results in Figure 4. We observed in this application that using sufficient amount of information for a linear interpolation in $f$ is useful for giving good prediction. For weighted median filtering (Brownrigg, 1984) $g$ in all SSRL setups, we used the following weights:
407
+
408
+ $[ 1 , 2 , 1 ; 2 , \sqrt { 9 \ldots 2 } ; 1 , 2 , 1 ]$ , where a box denotes the central weight. The dilation rates of weighted median filtering for SSRL in the Noise2Self, Noise2Same, and Neighbor2Neighbor setups are 3, 9, and 1, respectively, corresponding to the distances between pixels in $J$ . For SSRL-Noise2Self, we computed $\mathcal { L } _ { \mathrm { i n d } }$ in (7) only on $J$ (see Figure 2(bottom)). For SSRL-Noise2Same, we used the same balancing parameter $\sigma$ as Noise2Same used, i.e., $\sigma = 1$ , and computed $\mathcal { L }$ (both terms) in (9) only on $J$ .
409
+
410
+ The DnCNN and U-Net training time for each experiment was less than 72 hours with an NVIDIA TITAN V GPU.
411
+
412
+ # S.2.4 IMPLEMENTATION DETAILS FOR EXPERIMENTS WITH SYNTHETIC LOW-DOSE CT DENOISING DATA
413
+
414
+ We used fan-beam geometry for sinogram simulation, where width of each detector column is $1 . 2 8 5 8 ~ \mathrm { m m }$ , source to detector distance is $1 0 8 5 . 6 \ \mathrm { m m }$ , and source to rotation center distance is $5 9 5 ~ \mathrm { m m }$ . For the FBP method, we used a ramp filter because in general, it better preserves the sharpness of edges on reconstructed images than Hanning filter (but overall noise increases).
415
+
416
+ The common hyperparameters for all learning methods were defined as follows. We used 8-layer DnCNN (Zhang et al., 2017) with its default setup and the modified U-Net used in Noise2Self (Batson & Royer, 2019), and trained all DnCNNs and U-Nets with the mini-batch version of Adam (Kingma & Ba, 2015). We selected the batch size and the number of epochs as 2 and 1,000, respectively, and decayed the learning rates by a factor of 0.95 every 10 epochs. In training DnCNNs and U-Nets, we selected the initial learning rates as 0.1 and $5 \times 1 0 ^ { - 5 }$ , respectively, unless stated otherwise.
417
+
418
+ For proposed SSRL-Noise2Self and SSRL-Noise2Same, we used complementary checkboard masks $J$ and $J ^ { c }$ in Figure 2(top). We observed in this application that if $g$ is set to use small amount of information, i.e., $\vert J \vert \ll \vert J ^ { c } \vert$ , then pre-trained $g$ makes poor prediction. For SSRL-Noise2Self, we set $g$ as pre-trained NN by Noise2Self with complementary checkerboard masks (see its inference results with 8-layer DnCNN and U-Net in Figures S.7(a) and S.4, respectively). In training DnCNNs, we used the same initial learning rate as that used in pre-training $g , 0 . 0 1$ . We computed $\mathcal { L } _ { \mathrm { i n d } }$ as given in (7) (see Figure 2(top)).
419
+
420
+ For SSRL in the Noise2Inverse setup, we set $f$ and $g$ as $f / 2$ and $\mathcal { T } - g / 2$ , respectively, where $g$ is pre-trained NN by Noise2Inverse. In training DnCNNs, we used the same initial learning rate as that used in pre-training $g , \ 0 . 0 0 1$ . In inference, we averaged the predictions from $f$ and $g$ , as this corresponds to training setup above. In all Noise2Inverse inferences (including SSRLNoise2Inverse), we input full-view FBP images since this is consistent with other experiments and gave better denoising performance than denoising half-view FBP images. For SSRL-Noise2Same, we set $g$ as pre-trained NN by Noise2Same with complementary checkerboard masks (see its test results with DnCNN and U-Net in Figures S.7(b) and S.4, respectively), and computed $\mathcal { L }$ (both terms) in (9) only on $J ^ { c }$ . We chose the balancing parameter √ $\sigma$ as 15, setting the ratio of the first term to the squared second term $2 \sigma \sqrt { M } \lVert f ( x ) _ { J ^ { c } } - f ( x _ { J ^ { c } } ) _ { J ^ { c } } \rVert _ { 2 } ^ { 2 }$ in (9) as 10. For Noise2Same with either the default setup and complementary checkerboard masks, we chose the balancing parameter $\sigma$ as 500. For self-supervised denoising methods with complementary checkerboard masks, we interpolated missing pixels in both $x J c$ and $x _ { J }$ , by averaging their 4 neighboring pixels.
421
+
422
+ The DnCNN and U-Net training time for existing self-supervised denoising methods and proposed SSRL methods was less than 10 hours and 12 hours, respectively, with an NVIDIA TITAN Xp GPU. It took total less than 22 hours to train both $f$ and $g$ .
423
+
424
+ # S.3 SUPPLEMENTARY EXPERIMENTAL RESULTS FOR SECTION 4
425
+
426
+ This section mainly includes supplementary materials to Section 4.
427
+
428
+ # S.3.1 SUPPLEMENTARY EXPERIMENTAL RESULTS WITH SYNTHETIC DATASETS
429
+
430
+ Figures S.1 and S.2 show error maps of denoised images via DnCNNs from different learning methods in camera image denoising in mixed noise and low-dose CT, respectively. These show for both applications that in all the three comparison setups, SSRL significantly reduces errors and artifacts across the entire image, over existing self-supervised denoising methods. Red boxes compare existing self-supervised denoising method to proposed SSRL in the corresponding setup.
431
+
432
+ ![](images/71ef1ff73e57b5040e7e3edae4fea666d2364f69de8c2c5f4e9b7be74d6f46eb.jpg)
433
+ Figure S.1: Error map comparisons of denoised images via DnCNNs from different learning methods in camera image denoising (blue and yellow denote 0 and 50 absolute errors, respectively). PSNR and SSIM values were averaged across all BSD 300 test samples.
434
+
435
+ ![](images/bdd25678fe2b8ae401f14a0cd96ba3ee08900ec800fb224fe9718909c4dc6936.jpg)
436
+ Figure S.2: Error map comparisons of denoised images via DnCNNs from different learning methods in low-dose CT (blue and yellow denote 0 and 50 absolute errors in HU, respectively). RMSE values were averaged across all test samples from The 2016 Low Dose CT Grand Challenge data.
437
+
438
+ Figures S.3 and S.4 show denoised images via U-Nets from different learning methods in camera image denoising in mixed noise and low-dose CT, respectively. These demonstrate for both applications that in all the three comparison setups, SSRL significantly improves existing self-supervised denoising methods regardless of the regression neural network architecture.
439
+
440
+ ![](images/3651f72d0ed5a760464da8c7b798337fded0850c7230c3bca24f9974a67cf5e8.jpg)
441
+ Figure S.3: Comparisons of denoised images (left) via U-Nets from different learning methods and their saturation error maps (right) in camera image denoising (blue and yellow denote 0 and 0.5 absolute errors, respectively). PSNR and SSIM values were averaged across all BSD 300 test samples.
442
+
443
+ ![](images/ea5d00758ae54265dcb5367208b0c667bdf9dfb6d664bde6c7b2a1d81a2ec03c.jpg)
444
+ Figure S.4: Comparisons of denoised images via U-Nets from different learning methods in lowdose CT (display window is [800, 1200] HU). RMSE values were averaged across all test samples from The 2016 Low Dose CT Grand Challenge data.
445
+
446
+ Tables S.1–S.3 report quantitative image denoising results with DnCNN and U-Net with BSD 300 and Set 5 data in camera image denoising in mixed noise, and with chest slices of The 2016 Low Dose CT Grand Challenge data in low-dose CT. Red boxes in Tables S.1–S.3 compare an existing self-supervised denoising method to proposed SSRL in the corresponding setup.
447
+
448
+ Table S.1: Averaged test PSNR (dB) (first and third rows) and SSIM (second and fourth rows) comparisons with from different learning methods with DnCNN (first and second rows) and U-Net (third and fourth rows) in camera image denoising (simulated noisy BSD 300 dataset).
449
+
450
+ <table><tr><td>Noise2True</td><td>Noise2Self</td><td>Proposed SSRL in Noise2Self setup</td><td>Neighbor2- Neighbor</td><td>Proposed SSRL in Neighbor2- Neighbor setup</td><td>Noise2Same</td><td>Proposed SSRL in Noise2Same setup</td></tr><tr><td>25.2 0.819</td><td>20.6 0.711</td><td>22.1 0.748</td><td>20.2 0.703</td><td>22.3 0.756</td><td>20.1 0.690</td><td>21.2 0.705</td></tr><tr><td>26.0 0.849</td><td>20.9 0.730</td><td>22.5 0.765</td><td>20.8 0.728</td><td>22.4 0.767</td><td>19.5 0.612</td><td>20.7 0.660</td></tr></table>
451
+
452
+ Table S.2: Averaged test PSNR (dB) (first and third rows) and SSIM (second and fourth rows) comparisons from different learning methods with DnCNN (first and second rows) and U-Net (third and fourth rows) in camera image denoising (simulated noisy Set 5 dataset).
453
+
454
+ <table><tr><td>Noise2True</td><td>Noise2Self</td><td>Proposed SSRL in Noise2Self setup</td><td>Neighbor2- Neighbor</td><td>Proposed SSRL in Neighbor2- Neighbor setup</td><td>Noise2Same</td><td>Proposed SSRL in Noise2Same setup</td></tr><tr><td>26.4 0.890</td><td>19.3 0.743</td><td>21.2 0.785</td><td>19.0 0.744</td><td>21.9 0.806</td><td>18.9 0.729</td><td>20.0 0.753</td></tr><tr><td>27.2 0.910</td><td>19.5 0.752</td><td>21.8 0.802</td><td>19.4 0.751</td><td>21.6 0.800</td><td>17.7 0.626</td><td>19.3 0.712</td></tr></table>
455
+
456
+ Table S.3: Averaged test RMSE (HU) comparisons from different learning methods with DnCNN (first row) and U-Net (second row) in low-dose CT denoising (simulated low-dose CT dataset).
457
+
458
+ <table><tr><td>Noise2True</td><td>Noise2Self</td><td>Proposed SSRL in Noise2Self setup</td><td>Noise2- Inverse</td><td>Proposed SSRL in Noise2- Inverse setup</td><td>Noise2Same</td><td>Proposed SSRL in Noise2Same setup</td></tr><tr><td>16.3</td><td>36.2</td><td>25.0</td><td>22.9</td><td>21.9</td><td>28.4</td><td>26.0</td></tr><tr><td>18.5</td><td>32.3</td><td>26.7</td><td>24.0</td><td>23.5</td><td>31.1</td><td>28.2</td></tr></table>
459
+
460
+ Figure S.5 compares prediction uncertainty of trained DnCNN denoisers via different learning methods in both applications. The error bar graphs in Figure S.5 show that for both applications, in all the three comparison sets, proposed SSRL gives similar or lower prediction uncertainty over the existing self-supervised denoising methods, Noise2Self, Neighbor2Neighbor, Noise2Inverse, and Noise2Same.
461
+
462
+ Figure S.6 shows denoised camera images from SSRL-Noise2Self and SSLR-Noise2Same using the default masking parameters in Noise2Self and Noise2Same (see Section S.2.3). Compare the results in Figure S.6 with the corresponding ones in Figure 4 using the designed setups (see Section S.2.3). The comparisons demonstrate that the default and designed setups give very similar PSNR results, i.e., $\leq 0 . 1$ dB, but the designed setups gives slightly more visually appealing results than the default ones in Noise2Self and Noise2Same.
463
+
464
+ Figure S.7 shows denoised images from Noise2Self and Noise2Same with DnCNN and complementary checkerboard masks $J$ and $J ^ { c }$ , and reports the corresponding quantitative test results, in low-dose CT denoising. Comparing the results in Figure S.7 to those of Noise2Self and Noise2Same using the default masking setups in Figures 5 and S.2 shows that checkerboard masking improves denoising quality over default masking in Noise2Self, and achieves comparable denoising performance to default masking in Noise2Same. (See their default masking setups in Section S.2.2.) SSRL-Noise2Self with checkerboard masking achieves significantly better denoising quality compared to Noise2Self with checkerboard masking. We used pre-trained DnCNN from these two setups as $g$ in the corresponding SSRL setup.
465
+
466
+ ![](images/71424473522888a7593c2f90cfdee22d6bc7b34b70143544f5a126241a5b5785.jpg)
467
+ Figure S.5: Denoising performance error bars for different learning methods with DnCNN in camera image denoising in mixed noise (with BSD 300) (left, 300 test images) and low-dose CT (right, 30 test images). Red asterisks denote the averaged test PSNR or RMSE values. Error bar represents one standard deviation of test PSNR or RMSE values.
468
+
469
+ ![](images/68d3c9ad303c6f0bdac7793fdefa5d3053c2ff9f065332082f3b82d2e4f9ab28.jpg)
470
+ Figure S.6: Denoised images via DnCNNs and their corresponding error maps from SSRLNoise2Self and SSRL-Noise2Same with default masks setup in camera image denoising. (In error maps, blue and yellow denote 0 and 50 absolute errors, respectively.) PSNR values were averaged across all BSD 300 test samples.
471
+
472
+ ![](images/792bd102dc4794c0afd7c3063f57a23aed0e57249a453fa73926e4ab64100fba.jpg)
473
+ Figure S.7: Denoised images via DnCNNs and their corresponding error maps from Noise2Self and Noise2Same with complementary checkerboard masks in low-dose CT. (The display window of denoised images is [800, 1200] HU; in error maps, blue and yellow denote 0 and 50 absolute errors in HU, respectively.) RMSE values were averaged across all test samples.
474
+
475
+ Figures S.8 and S.9 show error maps of denoised images via DnCNNs from different learning methods in camera image and low-dose CT denoising with real-world datasets, respectively. These show for both applications that in Neighbor2Neighbor, Noise2Self, or Noise2Same comparison setups, SSRL significantly improve the entire image without having their exact noise properties.
476
+
477
+ ![](images/9da6b749a7733a3d85303ecbdd1b81cf15a21eed7b5e016f91788bcc9ec04939.jpg)
478
+ Figure S.8: Error map comparisons of denoised images via DnCNNs from different learning methods in camera image denoising with real-world dataset (blue and yellow denote 0 and 50 absolute errors, respectively). PSNR and SSIM values were averaged across all SIDD sRGB validation samples.
479
+
480
+ ![](images/a0ccddadb41662b1f932e8d1d4378efce5855cfce4468663f11921d6046ca1b7.jpg)
481
+ Figure S.9: Error map comparisons of denoised images via DnCNNs from different learning methods in low-dose CT with real-world dataset (blue and yellow denote 0 and 100 absolute errors in HU, respectively). RMSE values were averaged across all test samples.
482
+
483
+ # S.4 EMPIRICAL RESULTS TO SUPPORT SOME CLAIMS IN MAIN PAPER
484
+
485
+ The following empirical results support that proposed SSRL loss better approximates the supervision (Noise2True) loss than existing self-supervised learning, particularly when Assumptions 1–2 are not completely satisfied. We used the representative self-supervised denoising setup, Noise2Self. In the camera image denoising experiments in Section 4.1, the empirical loss values (at the last epoch) of {Noise2Self, SSRL-Noise2Self, Noise2True $\}$ are {0.296, 0.244, 0.170} (in RMSE); in the low-dose CT denoising experiments in Section 4.1, those are {2186.4, 329.1, 270.2} (in $\mathrm { H U ^ { 2 } }$ ).
486
+
487
+ Figure S.10 empirically supports our claim in Section 3.1 that $g$ design “approximately” satisfy $\mathbb { E } [ g ( x ) | y ] = y$ in camera image denoising, with both simulated and real-word datasets. We calculated empirical $\mathbb { E } [ x - y | y ]$ and ${ \mathbb E } [ { \boldsymbol { g } } ( { \boldsymbol { x } } ) - { \boldsymbol { y } } | { \boldsymbol { y } } ]$ with simulated noisy BSD 300 test samples (using noise model (10)) and the real-world noisy dataset (specifically, SIDD sRGB validation samples) in Section A.4.1, where $g$ is median filtering. In the simulated dataset, the empirical measures for $\{ \arg ( | \mathbb { E } [ x - y | y ] | )$ , $\arg ( | \mathbb { E } [ g ( x ) - y | y ] | ) \}$ are $\{ 0 . 0 2 0 1 , 0 . 0 0 9 8 \}$ , where avg denotes averaging across pixels. In the real-word dataset, those are $\{ 0 . 0 1 1 3 , 0 . 0 0 8 3 \}$ . These support our claim that $\mathbb { E } [ g ( x ) | y ] = y$ is approximately satisfied with median filtering $g$ .
488
+
489
+ Figure S.11 empirically supports our claim in Section 3.2 that noise of FBP-reconstructed images in low-dose CT, i.e., $e$ in (11), has approximately zero-mean. The position of the patient table base is similar across FBP images, so it gave higher errors in the calculated sample mean; see the bottom of the image in Figure S.11.
490
+
491
+ The following empirical results support the claim in Section 3.2 that pre-trained $g$ will give better reference than $g \ : = \ : \mathcal { I }$ in low-dose CT denoising: the empirical measure of the Noise2Self loss (Batson & Royer, $2 0 1 9 ) - \mathbb { E } \| g ( x _ { J } ) _ { J ^ { c } } - x _ { J ^ { c } } \| _ { 2 } ^ { 2 } +$ – with simulated noisy CT test samples by setting $g$ as $\mathcal { T }$ and pre-trained DnCNN by Noise2Self are 2455.7 and 1839.1 (in $\mathrm { H U ^ { 2 } }$ ), respectively.
492
+
493
+ ![](images/7ddad091b1c42320612d8782483eaa3cb7fd9d06b6f3cee9e0b9a974bfdcd4aa.jpg)
494
+ Figure S.10: Empirical observations of $| \mathbb { E } [ x - y | y ] |$ (left) and $| \mathbb { E } [ g ( x ) - y | y ] |$ (right) in camera image denoising ((a) Blue and yellow denote 0 and 0.1 absolute errors, respectively. (b) Blue and yellow denote 0 and 0.02 absolute errors, respectively.)
495
+
496
+ ![](images/e1e0574f255e6c40a10bc51d59839e559fc6fa994a94f0de69f47b3c898c8110.jpg)
497
+ Figure S.11: Sample mean of noise in low-dose FBP images – e in (11). We calculated the sample mean with 200 samples.
498
+
499
+ # S.5 EXPERIMENTAL RESULTS WITH GAUSSIAN AND POISSON $^ +$ GAUSSIAN NOISE MODELS
500
+
501
+ This section studies the performance of the proposed SSRL framework with benchmark noisy datasets, MIT-Adobe FiveK data (Bychkovsky et al., 2011), corrupted by sole Gaussian and Poisson+Gaussian noises.
502
+
503
+ # S.5.1 EXPERIMENTAL SETUP
504
+
505
+ In Guassian denoising experiments, we simulated AWGN with the standard deviation value $\sigma _ { \epsilon } = 2 5$ (Huang et al., 2021; Xu et al., 2020), and selected $g$ as Wiener filtering that is known to be optimal in the sense of minimum MSE in Gaussian denoising. In Poisson+Gaussian denoising experiments, we followed the noise simulation setup (Byun et al., 2021, Tab. 5: $( \alpha , \sigma ) = ( 0 . 0 5 , 0 . 0 2 ) )$ that corresponds to $( \lambda , \sigma _ { \epsilon } ) = ( 2 0 , 5 . 1 )$ where $\lambda$ and $\sigma _ { \epsilon }$ are defined in (10). To better visualize the results, we enhanced the brightness with gamma correction (with the parameter 3). We choose the representative comparison setup, Neighbor2Neighbor, from the camera image denoising experiments in Section 4.1. This is also a state-of-the-art self-supervised denoising method, particularly when only single noisy images are available (Huang et al., 2021).
506
+
507
+ # S.5.2 COMPARISONS BETWEEN DIFFERENT LEARNING METHODS
508
+
509
+ Two observations in Figure S.12. First, in both Gaussian and Poisson+Gaussian denoising, proposed SSRL using “good” $g$ further improved a state-of-the-art self-supervised denoising method, Neighbor2Neighbor. Second, in both Gaussian and Poisson $^ +$ Gaussian denoising, the performance gap between Noise2True and Neighbor2Neighbor, is small, where the PSNR gap numbers well correspond to existing literature (Huang et al., 2021; Byun et al., 2021). We conjecture that this is because the noise assumptions of self-supervised denoising method are well satisfied in the aforementioned two experiments. This is connected to our conjecture in Section 4.2 that self-supervised denoising performance degrades, if its assumptions are not completely satisfied.
510
+
511
+ ![](images/c5f697117e0cecb60440423ee8b7722bedc019f5a1b5820ecea230a4b1436a3f.jpg)
512
+ (b) Poisson+Gaussian denoising (i.i.d. with $( \lambda , \sigma _ { \epsilon } ) = ( 2 0 , 5 . 1 ) )$
513
+ Figure S.12: Comparisons of denoised images via DnCNNs from different learning methods in camera image denoising. PSNR vlaues were averaged across all MIT-Adobe FiveK test samples.
514
+
515
+ # S.6 COMPARISONS TO SELF2SELF
516
+
517
+ This section compares the proposed SSRL framework with a state-of-the-art blind image denoising (a.k.a. self-supervised denoising with a single image) method, Self2Self (Quan et al., 2020), with synthetic and real-world noisy datasets for each application (see Section 4). (We used the authors’ Self2Self implementation.)
518
+
519
+ First, in Figure S.13 and S.14, compare Self2Self with Neighbor2Neighbor and Noise2Self (the representative comparison setup in each simulated imaging experiment in Section 4.1), respectively. The comparisons show that Self2Self gives comparable results to Neighbor2Neighbor/Noise2Self.
520
+
521
+ Remind, however, that Self2Self is a blind denoising method, so it needs a significantly larger computations than Neighbor2Neighbor, when one denoises a new noisy image. With good $g$ designs (see Sections 3.1–3.2), proposed SSRL significantly outperformed Self2Self in both applications, regardless of whether their dataset is real or simulated.
522
+
523
+ ![](images/9a34e983c24b1111bd1917f1b17261ead1a1e5ccc6fa69bcc596766cea545dd5.jpg)
524
+ Figure S.13: Comparisons of denoised images (right) from different learning methods and their error maps (left) in camera image denoising (blue and yellow 0 and 50 absolute errors, respectively). PSNR values were averaged across all test samples.
525
+
526
+ ![](images/d47726df85c8eb009d4c37e5d17e6df981c7def84c88d97c3c095fd4aea4e914.jpg)
527
+ Figure S.14: Comparisons of denoised images from different learning methods in low-dose CT with synthetic and real-world datasets (display window is [800, 1200] HU). RMSE values were averaged across all test samples.
528
+
529
+ # S.7 PRELIMINARY RESULTS WITH THE TEACHER-STUDENT LEARNING PERSPECTIVE
530
+
531
+ The proposed SSRL framework is applicable to teacher-student learning (Wang & Yoon, 2021; Hinton et al., 2015; Bucilua et al., 2006) that aims to learn a smaller student network from bigger teacher ˇ network(s). We ran preliminary experiments in self-supervised low-dose CT denoising (using simulated data). The teacher model $g$ is the pre-trained 8-layer DnCNN by Noise2Self (with checkerboard masking), and we set the student model $f$ as $\{ 8 , 7 , 6 , 5 , 4 , 3 \}$ -layer DnCNN. Applying SSRLNoise2Self, we obtained the following numerical results: the RMSE (HU) values of student models with $\{ 8 , 7 , 6 , 5 , 4 , 3 \}$ -layer DnCNNs are $\{ 2 5 . 0 , 2 5 . 3 , 2 5 . 5 , 2 5 . 4 , 2 5 . 2 , 2 7 . 5 \}$ , respectively. The student DnCNNs that have the equal or lower complexity compared to its teacher network, significantly improves its teacher model of which RMSE value is 30.9 (in HU). The results might imply that student models learned from SSRL can outperform their teacher model, if they retain sufficiently high network complexity as compared to their teacher’s (e.g., 3-layer DnCNN). In addition, we have additional SSRL experiment in low-dose CT denoising with the “iterative” teacher-student perspective. The teacher model $g$ is pre-trained 5-layer DnCNN from the non-iterative teacher-student SSRL method above, and we set the student model $f$ as 3-layer DnCNN. We obtained 27.3 RMSE (in HU), implying only marginal improvement over the 3-layer DnCNN obtained by the non-iterative teacher-student SSRL method. We conjecture that iterative teacher-student SSRL needs more sophisticated $g$ -setups, such as an ensemble of teacher models (Hinton et al., 2015).
532
+
533
+ # REFERENCES
534
+
535
+ Abdelrahman Abdelhamed, Stephen Lin, and Michael S. Brown. A high-quality denoising dataset for smartphone cameras. In Proc. IEEE CVPR, pp. 1692–1700, Salt Lake City, Utah, Jun. 2018.
536
+ Joshua Batson and Loic Royer. Noise2Self: Blind denoising by self-supervision. In Proc. ICML, pp. 524–533, Long Beach, CA, Jun. 2019.
537
+ David RK Brownrigg. The weighted median filter. Commun. of the ACM, 27:807–818, 1984.
538
+ Cristian Bucilua, Rich Caruana, and Alexandru Niculescu-Mizil. Model compression. In ˇ Proc. ACM. SIGKDD., pp. 535–541, 2006.
539
+ Vladimir Bychkovsky, Sylvain Paris, Eric Chan, and Fredo Durand. Learning photographic global ´ tonal adjustment with a database of input / output image pairs. In Proc. IEEE CVPR, pp. 97–104, Colorado Springs, CO, Jun. 2011.
540
+ Jaeseok Byun, Sungmin Cha, and Taesup Moon. Fbi-denoiser: Fast blind image denoiser for poisson-gaussian noise. In Proc. IEEE CVPR, pp. 5768–5777, Virtual, Jun. 2021.
541
+ J. A. Fessler. Michigan image reconstruction toolbox (MIRT) for Matlab. Available from http: //web.eecs.umich.edu/˜fessler, 2016.
542
+ Allard Adriaan Hendriksen, Daniel Maria Pelt, and K Joost Batenburg. Noise2Inverse: Self- ¨ supervised deep convolutional denoising for tomography. IEEE Trans. Comput. Imag., 6:1320– 1335, Aug. 2020.
543
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. In Proc. NIPS Workshop, pp. 1790–1798, Montreal, Canada, Dec. 2015.
544
+ Tao Huang, Songjiang Li, Xu Jia, Huchuan Lu, and Jianzhuang Liu. Neighbor2Neighbor: Selfsupervised denoising from single noisy images. In Proc. IEEE/CVF CVPR, pp. 14781–14790, Virtual, Jun. 2021.
545
+ Diederik P Kingma and Jimmy Lei Ba. Adam: A method for stochastic optimization. In Proc. ICLR 2015, pp. 1–15, San Diego, CA, May 2015.
546
+ Alexander Krull, Tim-Oliver Buchholz, and Florian Jug. Noise2Void - Learning denoising from single noisy images. In Proc. IEEE/CVF CVPR, pp. 2129–2137, Long Beach, CA, Jun. 2019.
547
+
548
+ Jaakko Lehtinen, Jacob Munkberg, Jon Hasselgren, Samuli Laine, Tero Karras, Miika Aittala, and Timo Aila. Noise2Noise: Learning image restoration without clean data. In Proc. ICML, pp. 2965–2974, Stockholm, Sweden, Jul. 2018.
549
+
550
+ C. McCollough. TU-FG-207A-04: Overview of the low dose CT grand challenge. Med. Phys., 43 (6Part35):3759–3760, Jun. 2016.
551
+
552
+ Taylor R Moen, Baiyu Chen, David R Holmes III, Xinhui Duan, Zhicong Yu, Lifeng Yu, Shuai Leng, Joel G Fletcher, and Cynthia H McCollough. Low-dose CT image and projection dataset. Med. Phys., 48(2):902–911, Feb. 2021.
553
+
554
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. PyTorch: An imperative style, high-performance deep learning library. In Proc. NIPS, volume 32, pp. 8026–8037, Vancouver, Canada, Dec. 2019.
555
+
556
+ Yuhui Quan, Mingqin Chen, Tongyao Pang, and Hui Ji. Self2Self with dropout: Learning selfsupervised denoising from single image. In Proc. IEEE/CVF CVPR, pp. 1890–1898, Virtual, Jun. 2020.
557
+
558
+ Lin Wang and Kuk-Jin Yoon. Knowledge distillation and student-teacher learning for visual intelligence: A review and new outlooks. IEEE Trans. Pattern Anal. Mach. Intell., Jan. 2021.
559
+
560
+ Yaochen Xie, Zhengyang Wang, and Shuiwang Ji. Noise2Same: Optimizing a self-supervised bound for image denoising. In Proc. NIPS, volume 33, pp. 20320–20330, Vancouver, Canada, Dec. 2020.
561
+
562
+ Jun Xu, Yuan Huang, Li Liu, Fan Zhu, Xingsong Hou, and Ling Shao. Noisy-As-Clean: Learning unsupervised denoising from the corrupted image. IEEE Trans. Image Process., 29:9316–9329, Sep. 2020.
563
+
564
+ Kai Zhang, Wangmeng Zuo, Yunjin Chen, Deyu Meng, and Lei Zhang. Beyond a Gaussian denoiser: Residual learning of deep CNN for image denoising. IEEE Trans. Image Process., 26(7):3142– 3155, Feb. 2017.
md/dev/MeeQkFYVbzW/MeeQkFYVbzW.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/MtGmCCPJD-/MtGmCCPJD-.md ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REPOSITORY-LEVEL PROMPT GENERATION FOR LARGE LANGUAGE MODELS OF CODE
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ With the success of large language models (LLMs) of code and their use as code assistants (e.g. Codex (Chen et al., 2021) used in GitHub Copilot1), techniques for introducing domain-specific knowledge in the prompt design process become important. In this work, we propose a framework called Repo-Level Prompt Generator that learns to generate example-specific prompts using prompt proposals. The prompt proposals take context from the entire repository, thereby incorporating both the structure of the repository and the context from other relevant files (e.g. imports, parent class files). Our technique doesn’t require any access to the weights of the LLM, making it applicable in cases where we only have black-box access to the LLM. We conduct experiments on the task of single-line code-autocompletion using code repositories taken from Google Code archives. We demonstrate that an oracle constructed from our prompt proposals gives a remarkably high relative improvement of $36 \%$ over Codex, showing the quality of these proposals. Further, we show that when we train a model to predict a prompt proposal, we can achieve significant performance gains over Codex and other baselines.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Large Language Models (LLMs) have demonstrated remarkable performance in natural language processing tasks (Brown et al., 2020; Chowdhery et al., 2022), text-to-image generation (Ramesh et al., 2022; Rombach et al., 2021), protein-sequencing (Rives et al., 2019) and even as a generalized agent (Reed et al., 2022). As opposed to the pretrain-finetune paradigm, prompting these LLMs has been found to yield good performance even with few-examples (Liu et al., 2021a). A prompt is an input to the LM such that the desired task can be expressed as predictions generated from the LM. Besides providing a mechanism to control and evaluate a LM, prompts have shown to elicit emergent behaviour as well. Examples of this behavior include GPT-3 (Brown et al., 2020) doing better in tasks it has never seen during training and improved reasoning capabilities with few-shot (Wei et al., 2022) and zero-shot (Kojima et al., 2022) prompts that encourage a chain of thoughts. These factors highlight the importance of designing an effective task-specific prompt 2. However, currently we have limited understanding of how to do this (Reynolds & McDonell, 2021).
12
+
13
+ LLMs have also been used for modeling source code with impressive results (Austin et al., 2021; Fried et al., 2022; Xu et al., 2022a). In particular, one of the best performing LLM, Codex (Chen et al., 2021), has been deployed as part of GitHub Copilot 1, a state-of-the-art in-IDE code assistant. Despite the growing popularity of LLMs of code, there is no work that systematically tackles different aspects of prompt generation in relation to source code. One such aspect is that when it comes to code, the relevant context to be put in the prompt can come from not just the current file, but also from outside, such as imports and parent classes. Also, depending on the scenario, the relevant context can be scattered across multiple locations. Since the LLMs have a limited context length available for the prompt, it becomes increasing crucial for our domain-specific understanding to guide the selection of relevant context. Currently, it is not clear how to integrate this domain knowledge of what constitutes a relevant context, into the process of creating prompts. Addressing this question has potential benefits in other domains such as question answering (Liu et al., 2022) and multi-document summarization (Xiao et al., 2022), where domain-specific structured retrieval of context can be useful.
14
+
15
+ ![](images/f066b03f73505449d0a23bfdc4eba54ae982ddc94bc3b16dfeaf367cb857e306.jpg)
16
+ Figure 1: Repo-Level Prompt Generator: The prompt is generated by combining the context from the predicted prompt proposal $p = 1 4$ , i.e., method names and bodies from the imported file, MaximizingGibbsSampler.java (violet) with the default Codex context (gray).
17
+
18
+ In this work, we address this problem by proposing Repo-Level Prompt Generator (RLPG), a framework that while generating the prompt, incorporates both the structure of the repository as well as the relevant context in all the files of the repository. In RLPG, the choice of where from and what to take from the repository is specified by a set of prompt proposals. For example, one of the prompt proposal can be to take all the identifiers used in the first import file. These prompt proposals allow the prompt engineers to induce their domain expertise in the prompt-designing process. With the increasing use of LLMs as assistive agents to humans, demand for transparency and the desire for software engineers to take active part in tailoring prompts to suit their requirements (Jiang et al., 2022; Sun et al., 2022), this capability becomes important. As suggested in some previous works in NLP (Shin et al., 2020; Schick & Schütze, 2021), our prompt proposals are discrete. However, rather than fixing one particular prompt proposal for each example, we instead predict the best prompt proposal conditioned on the example. We do this by coming up with a neural network called Prompt Proposal Classifier (PPC), that given an example, learns to select a prompt proposal such that the resulting prompt is likely to produce the desired output. Therefore, RLPG allows the introduction of domain expertise, and at the same time facilitates automatic example-specific prompt generation via a learned neural network. Note that there are some techniques for automatic prompt generation in NLP (Li & Liang, 2021; Shin et al., 2020; Lester et al., 2021) that require updating some or all of the weights of the LLM. However, the strongest LLMs are not publicly available (e.g. OpenAI provides access only to the generated output from Codex via an API 3 and no access to model weights and data is provided), making these techniques less useful under this scenario. RLPG addresses this limitation by generating prompts assuming only black-box access to the LLM.
19
+
20
+ We focus on the task of single-line code-autocompletion in an IDE, where the objective is to predict the blanked-out portion (or target hole) starting from the position of an imagined cursor to the end of line. We operate under the line-level maintenance setting (Shrivastava et al., 2020; Hellendoorn & Devanbu, 2017) that reflects the scenario where a user is editing an existing file. This means that there can be code following the line. Figure 1 provides an illustration of our approach. The prompt proposal classifier takes in the hole position (position of the cursor) in the current file, the repository to which the current file belongs and a set of repo-level prompt proposals as input, and predicts a prompt proposal. In our illustrated example, the predicted prompt proposal corresponds to taking the method names and bodies from MaximizingGibbsSampler.java (mg.before the hole position indicates that a method from the imported file is likely to be invoked). The Prompt Composer uses the context from the predicted prompt proposal and combines it with the default Codex context, i.e., code prior to the position of the hole in the current file. The resulting prompt consists of the method name InitializeToAssignment (from the prompt proposal context) and the method CurrentAssignments() (from the default Codex context), resulting in a successful prediction (brown box on the top) of the target hole. Our key contributions are as follows:
21
+
22
+ • We propose a framework called the Repo-Level Prompt Generator (RLPG) that learns to generate prompts conditioned on the example, without requiring access to the weights of the LLM. • To incorporate domain-knowledge in the prompt design process, RLPG uses a set of repository-level prompt proposals. These prompt proposals are designed to incorporate both the structure of the repository as well as the relevant context from all files in the repository. • On the task of single-line code-autocompletion, we show that an oracle constructed from our proposed prompt proposals gives up to $36 \%$ relative improvement over Codex. This improvement is pleasantly surprising as Codex has never seen prompts made from these prompt proposals during training. Further, we show that when we use our prompt proposal classifier to predict the best prompt proposal, we can achieve up to $17 \%$ relative improvement over Codex.
23
+
24
+ # 2 REPO-LEVEL PROMPT GENERATOR (RLPG)
25
+
26
+ In this section, we provide details of our framework. We start by describing our prompt proposals and then discuss our prompt proposal classifier which is followed by a description of prompt composer.
27
+
28
+ # 2.1 REPO-LEVEL PROMPT PROPOSALS
29
+
30
+ The core idea of RLPG consists of substituting part of the default context used by Codex with context coming from somewhere else in the repository. The decision of what to take and from where in the repository to take from is governed by a set of prompt proposals. These prompt proposals were decided based on manual inspection of our training data and intend to capture common coding patterns (but more generally can also include project/organization-specific coding practises). A prompt proposal can be thought of as a function that takes as input a target hole’s position and the repository that the hole is a part of, and that returns the prompt proposal context (a string constituted by the context from the prompt proposal). A prompt proposal is specified by a prompt source and a prompt context type. We mention each of these along with their motivation below.
31
+
32
+ Prompt Source: For a target hole position, a prompt source determines from where should we take code that will be part of the prompt proposal context. We propose ten different prompt sources:
33
+
34
+ 1. Current: take code from the current file excluding the contents of the target hole. The current file is the file that contains the target hole. The code in the current file (e.g. the lines after the hole position) can be very useful in predicting the target hole.
35
+ 2. Parent Class: take code from the file that contains the parent of the class to which the target hole belongs. The intuition behind this is to account for cases where a method present in the parent class is invoked in the current file (i.e. the child class).
36
+ 3. Import: take code from the import files used in the current file. The dependencies specified via imports can provide useful cues to predict the target hole.
37
+ 4. Sibling: take code from the files that are in the same directory as the current file. Files in the same directory tend to share code variables (e.g. identifiers).
38
+ 5. Similar Name: take code from files that have a similar name as the current file. Similar names are determined by doing a splitting of the file name based on underscore or camel-case formatting and then matching parts of the filename. If one or more parts matches, two files are considered to have similar names. The intuition behind this is that software developers tend to name files based on the functionality of the code written in that file. Therefore, a similar name file might contain some portion of the code that is common with the current file and hence might be useful for predicting the target hole.
39
+ 6. Child Class: take code from files that have the current file as their parent class file.
40
+ 7. Import of Parent Class: take code from the import files used in the parent class files.
41
+ 8. Import of Sibling: take code from the import files used in the sibling files.
42
+ 9. Import of Similar Name: take code from the import files used in the similar name files.
43
+ 10. Import of Child Class: take code from the import files used in the child class files.
44
+
45
+ The last four prompt sources are useful when the target hole occurs at the very beginning of the current file. In these cases, there would be less context coming from other prompt sources. For each prompt source, we can get either a single file or a ranked list of files (see Appendix B.1). In the latter case, we will take context from these files until we exhaust the maximum context length allocated to the prompt proposal.
46
+
47
+ Prompt Context Type: The prompt context type determines what code to take from the prompt source. We propose seven different prompt context types (Appendix B.2 has examples of each type):
48
+
49
+ 1. Post Lines (PL): Take all the lines after the target hole line till we reach the end of the file. This context type is applicable only when prompt source is the current file 4.
50
+ 2. Identifiers (I): Take all the identifiers used in the prompt source.
51
+ 3. Type Identifiers (TI): Take all the type identifiers used in the prompt source.
52
+ 4. Field Declarations (FD): Take all the field declarations used in the prompt source.
53
+ 5. String Literals (SL): Take all the string literals used in the prompt source.
54
+ 6. Method Names (MN): Take all the method names along with their signatures that are used in the prompt source.
55
+ 7. Method Names and Bodies (MNB): Take all the method names along with their signatures and corresponding bodies used in the prompt source.
56
+
57
+ By combining prompt sources with prompt context types, we get a total of 63 prompt proposals (see Appendix B.4 for details). Note that depending on the target hole, not all prompt proposals would be applicable (e.g. if there are no parent classes in the current file, prompt proposals with prompt source as parent class file won’t be applicable). In Figure 1, the predicted prompt proposal corresponds to taking prompt source Import and prompt context type MNB. We aimed for a set of prompt proposals that offer more diversity rather than a set of prompt proposals that are all good. This in turn ensures that for any hole position, a significant number of prompt proposals are applicable.
58
+
59
+ # 2.2 PROMPT PROPOSAL CLASSIFIER (PPC)
60
+
61
+ Given a hole position, the goal of the prompt proposal classifier is to predict the prompt proposal $p$ that will lead to success, where success happens when the predicted hole $\hat { h }$ exactly matches the target hole $h$ . This task is formulated as a multi-label binary classification problem since for a given target hole, more than one prompt proposals can lead to success. In this formulation, we treat the default Codex context as one of the prompt proposals. Next, we describe the training procedure for PPC.
62
+
63
+ Training: For each target hole $h$ , we generate a ground-truth vector $Y ^ { h } = [ y _ { p } ^ { h } ] _ { p = 1 } ^ { M }$ which is a multi-hot vector of size $M$ , where $M$ is the total number of prompt proposals. This vector is obtained by feeding the prompt generated from prompt proposal $p$ into Codex and then seeing whether $\hat { h } = h$ . If there is a match, we say that the prompt proposal $p$ is successful. For hole $h$ , if a prompt proposal $p$ is applicable and leads to success, $y _ { p } ^ { h } = 1$ and will be zero otherwise. For each hole $h$ , we obtain a mask $T ^ { h }$ where $T _ { p } ^ { h } = 1$ when $p$ is applicable or zero otherwise. The overall training loss $\mathcal { L }$ can be expressed as the sum of individual hole losses ${ \mathcal { L } } ^ { h }$ as follows:
64
+
65
+ $$
66
+ \mathcal { L } = \frac { 1 } { N } \sum _ { h = 1 } ^ { N } \mathcal { L } ^ { h } = \frac { 1 } { N } \sum _ { h = 1 } ^ { N } \frac { 1 } { M ^ { h } } \sum _ { p = 1 } ^ { M ^ { h } } B C E ( \hat { y } _ { p } ^ { h } , y _ { p } ^ { h } ) * T _ { p } ^ { h } \quad w h e r e \quad M ^ { h } = \sum _ { p } T _ { p } ^ { h }
67
+ $$
68
+
69
+ In the above equation, $N$ is the total number of holes encountered while training, $M ^ { h }$ denotes the total number of applicable prompt proposals for $h$ and $B C E$ corresponds to the binary cross entropy loss. Masking ensures that we consider only the prompt proposals that are applicable. Next, we describe our two variants of PPC that can be used to obtain the prediction $\hat { y } _ { p } ^ { h }$ .
70
+
71
+ RLPG-H: Let $H ^ { h }$ be the hole window that includes code present around the hole $h$ excluding the hole itself. In our work, we take two lines before the hole position, the code up to the hole position and two lines after the hole position. We use a pretrained model $F _ { \phi }$ to obtain a context representation vector of size $Z$ , where $Z$ is the dimension of the hidden state of the model. Specifically, we take the hidden state at the first position, i.e. the representation of the [CLS] token. To make training of PPC computationally efficient, the parameters $\phi$ are frozen during training. The RLPG-H model takes the context representation of the hole window and projects it to the prompt proposal space of size $M$ via two dense layers with a non-linearity in between (see Equation 2). Taking the sigmoid of this output gives the prediction of the prompt proposal.
72
+
73
+ $$
74
+ { \hat { y } } _ { p } ^ { h } = P ( y _ { p } ^ { h } = 1 | H ^ { h } ) = { \mathrm { s i g m o i d } } ( W ^ { 2 } ( { \mathrm { r e l u } } ( W ^ { 1 } ( F _ { \phi } ( H ^ { h } ) ) + b ^ { 1 } ) ) + b ^ { 2 } )
75
+ $$
76
+
77
+ RLPG-R: The motivation behind this variant is to use the similarity of the hole window and the prompt proposal context to determine which prompt proposal can be useful. Given a particular hole $h$ , let $\hat { C } _ { p } ^ { h }$ denote the prompt proposal context from prompt proposal $p$ . Intuitively, if the hole window contains variables (e.g. identifiers) that are similar to the variables in the prompt proposal context, then there are chances that $h$ might occur somewhere in $C _ { p } ^ { h }$ . The similarity is modeled using a multiheaded attention mechanism (Vaswani et al., 2017), by treating the projected hole window representation as a query $Q ^ { h }$ and the projected prompt proposal context representation $K _ { p } ^ { h }$ as a key (Equation 3). The value $V _ { p } ^ { h }$ is the same as the key.
78
+
79
+ $$
80
+ \begin{array} { r l } & { \quad Q ^ { h } = F _ { \phi } ( H ^ { h } ) , \quad K _ { p } ^ { h } = F _ { \phi } ( C _ { p } ^ { h } ) , \quad V _ { p } ^ { h } = F _ { \phi } ( C _ { p } ^ { h } ) } \\ & { \quad A t t ( Q ^ { h } , K _ { p } ^ { h } , V _ { p } ^ { h } ) = V _ { p } ^ { h } \mathrm { s o f t m a x } \Big ( \frac { Q ^ { h ^ { \top } } K _ { p } ^ { h } } { \sqrt { d _ { k } } } \Big ) } \\ & { M u l t i H e a d ( Q ^ { h } , K _ { p } ^ { h } , V _ { p } ^ { h } ) = W ^ { O } \mathrm { c o n c a t } ( h e a d _ { i } , h e a d _ { 2 } , . . . h e a d _ { \tau } ) } \\ & { \quad \quad \quad \quad \mathrm { w h e r e } \quad h e a d _ { i } = A t t ( W _ { i } ^ { Q } Q ^ { h } , W _ { i } ^ { K } K _ { p } ^ { h } , W _ { i } ^ { V } V _ { p } ^ { h } ) } \\ & { \quad \quad \quad \hat { y } _ { p } ^ { h } = P ( y _ { p } ^ { h } = 1 | H ^ { h } , C _ { p } ^ { h } ) = \mathrm { s i g m o i d } \Big ( W _ { p } G ( M u l t i H e a d ( Q ^ { h } , K _ { p } ^ { h } , V _ { p } ^ { h } ) ) + b _ { p } \Big ) } \end{array}
81
+ $$
82
+
83
+ In the equations above, $d _ { k }$ is the dimension of the key, $W _ { i } ^ { Q } , W _ { i } ^ { K } , W _ { i } ^ { V }$ are the query, key and value projection matrices, $\tau$ is the number of heads and $W ^ { O }$ is the linear projection that combines the heads. The output from Equation 5 is fed to module $G$ consisting of two-layers of feedforward network with relu activation in between (see Appendix C for more details). The resulting output is then linearly projected and a sigmoid is applied to get the predicted prompt proposal (Equation 6).
84
+
85
+ # 2.3 PROMPT COMPOSER
86
+
87
+ The prompt composer combines the context from the selected prompt proposal (given by PPC) with the context normally used by Codex (default Codex context) to generate the prompt. Since the total length that can be used for a prompt is fixed, we adopted a dynamic context allocation strategy where if the prompt proposal context is shorter than its allocated length, we assign the remaining portion from the prompt proposal context to the default Codex context. The prompt proposal context is always added before the default Codex context. For all prompt proposals, we assign half of the total context length to the prompt proposal context and the remaining to the default Codex context. For post lines, in addition, we also assign one-fourth and three-fourths of the total context length to the prompt proposal context. If the prompt proposal context or the default Codex context is greater than the context length allocated to it, we truncate it (see Appendix B.3 for our truncation strategies).
88
+
89
+ # 3 EXPERIMENTS AND RESULTS
90
+
91
+ In this section, we describe our process of dataset creation, details of experiments along with their results and interesting ablation studies.
92
+
93
+ # 3.1 DATASET CREATION
94
+
95
+ To mitigate the effects caused by potential memorization of the code present in the dataset used for training Codex, we avoided code repositories from GitHub (Chen et al., 2021). Instead, we scraped Google Code 5 for repositories in Java (removing the ones that matched with a repository on GitHub with the same name). We selected the repositories that had a permissive license giving us a total of 47 repositories. We divided the repositories into train, validation and test splits, where each repository in its entirety is part of a split. In each file within a repository, we remove lines that are blank and comments, and set the hole position to be the middle character in the line. All the characters from the middle position to the end of the line constitute the target hole.
96
+
97
+ Since code duplication has been shown to have adverse effects (Allamanis, 2018), within a repository, we look for files that are exact replica of each other, but placed in a different folder. We mark all such copies as duplicates and omit all of them when creating target holes for our dataset. Note that the prompt proposal context can still come from the duplicate files. We felt comfortable with this choice since we wouldn’t want to predict a target hole in a duplicate file, but we can still use the context from the duplicate file to predict the hole in a file that is not its duplicate (e.g. in a sibling file). Further, we found that the repositories were quite uneven in terms of their size. To avoid large repositories dominating the training of PPC, we capped the maximum contribution of holes from a repository to 10,000, i.e. if the total number of holes in the repository exceeded 10,000, we selected 10,000 holes randomly from the total holes.
98
+
99
+ Please see the left part of Figure 2 for statistics of our dataset. The #Holes represents the holes after deduplication and capping. For some of our prompt proposals, we require semantic information that can be obtained with a parse tree. We used the tree-sitter API for Java 6 that enables us to get the AST of a file and query it. Since our prompt proposals need information at a repository level, we stored some extra information that allowed us to collate the information from individual files according to the directory structure inside the repository (see Appendix A for more details).
100
+
101
+ # 3.2 EXPERIMENTAL DETAILS
102
+
103
+ Prompt Generation: We used the OpenAI Codex Completions API for generating the predicted hole from the Codex model. In particular, we used the code-davinci-001 engine with temperature set to 1.0 and stop criteria as newline. The completion length was kept to be 24 and the maximum prompt length was 4072. Tokenization was done using the suggested tokenizer 7. To allow for fast computation, we used simple models like CodeBERT (Feng et al., 2020) and GraphCodeBERT (Guo et al., 2020) as our pretrained models. One of the limitations of these pretrained models is that the maximum context length that can be taken as input by these models is much smaller than the maximum context length allowed by Codex. Therefore, when getting the representation of the prompt proposal context that is used by PPC, we need to truncate the prompt proposal context that might lead to omitting important parts of the prompt proposal context in certain cases. Using pretrained models that allow larger context length or models that augment the context (Wu et al., 2022) offer avenues for future work. See Appendix D.4 for results when using a smaller context length from Codex.
104
+
105
+ Computational Complexity and Scalability of RLPG: To collect the ground-truth data for training our prompt proposal classifier, we queried the Codex API for each applicable prompt proposal per hole (maximum rate limit of 400 holes per minute). The computational complexity of training our larger RLPG-R variant (3.6M parameters, 141269 holes and 9.19 minutes per epoch on a single Tesla $\mathbf { V } 1 0 0 \mathbf { G P U }$ ) is much smaller than finetuning all or some part of Codex (12B parameters). During inference, we need to calculate the repo-level statistics just once and all the subsequent hole completions in the repo can utilize this cached information, incurring no additional computational complexity. Besides training the PPC, all our experiments were performed on a CPU with 8GB RAM. Our prompt proposals are based on concepts such as post lines, imports, similar name files, method names and identifiers that are quite general and are applicable to other programming languages. In addition to the existing prompt proposals, our framework provides the flexibility to incorporate new prompt proposals. Since the cost of retraining RLPG with the extended prompt proposals is extremely low (much lower than finetuning Codex with the new prompt proposals), our framework can be used to make interventions on the LLM to address observed weaknesses as long as the intervention can be expressed as a prompt proposal that adds the missing context to the LLM. As opposed to techniques that perform prompt engineering in the latent space and require access to the weights of the LLM such as Li & Liang (2021), RLPG facilitates expressing intent in the form of prompt proposals that are intuitive for humans, easy to understand and do not require access to the weights of the LLM.
106
+
107
+ Figure 2: (Left) Statistics of our dataset; (Right) Performance of the oracle relative to Codex.
108
+
109
+ <table><tr><td>Feature</td><td>Train</td><td>Val</td><td>Test</td><td>Total</td></tr><tr><td># Repositories</td><td>19</td><td>14</td><td>14</td><td>47</td></tr><tr><td>#Files</td><td>2655</td><td>1060</td><td>1308</td><td>4757</td></tr><tr><td>#Holes</td><td>92721</td><td>48548</td><td>48288</td><td>189557</td></tr></table>
110
+
111
+ <table><tr><td>Data Split</td><td>SR Codex(%)</td><td>SR Oracle(%)</td><td>Rel.个 over Codex(%)</td></tr><tr><td>Train</td><td>59.78</td><td>80.29</td><td>34.31</td></tr><tr><td>Val</td><td>62.10</td><td>79.05</td><td>27.28</td></tr><tr><td>Test</td><td>58.73</td><td>79.63</td><td>35.58</td></tr></table>
112
+
113
+ Methods: We experimented with the following methods for generating the prompt:
114
+
115
+ 1. Codex: Using the default context from Codex as the entire prompt.
116
+
117
+ 2. Oracle: Using the ground-truth vector $Y ^ { h }$ (mentioned in Section 2.2). The prompt generated corresponds to using any of the successful prompt proposals (i.e., $y _ { p } ^ { h } \overset { \cdot } { = } 1 .$ ). Since this information is not available at inference, the oracle performance represents an upper bound.
118
+
119
+ 3. Fixed Prompt Proposal: Using the most successful prompt proposal for all target holes. This was chosen based on the performance on the validation set and corresponded to taking $7 5 \%$ of the total context length from post lines in the current file.
120
+
121
+ 4. RLPG-H and RLPG-R: Using the prompt proposal predicted by the RLPG-H and RLPG-H varients of PPC. The selected prompt proposal corresponds to taking the argmax of the predicted probabilities over different prompt proposals.
122
+
123
+ 5. RLPG-BM25: Instead of using PPC to rank prompt proposals, using the scores obtained by BM25 (Jones et al., 2000) to select the best prompt proposal. The scores are calculated with the hole window being the query and prompt proposal contexts being the search documents. This serves as a non-learned retrieval method that makes use of our prompt proposals.
124
+
125
+ 6. File-level BM25: Same as above, except that instead of using our prompt proposal contexts, search documents consist of full context from other files in the repository.
126
+
127
+ 7. Random: For each target hole, select a context randomly from anywhere in the reposito
128
+
129
+ 8. Random NN: Same as Random, except that amongst the randomly chosen contexts, we take the nearest neighbours of the hole window in the representation space of a pretrained model. This is analogous to the technique used in Liu et al. (2022).
130
+
131
+ 9. Identifier Usage: For each target hole, we take the closest identifier and take usage windows of that identifier from everywhere in the repository. We take two lines above, two lines below and the usage line as the usage window. We can rank the usage windows either randomly (random) or based on the nearest neighbour distance to the hole window in the representation space (NN).
132
+
133
+ The last four methods help us understand the performance when a context other than the prompt proposal context is used. To generate a prompt using these methods, we take $50 \%$ of the context from these followed by the default Codex context that takes up the remaining context length. For the NN baselines, we use CodeBERT (Feng et al., 2020) as the pretrained model. The contexts are taken in the increasing order of the nearest neighbour distances, until we exhaust the allocated context length. RLPG-BM25 helps us understand the role of PPC. See Appendix C.3 for more details on the implementation of these methods.
134
+
135
+ Evaluation Metric: As mentioned in Section 2.2, to measure success, we used exact match between the predicted hole string generated by Codex and the target hole string. In our experiments, we report the percentage of successful holes divided by the total number of holes for each split. We will call this success rate (SR) going forward.
136
+
137
+ # 3.3 RESULTS
138
+
139
+ In this section, we present the results of the following two research questions explored in this paper:
140
+
141
+ [RQ1] Is it useful to generate a prompt that is composed of code context that is different from the default Codex context? If yes, what context can be useful?
142
+ [RQ2] For each target hole, is there a way of automatically selecting the prompt? If yes, how does this system perform relative to Codex?
143
+
144
+ RQ1 - Performance of Prompt Proposals: We found that combining the prompt proposal context (context from other files in the repository) with the default Codex context led to substantial improvement in performance. The right part of Figure 2 shows the performance of an oracle constructed from our prompt proposals. We see that across all data splits, the prompt proposals contribute to significantly large improvements over Codex (upto $36 \%$ for test split). These results might seem surprising as Codex has not been trained on prompts that consist of context other than the default Codex context. What makes this result more surprising is that in most of the cases, the prompt consists of mashed up context without logical ordering that may not even look like a semantically meaningful chunk of code (e.g. list of string literals from a sibling file followed by the default Codex context or post lines placed before the default Codex context as opposed to after). These results might suggest that as long as the relevant context (in our case repo-level knowledge in the form of prompt proposals) is present in any form in the prompt, it can be quite effective.
145
+
146
+ Table 1: Success Rate (SR) of different methods on the test data when averaged across all holes (hole-wise) and across individual repositories (repo-wise)
147
+
148
+ <table><tr><td>Method</td><td>Success Rate(%) (hole-wise)</td><td>Rel. ↑(%) (hole-wise)</td><td>Success Rate(%) (repo-wise)</td><td>Rel.↑(%) (repo-wise)</td></tr><tr><td>Codex (Chen et al.,2021)</td><td>58.73</td><td>-</td><td>60.64</td><td>=</td></tr><tr><td>Oracle</td><td>79.63</td><td>35.58</td><td>80.24</td><td>32.31</td></tr><tr><td>Random</td><td>58.13</td><td>-1.02</td><td>58.95</td><td>-2.79</td></tr><tr><td>Random NN</td><td>58.98</td><td>0.43</td><td>60.04</td><td>-0.99</td></tr><tr><td>File-level BM25</td><td>63.14</td><td>7.51</td><td>64.28</td><td>6.00</td></tr><tr><td>Identifier Usage (Random)</td><td>64.93</td><td>10.55</td><td>67.83</td><td>11.85</td></tr><tr><td>Identifier Usage (NN)</td><td>64.91</td><td>10.52</td><td>67.94</td><td>12.03</td></tr><tr><td>Fixed Prompt Proposal</td><td>65.78</td><td>12.00</td><td>68.01</td><td>12.15</td></tr><tr><td>RLPG-BM25</td><td>66.41</td><td>13.07</td><td>68.15</td><td>12.39</td></tr><tr><td>RLPG-H</td><td>68.51</td><td>16.65</td><td>69.26</td><td>14.21</td></tr><tr><td>RLPG-R</td><td>67.80</td><td>15.44</td><td>69.28</td><td>14.26</td></tr></table>
149
+
150
+ RQ2 - Performance of PPC: Having seen promise in our prompt proposals, next we present the results of RLPG, which for each target hole predicts a single best prompt proposal. Table 1 presents the success rates along with the percentage of relative improvements for the test data. The second and third columns correspond to the averages across all holes in the test data. The last two columns correspond to the average success rate of individual repositories. The latter metric doesn’t account for the size of the repository. As can be seen from the table, all the RLPG variants as well as the fixed prompt proposal improve the performance significantly over Codex. The random baselines are either worse or on par with Codex. Identifier usage is a good baseline but still performs worse than either the fixed prompt proposal or RLPG. The improved performance of RLPG-BM25 as compared to fixed prompt proposal shows the value of generating example-specific prompts using RLPG. However, both the learned variants of RLPG, i.e., RLPG-H and RLPG-R outperform the RLPG-BM25, highlighting the importance of learning PPC. See Appendix D.5 for performance of all methods on individual repositories. Note that even though we consider identifier usage as a separate baseline, one could consider it as one of the prompt proposal leading to further improved performance of RLPG.
151
+
152
+ Despite our efforts of avoiding overlap, since the training data for Codex is not exactly known, there might be a slight possibility that part of our Google Code data is part of the training data for Codex. Even if there were an overlap, we want to point out that since Codex has seen the default Codex context during training, it would be more beneficial to use the default Codex context in the prompt rather than the context from the prompt proposals or any other context from other baselines. Therefore, under this scenario, our evaluation would be more generous to the Codex baseline with results biased more in favour of the Codex baseline than other methods we have used.
153
+
154
+ Variation with #attempts: Imagine a scenario where we have a human-in-the-loop who has been given $k$ attempts to prompt the LLM and then can choose one of the $k$ hole predictions. We wanted to see how does the performance of our framework varies with #attempts under this setting. This corresponds to using $k$ prompts generated with top- $k$ prompt proposals (one prompt per proposal) and marking success if any of the $k$ prompts lead to success. The left part of Figure 3 shows the variation of SR over the validation data with the value of $k$ . For RLPG, the top- $k$ prompt proposals were chosen based on the decreasing order of probabilities given by PPC. For the fixed prompt proposal, the top- $k$ prompt proposals were decided based on decreasing order of success rate of the individual prompt proposals on the validation dataset. From the figure, we notice that as we increase the value of $k$ , the performance increases gradually at first and then saturates towards the oracle performance $( 7 9 . 0 5 \%$ for val data). This behaviour is observed for both fixed prompt proposal as well as RLPG. However, we see that for the same value of $k$ , the success rate for RLPG is higher indicating that PPC learns a useful ranking of the prompt proposal contexts that can scale well with the #attempts.
155
+
156
+ ![](images/49fec1668a029afaba203df6b240c5fc376edc8d5b0d320c45dad4588df1a682.jpg)
157
+ Figure 3: (Left) Variation of RLPG and Fixed Prompt Proposal with #attempts $( k )$ ; (Right) Mean success rates of different prompt sources when they are applicable.
158
+
159
+ Performance based on Prompt Proposals: The right part of Figure 3 shows mean success rate of prompt sources when we count success only when the corresponding prompt source is applicable. From the figure, we see that the current file is the most important prompt source. Closely following are sibling files and similar name files. We see that all prompt sources have non-zero chances of success, highlighting the usefulness of each prompt source. See Appendix D.1 for a similar breakdown based on prompt context type and Appendix E for analysis of successful and failed sample cases.
160
+
161
+ # 4 RELATED WORK
162
+
163
+ LLMs for Code: Recently, there has been a lot of work around large language models of code. One class of models are the decoder-only models that correspond to generating code from left-to-right. Codex (Chen et al., 2021), Google’s model (Austin et al., 2021), GPT-J-6B (Wang & Komatsuzaki, 2021), GPT-Neo (Black et al., 2021b), GPT-Neo-X (Black et al., 2021a), CodeParrot (Tunstall et al., 2022), PolyCoder (Xu et al., 2022a) and InCoder (Fried et al., 2022) are some examples. We also have some encoder-only models that use a masked language modelling objective. CodeBERT (Feng et al., 2020), GraphcodeBERT (Guo et al., 2020) and CuBERT (Kanade et al., 2020) are examples of such models. Lastly, we have the class of encoder-decoder models that generally use a bidirectional encoding of a context to decode a series of masked tokens. Code-T5 (Wang et al., 2021) and AlphaCode (Li et al., 2022) are examples of such models.
164
+
165
+ Repo-Level Info: Fewer works use information from outside the current file. Hellendoorn & Devanbu (2017) propose a nested n-gram model that utilizes a locality-based cache where the locality consists of all directories from the root of the project (inclusive of the current file). Zhang et al. (2021) uses the parent class to generate the comments for the child class. Pashakhanloo et al. (2022b;a) capture the structure and semantics of the repository by converting it into a relational database and propose a graph-walk based mechanism for pruning the unrelated context. Lyu et al. (2021) incorporates the API-dependency graph in a LSTM-based Seq2Seq model to assist in code generation. Xu et al. (2022b) incorporate three types of structural locality features while training the kNN-LM (Khandelwal et al., 2020). These features are binary variables that correspond to the presence or absence of similar hierarchy. The three levels of hierarchy are (a) sibling file, (b) file in the same repo (c) no hierarchy. In contrast we have a much richer set of prompt proposals incorporating the semantics and structure of the repository. Also, we assume black-box access to the actual LM and restrict ourselves to generating a prompt for the LLM without performing any finetuning of the LLM.
166
+
167
+ Prompt Generation: There have been promising works around prompt generation techniques in NLP. Broadly, there are two categories of automatic prompt generation techniques. The first category corresponds to producing continuous/soft prompts where the prompt is described in the latent space of a language model (Li & Liang, 2021; Qin & Eisner, 2021; Bragg et al., 2021; Lester et al., 2021; Liu et al., 2021b). For example, Prefix-Tuning (Li & Liang, 2021) adds a prefix to the LM that can be learned by finetuning on examples from the downstream task. The second category produces discrete prompts where the prompt is a text string that can be interpreted by a human (Shin et al., 2020; Gao et al., 2021; Schick & Schütze, 2021). For example, Autoprompt (Shin et al., 2020) generates prompt using a fixed template consisting of trigger tokens. The trigger tokens are shared across all inputs and determined by a gradient-guided search involving the LM. Our work falls in the category of discrete prompt generation techniques as we produce a prompt consisting of code tokens that can be easily interpreted by a human. However, in contrast to prior works that use a set of fixed templates for all examples, we learn to produce prompts conditioned on each example. Another important distinction is that we do not require access to the weights of the LM. A concurrent work as ours (Wang et al., 2022) studies the role of prompt-tuning when compared to fine-tuning for code translation, defect localization and code summarization. However, their technique requires access to the weights of the LLM and they perform experiments over models that are much smaller in scale than Codex. To the best of our knowledge, our work is the first to explore automatic prompt generation in a black-box access setting in the domain of source code.
168
+
169
+ # 5 CONCLUSIONS AND FUTURE DIRECTIONS
170
+
171
+ We present RLPG, a framework that learns to automatically generate prompts conditioned on the example, without requiring access to the weights of the LLM. RLPG utilizes the structure of the repository as well as the context from other files in the repository using a set of easy to understand prompt proposals. Note that even though we have scoped and worded our prompt proposals to be repository-level, the idea of RLPG and prompt proposals in itself is quite universal and need not be scoped to a repository. Taking context from other repositories as well as external knowledge such as API dependencies offers an interesting direction to explore in the future. In this work, we are taking context from only one prompt proposal. For future work, we want to learn a model that can automatically compose a prompt from multiple prompt proposals (see Appendix D.3 for promising initial results). Other interesting directions include incorporating the user’s feedback in RLPG and extending RLPG to multi-line code autocompletion.
172
+
173
+ # REFERENCES
174
+
175
+ Miltiadis Allamanis. The adverse effects of code duplication in machine learning models of code, 2018. URL https://arxiv.org/abs/1812.06469.
176
+
177
+ Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.
178
+
179
+ Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer normalization, 2016.
180
+
181
+ Sid Black, Stella Biderman, Alex Andonian, Quentin Anthony, Preetham Gali, Leo Gao, Eric Hallahan, Josh Levy-Kramer, Connor Leahy, Lucas Nestler, Kip Parker, Jason Phang, Michael Pieler, Shivanshu Purohit, Tri Songz, Phil Wang, and Samuel Weinbach. GPT-NeoX: Large scale autoregressive language modeling in pytorch, 2021a. URL http://github.com/eleutherai/ gpt-neox.
182
+
183
+ Sid Black, Leo Gao, Phil Wang, Connor Leahy, and Stella Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, March 2021b. URL https:// doi.org/10.5281/zenodo.5297715. If you use this software, please cite it using these metadata.
184
+
185
+ Jonathan Bragg, Arman Cohan, Kyle Lo, and Iz Beltagy. FLEX: Unifying evaluation for few-shot NLP. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum? id=_WnGcwXLYOE.
186
+
187
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and
188
+
189
+ Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips. cc/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
190
+
191
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
192
+
193
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
194
+
195
+ Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. arXiv preprint arXiv:2002.08155, 2020.
196
+
197
+ Daniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang, Eric Wallace, Freda Shi, Ruiqi Zhong, Wen-tau Yih, Luke Zettlemoyer, and Mike Lewis. Incoder: A generative model for code infilling and synthesis, 2022. URL https://arxiv.org/abs/2204.05999.
198
+
199
+ Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 3816–3830, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.295. URL https://aclanthology.org/2021.acllong.295.
200
+
201
+ Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. Graphcodebert: Pre-training code representations with data flow. arXiv preprint arXiv:2009.08366, 2020.
202
+
203
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
204
+
205
+ Vincent J. Hellendoorn and Premkumar Devanbu. Are deep neural networks the best choice for modeling source code? In Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017, pp. 763–773, New York, NY, USA, 2017. Association for Computing Machinery. ISBN 9781450351058. doi: 10.1145/3106237.3106290. URL https://doi.org/10.1145/3106237.3106290.
206
+
207
+ Ellen Jiang, Edwin Toh, Alejandra Molina, Kristen Olson, Claire Kayacik, Aaron Donsbach, Carrie J Cai, and Michael Terry. Discovering the syntax and strategies of natural language programming with generative language models. In Proceedings of the 2022 CHI Conference on Human Factors in Computing Systems, CHI ’22, New York, NY, USA, 2022. Association for Computing Machinery. ISBN 9781450391573. doi: 10.1145/3491102.3501870. URL https://doi.org/10.1145/ 3491102.3501870.
208
+
209
+ Karen Sparck Jones, Steve Walker, and Stephen E. Robertson. A probabilistic model of information retrieval: development and comparative experiments - part 1. Inf. Process. Manag., 36(6):779–808, 2000. doi: 10.1016/S0306-4573(00)00015-7. URL https://doi.org/10.1016/S0306- 4573(00)00015-7.
210
+
211
+ Aditya Kanade, Petros Maniatis, Gogul Balakrishnan, and Kensen Shi. Learning and evaluating contextual embedding of source code. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 12-18 July 2020, Proceedings of Machine Learning Research. PMLR, 2020.
212
+
213
+ Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\cdot ^ { = }$ HklBjCEKvH.
214
+
215
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015.
216
+
217
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv preprint arXiv:2205.11916, 2022.
218
+
219
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 3045–3059, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. URL https://aclanthology.org/2021. emnlp-main.243.
220
+
221
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 4582–4597, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/ v1/2021.acl-long.353. URL https://aclanthology.org/2021.acl-long.353.
222
+
223
+ Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. Competition-level code generation with alphacode, 2022. URL https://arxiv.org/abs/2203.07814.
224
+
225
+ Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for GPT-3? In Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, pp. 100–114, Dublin, Ireland and Online, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.deelio-1.10. URL https://aclanthology.org/2022. deelio-1.10.
226
+
227
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing, 2021a. URL https://arxiv.org/abs/2107.13586.
228
+
229
+ Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. Gpt understands, too. arXiv:2103.10385, 2021b.
230
+
231
+ Chen Lyu, Ruyun Wang, Hongyu Zhang, Hanwen Zhang, and Songlin Hu. Embedding api dependency graph for neural code generation. Empirical Softw. Engg., 26(4), jul 2021. ISSN 1382-3256. doi: 10.1007/s10664-021-09968-2. URL https://doi.org/10.1007/s10664-021- 09968-2.
232
+
233
+ Pardis Pashakhanloo, Aaditya Naik, Hanjun Dai, Petros Maniatis, and Mayur Naik. Learning to walk over relational graphs of source code. In Deep Learning for Code Workshop, 2022a. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SubGAoOWJWc.
234
+
235
+ Pardis Pashakhanloo, Aaditya Naik, Yuepeng Wang, Hanjun Dai, Petros Maniatis, and Mayur Naik. Codetrek: Flexible modeling of code using an extensible relational representation. In International Conference on Learning Representations, 2022b. URL https://openreview. net/forum?id=WQc075jmBmf.
236
+
237
+ Guanghui Qin and Jason Eisner. Learning how to ask: Querying LMs with mixtures of soft prompts. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 5203–5212, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.410. URL https: //aclanthology.org/2021.naacl-main.410.
238
+
239
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical TextConditional Image Generation with CLIP Latents. arXiv e-prints, art. arXiv:2204.06125, April 2022.
240
+
241
+ Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent, 2022. URL https: //arxiv.org/abs/2205.06175.
242
+
243
+ Laria Reynolds and Kyle McDonell. Prompt programming for large language models: Beyond the few-shot paradigm, 2021. URL https://arxiv.org/abs/2102.07350.
244
+
245
+ Alexander Rives, Joshua Meier, Tom Sercu, Siddharth Goyal, Zeming Lin, Jason Liu, Demi Guo, Myle Ott, C. Lawrence Zitnick, Jerry Ma, and Rob Fergus. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. bioRxiv, 2019. doi: 10.1101/622803. URL https://www.biorxiv.org/content/10.1101/622803v4.
246
+
247
+ Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. Highresolution image synthesis with latent diffusion models, 2021.
248
+
249
+ Timo Schick and Hinrich Schütze. Exploiting cloze-questions for few-shot text classification and natural language inference. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pp. 255–269, Online, April 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.20. URL https://aclanthology.org/2021.eacl-main.20.
250
+
251
+ Taylor Shin, Yasaman Razeghi, Robert L. Logan IV, Eric Wallace, and Sameer Singh. AutoPrompt: Eliciting knowledge from language models with automatically generated prompts. In Empirical Methods in Natural Language Processing (EMNLP), 2020.
252
+
253
+ Disha Shrivastava, Hugo Larochelle, and Daniel Tarlow. On-the-fly adaptation of source code models. In NeurIPS 2020 Workshop on Computer-Assisted Programming, 2020. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ FeVaSthrFst.
254
+
255
+ Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. J. Mach. Learn. Res., 15(1): 1929–1958, jan 2014. ISSN 1532-4435.
256
+
257
+ Jiao Sun, Q. Vera Liao, Michael Muller, Mayank Agarwal, Stephanie Houde, Kartik Talamadupula, and Justin D. Weisz. Investigating explainability of generative ai for code through scenario-based design. In 27th International Conference on Intelligent User Interfaces, IUI ’22, pp. 212–228, New York, NY, USA, 2022. Association for Computing Machinery. ISBN 9781450391443. doi: 10.1145/3490099.3511119. URL https://doi.org/10.1145/3490099.3511119.
258
+
259
+ Lewis Tunstall, Leandro von Werra, and Thomas Wolf. Natural Language Processing with Transformers. " O’Reilly Media, Inc.", 2022.
260
+
261
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, undefinedukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, pp. 6000–6010, Red Hook, NY, USA, 2017. Curran Associates Inc. ISBN 9781510860964.
262
+
263
+ Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
264
+
265
+ Chaozheng Wang, Yuanhang Yang, Cuiyun Gao, Yun Peng, Hongyu Zhang, and Michael R. Lyu. No more fine-tuning? an experimental evaluation of prompt tuning in code intelligence. In Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. ACM, nov 2022. doi: 10.1145/3540250.3549113. URL https://doi.org/10.1145%2F3540250.3549113.
266
+
267
+ Yue Wang, Weishi Wang, Shafiq Joty, and Steven C.H. Hoi. Codet5: Identifier-aware unified pretrained encoder-decoder models for code understanding and generation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, EMNLP 2021, 2021.
268
+
269
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
270
+
271
+ Yuhuai Wu, Markus Norman Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In International Conference on Learning Representations, 2022. URL https: //openreview.net/forum?id ${ . } =$ TrjbxzRcnf-.
272
+
273
+ Wen Xiao, Iz Beltagy, Giuseppe Carenini, and Arman Cohan. PRIMERA: Pyramid-based masked sentence pre-training for multi-document summarization. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 5245– 5263, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/ 2022.acl-long.360. URL https://aclanthology.org/2022.acl-long.360.
274
+
275
+ Frank F Xu, Uri Alon, Graham Neubig, and Vincent J Hellendoorn. A systematic evaluation of large language models of code. arXiv preprint arXiv:2202.13169, 2022a.
276
+
277
+ Frank F. Xu, Junxian He, Graham Neubig, and Vincent Josua Hellendoorn. Capturing structural locality in non-parametric language models. In International Conference on Learning Representations, 2022b. URL https://openreview.net/forum?id $=$ nnU3IUMJmN.
278
+
279
+ Jiyang Zhang, Sheena Panthaplackel, Pengyu Nie, Raymond J. Mooney, Junyi Jessy Li, and Milos Gligoric. Learning to generate code comments from class hierarchies, 2021. URL https: //arxiv.org/abs/2103.13426.
280
+
281
+ # A DATASET CREATION DETAILS
282
+
283
+ # A.1 CREATION OF HOLE COMPLETION DATA
284
+
285
+ To collect the hole completion data, we scraped Google Code 8 for repositories tagged with the language “Java”. Then we deduplicated repositories by searching for a matching repository with the same name on GitHub. For those repositories with zero matching names on GitHub, we downloaded the archive and extracted the source code (preserving the directory structure). Next, we tried to determine the licenses of all repositories by either looking for a LICENSE file or matching with keywords "license", "copyright", "mit", etc. For repos for which our process was able to come up with a known license, we selected the ones having a permissive license, i.e., MIT, ApacheV2 and BSD. This was followed by removing files that are exact duplicates of each other within a repo. One of the reasons we found this inter-repository duplication may be because sometimes developers adopt lousy practises where instead of declaring a package and importing functions, they simply copy-paste the desired file in the current folder. The target holes coming from any of the duplicate files do not form part of the hole completion dataset. However, these files might be used to contribute to prompt proposal context for completing a target hole in a non-duplicate file. For the remaining files, we took each line that is not a blanked line or a comment, and chose the middle character as the hole position, i.e., all the characters from the middle of the line to the end of the line form target hole. To avoid large repos having strong bias on our prompt proposal classifier, we capped the contribution from each repo to be a maximum of 10000 holes. If the number of holes in the repo exceeds 10000, we randomly select 10000 holes.
286
+
287
+ # A.2 CREATION OF DATA FOR REPO-LEVEL PROMPT PROPOSALS
288
+
289
+ We used the tree-sitter API for Java 9 to get the parse-tree of an individual file in a repo. To get information at a repo-level, for each file in the repo, we stored the following information:
290
+
291
+ 1. list of all class names in the file. This helped us to get the parent or child class file corresponding to a given parent or child class.
292
+ 2. the file corresponding to each import statement.
293
+ 3. for each import statement in the file, the position in the file where the import is used. This is used for ranking the files based on the heuristics mentioned in Table 2.
294
+ 4. list of sibling files
295
+ 5. list of similar name files. This was done by splitting the filenames based on either camel-case or underscore. If the sub-parts of two files match, then they are said to have similar name.
296
+
297
+ The above meta-data was calculated only once for each repo. The subsequent hole completions can use the same cached information. In practise, we can use a hash to store and retrieve this info efficiently. For a prompt proposal, given the prompt source, we first obtain a single file or ranked list of files (see Table 2) using the info in the parse tree in conjugation with the above repo-level meta-data. All the prompt proposal context type information (MN, MNB, SL, I, TI, FD) can then be obtained by querying the parse tree of the selected file.
298
+
299
+ # B PROMPT PROPOSAL DETAILS
300
+
301
+ # B.1 RANKING OF FILES BASED ON PROMPT SOURCE
302
+
303
+ In Table 2, we provide details of how we select files for a given prompt source. Depending on the prompt proposal, we get either a single file or a list of files ranked based on some criteria. For example, if the prompt source is Import, we take all the import statements used in the current file and identify the location in the current file where the corresponding imports have been used. According to our heuristic, the closer is the import usage to the hole position, the more likely it is for the prompt proposal context coming from the corresponding import file to be more relevant (to predict the target hole). We get a ranked list of import files sorted based on increasing order of distance (i.e., number of lines ) between the import usage and the hole position. We start by taking all of the prompt proposal context from the first file in the ranked list and then keep iterating the ranked list until either the total context length allocated to the prompt proposal gets exhausted or we reach the end of the ranked list.
304
+
305
+ Table 2: Selecting files for a prompt source
306
+
307
+ <table><tr><td>Prompt Source</td><td>File Ranking</td></tr><tr><td>Current Parent Class</td><td>file with the target hole.Returns a single file. file that contains the parent class that occurs closest to the target hole.</td></tr><tr><td>Import</td><td>Returns a single file. files with the corresponding import usage ranked based on the proximity</td></tr><tr><td>Sibling</td><td>to the hole.Returns a ranked list of files. files with import usage common to the current file and the sibling file,</td></tr><tr><td>Similar Name</td><td>ranked based on the proximity to the hole.The total number of common imports between the current and the sibling file is used as a tie-breaker. Returnsa ranked list of files. files with import usage common to the current file and the similar name</td></tr><tr><td>Child Class</td><td>file,ranked based on the proximity to the hole.The total number of common imports between the current and the similar name file is used as a tie-breaker.Returns a ranked list of files. files with import usage common to the current file and the child file,</td></tr><tr><td></td><td>ranked based on the proximity to the hole.The total number of common imports between the current and the child class file is used as a tie-breaker. Returns a ranked list of files.</td></tr><tr><td>Import of Sibling</td><td>import files ranked based on the frequency of usage in all the sibling files. Returns a ranked list of files.</td></tr><tr><td>Import of Similar Name</td><td>import file ranked on the basis of frequency of usage in all the similar name files.Returns a ranked list of files.</td></tr><tr><td>Import of Parent Class</td><td>import file ranked on the basis of frequency of usage in all the parent</td></tr><tr><td>Importof Child Class</td><td>class files.Returns a ranked list of fles. import file ranked on the basis of frequency of usage in all the child class</td></tr></table>
308
+
309
+ # B.2 EXAMPLES OF PROMPT CONTEXT TYPE
310
+
311
+ We provide examples of each of our prompt context type below:
312
+
313
+ 1. Post Lines (PL) : For the example shown in Figure 1 of the main paper, post lines will take all the lines after the line mg.InitializeToAssignment(CurrentAssignments()) till we reach the end of the file (AffinityPropagation.java).
314
+
315
+ 2. Identifiers (I): Identifiers are the names of variables used in the code. For example, for the prompt proposal context taken from the imported file shown in Figure 1 in the main paper (highlighted in violet), identifiers are InitializeToAssignment (line 1), a (line 1), currentAssignment_ (line 2), a ( line 2), clone (line 2), alreadyInitialized_ (line 3), justOneRound_ (line 4).
316
+
317
+ 3. Type Identifiers (TI): Type Identifiers define the type of an identifier. For example, in the code snippet class DPAffinityPropagation extends AffinityPropagation [ AffinityPropagation is labeled as a type identifier. Similarly in the snippet DPAPParameters parameters_;, DPAPParameters is a type identifier.
318
+
319
+ 4. Field Declarations (FD): The variables of a class type are introduced by field declarations. For example, double[][] mHijMujT_; and MessageValuePair[][] sortedMHijMujTs_; are examples of field declarations.
320
+
321
+ 5. String Literals (SL): A string literal is the sequence of characters enclosed in doublequotes. For example, in the code snippet, System.err.println("DPAP load Warning: unknown parameter " $^ +$ entries[0] + ", value $\begin{array} { r l r } { \mathbf { \Sigma } } & { { } = } & { \mathbf { \Sigma } ^ { \mathsf { ~ \pm ~ } } } \end{array} \quad \Sigma \left( \begin{array} { l l } { \mathbf { \Sigma } } & { \mathbf { \Sigma } } \\ { \mathbf { \Sigma } } & { \mathbf { \Sigma } } \end{array} \right. + \mathbf { \Sigma }$ entries[1]);, we have two string literals: (a) "DPAP load Warning: unknown parameter " ; (b) ", value = "
322
+
323
+ 6. Method Names (MN): For the example shown in Figure 1 of the main paper, public void InitializeToAssignment(int[] a) is the method name prompt context type. 7. Method Names and Bodies (MNB): For the example shown in Figure 1 of the main paper, the part highlighted in violet represents the method names and bodies.
324
+
325
+ B.3 TRUNCATION STRATEGIES FOR PROMPT PROPOSAL CONTEXT
326
+
327
+ If the prompt proposal context is greater than the context length allocated to it, then we need to truncate the prompt proposal context. We followed the below two schemes for truncating context:
328
+
329
+ • front: We truncate the context from the front. This is used for all prompt sources except Parent Class and when we take PL from Current.
330
+ • back: We truncate the context from the back. This is used when the prompt source is Parent Class and when we take prompt context types other than PL from Current.
331
+
332
+ The truncation strategies for each case were selected based on results on a small validation set. For the prompt source Current, except when the prompt context type is PL, we always start by taking code of prompt context type from after the hole position. This makes sense as the default Codex context will anyways contain code before the hole. Only if this turns out to be blank, we will use the code of context type from before the hole.
333
+
334
+ # B.4 LIST OF PROMPT PROPOSALS
335
+
336
+ Table 3: List of our proposed repo-level prompt proposals
337
+
338
+ <table><tr><td>Prompt Proposal ID</td><td>Prompt Source</td><td>Prompt Context Type</td></tr><tr><td>0,1,2,3,4</td><td>Current</td><td>MN, I, TI, SL,FD</td></tr><tr><td>5,6,7</td><td>Current</td><td>PL (taking 25%,50% and 75% contribution to the total context length)</td></tr><tr><td>8,9,10,11,12,13</td><td>Parent Class</td><td>MNB,MN,I, TI, SL,FD</td></tr><tr><td>14,15,16,17,18,19</td><td>Import</td><td>MNB,MN,I,TI, SL,FD</td></tr><tr><td>20,21,22,23,24,25</td><td>Sibling</td><td>MNB,MN,I, TI, SL,FD</td></tr><tr><td>26,27,28,29,30,31</td><td>Similar Name</td><td>MNB,MN,I,TI, SL,FD</td></tr><tr><td>32,33,34,35,36,37</td><td>Child Class</td><td>MNB,MN,I, TI, SL,FD</td></tr><tr><td>38,39,40,41,42,43</td><td>Import of Sibling</td><td>MNB,MN,I,TI,SL,FD</td></tr><tr><td>44,45,46,47,48,49</td><td>Import of Similar Name</td><td>MNB,MN,I,TI, SL,FD</td></tr><tr><td>50,51,52,53,54,55</td><td>Import of Parent Class</td><td>MNB,MN,I, TI, SL,FD</td></tr><tr><td>56,57,58,59,60,61</td><td>Import of Child Class</td><td>MNB,MN,I,TI, SL,FD</td></tr><tr><td>62</td><td>Codex</td><td></td></tr></table>
339
+
340
+ # B.5 OTHER PROMPT PROPOSAL VARIATIONS
341
+
342
+ We experimented with other variations that include: (a) appending class names at the beginning of the prompt proposal context, (b) using newline or space to join the prompt proposal context and the default Codex context, (c) taking all or the top- $k$ of the prompt context types, (d) ordering of top- $k$ .
343
+
344
+ • Context Separator: This defines how we join the prompt proposal context string to the default Codex context string. We experimented with space and newline as context separators. • Prompt Proposal Context Formatting: We can format the prompt proposal context before giving it to the Prompt Composer. We experimented with the following options:
345
+ 1. class_name: append [class name of the file] at the beginning of the prompt proposal context taken from each file that is part of the prompt source. For example, if we are taking prompt proposal context from two import files $f 1$ and $f 2$ , the prompt proposal context will be formatted as: [class name of $f 1 ]$ prompt proposal context from $f 1 + { \mathrm { s p a c e } } +$ [class name of $f 2 ]$ prompt proposal context from $f 2$ . We use this when the prompt proposal context types are MN, I, TI, FD and SL.
346
+ 2. class_method_name: we apply this only when the prompt proposal context type is MNB. We append method names at the beginning of each of the corresponding method bodies. We also
347
+
348
+ append the prompt proposal context from a file with the name of the class as described in the previous item.
349
+
350
+ 3. comment: Adding in the prompt proposal context as a comment, i.e., formatting it as: $/ * *$ prompt proposal context $^ { * } / .$ . This wasn’t found to be much useful.
351
+
352
+ 4. none: passing the prompt proposal context as it is. We use this when the prompt proposal context type is PL.
353
+
354
+ • Top- $\mathbf { k }$ Type: For each of the prompt proposal context types, except PL, we experimented with taking the (a) first (b) last and (c) all of the prompt proposal context types, i.e., we can take first-10 identifiers. We found ’all’ to be the best among all.
355
+
356
+ • Top-k: We experiment with k values of (a) 10 (b) 20 and (c) all. We found ’all’ to work best for all prompt context types.
357
+
358
+ # C IMPLEMENTATION DETAILS
359
+
360
+ # C.1 RLPG-H
361
+
362
+ We used Adam (Kingma & Ba, 2015) optimizer with a learning rate of 3e-4 and batch size of 64. We used CodeBERT (Feng et al., 2020) as our pretrained model $F _ { \phi }$ to obtain the representation of hole window. The size of the representation (corresponding to the hidden dimension of the [CLS] token) is 768. $W ^ { 1 } \in \mathbb { R } ^ { 5 1 2 \times 7 6 8 } , b ^ { \hat { 1 } } = 5 1 2 , W ^ { 2 } \in \mathbb { R } ^ { 6 3 \times 5 1 2 } , b ^ { \hat { 2 } } = 6 3$ .
363
+
364
+ # C.2 RLPG-R
365
+
366
+ We used Adam (Kingma & Ba, 2015) optimizer with a learning rate of 3e-4 and batch size of 64. We used CodeBERT (Feng et al., 2020) as our pretrained model $F _ { \phi }$ to obtain the representation of hole window and prompt proposal context. The size of the representation (corresponding to the hidden dimension of the [CLS] token) is 768. In equations 1, 2 and 3 in Section 3.2, the projection matrices $W _ { i } ^ { Q } \in \mathbb { R } ^ { d _ { q } \times d _ { m o d e l } }$ , $W _ { i } ^ { K } \in \mathbb { R } ^ { d _ { k } \times d _ { m o d e l } }$ , $W _ { i } ^ { V } \in \mathbb { R } ^ { d _ { v } \times d _ { m o d e l } }$ , $W ^ { O } \in \mathbb { R } ^ { d _ { m o d e l } \times \tau d _ { v } }$ . For the multihead attention, we used $d _ { k } = d _ { q } = d _ { v } = 3 2$ , $\tau = 4$ and $d _ { m o d e l } = 7 6 8$ , $W _ { r } \in \mathbb { R } ^ { 6 3 \times 7 6 8 }$ and $b _ { p } = 6 3$ . For each head, we perform a scaled dot-product attention (Equation 4). $G$ module consists of a dropout (Srivastava et al., 2014) layer, a residual connection (He et al., 2016), a layernorm (Ba et al., 2016), followed by a sequence of (a) dense layer of weights $= 2 0 4 8 \times 7 6 8$ , bias $\scriptstyle \sum 7 6 8$ , (b) relu activation, (c) dense layer of weights $= 7 6 8 \times 2 0 4 8$ , bias ${ \it \Omega } = \mathrm { 2 0 4 8 }$ , (d) dropout layer, (e) residual connection, (f) layernorm. A dropout value of 0.25 was used while training. Our model resembles one layer of the transformer encoder block (Vaswani et al., 2017).
367
+
368
+ # C.3 BASELINES
369
+
370
+ Random baseline first selects a file randomly from the current repository followed by selecting a random line within that file. We choose all the lines starting from that line to the end line of the chosen file as context (excluding the hole window if the chosen file is the current file). The nearest neighbour similarity is based on the dot product between the representation of the hole window and the representation of the context, where we use a pretrained CodeBERT (Feng et al., 2020) model to obtain the representations. For the Identifier Usage baseline, if the nearest identifier to the hole doesn’t return any usage window, we proceed to the next nearest identifier. For faster computation and to avoid memory issues when running on our hardware, for NN baselines, we collect 64 random neighbours and then rank based on the nearest neighbour distance. The BM25-based baselines use the Okapi BM25 implementation with default parameters given by the pip package rank-bm25 0.2.2 10. For file-level BM25, if the file context exceeds the allocated context length, we truncate from the back.
371
+
372
+ # D ADDITIONAL RESULTS
373
+
374
+ D.1 ABLATION ON PERFORMANCE BASED ON PROMPT PROPOSAL
375
+
376
+ Figure 4 shows the mean success rate of prompt context types when success is counted only for the cases when these prompt contexts are applicable. As can be seen from the figure, post lines is the most useful prompt context type on an average. The contribution from other prompt context types though smaller than post lines is still significant highlighting the importance of each prompt context type.
377
+
378
+ ![](images/e0147e7d8fcca6902e5b053cf00ae88388dd3aafbe49c1c4ae70c33567a3651e.jpg)
379
+ Figure 4: Mean success rate on validation data based on prompt context type when they are applicable.
380
+
381
+ ![](images/d890dbe3bd6bec3c791e81218c083111277e0c343dbeb4d1f6ac79d04d18ca56.jpg)
382
+ Figure 5: (Left) Normalized success rate of prompt sources when applicable, (Right) Normalized success rate of prompt context types when applicable
383
+
384
+ Figure 5 shows the normalized success rates where the normalization is performed across the prompt proposals. This helps us understand the relative performance of prompt proposal sources and context types. The left part of the figure breaks down the performance based on prompt sources and the right part breaks down based on prompt context types. One thing to note from the plot of prompt context types is that when we consider relative performance, post lines is no longer the most dominant context type. This is because post lines is tied to only when the prompt source corresponds to the current file, thereby contributing to lower numbers when compared to most of the other context types that are tied to all prompt sources.
385
+
386
+ # D.2 PERFORMANCE ON NON-IMMEDIATE POST LINES
387
+
388
+ Table 4 shows the performance of post lines when starting the fourth line after the target hole line (i.e., skipping three lines after the target hole) as opposed to starting from the line that immediately follows the target hole line. This experiment helps us understand the performance when we are interested in doing a much harder task of multi-line code autocompletion, wherein the objective is to predict not just the blanked out portion in the current line but also say the next three lines. This can correspond to completing a block of code like a function body. As can be seen from the table, when starting from the fourth line, we see a very slight deterioration in performance. This is expected because the farther away we move from the target hole, the less relevant the post lines context would be. However, the performance drop is not significant suggesting that post lines is still a very useful prompt context type that can be used under the setting of multi-line code-autocompletion. Equivalently, we can include this as one of the prompt proposals in our framework along with the current version of post lines.
389
+
390
+ Table 4: Success Rate (SR) when taking different versions of post lines.
391
+
392
+ <table><tr><td>Method</td><td>Success Rate(%) (hole-wise)</td><td>Rel. ↑(%) (hole-wise)</td><td>Success Rate(%) (repo-wise)</td><td>Rel. ↑(%) (repo-wise)</td></tr><tr><td>Codex (Chen et al., 2021)</td><td>58.73</td><td>1</td><td>60.64</td><td>1</td></tr><tr><td>Post Lines (immediate line after the hole)</td><td>65.78</td><td>12.00</td><td>68.01</td><td>12.15</td></tr><tr><td>Post Lines (skipping three lines after the hole)</td><td>65.11</td><td>10.86</td><td>66.42</td><td>9.53</td></tr></table>
393
+
394
+ # D.3 COMPOSITION OF PROMPT PROPOSALS
395
+
396
+ Table 5 shows the performance of the two versions of RLPG when we compose the prompt proposal context from $l$ prompt proposals. We take the top- $\mathbf { \nabla } \cdot \mathbf { \vec { \tau } }$ prompt proposals given by RLPG based on decreasing order of probability. To decide how much context should be used for each prompt proposal, we divide the total context length in proportion to the normalized probabilities of the top-l prompt proposals. As can be seen from the table, even though PPC is not explicitly trained to perform composition (both the ground-truth vector and the representation of prompt proposal context involve a single prompt proposal), all the compositions lead to significant improvements over Codex. However, as expected the best results correspond to taking context from a single prompt proposal (i.e., the training setting). The drop in success rate with $l = 2$ and $l = 5$ is not that significant, which suggests that explicitly training RLPG to learn to compose contexts from different prompt proposals can lead to promising results and hence offers an interesting future direction.
397
+
398
+ Table 5: Success Rate (SR) of different compositions of the prompt proposals on the test set.
399
+
400
+ <table><tr><td>Method</td><td>Success Rate(%) (hole-wise)</td><td>Rel. ↑(%) (hole-wise)</td><td>Success Rate(%) (repo-wise)</td><td>Rel. ↑(%) (repo-wise)</td></tr><tr><td>Codex (Chen et al.,2021)</td><td>58.73</td><td></td><td>60.64</td><td></td></tr><tr><td>RLPG-H(𝑙 = 1)</td><td>68.51</td><td>16.65</td><td>69.26</td><td>14.21</td></tr><tr><td>RLPG-R (𝑙 = 1)</td><td>67.80</td><td>15.44</td><td>69.28</td><td>14.26</td></tr><tr><td>RLPG-H(l = 2)</td><td>67.07</td><td>14.20</td><td>67.87</td><td>11.91</td></tr><tr><td>RLPG-R ( = 2)</td><td>66.57</td><td>13.35</td><td>67.88</td><td>11.94</td></tr><tr><td>RLPG-H(l = 5)</td><td>66.60</td><td>13.40</td><td>67.91</td><td>11.98</td></tr><tr><td>RLPG-R (l = 5)</td><td>65.78</td><td>12.01</td><td>67.69</td><td>11.62</td></tr><tr><td>RLPG-H(l = 10)</td><td>65.53</td><td>11.58</td><td>67.24</td><td>10.88</td></tr><tr><td>RLPG-R (l = 10)</td><td>63.59</td><td>8.27</td><td>65.98</td><td>8.79</td></tr></table>
401
+
402
+ # D.4 EFFECT OF CONTEXT LENGTH
403
+
404
+ To understand the effect of context length on the performance of our prompt proposals, we took half of the context length available for a prompt in Codex and observed the performance of the oracle and fixed prompt proposal. As before, we saw that an oracle constructed from our prompt proposals shows remarkable improvement over Codex highlighting the value of our prompt proposals. However, when compared to a larger context length, the relative gains are smaller. This is expected as a smaller context length means that the relevant context coming from a prompt proposal needs to be truncated to make it fit inside the prompt, thereby leading to loss of information.
405
+
406
+ Table 6: Success Rate (SR) of Codex and oracle over the test set when the total context length $= 2 0 4 8$ .
407
+
408
+ <table><tr><td>Method</td><td>Success Rate(%) (hole-wise)</td><td>Rel. ↑(%) (hole-wise)</td><td>Success Rate(%) (repo-wise)</td><td>Rel. ↑(%) (repo-wise)</td></tr><tr><td>Codex (Chen et al., 2021)</td><td>57.77</td><td>1</td><td>58.90</td><td>1</td></tr><tr><td>Oracle</td><td>61.90</td><td>7.15</td><td>67.18</td><td>14.07</td></tr></table>
409
+
410
+ # D.5 PERFORMANCE ON INDIVIDUAL REPOSITORIES
411
+
412
+ Table 7: Success Rate of different methods on training data
413
+
414
+ <table><tr><td>Repo name</td><td>#Total Holes</td><td>Oracle</td><td>Codex</td><td>Fixed prompt proposal</td><td>RLPG-H</td><td>RLPG-R</td></tr><tr><td>largemail</td><td>1653</td><td>75.38</td><td>55.11</td><td>62.73</td><td>63.94</td><td>63.28</td></tr><tr><td>ftpserverremoteadmin</td><td>7323</td><td>86.44</td><td>66.11</td><td>76.09</td><td>76.21</td><td>76.76</td></tr><tr><td>myt5lib</td><td>838</td><td>91.65</td><td>53.58</td><td>61.34</td><td>73.51</td><td>74.46</td></tr><tr><td>seamlets</td><td>4890</td><td>92.74</td><td>62.25</td><td>62.72</td><td>71.55</td><td>74.27</td></tr><tr><td>gloodb</td><td>10000</td><td>91.07</td><td>57.50</td><td>57.50</td><td>70.32</td><td>72.31</td></tr><tr><td>jjskit</td><td>9043</td><td>80.36</td><td>65.61</td><td>72.18</td><td>72.00</td><td>72.44</td></tr><tr><td>mobileexpensetracker</td><td>2298</td><td>75.94</td><td>57.88</td><td>67.28</td><td>66.84</td><td>66.97</td></tr><tr><td>gfsfa</td><td>10000</td><td>80.55</td><td>57.33</td><td>57.33</td><td>59.28</td><td>65.24</td></tr><tr><td>swe574-group3</td><td>2029</td><td>76.79</td><td>54.46</td><td>66.19</td><td>65.16</td><td>64.91</td></tr><tr><td>strudem-sicsa</td><td>6131</td><td>77.83</td><td>64.96</td><td>72.55</td><td>73.25</td><td>73.32</td></tr><tr><td>soap-dtc</td><td>1370</td><td>81.24</td><td>64.82</td><td>70.73</td><td>71.61</td><td>72.70</td></tr><tr><td>openprocesslogger</td><td>7191</td><td>81.06</td><td>62.19</td><td>71.77</td><td>72.22</td><td>72.62</td></tr><tr><td>tapestry-sesame</td><td>397</td><td>72.54</td><td>45.84</td><td>61.21</td><td>60.71</td><td>63.98</td></tr><tr><td>exogdx</td><td>735</td><td>84.76</td><td>63.81</td><td>75.51</td><td>75.92</td><td>76.60</td></tr><tr><td>designpatternjavapedro</td><td>1069</td><td>78.30</td><td>54.82</td><td>64.36</td><td>63.99</td><td>68.57</td></tr><tr><td>quidsee</td><td>3020</td><td>81.66</td><td>60.79</td><td>69.50</td><td>70.36</td><td>70.26</td></tr><tr><td>healpix-rangeset</td><td>4734</td><td>63.54</td><td>48.71</td><td>54.67</td><td>54.94</td><td>55.07</td></tr><tr><td>sol-agent-platform</td><td>10000</td><td>73.76</td><td>58.22</td><td>65.72</td><td>65.65</td><td>65.94</td></tr><tr><td>rsbotownversion</td><td>10000</td><td>75.23</td><td>57.89</td><td>65.58</td><td>66.22</td><td>66.31</td></tr></table>
415
+
416
+ Table 8: Success Rate of different methods on validation data
417
+
418
+ <table><tr><td rowspan=1 colspan=1>Repo name</td><td rowspan=1 colspan=1>#Total Holes</td><td rowspan=1 colspan=1>Oracle</td><td rowspan=1 colspan=1>Codex</td><td rowspan=1 colspan=1>Fixed prompt proposal</td><td rowspan=1 colspan=2>RLPG-H</td><td rowspan=1 colspan=1>RLPG-R</td></tr><tr><td rowspan=14 colspan=1>tyrondmath-mech-eshopinfinispan-storage-serviceteammates-shakthijavasummerframeworktinwiki jlooglejcontenedorsohocmsaffinity_propagation_javajata4testswinagilenavigablep2pspringlime</td><td rowspan=1 colspan=1>721</td><td rowspan=1 colspan=1>83.91</td><td rowspan=1 colspan=1>60.33</td><td rowspan=1 colspan=1>71.15</td><td rowspan=1 colspan=2>71.57</td><td rowspan=5 colspan=1>72.6873.1777.7572.4665.55</td></tr><tr><td rowspan=1 colspan=1>2225</td><td rowspan=1 colspan=1>83.46</td><td rowspan=1 colspan=1>62.20</td><td rowspan=1 colspan=1>72.76</td><td rowspan=1 colspan=2>73.53</td></tr><tr><td rowspan=1 colspan=1>373</td><td rowspan=1 colspan=1>82.31</td><td rowspan=1 colspan=1>71.85</td><td rowspan=1 colspan=1>78.55</td><td rowspan=1 colspan=2>76.94</td></tr><tr><td rowspan=1 colspan=1>7665</td><td rowspan=1 colspan=1>82.02</td><td rowspan=1 colspan=1>63.74</td><td rowspan=1 colspan=1>72.38</td><td rowspan=1 colspan=2>72.47</td></tr><tr><td rowspan=1 colspan=1>10000</td><td rowspan=1 colspan=1>79.27</td><td rowspan=1 colspan=1>55.92</td><td rowspan=1 colspan=1>65.30</td><td rowspan=1 colspan=2>65.74</td></tr><tr><td rowspan=1 colspan=1>10000</td><td rowspan=1 colspan=1>73.67</td><td rowspan=1 colspan=1>69.27</td><td rowspan=1 colspan=1>69.27</td><td rowspan=1 colspan=2>69.12</td><td rowspan=1 colspan=1>69.58</td></tr><tr><td rowspan=1 colspan=1>3145</td><td rowspan=1 colspan=1>84.55</td><td rowspan=1 colspan=1>73.16</td><td rowspan=1 colspan=1>77.87</td><td rowspan=1 colspan=2>77.17</td><td rowspan=3 colspan=1>77.3668.3267.62</td></tr><tr><td rowspan=2 colspan=1>5464772</td><td rowspan=1 colspan=1>81.26</td><td rowspan=1 colspan=1>58.99</td><td rowspan=1 colspan=1>67.77</td><td rowspan=1 colspan=2>67.95</td></tr><tr><td rowspan=1 colspan=1>76.68</td><td rowspan=1 colspan=1>57.90</td><td rowspan=1 colspan=1>67.10</td><td rowspan=1 colspan=1>67.49</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>1466</td><td rowspan=1 colspan=1>79.54</td><td rowspan=1 colspan=1>59.14</td><td rowspan=1 colspan=1>70.33</td><td rowspan=1 colspan=2>70.26</td><td rowspan=2 colspan=1>70.2657.47</td></tr><tr><td rowspan=1 colspan=1>1921</td><td rowspan=1 colspan=1>71.06</td><td rowspan=1 colspan=1>44.09</td><td rowspan=1 colspan=1>54.92</td><td rowspan=1 colspan=2>55.91</td></tr><tr><td rowspan=1 colspan=1>2595</td><td rowspan=1 colspan=1>79.69</td><td rowspan=1 colspan=1>63.01</td><td rowspan=1 colspan=1>72.29</td><td rowspan=1 colspan=2>72.49</td><td rowspan=1 colspan=1>72.68</td></tr><tr><td rowspan=2 colspan=1>1322879</td><td rowspan=1 colspan=1>75.72</td><td rowspan=1 colspan=1>59.76</td><td rowspan=1 colspan=1>65.43</td><td rowspan=1 colspan=2>65.13</td><td rowspan=2 colspan=1>65.2874.40</td></tr><tr><td rowspan=1 colspan=1>83.50</td><td rowspan=1 colspan=1>62.34</td><td rowspan=1 colspan=1>74.18</td><td rowspan=1 colspan=2>74.86</td></tr></table>
419
+
420
+ Table 9: Success Rate of different methods on test data
421
+
422
+ <table><tr><td>Repo Name</td><td>#Total Holes</td><td>Oracle</td><td>Codex</td><td>Fixed PP</td><td>RLPG-H</td><td>RLPG-R</td><td>Random</td><td>Random NN</td><td>Iden Usage (Random)</td><td>Iden Usage (NN)</td><td>File-Level BM25</td><td>RLPG- BM25</td></tr><tr><td>dovetaildb</td><td>10000</td><td>76.89</td><td>57.12</td><td>66.45</td><td>66.06</td><td>66.25</td><td>57.45</td><td>57.58</td><td>61.39</td><td>60.77</td><td>59.39</td><td>66.09</td></tr><tr><td>project-pt-diaoc</td><td>10000</td><td>82.01</td><td>52.67</td><td>52.81</td><td>65.08</td><td>61.25</td><td>51.58</td><td>52.93</td><td>55.54</td><td>56.21</td><td>57.04</td><td>58.29</td></tr><tr><td>realtimegc</td><td>2513</td><td>77.64</td><td>57.58</td><td>67.01</td><td>67.85</td><td>68.48</td><td>57.78</td><td>58.89</td><td>63.51</td><td>63.99</td><td>61.84</td><td>66.69</td></tr><tr><td>fswuniceubtemplates</td><td>2070</td><td>77.44</td><td>55.7</td><td>58.89</td><td>66.81</td><td>65.8</td><td>55.22</td><td>55.89</td><td>65.7</td><td>66.43</td><td>59.28</td><td>66.71</td></tr><tr><td>qwikioffice-java</td><td>1138</td><td>76.45</td><td>70.21</td><td>70.21</td><td>69.86</td><td>70.56</td><td>46.13</td><td>48.15</td><td>60.37</td><td>62.92</td><td>64.41</td><td>58.17</td></tr><tr><td>glperaudsimon</td><td>1766</td><td>78.65</td><td>53.57</td><td>62.51</td><td>62.4</td><td>61.66</td><td>55.66</td><td>57.76</td><td>69.42</td><td>68.4</td><td>69.14</td><td>61.55</td></tr><tr><td>xiaonei-java-api</td><td>839</td><td>73.42</td><td>57.57</td><td>62.1</td><td>62.69</td><td>63.29</td><td>57.09</td><td>57.21</td><td>71.28</td><td>72.35</td><td>63.77</td><td>63.29</td></tr><tr><td>ircrpgbot</td><td>6591</td><td>83.67</td><td>69.67</td><td>77.24</td><td>76.71</td><td>76.65</td><td>69.55</td><td>70.54</td><td>74.68</td><td>74.43</td><td>69.32</td><td>75.75</td></tr><tr><td>robotsimulator2009w</td><td>7514</td><td>75.63</td><td>56.28</td><td>67.55</td><td>67.53</td><td>67.55</td><td>56.4</td><td>56.18</td><td>64.61</td><td>64.71</td><td>62.96</td><td>66.12</td></tr><tr><td>gwt-plugindetect</td><td>73</td><td>84.93</td><td>60.27</td><td>68.49</td><td>65.75</td><td>68.49</td><td>58.9</td><td>57.53</td><td>63.01</td><td>63.01</td><td>50.68</td><td>75.34</td></tr><tr><td>apiitfriends</td><td>1385</td><td>85.05</td><td>65.05</td><td>74.8</td><td>75.67</td><td>75.31</td><td>65.7</td><td>68.59</td><td>70.25</td><td>70.11</td><td>66.93</td><td>73.57</td></tr><tr><td>wicketbits</td><td>754</td><td>83.02</td><td>59.81</td><td>72.94</td><td>72.81</td><td>73.08</td><td>60.21</td><td>61.94</td><td>81.96</td><td>79.31</td><td>84.48</td><td>73.47</td></tr><tr><td>hucourses</td><td>590</td><td>84.41</td><td>70.68</td><td>77.46</td><td>77.63</td><td>77.97</td><td>70</td><td>72.2</td><td>70.68</td><td>72.54</td><td>53.39</td><td>75.08</td></tr><tr><td>xfuze</td><td>3055</td><td>84.09</td><td>62.82</td><td>73.62</td><td>72.73</td><td>73.62</td><td>63.67</td><td>65.17</td><td>77.25</td><td>75.97</td><td>77.32</td><td>74.01</td></tr></table>
423
+
424
+ Table 7, Table 8 and Table 9 present the success rates of different methods over individual repositories in the training, validation and test splits, respectively. The repo-wise averages in Table 2 in the main paper were calculated by taking the average of numbers corresponding to each column. The hole-wise averages correspond to multiplying the repo-wise numbers of each method by the total holes in the repo to get the total number of successful holes by that method for that repo. We then add the total number of successful holes across repos and divide it by the total number of holes in the entire data split to get the hole-wise averages.
425
+
426
+ # E ANALYSIS OF SAMPLE CASES
427
+
428
+ In Figure 1, RLPG selects the prompt proposal that corresponds to taking method names and bodies from the imported file (i.e. MaximizingGibbsSampler.java ). Note that mg. before the hole position indicates that a method used in the imported file is likely to be invoked. In this case, the prompt proposal context (highlighted in violet) contains the method name InitializeToAssignment (part of target hole). This in conjunction with the default Codex context which contains the method CurrentAssignments() (part of target hole) leads to generation of a successful prompt. On the other hand, the prompt created from the default Codex context fails to predict the target hole in this case. In general, we observed that in the absence of a strong signal, Codex has a tendency to give preference to natural language comments occurring before the hole position, e.g. naming the method based on the comment. This in certain cases might hurt. We provide insatnces of positive and negative samples cases for RLPG below:
429
+
430
+ # E.1 POSITIVE CASES
431
+
432
+ We provide some examples of cases where RLPG led to the correct prediction and Codex failed.
433
+
434
+ 1. Cases where part of the target hole is found exactly in the prompt proposal context.
435
+
436
+ • RLPG $=$ Propagation(int numVars) vs Codex $=$ Propagation()
437
+ • RLPG $=$ tersFromFile(String filename) vs Codex
438
+ ters(String filename) {
439
+ • RLPG $=$ als("dampingFactor")) { vs Codex $=$ als("numVars")) {
440
+ • ${ \mathrm { R L P G } } = { \mathrm { ~ ~ \ k ~ } } ] + { \mathrm { ~ ~ \ " ~ } }$ , value $\begin{array} { r l r l } { \mathbf { \Sigma } } & { { } = } & { \mathbf { \Sigma } ^ { \mathsf { ~ I I ~ } } } & { + } \end{array}$ entries[1]); vs Codex $=$ ]);
441
+ • RLPG $=$ stem.exit(1); vs Codex $=$ stem.err.println("DPAP load error: " $^ +$ ex.get
442
+
443
+ 2. Cases where Codex takes strong hint from the preceding natural language comment, thereby producing incorrect predictions.
444
+
445
+ • RLPG $=$ d PassMessages() vs Codex $=$ d DoOneRoundOfMessagePassing() • RLPG $=$ teger> CurrentExemplars() { vs Codex = teger> ChooseExemplars() {
446
+
447
+ <table><tr><td>·RLPG</td><td>=</td><td>ring FileName(){</td><td>VS</td><td>Codex</td></tr><tr><td></td><td>ring GetAlgorithmFilename(){</td><td></td><td></td><td></td></tr></table>
448
+
449
+ # E.2 NEGATIVE CASES
450
+
451
+ In certain cases, extra information from prompt proposal-context might lead to confusion and produce incorrect predictions.
452
+
453
+ • RLPG $=$ an hasConverged_; vs Codex $=$ an converged_;
454
+ • RLP $\mathbf { \dot { G } = \_ } [ \dot { \textrm { i } } ] \ [ \dot { \textrm { j } } ] \ =$ -Double.MAX_VALUE; vs $\mathrm { C o d e x } = \mathrm { \small ~ \underline { ~ } { ~ [ ~ i ~ ] ~ } ~ [ ~ j ~ ] ~ } \ = \ 0 \ ;$ ;
md/dev/PlKWVd2yBkY/PlKWVd2yBkY.md ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PSEUDO NUMERICAL METHODS FOR DIFFUSION MODELS ON MANIFOLDS
2
+
3
+ Luping Liu, Yi Ren, Zhijie Lin & Zhou Zhao∗ Zhejiang University {luping.liu,rayeren,linzhijie,zhaozhou}@zju.edu.cn
4
+
5
+ # ABSTRACT
6
+
7
+ Denoising Diffusion Probabilistic Models (DDPMs) can generate high-quality samples such as image and audio samples. However, DDPMs require hundreds to thousands of iterations to produce final samples. Several prior works have successfully accelerated DDPMs through adjusting the variance schedule (e.g., Improved Denoising Diffusion Probabilistic Models) or the denoising equation (e.g., Denoising Diffusion Implicit Models (DDIMs)). However, these acceleration methods cannot maintain the quality of samples and even introduce new noise at a high speedup rate, which limit their practicability. To accelerate the inference process while keeping the sample quality, we provide a fresh perspective that DDPMs should be treated as solving differential equations on manifolds. Under such a perspective, we propose pseudo numerical methods for diffusion models (PNDMs). Specifically, we figure out how to solve differential equations on manifolds and show that DDIMs are simple cases of pseudo numerical methods. We change several classical numerical methods to corresponding pseudo numerical methods and find that the pseudo linear multi-step method is the best in most situations. According to our experiments, by directly using pre-trained models on Cifar10, CelebA and LSUN, PNDMs can generate higher quality synthetic images with only 50 steps compared with 1000-step DDIMs (20x speedup), significantly outperform DDIMs with 250 steps (by around 0.4 in FID) and have good generalization on different variance schedules.1
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Denoising Diffusion Probabilistic Models (DDPMs) (Sohl-Dickstein et al., 2015; Ho et al., 2020) is a class of generative models which model the data distribution through an iterative denoising process reversing a multi-step noising process. DDPMs have been applied successfully to a variety of applications, including image generation (Ho et al., 2020; Song et al., 2020b), text generation (Hoogeboom et al., 2021; Austin et al., 2021), 3D point cloud generation (Luo & Hu, 2021), textto-speech (Kong et al., 2021; Chen et al., 2020) and image super-resolution (Saharia et al., 2021).
12
+
13
+ Unlike Generative Adversarial Networks (GANs) (Goodfellow et al., 2014), which require careful hyperparameter tuning according to different model structures and datasets, DDPMs can use similar model structures and be trained by a simple denoising objective which makes the models fit the noise in the data. To generate samples, the iterative denoising process starts from white noise and progressively denoises it into the target domain according to the noise predicted by the model at every step. However, a critical drawback of DDPMs is that DDPMs require hundreds to thousands of iterations to produce high-quality samples and need to pass through a network at least once at every step, which makes the generation of a large number of samples extremely slow and infeasible. In contrast, GANs only need one pass through a network.
14
+
15
+ There have been many recent works focusing on improving the speed of the denoising process. Some works search for better variance schedules, including Nichol & Dhariwal (2021) and Watson et al. (2021). Some works focus on changing the inference equation, including Song et al. (2020a)
16
+
17
+ and Song et al. (2020b). Denoising Diffusion Implicit Models (DDIMs) (Song et al., 2020a) relying on a non-Markovian process accelerate the denoising process by taking multiple steps every iteration. Probability Flows (PFs) (Song et al., 2020b) build a connection between the denoising process and solving ordinary differential equations and use numerical methods of differential equations to accelerate the denoising process. Additionally, we introduce more related works in Appendix A.1.
18
+
19
+ However, this direct connection between DDPMs and numerical methods (e.g., forward Euler method, linear multi-step method and RungeKutta method (Timothy, 2017)) has weaknesses in both speed and effect (see Section 3.1). Some numerical methods are straightforward, like the forward Euler method, but they can only trade quality for speed. Some numerical methods can accelerate the reverse process without loss of quality, like the Runge-Kutta method, but
20
+
21
+ ![](images/50dbf5ca5b09ab08a54e777730ea0a2143b4755a78b4ba24ccff58bfbeb6ff30.jpg)
22
+ Figure 1: 5, 10, 20, 50 and 100-steps generated results using DDIMs, classical numerical methods and PNDMs.
23
+
24
+ they need to propagate forward more times along a neural network at every step. Furthermore, we also notice that numerical methods can introduce noticeable noise at a high speedup rate, which makes high-order numerical methods (e.g., Runge-Kutta method) even less effective than DDIMs. This phenomenon is also mentioned in Salimans & Ho (2022).
25
+
26
+ To figure out the reason for the performance degradation in classical numerical methods, we conduct some analyses and find that classical numerical methods may sample data far away from the main distribution area of the data, and the inference equations of DDPMs do not satisfy a necessary condition of numerical methods at the last several steps (see Section 3.2).
27
+
28
+ To tackle these problems, we design new numerical methods called pseudo numerical methods for diffusion models (PNDMs) to generate samples along a specific manifold in $\mathbb { R } ^ { n }$ , which is the highdensity region of the data. We first compute the corresponding differential equations of diffusion models directly and self-consistently, which builds a theoretical connection between DDPMs and numerical methods. Considering that classical numerical methods cannot guarantee to generate samples on certain manifolds, we provide brand-new numerical methods called pseudo numerical methods based on our theoretical analyses. We also find that DDIMs are simple cases of pseudo numerical methods, which means that we also provide a new way to understand DDIMs better. Furthermore, we find that the pseudo linear multi-step method is the fastest method for diffusion models under similar generated quality.
29
+
30
+ Besides, we provide a detailed theoretical analysis of our new theory and give visualization results to support our theory intuitively. According to our experiments, our methods have several advantages:
31
+
32
+ • Our methods combine the benefits of DDIMs and high-order numerical methods successfully. We theoretically prove that our new methods PNDMs are second-order convergent while DDIMs are first-order convergent, which makes PNDMs $2 0 \mathrm { x }$ faster without loss of quality on Cifar10 and CelebA.
33
+ • Our methods can reduce the best FID of pre-trained models with even shorter sampling time. With only 250 steps, our new denoising process can reduce the best FID by around 0.4 points Cifar10 and CelebA. We achieve a new SOTA FID score of 2.71 on CelebA.
34
+ • Our methods work well with different variance schedules, which means that our methods have a good generalization and can be used together with those works introducing better variance schedules to accelerate the denoising process further.
35
+
36
+ # 2 BACKGROUND
37
+
38
+ In this section, we introduce some backgrounds. Firstly, we present the classical understanding of DDPMs. Then we provide another understanding based on Song et al. (2020b), which inspires us to use numerical methods to accelerate the denoising process of diffusion models. After that, we introduce some background on numerical methods used later in this paper.
39
+
40
+ # 2.1 DENOISING DIFFUSION PROBABILISTIC MODELS
41
+
42
+ DDPMs model the data distribution from Gaussian distribution to image distribution through an iterative denoising process. Let $x _ { 0 }$ be an image, then the diffusion process is a Markov process and the reverse process has a similar form to the diffusion process, which satisfies:
43
+
44
+ $$
45
+ \begin{array} { r l } & { x _ { t + 1 } \sim \mathcal { N } ( \sqrt { 1 - \beta _ { t } } x _ { t } , \beta _ { t } \mathrm { I } ) , t = 0 , 1 , \cdots , N - 1 . } \\ & { x _ { t - 1 } \sim \mathcal { N } ( \mu _ { \theta } ( x _ { t } , t ) , \beta _ { \theta } ( x _ { t } , t ) \mathrm { I } ) , t = N , N - 1 , \cdots , 1 . } \end{array}
46
+ $$
47
+
48
+ Here, $\beta _ { t }$ controls the speed of adding noise to the data, calling them the variance schedule. $N$ is the total number of steps of the denoising process. $\mu _ { \theta }$ and $\beta _ { \theta }$ are two neural networks, and $\theta$ are their parameters.
49
+
50
+ Ho et al. (2020) get some statistics estimations of $\mu _ { \theta }$ and $\beta _ { \theta }$ . According to the properties of the conditional Gaussian distribution, we have:
51
+
52
+ $$
53
+ \begin{array} { r l } & { q ( x _ { t } | x _ { 0 } ) = \mathcal { N } ( \sqrt { \bar { \alpha } _ { t } } x _ { 0 } , ( 1 - \bar { \alpha } _ { t } ) \mathrm { I } ) , } \\ & { q ( x _ { t - 1 } | x _ { t } , x _ { 0 } ) = \mathcal { N } ( \bar { \mu } _ { t } ( x _ { t } , x _ { 0 } ) , \bar { \beta } _ { t } \mathrm { I } ) . } \end{array}
54
+ $$
55
+
56
+ Here, $\alpha _ { t } = 1 - \beta _ { t }$ , $\textstyle { \bar { \alpha } } _ { t } = \prod _ { i = 1 } ^ { t } \alpha _ { i }$ , $\begin{array} { r } { \bar { \mu } _ { t } = \frac { \sqrt { \bar { \alpha } _ { t - 1 } } \beta _ { t } } { 1 - \bar { \alpha } _ { t } } x _ { 0 } + \frac { \sqrt { \alpha _ { t } } \left( 1 - \bar { \alpha } _ { t - 1 } \right) } { 1 - \bar { \alpha } _ { t } } x _ { t } } \end{array}$ and $\begin{array} { r } { \bar { \beta } _ { t } = \frac { 1 - \bar { \alpha } _ { t - 1 } } { 1 - \bar { \alpha } _ { t } } \beta _ { t } } \end{array}$ 1−α¯t−1 βt. Then this paper sets $\beta _ { \theta } = \bar { \beta } _ { t }$ and designs a objective function to help neural networks to represent $\mu _ { \theta }$ .
57
+
58
+ Objective Function The objective function is defined by:
59
+
60
+ $$
61
+ \begin{array} { l } { { \displaystyle { \cal L } _ { t - 1 } = { \mathbb { E } } _ { q } \left[ | | \bar { \mu } _ { t } ( x _ { t } , x _ { 0 } ) - \mu _ { \theta } ( x _ { t } , t ) | | ^ { 2 } \right] } } \\ { { \displaystyle ~ = { \mathbb { E } } _ { x _ { 0 } , \epsilon } \left[ | | \frac { 1 } { \sqrt { \alpha _ { t } } } \left( x _ { t } ( x _ { 0 } , \epsilon ) - \frac { \beta _ { t } } { \sqrt { 1 - \bar { \alpha } _ { t } } } \epsilon \right) - \mu _ { \theta } ( x _ { t } ( x _ { 0 } , \epsilon ) , t ) | | ^ { 2 } \right] } } \\ { { \displaystyle ~ = { \mathbb { E } } _ { x _ { 0 } , \epsilon } \left[ \frac { \beta _ { t } ^ { 2 } } { \alpha _ { t } ( 1 - \bar { \alpha } _ { t } ) } | | \epsilon - \epsilon _ { \theta } ( \sqrt { \bar { \alpha } _ { t } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon , t ) | | ^ { 2 } \right] . } } \end{array}
62
+ $$
63
+
64
+ Here, $x _ { t } ( x _ { 0 } , \epsilon ) = \sqrt { \bar { \alpha } _ { t } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ , $\epsilon \sim \mathcal { N } ( 0 , 1 )$ , $\epsilon _ { \theta }$ is an estimate of the noise $\epsilon$ . The relationship between µθ and ϵθ is µθ = √1α ( $\begin{array} { r } { \mu _ { \theta } = \frac { 1 } { \sqrt { \alpha _ { t } } } ( x _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \bar { \alpha } _ { t } } } \epsilon _ { \theta } ) } \end{array}$ . Because $\epsilon \sim \mathcal { N } ( 0 , 1 )$ , we assume that the mean and variance of $\epsilon _ { \theta }$ are 0 and 1.
65
+
66
+ # 2.2 STOCHASTIC DIFFERENTIAL EQUATION
67
+
68
+ According to Song et al. (2020b), there is another understanding of DDPMs. The diffusion process can be treated as solving a certain stochastic differential equation $d x = ( { \sqrt { 1 - \beta ( t ) } } - 1 ) x ( t ) d t +$ $\sqrt { \beta ( t ) } d w$ . According to Anderson (1982), the denoising process also satisfies a similar stochastic differential equation:
69
+
70
+ $$
71
+ d x = \Big ( ( \sqrt { 1 - \beta ( t ) } - 1 ) x ( t ) - \beta ( t ) \epsilon _ { \theta } ( x ( t ) , t ) \Big ) d t + \sqrt { \beta ( t ) } d \bar { w } .
72
+ $$
73
+
74
+ This is Variance Preserving stochastic differential equations (VP-SDEs). Here, we change the domain of $t$ from $[ 1 , N ]$ to $[ 0 , 1 ]$ . When $N$ tends to infinity, $\{ \beta _ { i } \} _ { i = 1 } ^ { N }$ , $\{ x _ { i } \} _ { i = 1 } ^ { N }$ become continuous functions $\beta ( t )$ and $x ( t )$ on $[ 0 , 1 ]$ . Song et al. (2020b) also show that this equation has an ordinary differential equation (ODE) version with the same marginal probability density as Equation (4):
75
+
76
+ $$
77
+ d x = \left( ( { \sqrt { 1 - \beta ( t ) } } - 1 ) x ( t ) - { \frac { 1 } { 2 } } \beta ( t ) \epsilon _ { \theta } ( x ( t ) , t ) \right) d t .
78
+ $$
79
+
80
+ This different denoising equation with no random item and the same diffusion equation together is Probability Flows (PFs). These two denoising equations show us a new possibility that we can use numerical methods to accelerate the reverse process. As far as we know, DDIMs first try to remove this random item, so PFs can also be treated as an acceleration of DDIMs, while VP-SDEs are an acceleration of DDPMs.
81
+
82
+ # 2.3 NUMERICAL METHOD
83
+
84
+ Many classical numerical methods can be used to solve ODEs, including the forward Euler method, Runge-Kutta method and linear multi-step method (Timothy, 2017).
85
+
86
+ Forward Euler Method For a certain differential equation satisfying $\begin{array} { r } { \frac { d x } { d t } = f ( x , t ) } \end{array}$ . The trivial numerical method is forward Euler method satisfying $x _ { t + \delta } = x _ { t } + \delta f ( x _ { t } ^ { ^ { \mathrm { a } \delta } } t )$ .
87
+
88
+ Runge-Kutta Method Runge-Kutta method uses more information at every step, so it can achieve higher accuracy 2. Runge-Kutta method satisfies:
89
+
90
+ $$
91
+ \left\{ \begin{array} { r l } & { k _ { 1 } = f ( x _ { t } , t ) , \quad \quad k _ { 2 } = f ( x _ { t } + \frac { \delta } { 2 } k _ { 1 } , t + \frac { \delta } { 2 } ) } \\ & { k _ { 3 } = f ( x _ { t } + \frac { \delta } { 2 } k _ { 2 } , t + \frac { \delta } { 2 } ) , \quad k _ { 4 } = f ( x _ { t } + \delta k _ { 3 } , t + \delta ) } \\ & { x _ { t + \delta } = x _ { t } + \frac { \delta } { 6 } ( k _ { 1 } + 2 k _ { 2 } + 2 k _ { 3 } + k _ { 4 } ) . } \end{array} \right.
92
+ $$
93
+
94
+ Linear Multi-Step Method Linear multi-step method is another numerical method and satisfies:
95
+
96
+ $$
97
+ x _ { t + \delta } = x _ { t } + \frac { \delta } { 2 4 } \big ( 5 5 f _ { t } - 5 9 f _ { t - \delta } + 3 7 f _ { t - 2 \delta } - 9 f _ { t - 3 \delta } \big ) , f _ { t } = f ( x _ { t } , t ) .
98
+ $$
99
+
100
+ # 3 PSEUDO NUMERICAL METHOD FOR DDPM
101
+
102
+ In this section, we first compute the corresponding differential equations of diffusion models to build a direct connection between DDPMs and numerical methods. As a byproduct, we can directly use pre-trained models from DDPMs. After establishing this connection, we provide detailed analyses on the weakness of classical numerical methods. To solve the problems in classical numerical methods, we dive into the structure of numerical methods by dividing their equations into a gradient part and a transfer part and define pseudo numerical methods by introducing nonlinear transfer parts. We find that DDIMs can be regarded as simple pseudo numerical methods. Then, We explore the pros and cons of different numerical methods and choose the linear multi-step method to make numerical methods faster. Finally, we summarize our findings and analyses and safely propose our novel pseudo numerical methods for diffusion models (PNDMs), which combine our proposed transfer part and the gradient part of the linear multi-step method. Furthermore, we analyze the convergence order of pseudo numerical methods to demonstrate the effectiveness of our methods theoretically.
103
+
104
+ # 3.1 FORMULA TRANSFORMATION
105
+
106
+ According to Song et al. (2020a), the reverse process of DDPMs and DDIMs satisfies:
107
+
108
+ $$
109
+ x _ { t - 1 } = \sqrt { \bar { \alpha } _ { t - 1 } } \left( \frac { x _ { t } - \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon _ { \theta } ( x _ { t } , t ) } { \sqrt { \bar { \alpha } _ { t } } } \right) + \sqrt { 1 - \bar { \alpha } _ { t - 1 } - \sigma _ { t } ^ { 2 } } \epsilon _ { \theta } ( x _ { t } , t ) + \sigma _ { t } \epsilon _ { t } .
110
+ $$
111
+
112
+ Here, $\sigma _ { t }$ controls the ratio of random noise. If $\sigma _ { t }$ equals one, Equation (8) represents the reverse process of DDPMs; if $\sigma _ { t }$ equals zero, this equation represents the reverse process of DDIMs. And only when $\sigma _ { t }$ equals zero, this equation removes the random item and becomes a discrete form of a certain ODE. Theoretically, the numerical methods that can be used on differential equations with random items are limited. And Song et al. (2020b) have done enough research in this case. Empirically, Song et al. (2020a) have shown that DDIMs have a better acceleration effect when the number of total steps is relatively small. Therefore, our work concentrate on the case $\sigma _ { t }$ equals zero.
113
+
114
+ To find the corresponding ODE of Equation (8), we replace discrete $t - 1$ with a continuous version $t - \delta$ according to (Song et al., 2020a) and change this equation into a differential form, namely, subtract $x _ { t }$ from both sides of this equation:
115
+
116
+ $$
117
+ \mathfrak { z } _ { t - \delta } - \mathfrak { x } _ { t } = \left( \bar { \alpha } _ { t - \delta } - \bar { \alpha } _ { t } \right) \left( \frac { \mathfrak { x } _ { t } } { \sqrt { \bar { \alpha } _ { t } } \left( \sqrt { \bar { \alpha } _ { t - \delta } } + \sqrt { \bar { \alpha } _ { t } } \right) } - \frac { \epsilon _ { \theta } ( \mathfrak { x } _ { t } , t ) } { \sqrt { \bar { \alpha } _ { t } } \left( \sqrt { ( 1 - \bar { \alpha } _ { t - \delta } ) \bar { \alpha } _ { t } } + \sqrt { ( 1 - \bar { \alpha } _ { t } ) \bar { \alpha } _ { t - \delta } } \right) } \right) .
118
+ $$
119
+
120
+ Because $\delta$ is a continuous variable from 0 to $t$ , we can now compute the derivative of the generation data $x _ { t }$ and get that $\begin{array} { r } { \underset { \delta 0 } { \operatorname* { l i m } } \frac { x _ { t } - x _ { t - \delta } } { \delta } = - \bar { \alpha } ^ { \prime } ( t ) ( \frac { x ( t ) } { 2 \bar { \alpha } ( t ) } - \frac { \epsilon _ { \theta } ( x ( t ) , t ) } { 2 \bar { \alpha } ( t ) \sqrt { 1 - \bar { \alpha } ( t ) } } ) } \end{array}$ Here, $\bar { \alpha } ( t )$ is the continuous version of $\{ \bar { \alpha } _ { i } \} _ { i = 1 } ^ { N }$ like the definition of $x ( t )$ . Therefore, the corresponding ODE when $\delta$ tends to
121
+
122
+ zero of Equation (9) is:
123
+
124
+ $$
125
+ \frac { d x } { d t } = - \bar { \alpha } ^ { \prime } ( t ) \left( \frac { x ( t ) } { 2 \bar { \alpha } ( t ) } - \frac { \epsilon _ { \theta } ( x ( t ) , t ) } { 2 \bar { \alpha } ( t ) \sqrt { 1 - \bar { \alpha } ( t ) } } \right) .
126
+ $$
127
+
128
+ # 3.2 CLASSICAL NUMERICAL METHOD
129
+
130
+ After getting the target ODE, the easiest way to solve it is through classical numerical methods. However, We notice that classical numerical methods can introduce noticeable noise at a high speedup rate, making high-order numerical methods (e.g., Runge-Kutta method) even less effective than DDIMs. This phenomenon is also mentioned in Salimans & Ho (2022). To make better use of numerical methods, we analyze the differences between Equation (10) and usual differential equations and find two main problems when we directly use numerical methods with diffusion models.
131
+
132
+ The first problem is that the neural network $\epsilon _ { \theta }$ and Equation (10) are well-defined only in a limited area. Equation (2) shows that the data $x _ { t }$ is generated along a curve close to an arc. According to Figure 2, most of $x _ { t }$ is concentrated in a band with a width of around 0.1, namely the red area in Figure 2. This means that the neural network $\epsilon _ { \theta }$ cannot get enough examples to fit the noise successfully away from this area. Therefore, $\epsilon _ { \theta }$ and Equation (10), which contains $\epsilon _ { \theta }$ , are only well-defined in this limited area. However, all classical numerical methods generate results along a straight line instead of an arc. The generation process may generate samples away from the well-defined area and then introduce new errors. In Section 4.3 we will give more visualization results to support this.
133
+
134
+ ![](images/5d0a4adc964cc9dab17aeddee06c037ae60160c3540a2b0026d4c04a47a7047d.jpg)
135
+ Figure 2: the density distribution of the norm of the data.
136
+
137
+ The second problem is that Equation (10) is unbounded at most cases. We find that for most linear variance schedules $\beta _ { t }$ , Equation (10) tends to infinity when $t$ tends to zero (see Appendix A.4), which does not satisfy the condition of numerical methods mentioned in Section 2.3. This is an apparent theoretical weakness that previous works have not explored. On the contrary, in the original DDPMs and DDIMs, the prediction of the sample $x _ { t }$ and the noise $\epsilon _ { \theta }$ in the data are more and more precise as the index $t$ tends to zero (see Appendix A.5). This means original diffusion models do not make a significant error in the last several steps, whereas using numerical methods on Equation (10) does. This explains why DDIMs are better than higher-order numerical methods.
138
+
139
+ # 3.3 PSEUDO NUMERICAL METHOD ON MANIFOLD
140
+
141
+ The first problem above shows that we should try to solve our problems on certain manifolds. Here, target manifolds are the high-density region of the data √ $x _ { t }$ of DDPMs, which is defined by $x _ { t } ( x _ { 0 } , \epsilon ) \overset { } { = } \sqrt { \bar { \alpha } _ { t } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon , \epsilon \sim \bar { \mathcal { N } } ( 0 , \bar { 1 } )$ . Ernst & Gerhard (1996) show several numerical methods to solve differential equations on manifolds that have analytic expressions. Unfortunately, it’s challenging to use the above expression of manifolds. Because we do not know the target $x _ { 0 }$ in the reverse process and random items $\epsilon$ are hard to handle, too.
142
+
143
+ In this paper, we design a different way that we make our new equation of denoising process more fits with the equation of original DDIMs to make their results share similar data distribution. Firstly, we divide the classical numerical methods into two parts: gradient and transfer parts. The gradient part determines the gradient at each step, while the transfer part generates the result at the next step. For example, linear multi-step method can be divided into the gradient part $\begin{array} { r } { f ^ { \prime } = \frac { \delta } { 2 4 } ( 5 5 f _ { t } - 5 9 f _ { t - \delta } ) ^ { 2 } } \end{array}$ $3 7 f _ { t - 2 \delta } - 9 f _ { t - 3 \delta } )$ and the transfer part $x _ { t + \delta } = x _ { t } + \delta f ^ { \prime }$ . All classical numerical methods have the same linear transfer part, while gradient parts are different.
144
+
145
+ We define those numerical methods which use a nonlinear transfer part as pseudo numerical methods. And an expected transfer part should have the property that when the result from the gradient part is precise, then the result of the transfer part is as close to the manifold as possible and the error of this result is as small as possible. We find that Equation (9) satisfies such property.
146
+
147
+ Property 3.1 If ϵ is the precise noise in $x _ { t }$ , then the result of $x _ { t - \delta }$ from Equation (9) is also precise.
148
+
149
+ And we put the proof of this property in Appendix A.5. Therefore, we use:
150
+
151
+ $$
152
+ \phi ( x _ { t } , \epsilon _ { t } , t , t - \delta ) = \frac { \sqrt { \bar { \alpha } _ { t - \delta } } } { \sqrt { \bar { \alpha } _ { t } } } x _ { t } - \frac { \left( \bar { \alpha } _ { t - \delta } - \bar { \alpha } _ { t } \right) } { \sqrt { \bar { \alpha } _ { t } } ( \sqrt { ( 1 - \bar { \alpha } _ { t - \delta } ) \bar { \alpha } _ { t } } + \sqrt { ( 1 - \bar { \alpha } _ { t } ) \bar { \alpha } _ { t - \delta } } ) } \epsilon _ { t }
153
+ $$
154
+
155
+ as the transfer part and $\epsilon _ { \theta }$ as the gradient part. That if $\epsilon _ { \theta }$ is precise, the result of $x _ { t - \delta }$ is also precise, which means that $\epsilon _ { \theta }$ can determine the direction of the denoising process to generate the final results. Therefore, such a choice also satisfies the definition of a gradient part. Now, we have our gradient part $\epsilon _ { \theta }$ and transfer part $\phi$ .
156
+
157
+ This combination solves the two problems mentioned above successfully. Firstly, our new transfer parts do not introduce new errors. This property also means that it keeps the results at the next step on the target manifold because generating samples away is a kind of error. This shows that we solve the first problem. Secondly, we know that the prediction of $\epsilon _ { \theta }$ is more and more precise in the reverse process in the above subsection. And our new transfer part can generate precise results according to the precise prediction of $\epsilon _ { \theta }$ . Therefore, our generation results are more and more precise using pseudo numerical methods, while classical numerical methods can introduce obvious error at the last several steps. This shows that we solve the second problem, too. We also find that their combination $\phi ( x _ { t } , \epsilon _ { \theta } ( x _ { t } , t ) , t , t - 1 )$ is just the inference equation used by DDIMs, so DDIMs is a simple case of pseudo numerical methods. Here, we define DDIMs as DDIMs\*, emphasizing that it is a pseudo numerical method.
158
+
159
+ # 3.4 GRADIENT PART
160
+
161
+ Because we split numerical methods into two parts, we can use the same gradient part from different classical numerical methods freely (e.g., linear multi-step method), although we change the transfer part of our inference equation. Our theoretical analyses and experiments show that the gradient part from different classical methods can work well with our new transfer part (see Section 3.6, 4.2). By using the same gradient part of the linear multi-step method, we have:
162
+
163
+ $$
164
+ \left\{ \begin{array} { l l } & { e _ { t } = \epsilon _ { \theta } ( x _ { t } , t ) } \\ & { e _ { t } ^ { \prime } = \frac { 1 } { 2 4 } ( 5 5 e _ { t } - 5 9 e _ { t - \delta } + 3 7 e _ { t - 2 \delta } - 9 e _ { t - 3 \delta } ) } \\ & { x _ { t + \delta } = \phi ( x _ { t } , e _ { t } ^ { \prime } , t , t + \delta ) . } \end{array} \right.
165
+ $$
166
+
167
+ By using the same gradient part of Runge-Kutta method, we have:
168
+
169
+ # Algorithm 1 DDIMs
170
+
171
+ 1: $x _ { T } \sim \mathcal { N } ( 0 , I )$
172
+ 2: for $t = T - 1 , \cdots , 1 , 0$ do
173
+ 3: $x _ { t } = \phi ( x _ { t + 1 } , \epsilon _ { \theta } ( x _ { t + 1 } , t + 1 ) , t + 1 , t )$
174
+ 4: end for
175
+ 5: return $x _ { 0 }$
176
+
177
+ # Algorithm 2 PNDMs
178
+
179
+ $$
180
+ \left\{ \begin{array} { l l } { \begin{array} { l l } { e _ { t } ^ { 1 } = \epsilon _ { \theta } ( x _ { t } , t ) } \\ { x _ { t } ^ { 1 } = \phi ( x _ { t } , e _ { t } ^ { 1 } , t , t + \frac { \delta } { 2 } ) } \\ { e _ { t } ^ { 2 } = \epsilon _ { \theta } ( x _ { t } ^ { 1 } , t + \frac { \delta } { 2 } ) } \\ { x _ { t } ^ { 2 } = \phi ( x _ { t } , e _ { t } ^ { 2 } , t , t + \frac { \delta } { 2 } ) } \\ { e _ { t } ^ { 3 } = \epsilon _ { \theta } ( x _ { t } ^ { 2 } , t + \frac { \delta } { 2 } ) } \\ { x _ { t } ^ { 3 } = \phi ( x _ { t } , e _ { t } ^ { 3 } , t , t + \delta ) } \\ { e _ { t } ^ { 4 } = \epsilon _ { \theta } ( x _ { t } ^ { 4 } , t + \delta ) } \\ { e _ { t } ^ { 2 } = \frac { 1 } { 6 } ( e _ { t } ^ { 1 } + 2 e _ { t } ^ { 2 } + 2 e _ { t } ^ { 3 } + e _ { t } ^ { 4 } ) } \\ { x _ { t - \delta } = \phi ( x _ { t } , e _ { t } ^ { \prime } , t , t + \delta ) . } \end{array} } \end{array} \right.
181
+ $$
182
+
183
+ 1: $x _ { T } \sim \mathcal { N } ( 0 , I )$
184
+ 2: for $t = T - 1 , T - 2 , T - 3 \mathbf { d } \mathbf { 0 }$
185
+ 3: $x _ { t } , e _ { t } = \mathrm { P R K } ( x _ { t + 1 } , t + 1 , t )$
186
+ 4: end for
187
+ 5: for $t = T - 4 , \cdots , 1 , 0$ do
188
+ 6: $x _ { t } , e _ { t } = \operatorname { P L M S } ( x _ { t + 1 } , \{ e _ { p } \} _ { p > t } , t + 1 , t )$
189
+ 7: end for
190
+ 8: return $x _ { 0 }$
191
+
192
+ Abbreviate Equation (12) and (13) as $x _ { t + \delta } , e _ { t } ~ = ~ \mathrm { P L M S } ( x _ { t } , \{ e _ { p } \} _ { p < t } , t , t + \delta ) , ~ x _ { t + \delta } , e _ { t } ^ { 1 } ~ =$ $\mathrm { P R K } ( x _ { t } , t , t + \delta )$ .
193
+
194
+ Here, we have provided three kinds of pseudo numerical methods. Although advanced numerical methods can accelerate the denoising process, some may have to compute the gradient part $\epsilon _ { \theta }$ more times at every step, like the Runge-Kutta method. Propagating forward four times along a neural network makes the denoising process slower. However, we find that the linear multi-step method can reuse the result of $\epsilon _ { \theta }$ four times and only compute $\epsilon _ { \theta }$ once at every step. And theoretical analyses tell us that the Runge-Kutta and linear multi-step method have the same convergence order and similar results.
195
+
196
+ Therefore, we use the gradient part of the linear multi-step method and our new transfer part as our main pseudo numerical methods for diffusion models (PNDMs). In Table 1, we show the relationship between different numerical methods. Here, we can see PNDMs combine the benefits of higher-order classical numerical methods (in the gradient part) and DDIMs (in the transfer part).
197
+
198
+ Table 1: The relationship between different numerical methods.
199
+
200
+ <table><tr><td rowspan=1 colspan=1>order+</td><td rowspan=1 colspan=1>first</td><td rowspan=1 colspan=1>non-first</td></tr><tr><td rowspan=1 colspan=1>linear</td><td rowspan=1 colspan=1>forwardEuler</td><td rowspan=1 colspan=1>linearmulti-step,Runge-Kutta...</td></tr><tr><td rowspan=1 colspan=1>nonlinear</td><td rowspan=1 colspan=1>DDIM</td><td rowspan=1 colspan=1>PNDM</td></tr></table>
201
+
202
+ # 3.5 ALGORITHM
203
+
204
+ We can provide our whole algorithm of the denoising process of DDIMs now. According to Song et al. (2020a), the algorithm of the original method satisfies Algorithm 1. And our new algorithm of DNPMs uses the pseudo linear multi-step and pseudo Runge-Kutta method, which satisfies Algorithm 2. Here, we cannot use linear multi-step initially because the linear multi-step method cannot start automatically, which needs at least three previous steps’ information to generate results. So we use the Runge-Kutta method to compute the first three steps’ results and then use the linear multi-step method to calculate the remaining.
205
+
206
+ We also use the gradient parts of two second-order numerical methods to get another pseudo numerical method. We introduce the details of this method in Appendix A.3. We call it S-PNDMs, because its gradient part uses information from two steps at every step. Similarly, we also call our first PNDMs F-PNDMs, which use data from four steps, when we need to distinguish them.
207
+
208
+ # 3.6 CONVERGENCE ORDER
209
+
210
+ Change the transfer part of numerical methods may introduce unknown error. To determine the influence of our new transfer part theoretically, we compute the local and global error between the theoretical result of Equation (10) $x ( t + \delta )$ and our new methods, we find that $x ( t + \delta ) - x _ { \mathrm { D D I M } } ( x +$ $\delta ) = O ( \delta ^ { 2 } )$ and
211
+
212
+ $$
213
+ x ( t + \delta ) - x _ { \mathrm { S / F - P N D M } } ( x + \delta ) = O ( \delta ^ { 3 } ) .
214
+ $$
215
+
216
+ If the target ODE satisfies Lipschitz condition and local error $e _ { \mathrm { l o c a l } } = O ( \delta ^ { k } )$ , then there are $C$ and $h$ such that the global error $e _ { \mathrm { g l o b a l } }$ satisfies $e _ { \mathrm { g l o b a l } } \leq C \delta ^ { k } ( 1 + e ^ { h } + e ^ { 2 h } + \dot { \cdot } \dot { \cdot } \dot { \cdot } ) \leq C ^ { \prime } \delta ^ { k - 1 }$ . And we have that the convergence order is equal to the order of the global error. The detailed proof can be found in Appendix A.6. Therefore, we get the following property:
217
+
218
+ Property 3.2 S/F-PNDMs have third-order local error and are second-order convergent.
219
+
220
+ # 4 EXPERIMENT
221
+
222
+ # 4.1 SETUP
223
+
224
+ We conduct unconditional image generation experiments on four datasets: Cifar10 $( 3 2 \times 3 2 )$ ) (Krizhevsky et al., 2009), CelebA $( 6 4 \times 6 4 )$ (Liu et al., 2015), LSUN-church $( 2 5 6 \times 2 5 6 )$ and LSUN-bedroom $( 2 5 6 \times 2 5 6 )$ ) (Yu et al., 2016). According to the analysis in Section 3.1, we can use pre-trained models from prior works in our experiments. The pre-trained models for Cifar10, LSUNchurch and LSUN-bedroom are taken from Ho et al. (2020) and the pre-trained model for CelebA is taken from Song et al. (2020a). In these models, the number of total steps N is 1000 and the variance schedule is linear variance schedule. And we also use a pre-trained model for Cifar10, which uses a cosine variance schedule from improved denoising diffusion probabilistic models (iDDPMs (Nichol & Dhariwal, 2021)).
225
+
226
+ # 4.2 SAMPLE EFFICIENCY AND QUALITY
227
+
228
+ To analyze the acceleration effect, we test Fenchel Inception Distance (FID (Heusel et al., 2018)) on different datasets under different steps and different numerical methods, including DDIMs, S-PNDMs, F-PNDMs and classical fourth-order numerical methods (FONs) (e.g., Runge-Kutta
229
+
230
+ <table><tr><td>dataset</td><td>FID step model</td><td>10</td><td>20</td><td>50</td><td>100</td><td>250</td><td>1000</td><td>time</td></tr><tr><td>Cifar10</td><td>DDIM PF</td><td>13.4</td><td>6.84 13.8</td><td>4.67 3.89</td><td>4.16 3.69</td><td>3.71</td><td>4.04 3.72</td><td></td></tr><tr><td rowspan="3">Cifar10 (linear)</td><td>DDIM*</td><td>18.5</td><td>10.9</td><td>6.99</td><td>5.52</td><td>4.52</td><td>4.00</td><td>0.337</td></tr><tr><td>FON</td><td>13.1</td><td>7.41</td><td>5.26</td><td>4.65</td><td>4.12</td><td>3.71</td><td>0.390</td></tr><tr><td>S-PNDM</td><td>11.6</td><td>7.56</td><td>5.18</td><td>4.34</td><td>3.91</td><td>3.80</td><td>0.344</td></tr><tr><td rowspan="3">Cifar10 (cosine)</td><td>F-PNDM DDIM</td><td>7.03 14.5</td><td>5.00 8.79</td><td>3.95 5.86</td><td>3.72 4.92</td><td>3.60 4.30</td><td>3.70 3.69</td><td>0.391 0.505</td></tr><tr><td>S-PNDM</td><td>8.64</td><td>5.77</td><td>4.46</td><td>3.94</td><td>3.71</td><td>3.38</td><td>0.517</td></tr><tr><td>F-PNDM</td><td>7.05</td><td>4.61</td><td>3.68</td><td>3.53</td><td>3.49</td><td>3.26</td><td>0.595</td></tr><tr><td>CelebA</td><td>DDIM</td><td>17.3</td><td>13.7</td><td>9.17</td><td>6.53</td><td></td><td>3.51</td><td></td></tr><tr><td rowspan="4">CelebA (linear)</td><td>DDIM*</td><td>16.9</td><td>13.4</td><td>8.95</td><td>6.36</td><td>4.44</td><td>3.41</td><td>1.237</td></tr><tr><td>FON</td><td>16.0</td><td>11.6</td><td>8.13</td><td>6.70</td><td>5.14</td><td>4.17</td><td>1.431</td></tr><tr><td>S-PNDM</td><td>12.2</td><td>9.45</td><td>5.69</td><td>4.03</td><td>3.19</td><td>2.99</td><td>1.258</td></tr><tr><td>F-PNDM</td><td>7.71</td><td>5.51</td><td>3.34</td><td>2.81</td><td>2.71</td><td>2.86</td><td>1.433</td></tr></table>
231
+
232
+ Table 2: Image generation measured in FID on Cifar10 and CelebA. PFs use black box ODE solvers and we use the number of score function evaluations as the step of PFs. DDIM\* is a retest of DDIM. The bold results mean the best ones using the same pretrained model. We use the 50-step, 512 batch size experiment on an RTX3090 to test the computational cost and the column time is the average computational cost per step in seconds. And we put the results of standard deviation in Appendix A.12
233
+
234
+ method and linear multi-step method). On Cifar10 and CelebA, we first provide the results of previous works DDIMs. Then, we use the same pre-trained models to test numerical methods mentioned in this paper and put the results in Cifar10 / CelebA (linear). We also use models from iDDPMs to test nonlinear variance schedules and put the results in Cifar10 (cosine). Song et al. (2020b) do not provide detailed FID results of probability flows (PFs) under different steps, so we retest the results using its pretrained models by ourselves.
235
+
236
+ Efficiency Our two baselines are DDIM and PF. DDIM is a simple case of pseudo numerical methods, and PF is a case of classical numerical methods. However, PF uses a much bigger model than DDIM and uses some tricks to improve the sample quality. To ensure the experiment’s fairness, we use fourth-order numerical methods on Equation (10) and the model from DDIM. In Table 2, we find that the performance of FON is limited when the number of steps is small. By contrast, our new methods, including S-PNDM and F-PNDM, can improve the generated results regardless of whether the number of steps used is large or small. According to Cifar10 / CelebA (linear), F-PNDM can achieve lower FID than 1000 steps DDIM using only 50 steps, making diffusion models $2 0 \mathrm { x }$ faster without losing quality.
237
+
238
+ We draw a line chart of computation cost with FID according to the results of Cifar10 (linear) above in Figure 3. Because F-PNDM uses the pseudo Runge-Kutta method to generate the first three steps, it is slower than other methods at the first several steps. Therefore, S-PNDM can achieve the best FID initially, then F-PNDM becomes the best and the acceleration is significant.
239
+
240
+ Quality When the number of steps is relatively big, the results of FON become more and more similar to that of pseudo numerical methods. This is because all the methods are solving Equation (10), and their convergent results should be the same. However, pseudo numerical methods still work better using a large number of steps empirically. F-PNDM can improve the best FID around 0.4 using pretrained models and achieves a new SOTA FID score of 2.71 on CelebA, which shows that our work can not only accelerate diffusion models but also improve the sample quality topline. We also notice that the FID results of F-PNDM converge after more than 250 steps. The FID results will fluctuate around a value then. This phenomenon is more pronounced when we test our methods on LSUN (see Table 5, 6).
241
+
242
+ ![](images/988a0e4aa3b27ecdc0d0e15c4f94b23487b35295b934829b8f68160586957c92.jpg)
243
+ Figure 3: The FID results under different computation costs and different numerical methods on Cifar10. The unit of time is the computational cost of 1-step DDIM, which is 0.337s.
244
+
245
+ According to Cifar10 (cosine), the cosine variance schedule can lower FID using a relatively large number of steps. More analyses about variance schedule can be found in Appendix A.7. What’s more, we test our methods on other datasets and provide our FID results in Appendix A.9 and image results in Appendix A.10. We can draw similar conclusions on our methods’ acceleration and sampling quality, regardless of the datasets and the size of the images.
246
+
247
+ ![](images/65efd211782730face9f7f6f648ca37c2a522e6bc77cdc1991a885b3333e5f3f.jpg)
248
+ Figure 4: The upper part shows the change of norm with the number of steps using different methods and different steps. The lower part shows the generation curves of two points using different methods and different steps. DDIM-n means $\mathbf { n }$ -step DDIM method. Experiments in this subsection all use the Cifar10 dataset and we use the 1000-step DDIM’s result as our target result.
249
+
250
+ # 4.3 SAMPLE ON MANIFOLDS
251
+
252
+ Here, we design visualization experiments to show the effort of our new methods and support our analyses. Because it is hard to visualize high-dimensional data, we use the change of a global characteristic norm and a local characteristic pixel to show the change of the data under different steps. For pixel, we randomly choose two positions $p ^ { 1 } , p ^ { 2 }$ . Then for a series of images $x _ { T } , x _ { T - k } , \cdot \cdot \cdot , x _ { 0 }$ derived from the reverse process, we denote $y _ { t } ^ { k }$ as the value of $x _ { t }$ at position $p ^ { k }$ . Then we draw a polyline $( y _ { t } ^ { 1 } , y _ { t } ^ { 2 } ) _ { t = T , \cdots }$ in $\mathbb { R } ^ { 2 }$ . For norm, we first count the distribution of the norm of the training datasets under different steps and use this to make a heat map as the background. After that, we draw the norm of our generated results using different methods and steps above this heat map.
253
+
254
+ In Figure 4, we can see that the FON may run far away from the high-density area of the data, which explains why FON may introduce noticeable noise. However, PNDM can avoid this problem and appropriately fit the target result. More visualization results supporting our analysis can be found in Appendix A.11. What’s more, we design a toy example to test our new methods without the influence of neural networks and get similar conclusions as to the real cases above. We put the detailed results in Appendix A.8.
255
+
256
+ # 5 DISCUSSION
257
+
258
+ In this paper, we provided DNPMs, a new numerical method suitable for solving the corresponding ODEs of DDPMs. DNPMs can generate high-quality images using fewer steps without loss of quality successfully. Based on the idea of this work, further improvement can be explored in our future works: 1) find a better variance schedule for DNPMs: although we tested DNPMs on linear variance schedule and cosine variance schedule in this work, there might be another variance schedule more suitable for our proposed numerical methods. 2) Find higher-order convergent pseudo numerical methods: we analyzed the convergence order of S/F-DNPMs, which are both second-order convergent. However, F-DNPMs achieve better FID than S-DNPMs in most cases. We think this is because the result between our transfer part and target ODE has a higher-order error, which limits the convergence order of F-DNPMs. This error from the change of the transfer part is theoretical but does not influence the quality of images according to the property of Equation (11). However, making the transfer part higher-order convergent and finding the influence of such change is still exciting and needs more research. 3) Extend PNDMs to more general applications: when we proved the convergence order of DNPMs, we found that other kinds of transfer parts can keep the convergence order unchanged too, which means that pseudo numerical methods can be used on more general applications, like certain neural ODEs (Chen et al., 2019; Dupont et al., 2019).
259
+
260
+ # REFERENCES
261
+
262
+ Brian D.O. Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326, 1982. ISSN 03044149. doi: 10.1016/0304-4149(82)90051-5.
263
+
264
+ Jacob Austin, Daniel D. Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces, 2021.
265
+
266
+ Nanxin Chen, Yu Zhang, Heiga Zen, Ron J Weiss, Mohammad Norouzi, and William Chan. Wavegrad: Estimating gradients for waveform generation. arXiv preprint, 2020.
267
+
268
+ Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural Ordinary Differential Equations. arXiv:1806.07366 [cs, stat], December 2019.
269
+
270
+ Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. ILVR: Conditioning Method for Denoising Diffusion Probabilistic Models. CoRR, abs/2108.02938:14, 2021.
271
+
272
+ Emilien Dupont, Arnaud Doucet, and Yee Whye Teh. Augmented Neural ODEs. arXiv:1904.01681 [cs, stat], October 2019.
273
+
274
+ Hairer Ernst and Wanner Gerhard. Solving Ordinary Differential Equations II: Stiff and DifferentialAlgebraic Problems. Springer Series in Computational Mathematics 14. Springer-Verlag Berlin Heidelberg, 2 edition, 1996.
275
+
276
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
277
+
278
+ Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium. arXiv:1706.08500 [cs, stat], January 2018.
279
+
280
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv, 256, 2020.
281
+
282
+ Emiel Hoogeboom, Didrik Nielsen, Priyank Jaini, Patrick Forre, and Max Welling. Argmax Flows ´ and Multinomial Diffusion: Towards Non-Autoregressive Language Models. arXiv preprint, 2021.
283
+
284
+ Myeonghun Jeong, Hyeongju Kim, Sung Jun Cheon, Byoung Jin Choi, and Nam Soo Kim. DiffTTS: A Denoising Diffusion Model for Text-to-Speech. arXiv:2104.01409 [cs, eess], April 2021.
285
+
286
+ Dongjun Kim, Seungjae Shin, Kyungwoo Song, Wanmo Kang, and Il-Chul Moon. Score Matching Model for Unbounded Data Score. arXiv:2106.05527 [cs, stat], August 2021.
287
+
288
+ Zhifeng Kong and Wei Ping. On Fast Sampling of Diffusion Probabilistic Models. arXiv:2106.00132 [cs], June 2021.
289
+
290
+ Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. DiffWave: A Versatile Diffusion Model for Audio Synthesis. arXiv:2009.09761 [cs, eess, stat], March 2021.
291
+
292
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
293
+
294
+ Max W. Y. Lam, Jun Wang, Rongjie Huang, Dan Su, and Dong Yu. Bilateral Denoising Diffusion Models. arXiv:2108.11514 [cs, eess], August 2021.
295
+
296
+ Jinglin Liu, Chengxi Li, Yi Ren, Feiyang Chen, Peng Liu, and Zhou Zhao. Diffsinger: Singing voice synthesis via shallow diffusion mechanism. arXiv preprint arXiv:2105.02446, 2, 2021.
297
+
298
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
299
+
300
+ Shitong Luo and Wei Hu. Diffusion Probabilistic Models for 3D Point Cloud Generation. arXiv preprint, 2021.
301
+ Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. CoRR, abs/2102.09672, 2021.
302
+ Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. arXiv preprint arXiv:2104.07636, 2021.
303
+ Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. In International Conference on Learning Representations, 2022.
304
+ Jascha Sohl-Dickstein, Eric A Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. pp. 10, 2015.
305
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising Diffusion Implicit Models. arXiv preprint, pp. 1–19, 2020a.
306
+ Yang Song and Stefano Ermon. Improved Techniques for Training Score-Based Generative Models. arXiv:2006.09011 [cs, stat], October 2020a.
307
+ Yang Song and Stefano Ermon. Generative Modeling by Estimating Gradients of the Data Distribution. arXiv:1907.05600 [cs, stat], October 2020b.
308
+ Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-Based Generative Modeling through Stochastic Differential Equations. pp. 1–32, 2020b.
309
+ Sauer Timothy. Numerical Analysis. Pearson, 3 edition, 2017. ISBN 2017028491, 9780134696454, 013469645X.
310
+ Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based Generative Modeling in Latent Space. arXiv:2106.05931 [cs, stat], June 2021.
311
+ Daniel Watson, Jonathan Ho, Mohammad Norouzi, and William Chan. Learning to Efficiently Sample from Diffusion Probabilistic Models. CoRR, abs/2106.03802, 2021.
312
+ Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. LSUN: Construction of a Large-scale Image Dataset using Deep Learning with Humans in the Loop. arXiv:1506.03365 [cs], June 2016.
313
+
314
+ # A APPENDIX
315
+
316
+ # A.1 RELATED WORK
317
+
318
+ DDPMs have been well developed in the last few years. Some works concentrate on improving the quality and the speed of DDPMs and making DDPMs more practical. Song et al. (2020a) introduce new inference equations to accelerate DDPMs. Nichol & Dhariwal (2021), Watson et al. (2021) and Kong & Ping (2021) choose to find better variance schedules to improve the images quality. Vahdat et al. (2021) combine the advantages of DDPMs and Variational Autoencoders and get better results. Furthermore, Kim et al. (2021) try to solve an existing bottleneck that the inference equations of DDPMs are unbounded in some situations.
319
+
320
+ Song et al. (2020b) find the similarity between DDPMs and noise conditional score networks (NCSNs (Song & Ermon, 2020b)), which is that they both use a process similar to Langevin dynamics to produce samples. Therefore, some works (Song & Ermon, 2020a; Kim et al., 2021) that can improve the results of NCSNs also can be used in DDPMs. Additional, Song et al. (2020b) combine DDPMs and NCSNs under the framework of neural differential equations (Chen et al., 2019; Dupont et al., 2019). Therefore, numerical methods widely used in neural differential equations can also be applied to accelerate DDPMs. Our work successfully combines the advantages of Song et al. (2020a) and Song et al. (2020b). We use a transfer part from DDIMs and use different gradient parts from different numerical methods. Although we and Song et al. (2020b) solve certain differential equations derived from DDPMs, we use different target different equations and different numerical methods, which get better results.
321
+
322
+ The application of DDPMs is not limited to unconditional image generation. Some works apply DDPMs to various types of data successfully, including text-to-speech (Chen et al., 2020; Lam et al., 2021), singing voice (Liu et al., 2021), 3D Point Cloud (Luo & Hu, 2021), text generation (Austin et al., 2021). Additionally, DDPMs can also be used to generate conditional samples, too (Jeong et al., 2021; Choi et al., 2021).
323
+
324
+ # A.2 CONVERGENT ORDER OF METHOD
325
+
326
+ We use the forward Euler method and linear multi-step method to show what is the order of a method. Assume that $x _ { t }$ is precise and compute the error at $x _ { t + \delta }$ . For forward Euler method, we have:
327
+
328
+ $$
329
+ \begin{array} { l } { \displaystyle e _ { t , \delta } = \boldsymbol { x } ( t + \delta ) - \boldsymbol { x } _ { t , \delta } } \\ { \displaystyle = \bigg ( \boldsymbol { x } ( t ) + \delta f ( \boldsymbol { x } ( t ) , t ) + \frac { \delta ^ { 2 } } { 2 } f ^ { \prime \prime } ( c ) \bigg ) - ( \boldsymbol { x } ( t ) + \delta f ( \boldsymbol { x } _ { t } , t ) ) } \\ { \displaystyle = \frac { \delta ^ { 2 } } { 2 } f ^ { \prime \prime } ( c ) \leq \frac { \delta ^ { 2 } } { 2 } M } \end{array}
330
+ $$
331
+
332
+ Here, we assume that $f ^ { \prime \prime }$ is continuous, so $f ^ { \prime \prime }$ is bounded in a close area. $x ( t + \delta )$ is the precise result and $x _ { t , \delta }$ is the numerical result from $t$ to $t + \delta$ .
333
+
334
+ For linear multi-step method, we have:
335
+
336
+ $$
337
+ \begin{array} { l } { \displaystyle e _ { t , \delta } = x ( t + \delta ) - x _ { t , \delta } } \\ { \displaystyle = \Bigg ( x ( t ) + \frac { \delta } { 1 ! } f ( x ( t ) , t ) + \frac { \delta ^ { 2 } } { 2 ! } f ^ { \prime } ( x ( t ) , t ) + \cdots + \frac { \delta ^ { 4 } } { 4 ! } f ^ { ( 3 ) } ( x ( t ) , t ) + O \left( \delta ^ { 5 } \right) \Bigg ) } \\ { \displaystyle \quad - \left( x ( t ) + b _ { 1 } \delta f ( x ( t ) , t ) + \sum _ { s = 2 } ^ { 4 } b _ { s } \delta \left( \sum _ { k = 0 } ^ { 4 } \frac { ( - ( s - 1 ) \delta ) ^ { k } } { ( k ) ! } f ^ { ( k - 1 ) } ( x ( t ) , t ) + O \left( \delta ^ { 5 } \right) \right) \right) } \end{array}
338
+ $$
339
+
340
+ Here, $\{ b _ { s } \}$ satisfy $\textstyle \sum _ { s = 1 } ^ { 4 } b _ { s } = 1$ and the following equations for $j \in \{ 1 , \cdots , 3 \}$
341
+
342
+ $$
343
+ ( - 1 ) ^ { j } b _ { 2 } + ( - 2 ) ^ { j } b _ { 3 } + ( - 3 ) ^ { j } b _ { 4 } = \frac { 1 } { j + 1 } .
344
+ $$
345
+
346
+ We call the error at $x _ { t , \delta }$ local error, and the error at $x _ { t + M \delta }$ $\mathbf { M }$ is big enough but finite) global error. Assume the local error of our method has order $_ { \mathrm { k + 1 } }$ and the target ODE satisfies Lipschitz condition, then:
347
+
348
+ $$
349
+ \begin{array} { r l } & { x ( t + M \delta ) - x _ { t , M \delta } \leq \vert x ( t + M \delta ) - x _ { t + ( M - 1 ) \delta , \delta } \vert + \vert x _ { t + ( M - 1 ) \delta , \delta } - x _ { t , M \delta } \vert } \\ & { \qquad \leq e _ { t + ( M - 1 ) \delta , \delta } + e ^ { L \delta } \vert x ( t + ( M - 1 ) \delta ) - x _ { t , ( M - 1 ) \delta } \vert } \\ & { \qquad \leq e _ { t + ( M - 1 ) \delta , \delta } + e ^ { L \delta } e _ { t + ( M - 2 ) \delta , \delta } + \cdots } \\ & { \qquad \leq C \delta ^ { k + 1 } \left( 1 + e ^ { L h } + \cdots + e ^ { ( i - 1 ) L h } \right) } \\ & { \qquad = C h ^ { k + 1 } \frac { e ^ { i L \delta } - 1 } { e ^ { L \delta } - 1 } \leq C \delta ^ { k + 1 } \frac { e ^ { i L \delta } - 1 } { L \delta } } \\ & { \qquad = O ( \delta ^ { k } ) . } \end{array}
350
+ $$
351
+
352
+ Therefore, the global error will be one order lower than the local error. From Equation (15), we can see the forward Euler method has local error $O ( \delta ^ { 2 } )$ and global error $O ( \delta )$ , so we call it the first-order numerical method. And the linear multi-step method has local error ${ \dot { O } } ( \delta ^ { 5 } )$ and global error ${ \cal O } ( \delta ^ { 4 } )$ , and we call it the fourth-order numerical method.
353
+
354
+ In addition, assuming that a numerical method has kth-order global error, we can compute the convergence speed of this numerical method:
355
+
356
+ $$
357
+ \operatorname* { l i m } _ { \delta 0 } \frac { x _ { t + T } ^ { 2 \delta } - x ( t + T ) } { x _ { t + T } ^ { \delta } - x ( t + T ) } = \frac { ( 2 \delta ) ^ { k } } { \delta ^ { k } } = 2 ^ { k } .
358
+ $$
359
+
360
+ Here, $x _ { t + T } ^ { \delta }$ is the result at $\mathrm { t } { + } \mathrm { T }$ and move $\delta$ every step. This shows that the fourth-order method can converge to the exact solution faster than the first-order method when $\delta 0$ , which means that we can use a bigger iteration interval $\delta$ to achieve similar global error and a bigger iteration interval means that we can iterate fewer times to get results with high quality.
361
+
362
+ # A.3 PSEUDO SECOND-ORDER METHOD
363
+
364
+ We introduce two second-order numerical methods. First is improved Euler method satisfying:
365
+
366
+ $$
367
+ \left\{ \begin{array} { r l } & { k _ { 1 } = f ( x _ { t } , t ) } \\ & { k _ { 2 } = f ( x _ { t } + \delta k _ { 1 } , t + \delta ) } \\ & { x _ { t + \delta } = x _ { t } + \frac { \delta } { 2 } ( k _ { 1 } + k _ { 2 } ) } \end{array} \right.
368
+ $$
369
+
370
+ Second is another linear multi-step method called second-order linear multi-step method satisfying:
371
+
372
+ $$
373
+ x _ { t + \delta } = x _ { t } + \frac \delta 2 ( 3 f _ { t } - f _ { t - \delta } )
374
+ $$
375
+
376
+ And the corresponding pseudo improved Euler methods satisfying:
377
+
378
+ $$
379
+ \left\{ \begin{array} { l l } { \ { e } _ { t } ^ { 1 } = \epsilon _ { \theta } ( x _ { t } , t ) } \\ { \ { x } _ { t } ^ { 1 } = \phi ( x _ { t } , { e } _ { t } ^ { 1 } , t , t + \delta ) } \\ { \ { e } _ { t } ^ { 2 } = \epsilon _ { \theta } ( { x } _ { t } ^ { 1 } , t + \delta ) } \\ { \ { e } _ { t } ^ { \prime } = \frac { 1 } { 2 } ( { e } _ { t } ^ { 1 } + { e } _ { t } ^ { 2 } ) } \\ { \ { x } _ { t + \delta } = \phi ( { x } _ { t } , { e } _ { t } ^ { \prime } , t , t + \delta ) } \end{array} \right.
380
+ $$
381
+
382
+ Pseudo second-order linear multi-step method satisfying:
383
+
384
+ $$
385
+ \left\{ \begin{array} { r l } & { e _ { t } = \epsilon _ { \theta } ( x _ { t } , t ) } \\ & { e _ { t } ^ { \prime } = \frac { 1 } { 2 } ( 3 e _ { t } - e _ { t - \delta } ) } \\ & { x _ { t + \delta } = \phi ( x _ { t } , e _ { t } ^ { \prime } , t , t + \delta ) } \end{array} \right.
386
+ $$
387
+
388
+ Similar to what we do to get F-PNDMs, We combine them to get S-PNDMs. Abbreviate Equation (22) and (23) as
389
+
390
+ # Algorithm 3 S-PNDMs
391
+
392
+ $$
393
+ \begin{array} { r l } & { x _ { t + \delta } , e _ { t } = P I E ( x _ { t } , \{ e _ { p } \} _ { p < t } , t , t + \delta ) , } \\ & { x _ { t + \delta } , e _ { t } ^ { 1 } = P L M S ^ { \prime } ( x _ { t } , t , t + \delta ) . } \end{array}
394
+ $$
395
+
396
+ 1: $x _ { T } \sim \mathcal { N } ( 0 , I )$
397
+ 2: for t = T − 1 do
398
+ 3: $x _ { t } , e _ { t } = P I E ( x _ { t + 1 } , t + 1 , t )$
399
+ 4: end for
400
+ 5: for $t = T - 2 , \cdots , 1 , 0$ do
401
+ 6: $x _ { t } , e _ { t } = P L M S ^ { \prime } ( x _ { t + 1 } , \{ e _ { p } \} _ { p > t } , t + 1 , t )$
402
+ 7: end for
403
+ 8: return $x _ { 0 }$
404
+
405
+ # A.4 THE EXISTENCE OF A DERIVATIVE
406
+
407
+ Because $\bar { \alpha } _ { t }$ is usually obtained by multiplying a linear variance schedule $\beta _ { t }$ . So we have
408
+
409
+ $$
410
+ \bar { \alpha } _ { t } = e ^ { a t ^ { 2 } + b t + c } ,
411
+ $$
412
+
413
+ and $\bar { \alpha } _ { 0 } = 1$ , so $c = 0$ . Now we have
414
+
415
+ $$
416
+ \begin{array} { r l } & { \underset { \delta 0 } { \operatorname* { l i m } } \frac { x _ { t - \delta } - x _ { t } } { \delta } } \\ & { = \underset { \delta 0 } { \operatorname* { l i m } } \frac { \bar { \alpha } _ { t - \delta } - \bar { \alpha } _ { t } } { \delta } ( \frac { x _ { t } } { \sqrt { \bar { \alpha } _ { t } } ( \sqrt { \bar { \alpha } _ { t - \delta } } + \sqrt { \bar { \alpha } _ { t } } ) } - \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { \sqrt { \bar { \alpha } _ { t } } ( \sqrt { ( 1 - \bar { \alpha } _ { t - \delta } ) \bar { \alpha } _ { t } } + \sqrt { ( 1 - \bar { \alpha } _ { t } ) \bar { \alpha } _ { t - \delta } } ) } ) } \\ & { = \underset { \delta 0 } { \operatorname* { l i m } } \frac { \bar { \alpha } _ { t - \delta } - \bar { \alpha } _ { t } } { \delta } ( \frac { x _ { t } } { 2 \bar { \alpha } _ { t } } - \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { 2 \sqrt { 1 - \bar { \alpha } _ { t } } \bar { \alpha } _ { t } } ) = ( e ^ { a t ^ { 2 } + b t } ) ^ { \prime } ( \frac { x _ { t } } { 2 \bar { \alpha } _ { t } } - \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { 2 \sqrt { 1 - \bar { \alpha } _ { t } } \bar { \alpha } _ { t } } ) } \\ & { = ( 2 a t + b ) \bar { \alpha } _ { t } ( \frac { x _ { t } } { 2 \bar { \alpha } _ { t } } - \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { 2 \sqrt { 1 - \bar { \alpha } _ { t } } \bar { \alpha } _ { t } } ) = \frac { 1 } { 2 } ( 2 a t + b ) ( x _ { t } - \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { \sqrt { 1 - \bar { \alpha } _ { t } } } ) . } \end{array}
417
+ $$
418
+
419
+ To make $\begin{array} { r } { \operatorname* { l i m } _ { \delta \to 0 } \frac { x _ { t - \delta } - x _ { t } } { \delta } \big | _ { t = 0 } } \end{array}$ is well-defined, $b$ must equal to zero, or $\begin{array} { r } { ( 2 a t + b ) \frac { \epsilon _ { \theta } ( x _ { t } , t ) } { \sqrt { 1 - \bar { \alpha } _ { t } } } } \end{array}$ will tend to infinity. This is a strong condition that most variance schedules do not satisfy. In practice, DDPMs can choose the variance schedule very freely. This means that treating DDPMs as ODEs directly is not proper and has theoretical weakness.
420
+
421
+ # A.5 RELATIONSHIP BETWEEN $t$ , $\epsilon _ { \theta }$ AND $x _ { t }$
422
+
423
+ Relationship between $t$ and $\epsilon _ { \theta }$ . In Figure 5, we can see that the denoising process tends to converge, whether in the $\epsilon _ { \theta }$ domain or the sample/image domain when the step-index tends to zero. Therefore, we can say that the noise becomes more and more precise when step, namely $t$ , tends to zero.
424
+
425
+ ![](images/211a013ff6622187ddb6bed4a28631541d76a3f3c521f36bda044c85bdad9169.jpg)
426
+ Figure 5: The norm $\delta$ of the difference between two adjacent terms under different steps
427
+
428
+ Relationship between $\epsilon _ { \theta }$ and $x _ { t }$ To prove Property 3.1, assume that $x _ { t } = \sqrt { \bar { \alpha } _ { t } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ , NN is the neural network and $\epsilon _ { \theta } = \mathrm { N N } ( x _ { t } , t )$ . Because we assume that the gradient part is precise, then we have $\epsilon _ { \theta } = \epsilon$ . Then for all $t ^ { \prime } \leq t$ , we have:
429
+
430
+ $$
431
+ \begin{array} { r l } & { x _ { t ^ { \prime } } = \sqrt { \bar { \alpha } _ { t ^ { \prime } } } \left( \frac { x _ { t } - \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon _ { \theta } } { \sqrt { \bar { \alpha } _ { t } } } \right) + \sqrt { 1 - \bar { \alpha } _ { t ^ { \prime } } } \epsilon _ { \theta } } \\ & { ~ = \sqrt { \bar { \alpha } _ { t ^ { \prime } } } \left( \frac { \sqrt { \bar { \alpha } _ { t } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon - \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon } { \sqrt { \bar { \alpha } _ { t } } } \right) + \sqrt { 1 - \bar { \alpha } _ { t ^ { \prime } } } \epsilon _ { \theta } ( x _ { t } , t ) } \\ & { ~ = \sqrt { \bar { \alpha } _ { t ^ { \prime } } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t ^ { \prime } } } \epsilon . } \end{array}
432
+ $$
433
+
434
+ Here, we can find that $x _ { t ^ { \prime } } = \sqrt { \bar { \alpha } _ { t ^ { \prime } } } x _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t ^ { \prime } } } \epsilon$ is also precise, so Property 3.1 is true.
435
+
436
+ # A.6 ORDER ANALYSIS OF PSEUDO METHOD
437
+
438
+ For the convenience of theoretical analysis, we generalize the problem. Let $\phi ( x ( t ) , \epsilon , t , \delta ) \ =$ $f ( x ( t ) , t , \delta ) + g ( t , \delta ) \epsilon ( x ( t ) , t )$ and we have the property $f ( x ( t ) , \dot { } t , 0 ) = g ( t , 0 ) = \dot { 0 }$ . Then we have:
439
+
440
+ $$
441
+ \begin{array} { r l } & { x ( 1 ) = x ( 0 ) + \displaystyle \sum _ { \delta \to 0 } ( y ( t + \delta ) - y ( t ) ) } \\ & { \quad \quad = x ( 0 ) + \displaystyle \sum _ { \delta \to 0 } ( f ( x ( t ) , t , \delta ) + g ( t , \delta ) \epsilon ( x ( t ) , t ) ) } \\ & { \quad \quad = x ( 0 ) + \displaystyle \int _ { 0 } ^ { 1 } \left( \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ( x ( t ) , t ) \right) . } \end{array}
442
+ $$
443
+
444
+ Now, Equation (10) becomes a special case of this more general version and, in this special case, we have:
445
+
446
+ $$
447
+ \begin{array} { l } { f ( x ( t ) , t , \delta ) = \left( \displaystyle \frac { \sqrt { \alpha ( t + \delta ) } } { \sqrt { \alpha } } - 1 \right) x ( t ) } \\ { g ( t , \delta ) = \sqrt { 1 - \alpha ( t + \delta ) } - \displaystyle \frac { \sqrt { ( 1 - \alpha ( t ) ) \alpha ( t + \delta ) } } { \sqrt { \alpha ( t ) } } } \end{array}
448
+ $$
449
+
450
+ Now, we compute the local error of S-PNDMs. We first compute the theoretical and numerical results of different numerical methods. We have:
451
+
452
+ $$
453
+ \begin{array} { l } { { \displaystyle x ( t ) } } \\ { { \displaystyle x ( t ) + \delta \left( \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ( x ( t ) , t ) \right) + } } \\ { { \displaystyle \quad \frac { \delta ^ { 2 } } { 2 } \left( \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ( x ( t ) , t ) \right) ^ { \prime } + O ( \delta ^ { 3 } ) } } \\ { { \displaystyle - x ( t ) + \delta \left( \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ( x ( t ) , t ) \right) + O ( \delta ^ { 3 } ) + } } \\ { { \displaystyle \quad \frac { \delta ^ { 2 } } { 2 } \left( \frac { \partial ^ { 2 } f } { \partial \delta \partial t } ( x ( t ) , t , 0 ) + \frac { \partial ^ { 2 } f } { \partial \delta \partial x } ( x ( t ) , t , 0 ) \left( \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ( x ( t ) , t ) \right) \right) + } } \\ { { \displaystyle \quad \frac { \delta ^ { 2 } } { 2 } \left( \frac { \partial ^ { 2 } g } { \partial \delta \partial t } ( t , 0 ) \epsilon ( x ( t ) , t ) + \frac { \partial g } { \partial \delta } ( t , 0 ) \epsilon ^ { \prime } ( x ( t ) , t ) \right) } } \end{array}
454
+ $$
455
+
456
+ and
457
+
458
+ $$
459
+ \begin{array} { r l } & { \mathrm { S u s s ~ o u s : } \quad \mathcal { A } _ { 1 } ^ { \mathrm { n o t } } } \\ & { = \nu _ { 1 } ^ { ( n ) } - \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { = \nu _ { 1 } ^ { ( n ) } - \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { = \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { = \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad ( \frac { \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } } { \mu _ { 1 } ^ { ( 1 ) } } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad - \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad ( \frac { \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } } { \mu _ { 1 } ^ { ( 1 ) } } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad - \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad ( \frac { \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } } { \mu _ { 1 } ^ { ( 1 ) } } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad - \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } , } \\ & { \quad ( \frac { \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } } { \mu _ { 1 } ^ { ( 1 ) } } \mu _ { 1 } ^ { ( 1 ) } , } \\ & \quad ( \frac { \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ { ( 1 ) } } { \mu _ { 1 } ^ { ( 1 ) } } \mu _ { 1 } ^ { ( 1 ) } ) ^ { 2 } ) ^ { 2 } \mu _ { 1 } ^ { ( 1 ) } \mu _ { 1 } ^ { ( 1 ) } + \nu _ { 1 } ^ { ( n ) } \mu _ { 1 } ^ ( \end{array}
460
+ $$
461
+
462
+ Then we compute the difference between the theoretical and numerical results. We have:
463
+
464
+ $$
465
+ \begin{array} { r l } & { \quad x ( t + \delta ) - x _ { \mathrm { S } \cdot \mathrm { P N D M } } ( x + \delta ) } \\ & { = \frac { \delta ^ { 2 } } { 2 } \left( ( \frac { \partial ^ { 2 } f } { \partial \delta \partial t } - \frac { \partial ^ { 2 } f } { \partial \delta ^ { 2 } } ) ( x ( t ) , t , 0 ) + \frac { \partial ^ { 2 } f } { \partial \delta \partial x } ( x ( t ) , t , 0 ) \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) \right) + } \\ & { \quad \frac { \delta ^ { 2 } } { 2 } \left( ( \frac { \partial ^ { 2 } g } { \partial \delta \partial t } - \frac { \partial ^ { 2 } g } { \partial \delta ^ { 2 } } ) ( t , 0 ) + \frac { \partial ^ { 2 } f } { \partial \delta \partial x } ( x ( t ) , t , 0 ) \frac { \partial g } { \partial \delta } ( t , 0 ) \right) \epsilon ( x ( t ) , t ) + O ( \delta ^ { 3 } ) } \end{array}
466
+ $$
467
+
468
+ In this special case, we compute the derivatives of some items needed in Equation (31). We have:
469
+
470
+ $$
471
+ \begin{array} { r l } & { \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \\ & { \qquad \frac { \partial \theta _ { \theta } } { \partial t } \theta ( \theta , \phi , \phi ) } \end{array}
472
+ $$
473
+
474
+ Now we can compute the final result of Equation (31). We split it into three parts and the values of the first two terms. We have:
475
+
476
+ $$
477
+ \begin{array} { l } { { ( \frac { \partial ^ { 2 } f } { \partial \delta \partial t } - \frac { \partial ^ { 2 } f } { \partial \delta ^ { 2 } } ) ( x ( t ) , t , 0 ) + \frac { \partial ^ { 2 } f } { \partial \delta \partial x } ( x ( t ) , t , 0 ) \frac { \partial f } { \partial \delta } ( x ( t ) , t , 0 ) } } \\ { { = \left( \frac { \alpha ^ { \prime \prime } ( t ) } { 2 \alpha ( t ) } x ( t ) - \frac { \alpha ^ { \prime } ( t ) ^ { 2 } } { 2 \alpha ( t ) ^ { 2 } } x ( t ) \right) - \left( \frac { \alpha ^ { \prime \prime } ( t ) } { 2 \alpha ( t ) } x ( t ) + \frac { - \alpha ^ { \prime } ( t ) ^ { 2 } } { 4 \alpha ( t ) ^ { 2 } } x ( t ) \right) + \frac { 1 } { 2 \alpha ( t ) } \frac { \alpha ^ { \prime } ( t ) } { 2 \alpha ( t ) } x ( t ) } } \\ { { = 0 } } \end{array}
478
+ $$
479
+
480
+ and
481
+
482
+ $$
483
+ \begin{array} { l } { \displaystyle ( \frac { \partial ^ { 2 } g } { \partial \delta \partial t } - \frac { \partial ^ { 2 } g } { \partial \delta ^ { 2 } } ) ( t , 0 ) + \frac { \partial ^ { 2 } f } { \partial \delta \partial x } ( x ( t ) , t , 0 ) \frac { \partial g } { \partial \delta } ( t , 0 ) } \\ { = \frac { \sqrt { 1 - \alpha ( t ) } \alpha ^ { \prime } ( t ) ^ { 2 } } { 4 \alpha ( t ) ^ { 2 } } + \frac { \alpha ^ { \prime } ( t ) ^ { 2 } } { 4 \alpha ( t ) \sqrt { 1 - \alpha ( t ) } } + \frac { \alpha ^ { \prime } ( t ) } { 2 \alpha ( t ) } \left( \frac { - \alpha ^ { \prime } ( t ) } { 2 \sqrt { 1 - \alpha ( ( t ) ) } } - \frac { \sqrt { 1 - \alpha ( t ) } \alpha ^ { \prime } ( t ) } { 2 \alpha ( t ) } \right) } \\ { = \frac { \alpha ^ { \prime } ( t ) ^ { 2 } } { 4 \alpha ( t ) ^ { 2 } \sqrt { 1 - \alpha ( t ) } } + \frac { \alpha ^ { \prime } ( t ) } { 2 \alpha ( t ) } \left( \frac { - \alpha ^ { \prime } ( t ) } { 2 \sqrt { 1 - \alpha ( t ) } \alpha ( t ) } \right) } \\ { = 0 } \end{array}
484
+ $$
485
+
486
+ Finally, we get the final result of Equation (31):
487
+
488
+ $$
489
+ x ( t + \delta ) - x _ { \mathrm { S - P N D M } } ( x + \delta ) = O ( \delta ^ { 3 } )
490
+ $$
491
+
492
+ And the computation of the convergence order of F-PNDMs is similar, and we ignore it here. Therefore, Property 3.2 is true.
493
+
494
+ # A.7 VARIANCE SCHEDULE
495
+
496
+ According to Cifar10 (cosine) in Table 2, PNDMs can be used on both linear variance schedule and cosine variance schedule. However, we also notice cosine variance schedule can make FID lower when we use relatively big generation steps, but the effort is limited when the number of steps is small. F-PNDM uses information from four consecutive steps, so the smoothness of the schedule is more important for F-PNDM than DDIM. According to this experiment, our work can be used with works that pay attention to variance schedules to improve the acceleration effect further. However, a variance schedule that fits pseudo numerical methods better remains to be found in further work.
497
+
498
+ # A.8 TOY EXAMPLE
499
+
500
+ Here, we design a toy example to test our new methods without the influence of neural networks. We randomly generate the initial input $x _ { 1 } = ( m _ { 1 } , m _ { 2 } )$ , $m _ { i } \sim U ( 0 , 1 )$ and use a simple analytic equations $\epsilon _ { \theta } ( x ) = ( \sin x [ 0 ] , \cos x [ 1 ] )$ to replace the neural networks in real cases. Let $\phi$ in Equation (11) is unchanged and $\bar { \alpha } _ { t } = \alpha ( t ) = 1 - t$ , then we get:
501
+
502
+ $$
503
+ \begin{array} { r l } & { \quad \phi ( x _ { t } , \epsilon _ { \theta } ( x _ { t } ) , t , t - \delta ) } \\ & { = \frac { \sqrt { \bar { \alpha } _ { t - \delta } } } { \sqrt { \bar { \alpha } _ { t } } } x _ { t } - \frac { \left( \bar { \alpha } _ { t - \delta } - \bar { \alpha } _ { t } \right) } { \sqrt { \bar { \alpha } _ { t } } \left( \sqrt { \left( 1 - \bar { \alpha } _ { t - \delta } \right) \bar { \alpha } _ { t } } + \sqrt { \left( 1 - \bar { \alpha } _ { t } \right) \bar { \alpha } _ { t - \delta } } \right) } \epsilon _ { t } } \\ & { = \frac { \sqrt { 1 - \left( t - \delta \right) } } { \sqrt { 1 - t } } x _ { t } - \frac { \delta } { \sqrt { 1 - t } \left( \sqrt { \left( t - \delta \right) \left( 1 - t \right) } + \sqrt { t ( 1 - \left( t - \delta \right) ) } \right) } \epsilon _ { \theta } ( x _ { t } ) } \end{array}
504
+ $$
505
+
506
+ Here, we use three different numerical methods to generate $x _ { 0 }$
507
+
508
+ For DDIM, we have:
509
+
510
+ $$
511
+ x _ { t - \delta } = x _ { t } + \phi ( x _ { t } , \epsilon _ { \theta } ( x _ { t } ) , t , t - \delta )
512
+ $$
513
+
514
+ For FON, according to Equation (10), we have:
515
+
516
+ $$
517
+ \begin{array} { l } { { \displaystyle e _ { t } ^ { \prime } = \bar { \alpha } ^ { \prime } ( t ) \left( \frac { x _ { t } } { 2 \bar { \alpha } ( t ) } - \frac { \epsilon _ { \theta } ( x _ { t } ) } { 2 \bar { \alpha } ( t ) \sqrt { 1 - \bar { \alpha } ( t ) } } \right) } } \\ { { \displaystyle ~ = - \left( \frac { x _ { t } } { 2 ( 1 - t ) } - \frac { \epsilon _ { \theta } ( x _ { t } ) } { 2 ( 1 - t ) \sqrt { t } } \right) } } \\ { { \displaystyle x _ { t - \delta } = x _ { t } + \frac { \delta } { 2 4 } ( 5 5 e _ { t } ^ { \prime } - 5 9 e _ { t + \delta } ^ { \prime } + 3 7 e _ { t + 2 \delta } ^ { \prime } - 9 e _ { t + 3 \delta } ^ { \prime } ) } } \end{array}
518
+ $$
519
+
520
+ For F-PNDM, we have:
521
+
522
+ $$
523
+ \begin{array} { c } { { e ^ { \prime } = \displaystyle \frac { 1 } { 2 4 } \big ( 5 5 \epsilon _ { \theta } ( x _ { t } ) - 5 9 \epsilon _ { \theta } ( x _ { t + \delta } ) + 3 7 \epsilon _ { \theta } ( x _ { t + 2 \delta } ) - 9 \epsilon _ { \theta } ( x _ { t + 3 \delta } ) \big ) } } \\ { { x _ { t - \delta } = x _ { t } + \phi ( x _ { t } , e ^ { \prime } , t , t - \delta ) } } \end{array}
524
+ $$
525
+
526
+ Then we draw the corresponding generation curves in Figure 6. We find that the result is similar to the real cases. The main difference here is that FON can correct its results while the real case cannot. The reason is that the gradient is well-defined everywhere, while in real cases, the gradient is meaningful on the high-density region of the data $x _ { t }$ of DDPMs.
527
+
528
+ # A.9 MORE FID RESULTS
529
+
530
+ Here, We provide our more detailed FID results on Cifar10, CelebA, LSUN-church and LSUNbedroom in Table 3, 4, 5, 6.
531
+
532
+ ![](images/be45ffbce3a2d38e669a4bc00e9042c1345f1381c96712d8462385105dfde8f6.jpg)
533
+ Figure 6: The generation curve of our toy example.
534
+
535
+ Table 3: Cifar10 image generation measured in FID. The upper part uses linear variance schedule and the bottom half uses cosine variance schedule. The first line shows the FID provided by Song et al. (2020a).
536
+
537
+ <table><tr><td>steps</td><td>5</td><td>10</td><td>20</td><td>25</td><td>40</td><td>50</td><td>100</td><td>125</td><td>200</td><td>250</td><td>500</td><td>1000</td></tr><tr><td>DDIM</td><td></td><td>13.4</td><td></td><td>6.84</td><td></td><td>4.67</td><td>4.16</td><td></td><td></td><td></td><td></td><td>4.04</td></tr><tr><td>DDIM*</td><td>44.5</td><td>18.5</td><td>10.9</td><td>9.61</td><td>7.65</td><td>6.99</td><td>5.52</td><td>5.19</td><td>4.69</td><td>4.52</td><td>4.17</td><td>4.00</td></tr><tr><td>FON</td><td>98.0</td><td>13.1</td><td>7.41</td><td>6.41</td><td>5.50</td><td>5.26</td><td>4.65</td><td>4.54</td><td>4.23</td><td>4.12</td><td>3.84</td><td>3.71</td></tr><tr><td>S-PNDM</td><td>22.8</td><td>11.6</td><td>7.56</td><td>6.79</td><td>5.57</td><td>5.18</td><td>4.34</td><td>4.18</td><td>3.97</td><td>3.91</td><td>3.81</td><td>3.80</td></tr><tr><td>F-PNDM</td><td>13.9</td><td>7.03</td><td>5.00</td><td>4.76</td><td>4.10</td><td>3.95</td><td>3.72</td><td>3.64</td><td>3.60</td><td>3.60</td><td>3.64</td><td>3.70</td></tr><tr><td>DDIM*</td><td>28.7</td><td>14.5</td><td>8.79</td><td>7.83</td><td>6.41</td><td>5.86</td><td>4.92</td><td>4.75</td><td>4.42</td><td>4.30</td><td>3.98</td><td>3.69</td></tr><tr><td>S-PNDM</td><td>18.3</td><td>8.64</td><td>5.77</td><td>5.45</td><td>4.76</td><td>4.46</td><td>3.94</td><td>3.85</td><td>3.69</td><td>3.71</td><td>3.60</td><td>3.38</td></tr><tr><td>F-PNDM</td><td>18.2</td><td>7.05</td><td>4.61</td><td>4.32</td><td>3.85</td><td>3.68</td><td>3.53</td><td>3.46</td><td>3.47</td><td>3.49</td><td>3.44</td><td>3.26</td></tr></table>
538
+
539
+ Table 4: CelebA image generation measured in FID. All of them use linear variance schedule.
540
+
541
+ <table><tr><td>steps</td><td>5</td><td>10</td><td>20</td><td>25</td><td>40</td><td>50</td><td>100</td><td>125</td><td>200</td><td>250</td><td>500</td><td>1000</td></tr><tr><td>DDIM</td><td></td><td>17.3</td><td></td><td>13.7</td><td></td><td>9.17</td><td>6.53</td><td></td><td></td><td></td><td></td><td>3.51</td></tr><tr><td>DDIM*</td><td>24.4</td><td>16.9</td><td>13.4</td><td>12.3</td><td>9.99</td><td>8.95</td><td>6.36</td><td>5.74</td><td>4.78</td><td>4.44</td><td>3.75</td><td>3.41</td></tr><tr><td>FON</td><td>60.2</td><td>16.0</td><td>11.6</td><td>10.6</td><td>8.89</td><td>8.13</td><td>6.70</td><td>6.28</td><td>5.45</td><td>5.14</td><td>4.49</td><td>4.17</td></tr><tr><td>S-PNDM</td><td>15.2</td><td>12.2</td><td>9.45</td><td>8.42</td><td>6.50</td><td>5.69</td><td>4.03</td><td>3.72</td><td>3.30</td><td>3.19</td><td>3.01</td><td>2.99</td></tr><tr><td>F-PNDM</td><td>11.3</td><td>7.71</td><td>5.51</td><td>4.75</td><td>3.67</td><td>3.34</td><td>2.81</td><td>2.75</td><td>2.71</td><td>2.71</td><td>2.77</td><td>2.86</td></tr></table>
542
+
543
+ <table><tr><td>steps</td><td>5</td><td>10</td><td>20</td><td>25</td><td>40</td><td>50</td><td>100</td><td>125</td><td>200</td><td>250</td></tr><tr><td>DDIM</td><td></td><td>19.5</td><td>12.5</td><td></td><td></td><td>10.8</td><td>10.6</td><td></td><td></td><td></td></tr><tr><td>DDIM*</td><td>48.8</td><td>18.8</td><td>11.7</td><td>11.0</td><td>10.1</td><td>10.0</td><td>9.84</td><td>9.83</td><td>9.85</td><td>9.88</td></tr><tr><td>S-PNDM</td><td>20.5</td><td>11.8</td><td>9.20</td><td>9.13</td><td>9.31</td><td>9.49</td><td>9.82</td><td>9.88</td><td>10.0</td><td>10.0</td></tr><tr><td>F-PNDM</td><td>14.8</td><td>8.69</td><td>9.13</td><td>9.33</td><td>9.69</td><td>9.89</td><td>10.1</td><td>9.99</td><td>10.1</td><td>10.1</td></tr></table>
544
+
545
+ Table 5: LSUN-church image generation measured in FID. All of them use linear variance schedule.
546
+
547
+ <table><tr><td>steps</td><td>-5</td><td>10</td><td>20</td><td>25</td><td>40</td><td>50</td><td>100</td><td>125</td><td>200</td><td>250</td></tr><tr><td>DDIM</td><td></td><td>17.0</td><td>8.89</td><td></td><td></td><td>6.75</td><td>6.62</td><td></td><td></td><td></td></tr><tr><td>DDIM*</td><td>51.3</td><td>16.4</td><td>8.47</td><td>7.41</td><td>6.27</td><td>6.05</td><td>5.97</td><td>6.03</td><td>6.23</td><td>6.32</td></tr><tr><td>S-PNDM</td><td>18.1</td><td>10.2</td><td>6.50</td><td>6.02</td><td>5.74</td><td>5.81</td><td>6.29</td><td>6.44</td><td>6.69</td><td>6.75</td></tr><tr><td>F-PNDM</td><td>12.6</td><td>6.99</td><td>5.68</td><td>5.74</td><td>6.17</td><td>6.44</td><td>6.91</td><td>6.96</td><td>7.03</td><td>6.92</td></tr></table>
548
+
549
+ Table 6: LSUN-bedroom image generation measured in FID. All of them use linear variance schedule.
550
+
551
+ # A.10 MORE IMAGE RESULTS
552
+
553
+ Here, we show more generated images on Cifar10, CelebA, LSUN-church and LSUN-bedroom in Figure 7, 9, 8, 10, 11, 12.
554
+
555
+ ![](images/c4f5582ce5980bcd0e8ac8379e97701ac88de76a8102e86df5aca16d27de35cf.jpg)
556
+ Figure 7: 5, 10, 20, 50, 100, 250, 500-steps generated results using DDIMs, classical numerical methods and PNDMs on Cifar10.
557
+
558
+ ![](images/e2e55ffc863d3d86c6415bfe1c8e64af10a0a61e5ee41f0c7f50268bacabf7df.jpg)
559
+ Figure 8: 5, 10, 20, 50, 100, 250, 500-steps generated results using DDIMs, classical numerical methods and PNDMs on CelebA.
560
+
561
+ ![](images/8ca89fae4dfa5d0cdbfd05cf769104951e67eaa94405628c9c6e5dcf092ce347.jpg)
562
+ Figure 9: Generated images of PNDMs on Cifar10.
563
+
564
+ ![](images/707d628b8fe0c94f27302502b323c2339811ec6f9da5f802750e7f5b6dd536b0.jpg)
565
+ Figure 10: Generated images of PNDMs on CelebA.
566
+
567
+ ![](images/0cd7787d65de975dc53a90ae9f8d3dc7ad1ba175cb337e0fc21718a6c69f32fa.jpg)
568
+ Figure 11: 5, 10, 20, 50, 100-steps generated results using DDIMs, classical numerical methods and PNDMs on LSUN-church.
569
+
570
+ ![](images/ef1a6784558da2575fe140e396e950f9d691d70145b931cb4fa8ea9ddebd8afd.jpg)
571
+ Figure 12: 5, 10, 20, 50, 100-steps generated results using DDIMs, classical numerical methods and PNDMs on LSUN-bedroom.
572
+
573
+ # A.11 MORE VISUALIZATION RESULTS
574
+
575
+ Here, we put more visualization results similar to Figure 4 in Figure 13.
576
+
577
+ ![](images/eb24a50a2b3b3413ce7f38719c70a88204c3334e245ab79b82a85e12dd3e3dcb.jpg)
578
+ Figure 13: Visualization results under 5, 10, 20, 25, 40 and 50 steps.
579
+
580
+ # A.12 FID RESULT WITH STANDARD DEVIATION
581
+
582
+ Here, we report the mean and standard deviation of FID results, tested over four sampling runs.
583
+
584
+ <table><tr><td>dataset</td><td>FID\ step model</td><td>10</td><td>20</td><td>50</td><td>100</td><td>250</td><td>1000</td></tr><tr><td rowspan="4">Cifar10 (linear)</td><td>DDIM*</td><td>18.50±.06</td><td>10.86±.08</td><td>6.95±.04</td><td>5.49±.06</td><td>4.52±.02</td><td>4.02±.04</td></tr><tr><td>FON</td><td>13.00±.11</td><td>7.33±.06</td><td>5.24±.05</td><td>4.64±.04</td><td>4.12±.03</td><td>3.73±.03</td></tr><tr><td>S-PNDM</td><td>11.58±.10</td><td>7.53±.07</td><td>5.15±.05</td><td>4.34±.03</td><td>3.93±.02</td><td>3.83±.03</td></tr><tr><td>F-PNDM</td><td>6.12±.07</td><td>5.04±.07</td><td>4.01±.02</td><td>3.75±.04</td><td>3.67±.03</td><td>3.78±.04</td></tr></table>
585
+
586
+ Table 7: Image generation measured in FID on Cifar10. DDIM\* means a kind of pseudo numerical method and also a retest of DDIM.
md/dev/PzcvxEMzvQC/PzcvxEMzvQC.md ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GEODIFF: A GEOMETRIC DIFFUSION MODEL FOR MOLECULAR CONFORMATION GENERATION
2
+
3
+ Minkai $\mathbf { X } \mathbf { u } ^ { 1 , 2 }$ , Lantao $\mathbf { Y u ^ { 3 } }$ , Yang $\mathbf { S o n g ^ { 3 } }$ , Chence $\mathbf { S h i ^ { 1 , 2 } }$ , Stefano Ermon3∗, Jian Tang1,4,5∗
4
+
5
+ 1Mila - Québec AI Institute, Canada 2Université de Montréal, Canada
6
+ 3Stanford University, USA $^ { 4 } \mathrm { H E C }$ Montréal, Canada 5CIFAR AI Research Chair
7
+ {minkai.xu,chence.shi}@umontreal.ca
8
+ {lantaoyu,yangsong,ermon}@cs.stanford.edu
9
+ jian.tang@hec.ca
10
+
11
+ # ABSTRACT
12
+
13
+ Predicting molecular conformations from molecular graphs is a fundamental problem in cheminformatics and drug discovery. Recently, significant progress has been achieved with machine learning approaches, especially with deep generative models. Inspired by the diffusion process in classical non-equilibrium thermodynamics where heated particles will diffuse from original states to a noise distribution, in this paper, we propose a novel generative model named GEODIFF for molecular conformation prediction. GEODIFF treats each atom as a particle and learns to directly reverse the diffusion process (i.e., transforming from a noise distribution to stable conformations) as a Markov chain. Modeling such a generation process is however very challenging as the likelihood of conformations should be rototranslational invariant. We theoretically show that Markov chains evolving with equivariant Markov kernels can induce an invariant distribution by design, and further propose building blocks for the Markov kernels to preserve the desirable equivariance property. The whole framework can be efficiently trained in an end-toend fashion by optimizing a weighted variational lower bound to the (conditional) likelihood. Experiments on multiple benchmarks show that GEODIFF is superior or comparable to existing state-of-the-art approaches, especially on large molecules.1
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Graph representation learning has achieved huge success for molecule modeling in various tasks ranging from property prediction (Gilmer et al., 2017; Duvenaud et al., 2015) to molecule generation (Jin et al., 2018; Shi et al., 2020), where typically a molecule is represented as an atom-bond graph. Despite its effectiveness in various applications, a more intrinsic and informative representation for molecules is the 3D geometry, also known as conformation, where atoms are represented as their Cartesian coordinates. The 3D structures determine the biological and physical properties of molecules and hence play a key role in many applications such as computational drug and material design (Thomas et al., 2018; Gebauer et al., 2021; Jing et al., 2021; Batzner et al., 2021). Unfortunately, how to predict stable molecular conformation remains a challenging problem. Traditional methods based on molecular dynamics (MD) or Markov chain Monte Carlo (MCMC) are very computationally expensive, especially for large molecules (Hawkins, 2017).
18
+
19
+ Recently, significant progress has been made with machine learning approaches, especially with deep generative models. For example, Simm & Hernandez-Lobato (2020); Xu et al. (2021b) studied predicting atomic distances with variational autoencoders (VAEs) (Kingma & Welling, 2013) and flow-based models (Dinh et al., 2017) respectively. Shi et al. (2021) proposed to use denoising score matching (Song & Ermon, 2019; 2020) to estimate the gradient fields over atomic distances, through which the gradient fields over atomic coordinates can be calculated. Ganea et al. (2021) studied generating conformations by predicting both bond lengths and angles. As molecular conformations are roto-translational invariant, these approaches circumvent directly modeling atomic coordinates by leveraging intermediate geometric variables such as atomic distances, bond and torsion angles, which are roto-translational invariant. As a result, they are able to achieve very compelling performance. However, as all these approaches seek to indirectly model the intermediate geometric variables, they have inherent limitations in either training or inference process (see Sec. 2 for a detailed description). Therefore, an ideal solution would still be directly modeling the atomic coordinates and at the same time taking the roto-translational invariance property into account.
20
+
21
+ In this paper, we propose such a solution called GEODIFF, a principled probabilistic framework based on denoising diffusion models (Sohl-Dickstein et al., 2015). Our approach is inspired by the diffusion process in nonequilibrium thermodynamics (De Groot & Mazur, 2013). We view atoms as particles in a thermodynamic system, which gradually diffuse from the original states to a noisy distribution in contact with a heat bath. At each time step, stochastic noises are added to the atomic positions. Our high-level idea is learning to reverse the diffusion process, which recovers the target geometric distribution from the noisy distribution. In particular, inspired by recent progress of denoising diffusion models on image generation (Ho et al., 2020; Song et al., 2020), we view the noisy geometries at different timesteps as latent variables, and formulate both the forward diffusion and reverse denoising process as Markov chains. Our goal is to learn the transition kernels such that the reverse process can recover realistic conformations from the chaotic positions sampled from a noise distribution. However, extending existing methods to geometric generation is highly non-trivial: a direct application of diffusion models on the conformation generation task lead to poor generation quality. As mentioned above, molecular conformations are roto-translational invariant, i.e., the estimated (conditional) likelihood should be unaffected by translational and rotational transformations (Köhler et al., 2020). To this end, we first theoretically show that a Markov process starting from an roto-translational invariant prior distribution and evolving with roto-translational equivariant Markov kernels can induce an roto-translational invariant density function. We further provide practical parameterization to define a roto-translational invariant prior distribution and a Markov kernel imposing the equivariance constraints. In addition, we derive a weighted variational lower bound of the conditional likelihood of molecular conformations, which also enjoys the rototranslational invariance and can be efficiently optimized.
22
+
23
+ A unique strength of GEODIFF is that it directly acts on the atomic coordinates and entirely bypasses the usage of intermediate elements for both training and inference. This general formulation enjoys several crucial advantages. First, the model can be naturally trained end-to-end without involving any sophisticated techniques like bilevel programming (Xu et al., 2021b), which benefits from small optimization variances. Besides, instead of solving geometries from bond lengths or angles, the one-stage sampling fashion avoids accumulating any intermediate error, and therefore leads to more accurate predicted structures. Moreover, GEODIFF enjoys a high model capacity to approximate the complex distribution of conformations. Thus, the model can better estimate the highly multi-modal distribution and generate structures with high quality and diversity.
24
+
25
+ We conduct comprehensive experiments on multiple benchmarks, including conformation generation and property prediction tasks. Numerical results show that GEODIFF consistently outperforms existing state-of-the-art machine learning approaches, and by a large margin on the more challenging large molecules. The significantly superior performance demonstrate the high capacity to model the complex distribution of molecular conformations and generate both diverse and accurate molecules.
26
+
27
+ # 2 RELATED WORK
28
+
29
+ Recently, various deep generative models have been proposed for conformation generation. Among them, CVGAE (Mansimov et al., 2019) first proposed a VAE model to directly generate 3D atomic coordinates, which fails to preserve the roto-translation equivariance property of conformations and suffers from poor performance. To address this problem, the majority of subsequent models are based on intermediate geometric elements such as atomic distances and torsion angles. A favorable property of these elements is the roto-translational invariance, (e.g. atomic distances does not change when rotating the molecule), which has been shown to be an important inductive bias for molecular geometry modeling (Köhler et al., 2020). However, such a decomposition suffers from several drawbacks for either training or sampling. For example, GRAPHDG (Simm & HernandezLobato, 2020) and CGCF (Xu et al., 2021a) proposed to predict the interatomic distance matrix by VAE and Flow respectively, and then solve the geometry through the Distance Geometry (DG) technique (Liberti et al., 2014), which searches reasonable coordinates that matches with the predicted distances. CONFVAE further improves this pipeline by designing an end-to-end framework via bilevel optimization (Xu et al., 2021b). However, all these approaches suffer from the accumulated error problem, meaning that the noise in the predicted distances will misguide the coordinate searching process and lead to inaccurate or even erroneous structures. To overcome this problem, CONFGF (Shi et al., 2021; Luo et al., 2021) proposed to learn the gradient of the log-likelihood w.r.t coordinates. However, in practice the model is still aided by intermediate geometric elements, in that it first estimates the gradient w.r.t interatomic distances via denoising score matching (DSM) (Song & Ermon, 2019; 2020), and then derives the gradient of coordinates using the chain rule. The problem is, by learning the distance gradient via DSM, the model is fed with perturbed distance matrices, which may violate the triangular inequality or even contain negative values. As a consequence, the model is actually learned over invalid distance matrices but tested with valid ones calculated from coordinates, making it suffer from serious out-of-distribution (Hendrycks & Gimpel, 2016) problem. Most recently, another concurrent work (Ganea et al., 2021) proposed a highly systematic (rule-based) pipeline named GEOMOL, which learns to predict a minimal set of geometric quantities (i.e. length and angles) and then reconstruct the local and global structures of the conformation in a sophisticated procedure. Besides, there has also been efforts to use reinforcement learning for conformation search Gogineni et al. (2020). Nevertheless, this method relies on rigid rotor approximation and can only model the torsion angles, and thus fundamentally differs from other approaches.
30
+
31
+ # 3 PRELIMINARIES
32
+
33
+ # 3.1 NOTATIONS AND PROBLEM DEFINITION
34
+
35
+ Notations. In this paper each molecule with $n$ atoms is represented as an undirected graph $\mathcal { G } = \langle \nu , \mathcal { E } \rangle$ , where $\mathcal { V } = \{ v _ { i } \} _ { i = 1 } ^ { n }$ is the set of vertices representing atoms and $\mathcal { E } = \{ e _ { i j } \mid ( i , j ) \subseteq | \mathcal { V } | \times | \mathcal { V } | \}$ is the set of edges representing inter-atomic bonds. Each node $v _ { i } \in \mathcal V$ describes the atomic attributes, e.g., the element type. Each edge $e _ { i j } \in \mathcal { E }$ describes the corresponding connection between $v _ { i }$ and $v _ { j }$ , and is labeled with its chemical type. In addition, we also assign the unconnected edges with a virtual type. For the geometry, each atom in $\nu$ is embedded by a coordinate vector $\boldsymbol { c } \in \mathbb { R } ^ { 3 }$ into the 3-dimensional space, and the full set of positions (i.e., the conformation) can be represented as a matrix $\mathcal { C } = [ \pmb { c } _ { 1 } , \dot { \pmb { c } } _ { 2 } , \cdot \cdot \cdot , \pmb { c } _ { n } ] \in \mathbb { R } ^ { n \times 3 }$ .
36
+
37
+ Problem Definition. The task of molecular conformation generation is a conditional generative problem, where we are interested in generating stable conformations for a provided graph $\mathcal { G }$ . Given multiple graphs $\mathcal { G }$ , and for each $\mathcal { G }$ given its conformations $\mathcal { C }$ as i.i.d samples from an underlying Boltzmann distribution (Noé et al., 2019), our goal is learning a generative model $p _ { \theta } ( \mathcal { C } | \mathcal { G } )$ , which is easy to draw samples from, to approximate the Boltzmann function.
38
+
39
+ # 3.2 EQUIVARIANCE
40
+
41
+ Equivariance is ubiquitous in machine learning for atomic systems, e.g., the vectors of atomic dipoles or forces should rotate accordingly $w . r . t .$ the conformation coordinates (Thomas et al., 2018; Weiler et al., 2018; Fuchs et al., 2020; Miller et al., 2020; Simm et al., 2021; Batzner et al., 2021). It has shown effectiveness to integrate such inductive bias into model parameterization for modeling 3D geometry, which is critical for the generalization capacity (Köhler et al., 2020; Satorras et al., 2021a). Formally, a function $\mathcal { F } : \mathcal { X } \mathcal { Y }$ is equivariant $w . r . t$ a group $G$ if:
42
+
43
+ $$
44
+ \mathcal { F } \circ T _ { g } ( x ) = S _ { g } \circ \mathcal { F } ( x ) ,
45
+ $$
46
+
47
+ where $T _ { g }$ and $S _ { g }$ are transformations for an element $g \in G$ , acting on the vector spaces $\mathcal { X }$ and $\mathcal { V }$ , respectively. In this work, we consider the SE(3) group, i.e., the group of rotation, translation in 3D space. This requires the estimated likelihood unaffected with translational and rotational transformations, and we will elaborate on how our method satisfy this property in Sec. 4.
48
+
49
+ # 4 GEODIFF METHOD
50
+
51
+ In this section, we elaborate on the proposed equivariant diffusion framework. We first present a high level description of our 3D diffusion formulation in Sec. 4.1, based on recent progress of denoising diffusion models (Sohl-Dickstein et al., 2015; Ho et al., 2020). Then we emphasize several
52
+
53
+ $$
54
+ \textcircled { c ^ { T } } \underset { \sharp \ell \ell } { \longrightarrow } \cdots \longrightarrow \big ( \underset { \sharp ( C ^ { t } ) \subset \ell ^ { \prime } } { \widehat { C ^ { t } } } \big ) \underset { \sharp ( C ^ { t - 1 } ) \sharp ( C ^ { t } ) } { \longrightarrow } \big ( \underset { \sharp ( C ^ { t } ) \sharp ( C ^ { t } ) } { \longrightarrow } \big ) \underset { \sharp ( C ^ { t } ) \sharp ( C ^ { t } ) } { \longrightarrow } \big ( \underset { \sharp ( C ^ { t } ) \sharp ( C ^ { t } ) } { \longrightarrow } \big )
55
+ $$
56
+
57
+ Figure 1: Illustration of the diffusion and reverse process of GEODIFF. For diffusion process, noise from fixed posterior distributions $q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { t - 1 } )$ is gradually added until the conformation is destroyed. Symmetrically, for generative process, an initial state $\hat { \mathcal { C } ^ { T } }$ is sampled from standard Gaussian distribution, and the conformation is progressively refined via the Markov kernels $p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } )$ .
58
+
59
+ non-trivial challenges of building diffusion models for geometry generation scenario, and show how we technically tackle these issues. Specifically, in Sec. 4.2, we present how we parameterize $p _ { \theta } ( \mathcal { C } | \mathcal { G } )$ so that the conditional likelihood is roto-translational invariant, and in Sec. 4.3, we introduce our surgery of the training objective to make the optimization also invariant of translation and rotation. Finally, we briefly show how to draw samples from our model in Sec. 4.4.
60
+
61
+ # 4.1 FORMULATION
62
+
63
+ Let $\mathcal { C } ^ { 0 }$ denotes the ground truth conformations and let $\mathcal { C } ^ { t }$ for $t = 1 , \cdots , T$ be a sequence of latent variables with the same dimension, where $t$ is the index for diffusion steps. Then a diffusion probabilistic model (Sohl-Dickstein et al., 2015) can be described as a latent variable model with two processes: the forward diffusion process, and the reverse generative process. Intuitively, the diffusion process progressively injects small noises to the data $\mathcal { C } ^ { 0 }$ , while the generative process learns to revert the diffusion process by gradually eliminating the noise to recover the ground truth. We provide a high-level schematic of the processes in Fig. 1.
64
+
65
+ Diffusion process. Following the physical insight, we model the particles $\mathcal { C }$ as an evolving thermodynamic system. With time going by, the equilibrium conformation $\mathcal { C } ^ { 0 }$ will gradually diffuse to the next chaotic states $\mathcal { C } ^ { t }$ , and finally converge into a white noise distribution after $T$ iterations. Different from typical latent variable models, in diffusion model this forward process is defined as a fixed (rather than trainable) posterior distribution $q ( \mathcal { C } ^ { 1 : T } | \mathcal { C } ^ { 0 } )$ . Specifically, we define it as a Markov chain according to a fixed variance schedule $\beta _ { 1 } , \ldots , \beta _ { T }$ :
66
+
67
+ $$
68
+ q ( \mathcal { C } ^ { 1 : T } | \mathcal { C } ^ { 0 } ) = \prod _ { t = 1 } ^ { T } q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { t - 1 } ) , \quad q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { t - 1 } ) = \mathcal { N } ( \mathcal { C } ^ { t } ; \sqrt { 1 - \beta _ { t } } \mathcal { C } ^ { t - 1 } , \beta _ { t } I ) .
69
+ $$
70
+
71
+ Note that, in this work we do not impose specific (invariance) requirement upon the diffusion process, as long as it can efficiently draw noisy samples for training the generative process $p _ { \theta } ( \mathcal { C } ^ { 0 } )$ .
72
+
73
+ Let $\alpha _ { t } = 1 - \beta _ { t }$ and $\begin{array} { r } { \bar { \alpha } _ { t } = \prod _ { s = 1 } ^ { t } \alpha _ { s } } \end{array}$ , a special property of the forward process is that √ $q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { 0 } )$ of arbitrary timestep $t$ can be calculated in closed form $q ( \mathcal { C } ^ { t } \vert \mathcal { C } ^ { 0 } ) = \mathcal { N } ( \mathcal { C } ^ { t } ; \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { t } ) I ) ^ { 2 }$ . This indicates with sufficiently large $T$ , the whole forward process will convert $\mathcal { C } ^ { 0 }$ to whitened isotropic Gaussian, and thus it is natural to set $p ( \mathcal { C } ^ { T } )$ as a standard Gaussian distribution.
74
+
75
+ Reverse Process. Our goal is learning to recover conformations $\mathcal { C } ^ { 0 }$ from the white noise $\mathcal { C } ^ { T }$ , given specified molecular graphs $\mathcal { G }$ . We consider this generative procedure as a reverse dynamics of the above diffusion process, starting from the noisy particles $\dot { \mathcal { C } } ^ { T } \sim p ( \mathcal { C } ^ { T } )$ . We formulate this reverse dynamics as a conditional Markov chain with learnable transitions:
76
+
77
+ $$
78
+ p _ { \theta } ( \mathcal { C } ^ { 0 : T - 1 } | \mathcal { G } , \mathcal { C } ^ { T } ) = \prod _ { t = 1 } ^ { T } p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } ) , \quad p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } ) = \mathcal { N } ( \mathcal { C } ^ { t - 1 } ; \mu _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t ) , \sigma _ { t } ^ { 2 } I ) .
79
+ $$
80
+
81
+ Herein $\mu _ { \theta }$ are parameterized neural networks to estimate the means, and $\sigma _ { t }$ can be any user-defined variance. The initial distribution $p ( \mathcal { C } ^ { T } )$ is set as a standard Gaussian. Given a graph $\mathcal { G }$ , its 3D structure is generated by first drawing chaotic particles $\mathcal { C } ^ { T }$ from $p ( \mathcal { C } ^ { T } )$ , and then iteratively refined through the reverse Markov kernels $p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } )$ .
82
+
83
+ Having formulated the reverse dynamics, the marginal likelihood can be calculated by $p _ { \theta } ( \mathcal { C } ^ { 0 } | \mathcal { G } ) =$ $\begin{array} { r } { \int p ( \mathcal { C } ^ { T } ) p _ { \theta } ( \mathcal { C } ^ { 0 : T - 1 } | \mathcal { G } , \mathcal { C } ^ { T } ) \mathrm { d } \mathcal { C } ^ { 1 : T } } \end{array}$ . Herein a non-trivial problem is that the likelihood should be invariant $w . r . t$ translation and rotation, which has proved to be a critical inductive bias for 3D object generation (Köhler et al., 2020; Satorras et al., 2021a). In the following subsections, we will elaborate on how we parameterize the Markov kernels $p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } )$ to achieve this desired property, and also how to maximize this likelihood by taking the invariance into account.
84
+
85
+ # 4.2 EQUIVARIANT REVERSE GENERATIVE PROCESS
86
+
87
+ Instead of directly leveraging existing methods, we consider building the density $p _ { \theta } ( \mathcal { C } ^ { 0 } )$ that is invariant to rotation and translation transformations. Intuitively, this requires the likelihood to be unaffected by translations and rotations. Formally, let $T _ { g }$ be some roto-translational transformations of a group element $g \in { \mathrm { S E } } ( 3 )$ , then we have the following statement:
88
+
89
+ Proposition 1. Let $p ( x _ { T } )$ be an $S E ( 3 )$ -invariant density function, i.e., $p ( x _ { T } ) \ : = \ : p ( T _ { g } ( x _ { T } ) )$ . If Markov transitions $p ( x _ { t - 1 } | x _ { t } )$ are $S E ( 3 )$ -equivariant, i.e., $p ( x _ { t - 1 } | x _ { t } ) = p ( T _ { g } ( x _ { t - 1 } ) | \bar { T } _ { g } \bar { ( x _ { t } ) } ) ,$ , then we have that the density $\begin{array} { r } { p _ { \theta } ( x _ { 0 } ) = \int p ( x _ { T } ) p _ { \theta } ( x _ { 0 : T - 1 } | x _ { T } ) \mathrm { d } x _ { 1 : T } } \end{array}$ is also $S E ( 3 )$ -invariant.
90
+
91
+ This proposition indicates that the dynamics starting from an invariant standard density along an equivariant Gaussian Markov kernel can result in an invariant density. Now we provide a practical implementation of GEODIFF based on the recent denoising diffusion framework (Ho et al., 2020).
92
+
93
+ Invariant Initial Density $p ( \mathcal { C } ^ { T } )$ . We first introduce the invariant distribution $p ( \mathcal { C } ^ { T } )$ , which will also be employed in the equivariant Markov chain. We borrow the idea from Köhler et al. (2020) to consider systems with zero center of mass $\mathbf { \Gamma } ( { \bf C o M } )$ , termed CoM-free systems. We define $p ( \mathcal { C } ^ { T } )$ as a “CoM-free standard density” $\hat { \rho } ( \mathcal { C } )$ , built upon an isotropic normal density $\rho ( \mathcal { C } )$ : for evaluating the likelihood $\hat { \rho } ( \mathcal { C } )$ we can firstly translate $\mathcal { C }$ to zero CoM and then calculate $\rho ( \mathcal { C } )$ , and for sampling from $\hat { \rho } ( \mathcal { C } )$ we can first sample from $\rho ( \mathcal { C } )$ and then move the CoM to zero.
94
+
95
+ We provide a formal theoretical analysis of $\hat { \rho } ( \mathcal { C } )$ in Appendix A. Intuitively, the isotropic Gaussian is manifestly invariant to rotations around the zero CoM. And by considering CoM-free system, moving the particles to zero CoM can always ensure the translational invariance. Consequently, $\hat { \rho } ( \mathcal { C } )$ is constructed as a roto-transitional invariant density.
96
+
97
+ Equivariant Markov Kernels $p ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } )$ . Similar to the prior density, we also consider equipping all intermediate structures $\mathcal { C } ^ { t }$ as CoM-free systems. Specifically, given mean $\mu _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t )$ and variance $\sigma _ { t }$ , the likelihood of $\mathcal { C } ^ { t - 1 }$ will be calculated by $\hat { \rho } \big ( \frac { \mathcal { C } ^ { t - 1 } - \mu _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t ) } { \sigma _ { t } } \big )$ 1−µθ(G,Ct,t) ). The CoM-free Gaussian ensures the translation invariance in the Markov kernels. Consequently, to achieve the equivariant property defined in Proposition 1, we focus on the rotation equivariance.
98
+
99
+ Then in general, the key requirement is to ensure the means $\mu _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t )$ to be roto-translation equivariant $w . r . t \mathcal { C } ^ { t }$ . Following Ho et al. (2020), we consider the following parameterization of $\mu _ { \theta }$ :
100
+
101
+ $$
102
+ \mu _ { \theta } ( \mathcal { C } ^ { t } , t ) = \frac { 1 } { \sqrt { \alpha _ { t } } } \left( \mathcal { C } ^ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \bar { \alpha } _ { t } } } \epsilon _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t ) \right) ,
103
+ $$
104
+
105
+ where $\epsilon _ { \theta }$ are neural networks with trainable parameters $\theta$ . Intuitively, the model $\epsilon _ { \theta }$ learns to predict the noise necessary to decorrupt the conformations. This is analogous to the physical force fields (Schütt et al., 2017; Zhang et al., 2018; Hu et al., 2021; Shuaibi et al., 2021), which also gradually push particles towards convergence around the equilibrium states.
106
+
107
+ Now the problem is transformed to constructing $\epsilon _ { \theta }$ to be roto-translational equivariant. We draw inspirations from recent equivariant networks (Thomas et al., 2018; Satorras et al., 2021b) to design an equivariant convolutional layer, named graph field network (GFN). In the $l$ -th layer, GFN takes node embeddings $\mathbf { h } ^ { l } \in \mathbb { R } ^ { n \times b }$ ( $b$ denotes the feature dimension) and corresponding coordinate embeddings $\mathbf { x } ^ { l } \in \mathbb { R } ^ { n \times \overline { { 3 } } }$ as inputs, and outputs $\mathbf { h } ^ { l + 1 }$ and $\mathbf { x } ^ { l + 1 }$ as follows:
108
+
109
+ $$
110
+ \begin{array} { l } { { \displaystyle { { \bf { m } } _ { i j } } = \Phi _ { m } \left( { \bf { h } } _ { i } ^ { l } , { \bf { h } } _ { j } ^ { l } , \| { \bf { x } } _ { i } ^ { l } - { \bf { x } } _ { j } ^ { l } \| ^ { 2 } , e _ { i j } ; \theta _ { m } \right) } } \\ { { \displaystyle { { \bf { h } } } _ { i } ^ { l + 1 } = \Phi _ { h } \Big ( { \bf { h } } _ { i } ^ { l } , \sum _ { j \in \mathcal { N } ( i ) } { \bf { m } } _ { i j } ; \theta _ { h } \Big ) } } \\ { { \displaystyle { \bf { x } } _ { i } ^ { l + 1 } = \sum _ { j \in \mathcal { N } ( i ) } \frac { 1 } { d _ { i j } } \left( { \bf { c } } _ { i } - { \bf { c } } _ { j } \right) \Phi _ { x } \left( { \bf { m } } _ { i j } ; \theta _ { x } \right) } } \end{array}
111
+ $$
112
+
113
+ where $\Phi$ are feed-forward networks and $d _ { i j }$ denotes interatomic distances. $\mathcal { N } ( i )$ denotes the neighborhood of $i ^ { t h }$ node, including both connected atoms and other ones within a radius threshold $\tau$ , which enables the model to explicitly capture long-range interactions and support molecular graphs with disconnected components. Initial embeddings $\mathbf { h } ^ { 0 }$ are combinations of atom and timestep embeddings, and $\mathbf { x } ^ { 0 }$ are atomic coordinates. The main difference between proposed GFN and other GNNs lies in equation 7, where $\mathbf { x }$ is updated as a combination of radial directions weighted by $\Phi _ { x } : \mathbb { R } ^ { b } \mathbb { R }$ . Such vector field $\mathbf { x } ^ { L }$ enjoys the roto-translation equivariance property. Formally, we have:
114
+
115
+ Proposition 2. Parameterizing $\epsilon _ { \theta } ( \mathcal { G } , \mathcal { C } , t )$ as a composition of $L$ GFN layers, and take the $\mathbf { x } ^ { L }$ after $L$ updates as the output. Then the noise vector field $\epsilon _ { \theta }$ is $S E ( 3 )$ equivariant w.r.t the $3 D$ system $\mathcal { C }$ .
116
+
117
+ Intuitively, given $\mathbf { h } ^ { l }$ already invariant and $\mathbf { x } ^ { l }$ equivariant, the message embedding m will also be invariant since it only depends on invariant features. Since $\mathbf { x }$ is updated with the relative differences $\mathbf { c } _ { i } - \mathbf { c } _ { j }$ weighted by invariant features, it will be translation-invariant and rotation-equivariant. Then inductively, composing $\epsilon _ { \theta }$ with $L$ GFN layers enables equivariance with $\mathcal { C } ^ { t }$ . We provide the formal proof of equivariance properties in Appendix A.
118
+
119
+ # 4.3 IMPROVED TRAINING OBJECTIVE
120
+
121
+ Having formulated the generative process and the model parameterization, now we consider the practical training objective for the reverse dynamics. Since directly optimizing the exact log-likelihood is intractable, we instead maximize the usual variational lower bound $( { \mathrm { E L B O } } ) ^ { 3 }$ :
122
+
123
+ $$
124
+ \begin{array} { r l } & { \mathbb { E } \left[ \log p _ { \theta } ( \mathcal { C } ^ { 0 } | \mathcal { G } ) \right] = \mathbb { E } \left[ \log \mathbb { E } _ { q ( \mathcal { C } ^ { 1 : T } | \mathcal { C } ^ { 0 } ) } \frac { p _ { \theta } ( \mathcal { C } ^ { 0 : T } | \mathcal { G } ) } { q ( \mathcal { C } ^ { 1 : T } | \mathcal { C } ^ { 0 } ) } \right] } \\ & { \qquad \geq - \mathbb { E } _ { q } \left[ \displaystyle \sum _ { t = 1 } ^ { T } D _ { \mathrm { K L } } ( q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } ) \| p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { G } ) ) \right] : = - \mathcal { L } _ { \mathrm { E L B O } } } \end{array}
125
+ $$
126
+
127
+ where $q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } )$ is analytically tractable as $\begin{array} { r } { \mathcal { N } ( \frac { \sqrt { \bar { \alpha } _ { t - 1 } } \beta _ { t } } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \frac { \sqrt { \alpha _ { t } } ( 1 - \bar { \alpha } _ { t - 1 } ) } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { t } , \frac { 1 - \bar { \alpha } _ { t - 1 } } { 1 - \bar { \alpha } _ { t } } \beta _ { t } ) ^ { 3 } . } \end{array}$ Most recently, Ho et al. (2020) showed that under the parameterization in equation 4, the ELBO of the diffusion model can be further simplified by calculating the KL divergences between Gaussians as weighted $\mathcal { L } _ { 2 }$ distances between the means $\epsilon _ { \theta }$ and $\epsilon ^ { 3 }$ . Formally, we have:
128
+
129
+ Proposition 3. (Ho et al., 2020) Under the parameterization in equation 4, we have:
130
+
131
+ $$
132
+ \mathcal { L } _ { \mathrm { E L B O } } = \sum _ { t = 1 } ^ { T } \gamma _ { t } \mathbb { E } _ { \{ \mathcal { C } ^ { 0 } , \mathcal { G } \} \sim q ( \mathcal { C } ^ { 0 } , \mathcal { G } ) , \epsilon \sim \mathcal { N } ( 0 , I ) } \left[ \| \epsilon - \epsilon _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t ) \| _ { 2 } ^ { 2 } \right]
133
+ $$
134
+
135
+ $\mathcal { C } ^ { t } = \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ . The weights $\begin{array} { r } { \gamma _ { t } = \frac { \beta _ { t } } { 2 \alpha _ { t } \left( 1 - \bar { \alpha } _ { t - 1 } \right) } } \end{array}$ for $t > 1$ , and $\begin{array} { r } { \gamma _ { 1 } = \frac { 1 } { 2 \alpha _ { 1 } } } \end{array}$
136
+
137
+ The intuition of this objective is to independently sample chaotic conformations of different timesteps from $q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } )$ , and use $\epsilon _ { \theta }$ to model the noise vector $\epsilon$ . To yield a better empirical performance, Ho et al. (2020) suggests to set all weights $\gamma _ { t }$ as 1, which is in line with the the objectives of recent noise conditional score networks (Song & Ermon, 2019; 2020).
138
+
139
+ As $\epsilon _ { \theta }$ is designed to be equivariant, it is natural to require its supervision signal $\epsilon$ to be equivariant with $\mathcal { C } ^ { t }$ . Note that once this is achieved, the ELBO will also become invariant. However, the $\epsilon$ in the forward diffusion process is not imposed with such equivariance, violating the above properties. Here we propose two approaches to obtain the modified noise vector $\hat { \epsilon }$ , which, after replacing $\epsilon$ in the $\mathcal { L } _ { 2 }$ distance calculation in equation 9, achieves the desired equivariance:
140
+
141
+ Alignment approach. Considering the fact that $\epsilon$ can be calculated by $\frac { \mathcal { C } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } } { \sqrt { 1 - \bar { \alpha } _ { t } } }$ , we can first rotate and translate $\mathcal { C } ^ { 0 }$ to ${ \hat { \mathcal { C } } } ^ { 0 }$ by aligning $w . r . t \ C ^ { t }$ , and then compute $\hat { \epsilon }$ as $\frac { \mathcal { C } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \hat { \mathcal { C } } ^ { 0 } } { \sqrt { 1 - \bar { \alpha } _ { t } } }$ Since the aligned conformation ${ \hat { \mathcal { C } } } ^ { 0 }$ is equivariant with $\mathcal { C } ^ { t }$ , the processed $\hat { \epsilon }$ will also enjoy the equivariance. Specifically, the alignment is implemented by first translating $\mathcal { C } ^ { 0 }$ to the same CoM of $\mathcal { C } ^ { t }$ and then solve the optimal rotation matrix by Kabsch alignment algorithm (Kabsch, 1976).
142
+
143
+ Chain-rule approach. Another meaningful observation is that by reparameterizing the Gaussian√ √ distribution √ $q \bar { ( \mathcal { C } ^ { t } \vert \mathcal { C } ^ { 0 } ) }$ as $\mathcal { C } ^ { t } = \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ , $\epsilon$ can be viewed as a weighted score function $\sqrt { 1 - \bar { \alpha } _ { t } } \nabla \bar { c t ~ q } ( \dot { C ^ { t } } | \mathcal { C } ^ { \dot { 0 } } )$ . Shi et al. (2021) recently shows that generally this score function $\nabla c ^ { t } q ( \mathcal { C } ^ { t } | \cdot )$ can be designed to be equivariant by decomposing it into $\partial _ { { \mathcal { C } } ^ { t } } \bar { \mathbf { d } } ^ { t } { \nabla } _ { \mathbf { d } ^ { t } } g ( { \mathcal { C } } ^ { t } | \cdot )$ with the chain rule, where $\mathbf { d } ^ { t }$ can be any invariant features of the structures $\mathcal { C } ^ { t }$ such as the inter-atomic distances. We refer readers to Shi et al. (2021) for more details. The insight is that as gradient of invariant variables $w . r . t$ equivariant variables, the partial derivative $\partial _ { C ^ { t } } \mathbf { d } ^ { t }$ will always be equivalent with $\mathcal { C } ^ { t }$ . In this work, under the common assumption that $\mathbf { d }$ also follows a Gaussian distribution (Kingma & Welling, 2013), our practical implementation is to first approximately calculate $\nabla _ { \mathbf { d } ^ { t } } q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { 0 } )$ as $\frac { \mathbf { d } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \mathbf { d } ^ { 0 } } { 1 - \bar { \alpha } _ { t } }$ , and then compute the modified noise vector ˆ as √1 − α¯t ∂Ct dt( dt− α¯td01−α¯ ) $\begin{array} { r } { \sqrt { 1 - \bar { \alpha } _ { t } } \partial _ { \mathcal { C } ^ { t } } \mathbf { d } ^ { t } ( \frac { \mathbf { d } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \mathbf { d } ^ { 0 } } { 1 - \bar { \alpha } _ { t } } ) = \frac { \partial _ { \mathcal { C } ^ { t } } \mathbf { d } ^ { t } \cdot ( \mathbf { d } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \mathbf { d } ^ { 0 } ) } { \sqrt { 1 - \bar { \alpha } _ { t } } } } \end{array}$
144
+
145
+ # 4.4 SAMPLING
146
+
147
+ With a learned reverse dynamics $\epsilon _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t )$ , the transition means $\mu _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t } , t )$ can be calculated by equation 4. Thus, given a graph $\mathcal { G }$ , its geometry $\mathcal { C } ^ { 0 }$ is generated by first sampling chaotic particles $\begin{array} { r } { \mathcal { C } ^ { T } \sim p ( \breve { \mathcal { C } } ^ { T } ) } \end{array}$ , and then progressively sample Ct−1 $\dot { p } _ { \theta } ( \check { \mathcal { C } } ^ { t - 1 } | \mathcal { G } , \dot { \mathcal { C } } ^ { t } )$ for $t = T , T -$ $1 , \cdots , 1$ . This process is Markovian, which gradually shifts the previous noisy positions towards
148
+
149
+ # Algorithm 1 Sampling Algorithm of GEODIFF.
150
+
151
+ Input: the molecular graph $\mathcal { G }$ , the learned reverse model $\epsilon _ { \theta }$ . Output: the molecular conformation $\mathcal { C }$ .
152
+ 1: Sample $\mathcal { C } ^ { T } \sim p ( \mathcal { C } ^ { T } ) = \mathcal { N } ( 0 , I )$
153
+ 2: for $s = T , T - 1 , \cdots , 1$ do
154
+ 3: Shift $\mathcal { C } ^ { s }$ to zero CoM
155
+ 4: Compute $\mu _ { \theta } ( \mathcal { C } ^ { s } , \mathcal { G } , s )$ from $\epsilon _ { \theta } ( \mathcal { C } ^ { s } , \mathcal { G } , s )$ using equation 4 5: Sample $\mathscr { C } ^ { s - 1 } \sim \mathcal { N } ( \mathscr { C } ^ { s - 1 } ; \mu _ { \theta } ( \mathscr { C } ^ { s } , \mathscr { G } , s ) , \sigma _ { t } ^ { 2 } I )$
156
+ 6: end for
157
+ 7: return $\mathcal { C } ^ { 0 }$ as $\mathcal { C }$
158
+
159
+ equilibrium states. We provide the pseudo code of the whole sampling process in Algorithm 1.
160
+
161
+ # 5 EXPERIMENT
162
+
163
+ In this section, we empirically evaluate GEODIFF on the task of equilibrium conformation generation for both small and drug-like molecules. Following existing work (Shi et al., 2021; Ganea et al., 2021), we test the proposed method as well as the competitive baselines on two standard benchmarks: Conformation Generation (Sec. 5.2) and Property Prediction (Sec. 5.3). We first present the general experiment setups, and then describe task-specific evaluation protocols and discuss the results in each section. The implementation details are provided in Appendix C.
164
+
165
+ # 5.1 EXPERIMENT SETUP
166
+
167
+ Datasets. Following prior works (Xu et al., 2021a;b), we also use the recent GEOM-QM9 (Ramakrishnan et al., 2014) and GEOM-Drugs (Axelrod & Gomez-Bombarelli, 2020) datasets. The former one contains small molecules while the latter one are medium-sized organic compounds. We borrow the data split produced by Shi et al. (2021). For both datasets, the training split consists of 40, 000 molecules with 5 conformations for each, resulting in 200, 000 conformations in total. The valid split share the same size as training split. The test split contains 200 distinct molecules, with 22, 408 conformations for QM9 and 14, 324 ones for Drugs.
168
+
169
+ Baselines. We compare GEODIFF with 6 recent or established state-of-the-art baselines. For the ML approaches, we test the following models with highest reported performance: CVGAE (Mansimov et al., 2019), GRAPHDG (Simm & Hernandez-Lobato, 2020), CGCF (Xu et al., 2021a), CONFVAE (Xu et al., 2021b) and CONFGF (Shi et al., 2021). We also test the classic RDKIT (Riniker & Landrum, 2015) method, which is arguably the most popular open-source software for conformation generation. We refer readers to Sec. 2 for a detailed discussion of these models.
170
+
171
+ # 5.2 CONFORMATION GENERATION
172
+
173
+ Evaluation metrics. The task aims to measure both quality and diversity of generated conformations by different models. We follow Ganea et al. (2021) to evaluate 4 metrics built upon root-mean-square deviation (RMSD), which is defined as the normalized Frobenius norm of two atomic coordinates matrices, after alignment by Kabsch algorithm (Kabsch, 1976). Formally, let $S _ { g }$ and $S _ { r }$ denote the sets of generated and reference conformers respectively, then the Coverage and Matching metrics $\mathrm { { X u } }$ et al., 2021a) following the conventional Recall measurement can be defined as:
174
+
175
+ Table 1: Results on the GEOM-Drugs dataset, without FF optimization.
176
+
177
+ <table><tr><td></td><td colspan="2">COV-R (%) ↑</td><td colspan="2">MAT-R (A)↓</td><td colspan="2">COV-P (%) ↑</td><td colspan="2">MAT-P (A)↓</td></tr><tr><td>Models</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td></tr><tr><td>CVGAE</td><td>0.00</td><td>0.00</td><td>3.0702</td><td>2.9937</td><td>-</td><td>=</td><td>=</td><td>-</td></tr><tr><td>GRAPHDG</td><td>8.27</td><td>0.00</td><td>1.9722</td><td>1.9845</td><td>2.08</td><td>0.00</td><td>2.4340</td><td>2.4100</td></tr><tr><td>CGCF</td><td>53.96</td><td>57.06</td><td>1.2487</td><td>1.2247</td><td>21.68</td><td>13.72</td><td>1.8571</td><td>1.8066</td></tr><tr><td>CONFVAE</td><td>55.20</td><td>59.43</td><td>1.2380</td><td>1.1417</td><td>22.96</td><td>14.05</td><td>1.8287</td><td>1.8159</td></tr><tr><td>GEOMOL</td><td>67.16</td><td>71.71</td><td>1.0875</td><td>1.0586</td><td>1</td><td></td><td>=</td><td>=</td></tr><tr><td>CONFGF</td><td>62.15</td><td>70.93</td><td>1.1629</td><td>1.1596</td><td>23.42</td><td>15.52</td><td>1.7219</td><td>1.6863</td></tr><tr><td>GEODIFF-A</td><td>88.36</td><td>96.09</td><td>0.8704</td><td>0.8628</td><td>60.14</td><td>61.25</td><td>1.1864</td><td>1.1391</td></tr><tr><td>GEODIFF-C</td><td>89.13</td><td>97.88</td><td>0.8629</td><td>0.8529</td><td>61.47</td><td>64.55</td><td>1.1712</td><td>1.1232</td></tr></table>
178
+
179
+ \* The COV-R and MAT-R results of CVGAE, GRAPHDG, CGCF, and CONFGF are borrowed from Shi et al. (2021). The results of GEOMOL are borrowed from a most recent study Zhu et al. (2022). Other results are obtained by our own experiments. The results of all models for the GEOM-QM9 dataset (summarized in Tab. 5) are collected in the same way.
180
+
181
+ $$
182
+ \begin{array} { r l } & { \mathrm { C O V - R } ( S _ { g } , S _ { r } ) = \displaystyle \frac { 1 } { | S _ { r } | } \Big | \Big \{ \boldsymbol { \mathcal { C } } \in S _ { r } | \mathrm { R M S D } ( \boldsymbol { \mathcal { C } } , \boldsymbol { \hat { \mathcal { C } } } ) \leq \delta , \boldsymbol { \hat { \mathcal { C } } } \in S _ { g } \Big \} \Big | , } \\ & { \mathrm { M A T - R } ( S _ { g } , S _ { r } ) = \displaystyle \frac { 1 } { | S _ { r } | } \sum _ { \boldsymbol { \mathcal { C } } \in S _ { r } } \operatorname* { m i n } _ { \boldsymbol { \hat { \mathcal { C } } } \in S _ { g } } \mathrm { R M S D } ( \boldsymbol { \mathcal { C } } , \boldsymbol { \hat { \mathcal { C } } } ) , } \end{array}
183
+ $$
184
+
185
+ where $\delta$ is a pre-defined threshold. The other two metrics COV-P and MAT-P inspired by Precision can be defined similarly but with the generated and reference sets exchanged. In practice, $S _ { g }$ is set as twice of the size of $S _ { r }$ for each molecule. Intuitively, the COV scores measure the percentage of structures in one set covered by another set, where covering means the RMSD between two conformations is within a certain threshold $\delta$ . By contrast, the MAT scores measure the average RMSD of conformers in one set with its closest neighbor in another set. In general, higher COV rates or lower MAT score suggest that more realistic conformations are generated. Besides, the Precision metrics depend more on the quality, while the Recall metrics concentrate more on the diversity. Either metrics can be more appealing considering the specific scenario. Following previous works ( $\mathrm { X u }$ et al., 2021a; Ganea et al., 2021), $\delta$ is set as $0 . { 5 \bar { \mathrm { A } } }$ and $\mathrm { \dot { 1 . 2 5 \AA } }$ for QM9 and Drugs datasets respectively.
186
+
187
+ Results & discussion. The results are summarized in Tab. 1 and Tab. 5 (left in Appendix. D). As noted in Sec. 4.3, GEODIFF can be trained with two types of modified ELBO, named alignment and chain-rule approaches. We denote models learned by these two objectives as GEODIFF-A and GEODIFF-C respectively. As shown in the tables, GEODIFF consistently outperform the state-of-theart ML models on all datasets and metrics, especially by a significant margin for more challenging large molecules (Drugs dataset). The results demonstrate the superior capacity of GEODIFF to model the multi modal distribution, and generative both accurate and diverse conformations. We also notice that in general GEODIFF-C performs slightly better than GEODIFF-A, which suggests that chain-rule approach leads to a better optimization procedure. We thus take GEODIFF-C as the representative in the following comparisons. We visualize samples generated by different models in Fig. 2 to provide a qualitative comparison, where GEODIFF is shown to capture better both local and global structures.
188
+
189
+ On the more challenging Drugs dataset, we further test RDKIT. As shown in Tab. 2, our observation is in line with previous studies (Shi et al., 2021) that the state-of-the-art ML models (shown in Tab. 1) perform better on COV-R and MAT-R. However, for the new Precision-based metrics we found that ML models are still not comparable. This indicates that ML models tend to explore more possible representatives while RDKIT concentrates on a few most common ones, prioritizes quality over diversity. Previous works (Mansimov et al., 2019; Xu et al., 2021b) suggest that this is because RDKIT involves an additional empirical force field (FF) (Halgren, 1996) to optimize the structure, and we follow them to also combine GEODIFF with FF to yield a more fair comparison. Results in
190
+
191
+ ![](images/9b2807b7167597f7ee0fcf5c5c30a670a193c79bc2184d32ef62c3f4b18387ee.jpg)
192
+ Figure 2: Examples of generated structures from Drugs dataset. For every model, we show the conformation best-aligned with the ground truth. More examples are provided in Appendix E.
193
+
194
+ Table 2: Results on the GEOM-Drugs dataset, with FF optimization.
195
+
196
+ <table><tr><td>Models</td><td colspan="2">COV-R (%) ↑</td><td colspan="2">MAT-R (A)</td><td colspan="2">COV-P (%) ↑</td><td colspan="2">MAT-P(A)↓</td></tr><tr><td></td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td></tr><tr><td>RDKIT</td><td>60.91</td><td>65.70</td><td>1.2026</td><td>1.1252</td><td>72.22</td><td>88.72</td><td>1.0976</td><td>0.9539</td></tr><tr><td>GEODIFF + FF</td><td>92.27</td><td>100.00</td><td>0.7618</td><td>0.7340</td><td>84.51</td><td>95.86</td><td>0.9834</td><td>0.9221</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
197
+
198
+ Tab. 2 demonstrate that GEODIFF $+ \mathrm { F F }$ can keep the superior diversity (Recall metrics) while also enjoy significantly improved accuracy ((Precision metrics)).
199
+
200
+ # 5.3 PROPERTY PREDICTION
201
+
202
+ Evaluation metrics. This task estimates the molecular ensemble properties (Axelrod & Gomez-Bombarelli, 2020) over a set of generated conformations. This can provide an direct assessment on the quality of generated samples. In specific, we follow Shi et al. (2021) to extract a split from GEOM-QM9 covering 30 molecules, and generate 50 samples for each. Then we use
203
+
204
+ Table 3: MAE of predicted ensemble properties in eV.
205
+
206
+ <table><tr><td>Method</td><td>E</td><td>Emin</td><td>A</td><td>△emin</td><td>△emax</td></tr><tr><td>RDKIT</td><td>0.9233</td><td>0.6585</td><td>0.3698</td><td>0.8021</td><td>0.2359</td></tr><tr><td>GRAPHDG</td><td>9.1027</td><td>0.8882</td><td>1.7973</td><td>4.1743</td><td>0.4776</td></tr><tr><td>CGCF</td><td>28.9661</td><td>2.8410</td><td>2.8356</td><td>10.6361</td><td>0.5954</td></tr><tr><td>CONFVAE</td><td>8.2080</td><td>0.6100</td><td>1.6080</td><td>3.9111</td><td>0.2429</td></tr><tr><td>CONFGF</td><td>2.7886</td><td>0.1765</td><td>0.4688</td><td>2.1843</td><td>0.1433</td></tr><tr><td>GEODIFF</td><td>0.25974</td><td>0.1551</td><td>0.3091</td><td>0.7033</td><td>0.1909</td></tr></table>
207
+
208
+ the chemical toolkit PSI4 (Smith et al., 2020) to calculate each conformer’s energy $E$ and HOMOLUMO gap $\epsilon$ , and compare the average energy $\overline { E }$ , lowest energy $E _ { \mathrm { m i n } }$ , average gap $\overline { { \Delta \epsilon } }$ , minimum gap $\Delta \epsilon _ { \mathrm { m i n } }$ , and maximum gap $\Delta \epsilon _ { \mathrm { m a x } }$ with the ground truth.
209
+
210
+ Results $\pmb { \& }$ discussions. The mean absolute errors (MAE) between calculated properties and the ground truth are reported in Tab. 3. CVGAE is excluded due to the poor performance, which is also reported in Simm & Hernandez-Lobato (2020); Shi et al. (2021). The properties are highly sensitive to geometric structure, and thus the superior performance demonstrate that GEODIFF can consistently predict more accurate conformations across different molecules.
211
+
212
+ # 6 CONCLUSION
213
+
214
+ We propose GEODIFF, a novel probabilistic model for generating molecular conformations. GEODIFF marries denoising diffusion models with geometric representations, where we parameterize the reverse generative dynamics as a Markov chain, and novelly impose roto-translational invariance into the density with equivariant Markov kernels. We derive a tractable invariant objective from the variational lower bound to optimize the likelihood. Comprehensive experiments over multiple tasks demonstrate that GEODIFF is competitive with the existing state-of-the-art models. Future work includes further improving or accelerating the model with other recent progress of diffusion models, and extending our method to other challenging structures such as proteins.
215
+
216
+ # ACKNOWLEDGEMENT
217
+
218
+ Minkai thanks Huiyu Cai, David Wipf, Zuobai Zhang, and Zhaocheng Zhu for their helpful discussions and comments. This project is supported by the Natural Sciences and Engineering Research Council (NSERC) Discovery Grant, the Canada CIFAR AI Chair Program, collaboration grants between Microsoft Research and Mila, Samsung Electronics Co., Ltd., Amazon Faculty Research Award, Tencent AI Lab Rhino-Bird Gift Fund and a NRC Collaborative R&D Project (AI4D-CORE-06). This project was also partially funded by IVADO Fundamental Research Project grant PRF-2019- 3583139727. The Stanford team is supported by NSF(#1651565, #1522054, #1733686), ONR (N000141912145), AFOSR (FA95501910024), ARO (W911NF-21-1-0125) and Sloan Fellowship.
219
+
220
+ # REFERENCES
221
+
222
+ Mohammed AlQuraishi. End-to-end differentiable learning of protein structure. Cell systems, 8(4): 292–301, 2019.
223
+
224
+ Simon Axelrod and Rafael Gomez-Bombarelli. Geom: Energy-annotated molecular conformations for property prediction and molecular generation. arXiv preprint arXiv:2006.05531, 2020.
225
+
226
+ Simon Batzner, Tess E Smidt, Lixin Sun, Jonathan P Mailoa, Mordechai Kornbluth, Nicola Molinari, and Boris Kozinsky. Se (3)-equivariant graph neural networks for data-efficient and accurate interatomic potentials. arXiv preprint arXiv:2101.03164, 2021.
227
+
228
+ Julian Chibane, Thiemo Alldieck, and Gerard Pons-Moll. Implicit functions in feature space for 3d shape reconstruction and completion. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6970–6981, 2020.
229
+
230
+ Sybren Ruurds De Groot and Peter Mazur. Non-equilibrium thermodynamics. Courier Corporation, 2013.
231
+
232
+ Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using Real NVP. In ICLR, 2017.
233
+
234
+ David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In Advances in neural information processing systems, pp. 2224–2232, 2015.
235
+
236
+ Fabian Fuchs, Daniel Worrall, Volker Fischer, and Max Welling. Se(3)-transformers: 3d rototranslation equivariant attention networks. NeurIPS, 2020.
237
+
238
+ Octavian-Eugen Ganea, Lagnajit Pattanaik, Connor W Coley, Regina Barzilay, Klavs F Jensen, William H Green, and Tommi S Jaakkola. Geomol: Torsional geometric generation of molecular 3d conformer ensembles. arXiv preprint arXiv:2106.07802, 2021.
239
+
240
+ Niklas WA Gebauer, Michael Gastegger, Stefaan SP Hessmann, Klaus-Robert Müller, and Kristof T Schütt. Inverse design of 3d molecular structures with conditional generative neural networks. arXiv preprint arXiv:2109.04824, 2021.
241
+
242
+ Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1263–1272. JMLR. org, 2017.
243
+
244
+ T. Gogineni, Ziping Xu, Exequiel Punzalan, Runxuan Jiang, Joshua A Kammeraad, Ambuj Tewari, and P. Zimmerman. Torsionnet: A reinforcement learning approach to sequential conformer search. ArXiv, abs/2006.07078, 2020.
245
+
246
+ Thomas A Halgren. Merck molecular force field. v. extension of mmff94 using experimental data, additional computational data, and empirical rules. Journal of Computational Chemistry, 17(5-6): 616–641, 1996.
247
+
248
+ Paul CD Hawkins. Conformation generation: the state of the art. Journal of Chemical Information and Modeling, 57(8):1747–1756, 2017.
249
+
250
+ Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. arXiv preprint arXiv:1610.02136, 2016.
251
+
252
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020.
253
+
254
+ Weihua Hu, Muhammed Shuaibi, Abhishek Das, Siddharth Goyal, Anuroop Sriram, Jure Leskovec, Devi Parikh, and Larry Zitnick. Forcenet: A graph neural network for large-scale quantum chemistry simulation. 2021.
255
+
256
+ John Ingraham, Adam J Riesselman, Chris Sander, and Debora S Marks. Learning protein structure with a differentiable simulator. In International Conference on Learning Representations, 2019.
257
+
258
+ Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. arXiv preprint arXiv:1802.04364, 2018.
259
+
260
+ Bowen Jing, Stephan Eismann, Patricia Suriana, Raphael John Lamarre Townshend, and Ron Dror. Learning from protein structure with geometric vector perceptrons. In International Conference on Learning Representations, 2021.
261
+
262
+ John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021.
263
+
264
+ Wolfgang Kabsch. A solution for the best rotation to relate two sets of vectors. Acta Crystallographica Section A: Crystal Physics, Diffraction, Theoretical and General Crystallography, 32(5):922–923, 1976.
265
+
266
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, 2013.
267
+
268
+ Jonas Köhler, Leon Klein, and Frank Noe. Equivariant flows: Exact likelihood generative learning for symmetric densities. In Proceedings of the 37th International Conference on Machine Learning, 2020.
269
+
270
+ Leo Liberti, Carlile Lavor, Nelson Maculan, and Antonio Mucherino. Euclidean distance geometry and applications. SIAM review, 56(1):3–69, 2014.
271
+
272
+ Shitong Luo and Wei Hu. Diffusion probabilistic models for 3d point cloud generation. ArXiv, abs/2103.01458, 2021.
273
+
274
+ Shitong Luo, Chence Shi, Minkai Xu, and Jian Tang. Predicting molecular conformation via dynamic graph score matching. Advances in Neural Information Processing Systems, 34, 2021.
275
+
276
+ Elman Mansimov, Omar Mahmood, Seokho Kang, and Kyunghyun Cho. Molecular geometry prediction using a deep generative graph neural network. arXiv preprint arXiv:1904.00314, 2019.
277
+
278
+ B. Miller, M. Geiger, T. Smidt, and F. Noé. Relevance of rotationally equivariant convolutions for predicting molecular properties. ArXiv, abs/2008.08461, 2020.
279
+
280
+ Frank Noé, Simon Olsson, Jonas Köhler, and Hao Wu. Boltzmann generators: Sampling equilibrium states of many-body systems with deep learning. Science, 365(6457), 2019.
281
+
282
+ Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole Von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific data, 1(1):1–7, 2014.
283
+
284
+ Sereina Riniker and Gregory A. Landrum. Better informed distance geometry: Using what we know to improve conformation generation. Journal of Chemical Information and Modeling, 55(12): 2562–2574, 2015.
285
+
286
+ Victor Garcia Satorras, Emiel Hoogeboom, Fabian B Fuchs, Ingmar Posner, and Max Welling. E (n) equivariant normalizing flows for molecule generation in 3d. arXiv preprint arXiv:2105.09016, 2021a.
287
+
288
+ Victor Garcia Satorras, Emiel Hoogeboom, and Max Welling. E(n) equivariant graph neural networks, 2021b.
289
+
290
+ Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In Advances in Neural Information Processing Systems, pp. 991–1001. Curran Associates, Inc., 2017.
291
+
292
+ Andrew W Senior, Richard Evans, John Jumper, James Kirkpatrick, Laurent Sifre, Tim Green, Chongli Qin, Augustin Žídek, Alexander WR Nelson, Alex Bridgland, et al. Improved protein structure prediction using potentials from deep learning. Nature, 577(7792):706–710, 2020.
293
+
294
+ Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, and Jian Tang. Graphaf: a flow-based autoregressive model for molecular graph generation. arXiv preprint arXiv:2001.09382, 2020.
295
+
296
+ Chence Shi, Shitong Luo, Minkai Xu, and Jian Tang. Learning gradient fields for molecular conformation generation. ArXiv, 2021.
297
+
298
+ Muhammed Shuaibi, Adeesh Kolluru, Abhishek Das, Aditya Grover, Anuroop Sriram, Zachary Ulissi, and C Lawrence Zitnick. Rotation invariant graph neural networks using spin convolutions. arXiv preprint arXiv:2106.09575, 2021.
299
+
300
+ Gregor Simm and Jose Miguel Hernandez-Lobato. A generative model for molecular distance geometry. In Hal Daumé III and Aarti Singh (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119, pp. 8949–8958. PMLR, 2020.
301
+
302
+ Gregor N. C. Simm, Robert Pinsler, Gábor Csányi, and José Miguel Hernández-Lobato. Symmetryaware actor-critic for 3d molecular design. In International Conference on Learning Representations, 2021.
303
+
304
+ Daniel G. A. Smith, L. Burns, A. Simmonett, R. Parrish, M. C. Schieber, Raimondas Galvelis, P. Kraus, H. Kruse, Roberto Di Remigio, Asem Alenaizan, A. M. James, S. Lehtola, Jonathon P Misiewicz, et al. Psi4 1.4: Open-source software for high-throughput quantum chemistry. The Journal of chemical physics, 2020.
305
+
306
+ Jascha Sohl-Dickstein, Eric A Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv preprint arXiv:1503.03585, 2015.
307
+
308
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
309
+
310
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems, pp. 11918–11930, 2019.
311
+
312
+ Yang Song and Stefano Ermon. Improved techniques for training score-based generative models. NeurIPS, 2020.
313
+
314
+ N. Thomas, T. Smidt, Steven M. Kearnes, Lusann Yang, L. Li, Kai Kohlhoff, and P. Riley. Tensor field networks: Rotation- and translation-equivariant neural networks for 3d point clouds. ArXiv, 2018.
315
+
316
+ M. Weiler, M. Geiger, M. Welling, W. Boomsma, and T. Cohen. 3d steerable cnns: Learning rotationally equivariant features in volumetric data. In NeurIPS, 2018.
317
+
318
+ Minkai Xu, Shitong Luo, Yoshua Bengio, Jian Peng, and Jian Tang. Learning neural generative dynamics for molecular conformation generation. In International Conference on Learning Representations, 2021a.
319
+
320
+ Minkai Xu, Wujie Wang, Shitong Luo, Chence Shi, Yoshua Bengio, Rafael Gomez-Bombarelli, and Jian Tang. An end-to-end framework for molecular conformation generation via bilevel programming. arXiv preprint arXiv:2105.07246, 2021b.
321
+
322
+ Linfeng Zhang, Jiequn Han, Han Wang, Roberto Car, and Weinan E. Deep Potential Molecular Dynamics: A Scalable Model with the Accuracy of Quantum Mechanics. Physical Review Letters, 120(14):143001, 2018.
323
+
324
+ Jinhua Zhu, Yingce Xia, Chang Liu, Lijun Wu, Shufang Xie, Tong Wang, Yusong Wang, Wengang Zhou, Tao Qin, Houqiang Li, et al. Direct molecular conformation generation. arXiv preprint arXiv:2202.01356, 2022.
325
+
326
+ # A PROOFS
327
+
328
+ # A.1 PROPERTIES OF THE DIFFUSION MODEL
329
+
330
+ We include proofs for several key properties of the probabilistic diffusion model here to be selfcontained. For more detailed discussions, please refer to $\mathrm { H o }$ et al. (2020). Let $\big \{ \beta _ { 0 } , . . . , \beta _ { T } \big \}$ be a sequence of variances, and $\alpha _ { t } = 1 - \beta _ { t }$ and $\begin{array} { r } { \bar { \alpha } _ { t } = \prod _ { s = 1 } ^ { t } \alpha _ { s } } \end{array}$ . The two following properties are crucial for deriving the final tractable objective in equation 9.
331
+
332
+ Property 1. Tractable marginal of the forward process:
333
+
334
+ $$
335
+ q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { 0 } ) = \int q ( \mathcal { C } ^ { 1 : t } | \mathcal { C } ^ { 0 } ) d \mathcal { C } ^ { 1 : ( t - 1 ) } = \mathcal { N } ( \mathcal { C } ^ { t } ; \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { t } ) I ) .
336
+ $$
337
+
338
+ Proof. Let $\epsilon _ { i }$ ’s be independent standard Gaussian random variables. Then, by definition of the Markov kernels $q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { t - 1 } )$ in equation 2, we have
339
+
340
+ $$
341
+ \begin{array} { r l } { \mathcal { C } ^ { t } } & { = \sqrt { \alpha _ { t } } \mathcal { C } ^ { t - 1 } + \sqrt { \beta _ { t } } \epsilon _ { t } } \\ & { = \sqrt { \alpha _ { t } \alpha _ { t - 1 } } \mathcal { C } ^ { t - 2 } + \sqrt { \alpha _ { t } \beta _ { t - 1 } } \epsilon _ { t - 1 } + \sqrt { \beta _ { t } } \epsilon _ { t } } \\ & { = \sqrt { \alpha _ { t } \alpha _ { t - 1 } } \mathcal { C } _ { t - 1 } \mathcal { C } ^ { t - 3 } + \sqrt { \alpha _ { t } \alpha _ { t - 1 } \beta _ { t - 2 } } \epsilon _ { t - 2 } + \sqrt { \alpha _ { t } \beta _ { t - 1 } } \epsilon _ { t - 1 } + \sqrt { \beta _ { t } } \epsilon _ { t } } \\ & { = \cdot \cdot } \\ & { = \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \sqrt { \alpha _ { t } \alpha _ { t - 1 } \cdot \cdot \cdot \alpha _ { 2 } \beta _ { 1 } } \epsilon _ { 1 } + \cdot \cdot \cdot + \sqrt { \alpha _ { t } \beta _ { t - 1 } } \epsilon _ { t - 1 } + \sqrt { \beta _ { t } } \epsilon _ { t } } \end{array}
342
+ $$
343
+
344
+ Therefore $q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { 0 } )$ is still Gaussian, and the mean of $\mathcal { C } ^ { t }$ is $\sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 }$ , and the variance matrix is $( \alpha _ { t } \alpha _ { t - 1 } \cdot \cdot \cdot \cdot \alpha _ { 2 } \beta _ { 1 } + \cdot \cdot \cdot + \alpha _ { t } \beta _ { t - 1 } + \beta _ { t } ) I = ( 1 - \bar { \alpha } _ { t } ) I .$ . Then we have:
345
+
346
+ $$
347
+ q ( \mathcal { C } ^ { t } \vert \mathcal { C } ^ { 0 } ) = \mathcal { N } ( \mathcal { C } ^ { t } ; \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { t } ) I ) .
348
+ $$
349
+
350
+ This property provides convenient closed-form evaluation of $\mathcal { C } ^ { t }$ knowing $\mathcal { C } ^ { 0 }$ :
351
+
352
+ $$
353
+ \begin{array} { r } { \mathcal { C } ^ { t } = \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon , } \end{array}
354
+ $$
355
+
356
+ where $\epsilon \sim \mathcal { N } ( 0 , I )$ .
357
+
358
+ Besides, it is worth noting that,
359
+
360
+ $$
361
+ q ( \mathcal { C } ^ { T } \vert \mathcal { C } ^ { 0 } ) = { \mathcal { N } } ( \mathcal { C } ^ { T } ; \sqrt { \bar { \alpha } _ { T } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { T } ) I ) ,
362
+ $$
363
+
364
+ where $\begin{array} { r } { \bar { \alpha } _ { T } = \prod _ { t = 1 } ^ { T } ( 1 - \beta _ { t } ) } \end{array}$ approaches zero with large $T$ , which indicates the diffusion process can finally converge into a whitened noisy distribution.
365
+
366
+ Property 2. Tractable posterior of the forward process:
367
+
368
+ $$
369
+ q ( \mathcal { C } ^ { t - 1 } \vert \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } ) = \mathcal { N } ( \mathcal { C } ^ { t - 1 } ; \frac { \sqrt { \bar { \alpha } _ { t - 1 } } \beta _ { t } } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \frac { \sqrt { \alpha _ { t } } \big ( 1 - \bar { \alpha } _ { t - 1 } \big ) } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { t } , \frac { \big ( 1 - \bar { \alpha } _ { t - 1 } \big ) } { 1 - \bar { \alpha } _ { t } } \beta _ { t } I ) .
370
+ $$
371
+
372
+ $\begin{array} { r } { \tilde { \beta } _ { t } = \frac { 1 - \bar { \alpha } _ { t - 1 } } { 1 - \bar { \alpha } _ { t } } \beta _ { t } } \end{array}$
373
+
374
+ $$
375
+ \begin{array} { r l } { q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } ) } & { = \frac { q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { t - 1 } ) ~ q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { 0 } ) } { q ( \mathcal { C } ^ { t } | \mathcal { C } ^ { 0 } ) } } \\ & { = \frac { N ( \mathcal { C } ^ { t } ; \sqrt { \alpha _ { t } } \mathcal { C } ^ { t - 1 } , \beta _ { t } I ) N ( \mathcal { C } ^ { t - 1 } ; \sqrt { \bar { \alpha } _ { t - 1 } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { t - 1 } ) I ) } { N ( \mathcal { C } ^ { t } ; \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } , ( 1 - \bar { \alpha } _ { t } ) I ) } } \\ & { = ( 2 \pi \beta _ { t } ) ^ { - \frac { d } { 2 } } ( 2 \pi ( 1 - \bar { \alpha } _ { t - 1 } ) ) ^ { - \frac { d } { 2 } } ( 2 \pi ( 1 - \bar { \alpha } _ { t } ) ) ^ { \frac { d } { 2 } } \times } \\ & { ~ \exp \left( - \frac { \| \mathcal { C } ^ { t } - \sqrt { \alpha _ { t } } \mathcal { C } ^ { t - 1 } \| ^ { 2 } } { 2 \beta _ { t } } - \frac { \| \mathcal { C } ^ { t - 1 } - \sqrt { \bar { \alpha } _ { t - 1 } } \mathcal { C } ^ { 0 } \| ^ { 2 } } { 2 ( 1 - \bar { \alpha } _ { t - 1 } ) } + \frac { \| \mathcal { C } ^ { t } - \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } \| ^ { 2 } } { 2 ( 1 - \bar { \alpha } _ { t } ) } \right) } \\ & { = ( 2 \pi \tilde { \beta } _ { t } ) ^ { - \frac { d } { 2 } } \exp \left( - \frac { 1 } { 2 \tilde { \beta } _ { t } } \left\| \mathcal { C } ^ { t - 1 } - \frac { \sqrt { \bar { \alpha } _ { t - 1 } } \beta _ { t } } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } - \frac { \sqrt { \alpha _ { t } } ( 1 - \bar { \alpha } _ { t - 1 } ) } { 1 - \bar { \alpha } _ { t } } \mathcal { C } ^ { t } \right\| ^ { 2 } \right) } \endarray \end{array}
376
+ $$
377
+
378
+ Then we have the posterior $q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } )$ as the given form.
379
+
380
+ # A.2 PROOF OF PROPOSITION 1
381
+
382
+ Let $T _ { g }$ be some roto-translational transformations of a group element $g \in { \mathrm { S E } } ( 3 )$ , and let $p ( x _ { T } )$ be a density which is SE(3)-invariant, i.e., $p ( x _ { T } ) = p ( T _ { g } ( x _ { T } ) )$ . If the Markov transitions $p ( x _ { t - 1 } | x _ { t } )$ are SE(3)-equivariant, i.e., $p ( x _ { t - 1 } | x _ { t } ) = p ( T _ { g } ( x _ { t - 1 } ) | \bar { T } _ { g } ( x _ { t } ) )$ , then we have that the density $p _ { \theta } ( x _ { 0 } ) =$ $\begin{array} { r } { \int p ( x _ { T } ) p _ { \theta } ( x _ { 0 : T - 1 } | x _ { T } ) \mathrm { d } { x _ { 1 : T } } } \end{array}$ is also SE(3)-invariant.
383
+
384
+ Proof.
385
+
386
+ $$
387
+ \begin{array} { l } { \displaystyle p _ { \vartheta } ( T _ { g } ( x _ { 0 } ) ) = \int p ( T _ { g } ( x _ { T } ) ) p _ { \vartheta } ( T _ { g } ( x _ { 0 : \varSigma ^ { - 1 } } ) | T _ { g } ( x _ { T } ) ) \mathrm { d } x _ { 1 : T } } \\ { \displaystyle = \int p ( T _ { g } ( x _ { T } ) ) \Pi _ { t = 1 } ^ { T } p _ { \vartheta } ( T _ { g } ( x _ { t - 1 } ) | T _ { g } ( x _ { t } ) ) \mathrm { d } x _ { 1 : T } } \\ { \displaystyle = \int p ( x _ { T } ) \Pi _ { t = 1 } ^ { T } p _ { \vartheta } ( T _ { g } ( x _ { t - 1 } ) | T _ { g } ( x _ { t } ) ) \mathrm { d } x _ { 1 : T } \quad \mathrm { ( i n v a r i a n t ~ p i o r ~ } p ( x _ { T } ) ) } \\ { \displaystyle = \int p ( x _ { T } ) \Pi _ { t = 1 } ^ { T } p _ { \vartheta } ( x _ { t - 1 } | x _ { t } ) \mathrm { d } x _ { 1 : T } \quad \mathrm { ( e q u i v a r i a n t ~ k e r m e l s ~ } p ( x _ { t - 1 } | x _ { t } ) ) } \\ { \displaystyle = \int p ( x _ { T } ) p \ d _ { \vartheta } ( x _ { 0 : T - 1 } | x _ { T } ) \mathrm { d } x _ { 1 : T } } \\ { \displaystyle = p _ { \vartheta } ( x _ { 0 } ) } \end{array}
388
+ $$
389
+
390
+ # A.3 PROOF OF PROPOSITION 2
391
+
392
+ In this section we prove that the output $\mathbf { x }$ of GFN defined in equation 5, 6 and 7 is translationally invariant and rotationally equivariant with the input $\mathcal { C }$ . Let $g \in \mathbb { R } ^ { \mathbf { \hat { 3 } } }$ denote any translation transformations and orthogonal matrices $R \in \mathbb { R } ^ { 3 \times 3 }$ denote any rotation transformations. let $R \mathbf { x }$ be shorthand for $( R { \bf x } _ { 1 } , \cdots , R { \bf x } _ { N } )$ . Formally, we aim to prove that the model satisfies:
393
+
394
+ $$
395
+ R { \mathbf { x } } ^ { l + 1 } , \mathbf { h } ^ { l + 1 } = \mathrm { G F N } ( R { \mathbf { x } } ^ { l } , R { \mathcal { C } } + g , \mathbf { h } ^ { l } ) .
396
+ $$
397
+
398
+ This equation indicates that, given $\mathbf { x } ^ { l }$ already rotationally equivalent with $\mathcal { C }$ , and $\mathbf { h } ^ { l }$ already invariant, then such property can propagate through a single GFN layer to $\mathbf { x } ^ { l + 1 }$ and $\mathbf { h } ^ { l + 1 }$ .
399
+
400
+ Proof. Firstly, given that $\mathbf { h } ^ { l }$ already invariant to SE(3) transformations, we have that the messages $\mathbf { m } _ { i j }$ calculated from equation 5 will also be invariant. This is because it sorely relies on the distance between two atoms, which are manifestly invariant to rotations $\| R \mathbf { x } _ { i } ^ { l } - R \mathbf { x } _ { j } ^ { l } \| ^ { 2 } = ( \mathbf { x } _ { i } ^ { l } -$ $\begin{array} { r } { \mathbf { x } _ { j } ^ { l } ) ^ { \top } R ^ { \top } R ( \mathbf { x } _ { \cdot } ^ { l } - \mathbf { x } _ { j } ^ { l } ) = ( \mathbf { x } _ { i } ^ { l } - \mathbf { x } _ { j } ^ { l } ) ^ { \top } I ( \mathbf { x } _ { i } ^ { l } - \mathbf { x } _ { j } ^ { l } ) = \| \mathbf { x } _ { i } ^ { l } - \mathbf { x } _ { j } ^ { l } \| ^ { 2 } } \end{array}$ . Formally, the invariance of messages in equation 5 can be written as:
401
+
402
+ $$
403
+ \begin{array} { r } { \mathbf { m } _ { i , j } = \Phi _ { m } \left( \mathbf { h } _ { i } ^ { l } , \mathbf { h } _ { j } ^ { l } , \left. R \mathbf { x } _ { i } ^ { l } - R \mathbf { x } _ { j } ^ { l } \right. ^ { 2 } , e _ { i j } \right) = \Phi _ { m } \left( \mathbf { h } _ { i } ^ { l } , \mathbf { h } _ { j } ^ { l } , \left. \mathbf { x } _ { i } ^ { l } - \mathbf { x } _ { j } ^ { l } \right. ^ { 2 } , e _ { i j } \right) . } \end{array}
404
+ $$
405
+
406
+ And similarly, the $\mathbf { h } ^ { t + 1 }$ updated from equation 6 will also be invariant.
407
+
408
+ Next, we prove that the vector $\mathbf { x }$ updated from equation 7 preserves rotational equivariance and translational invariance. Given $\mathbf { m } _ { i j }$ already invariant as proven above, we have that:
409
+
410
+ $$
411
+ \sum _ { j \in \mathcal { N } ( i ) } \frac { 1 } { d _ { i j } } \left( R \mathbf { c } _ { i } + g - R \mathbf { c } _ { j } - g \right) \Phi _ { x } \left( \mathbf { m } _ { i , j } \right) = R \sum _ { j \in \mathcal { N } ( i ) } \frac { 1 } { d _ { i j } } \left( \mathbf { c } _ { i } - \mathbf { c } _ { j } \right) \Phi _ { x } \left( \mathbf { m } _ { i , j } \right) = R \mathbf { x } _ { i } ^ { l + 1 } .
412
+ $$
413
+
414
+ Therefore, we have that rotating and translating c results in the same rotation and no translation on $\mathbf { x } ^ { l + 1 }$ by updating through equation 7.
415
+
416
+ Thus we can conclude that the property defined in equation 15 is satisfied.
417
+
418
+ Having proved the equivariance property of a single GFN layer, then inductively, we can draw conclusion that a composition of $L$ GFN layers will also preserve the same equivariance.
419
+
420
+ # A.4 PROOF OF PROPOSITION 3
421
+
422
+ We first derive the variational lower bound (ELBO) objective in equation 8. The ELBO can be calculated as follows:
423
+
424
+ $$
425
+ \begin{array} { r l } { \pm \log _ { \mathbb { P } } ( \mathcal { C } ^ { 0 } | \mathcal { G } ^ { 1 } | \mathcal { G } ) = \Xi \log \Xi _ { \mathbb { G } ^ { ( \mathcal { R } ^ { \prime } ) } } \Big [ \frac { p _ { \mathbb { P } } ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } ) \mathbb { C } - 1 } | \mathcal { G } , \mathcal { G } ^ { \mathcal { R } ^ { \prime } } ) \times \mathcal { H } ( \mathcal { C } ^ { \mathcal { T } } ) } { q ( \mathcal { C } ^ { 1 } | \mathcal { G } ^ { \mathbb { C } } ) } \Big ] } \\ & { \ge \Xi _ { \mathbb { E } } \log \frac { p _ { \mathbb { P } } ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } ) \mathbb { C } - 1 } | \mathcal { G } , \mathcal { C } ^ { \mathcal { T } } ) \times \mathcal { H } ( \mathcal { G } ^ { \mathcal { T } } ) } { q ( \mathcal { C } ^ { 1 } | \mathcal { G } ^ { \mathbb { C } } ) } } \\ & { = \mathbb { P } _ { \mathbb { E } } \Big [ \log \mathcal { F } ^ { ( \mathcal { T } ) } - \frac { \sum } { c - 1 } \operatorname* { l i m } _ { \mathbb { P } } \frac { p _ { \mathbb { P } } ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } - 1 } | \mathcal { G } , \mathcal { G } ^ { \mathcal { R } ^ { \prime } } ) ) } { q ( \mathcal { G } ^ { 1 } | \mathcal { G } ^ { \mathbb { C } } ) } \Big ] } \\ & = \mathbb { E } _ { \mathbb { E } } \Big [ \log \mathcal { F } ^ { ( \mathcal { T } ) } - \log \frac { p _ { \mathbb { P } } ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } ) \mathbb { C } } , \mathcal { G } ^ { \mathcal { T } } ) } { q ( \mathcal { G } ^ { 1 } | \mathcal { G } ^ { \mathbb { P } } ) } - \frac { \sum } { c - 2 } \Big ( \log \frac p _ { \mathbb { P } } ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } - 1 } | \mathcal { G } , \mathcal { C } ^ { \mathcal { T } } ) \to \log \frac { q ( \mathcal { G } ^ { ( \mathcal { R } ^ { \prime } - 1 } | \mathcal { G } ^ { \mathcal { T } } ) ) } { q ( \mathcal { G } ^ { 1 } | \mathcal { G } ^ { \mathbb { P } } ) } q ( \mathcal { G } ^ { 1 } | \mathcal { G } ^ \end{array}
426
+ $$
427
+
428
+ It can be noted that the first term $\mathrm { K L } \left( q ( \mathcal { C } ^ { T } | \mathcal { C } ^ { 0 } ) | | p ( \mathcal { C } ^ { T } ) \right)$ is a constant, which can be omitted in the objective. Furthermore, for brevity, we also merge the final term $\log p _ { \theta } ( \mathcal { C } ^ { 0 } | \mathcal { G } , \mathcal { C } ^ { 1 } )$ into the second term (sum over $\mathrm { K L }$ divergences), and finally derive that $\begin{array} { r l } { \mathcal { L } _ { \mathrm { E L B O } } } & { { } = } \end{array}$ $\begin{array} { r l } { \sum _ { t = 1 } ^ { T } D _ { \mathrm { K L } } ( q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } ) | | p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } ) ) } & { { } } \end{array}$ as in equation 8.
429
+
430
+ Now we consider how to compute the KL divergences as the proposition 3. Since both $q ( \mathcal { C } ^ { t - 1 } | \mathcal { C } ^ { t } , \mathcal { C } ^ { 0 } )$ and $p _ { \theta } ( \mathcal { C } ^ { t - 1 } | \mathcal { G } , \mathcal { C } ^ { t } )$ are Gaussian share the same covariance matrix $\widetilde { \beta } _ { t } I$ , the KL divergence between them can be calculated by the squared $\ell _ { 2 }$ distance between their means weighed by a certain weights√ √ $\frac { 1 } { 2 \tilde { \beta } _ { t } }$ . By the expression of $q ( \mathcal { C } ^ { t } \bar { | { \mathcal { C } } } ^ { 0 } )$ , we have the reparameterization that $\mathcal { \bar { C } } ^ { t } = \sqrt { \bar { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ Then we can derive:
431
+
432
+ $$
433
+ \begin{array} { r l } & { \mathbb { E } _ { q } \operatorname { K L } ( q ( \mathcal { E } ^ { t - 1 } \vert \mathcal { E } ^ { t } , \mathcal { C } ^ { 0 } ) \vert p _ { \theta } ( \mathcal { G } , \mathcal { C } ^ { t - 1 } \vert \mathcal { L } ^ { t } ) ) } \\ & { = \frac { 1 } { 2 \tilde { \beta } _ { t } } \mathbb { E } _ { \mathcal { C } ^ { 0 } } \frac { \sqrt { \alpha _ { t - 1 } } \beta _ { t } } { 1 - \tilde { \alpha } _ { t } } \mathcal { C } ^ { 0 } + \frac { \sqrt { \alpha _ { t } } ( 1 - \tilde { \alpha } _ { t - 1 } ) } { 1 - \tilde { \alpha } _ { t } } \mathcal { C } ^ { t } - \frac { 1 } { \sqrt { \alpha _ { t } } } ( \mathcal { C } ^ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \tilde { \alpha } _ { t } } } \epsilon _ { \theta } ( \mathcal { C } ^ { t } , \mathcal { G } , t ) ) ^ { 2 } } \\ & { = \frac { 1 } { 2 \tilde { \beta } _ { t } } \mathbb { E } _ { \mathcal { C } ^ { 0 } } , \frac { \sqrt { \alpha _ { t - 1 } } \beta _ { t } } { 1 - \tilde { \alpha } _ { t } } \cdot \frac { \mathcal { C } ^ { t } - \sqrt { 1 - \tilde { \alpha } _ { t } } \epsilon } { \sqrt { \tilde { \alpha } _ { t } } } + \frac { \sqrt { \alpha _ { t } } ( 1 - \tilde { \alpha } _ { t - 1 } ) } { 1 - \tilde { \alpha } _ { t } } \mathcal { C } ^ { t } - \frac { 1 } { \sqrt { \alpha _ { t } } } ( \mathcal { C } ^ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \tilde { \alpha } _ { t } } } \epsilon _ { \theta } ( \mathcal { C } ^ { t } , \mathcal { G } , t ) ) } \\ & { = \frac { 1 } { 2 \tilde { \beta } _ { t } } \cdot \frac { \beta _ { t } ^ { 2 } } { \alpha _ { t } ( 1 - \tilde { \alpha } _ { t } ) } \mathbb { E } _ { \mathcal { C } ^ { 0 } , \epsilon } 0 \cdot \mathcal { C } ^ { t } + \epsilon - \epsilon _ { \theta } ( \mathcal { C } ^ { t } , \mathcal { G } , t ) ^ { 2 } } \\ & = \frac { \beta _ { t } ^ { 2 } } 2 ^ \end{array}
434
+ $$
435
+
436
+ where $\gamma _ { t }$ represent the wights $\frac { \beta _ { t } } { 2 \alpha _ { t } ( 1 - \bar { \alpha } _ { t - 1 } ) }$ . And we finish the proof.
437
+
438
+ # A.5 ANALYSIS OF THE INVARIANT DENSITY IN SEC. 4.2
439
+
440
+ Given a geometric system $x \in \mathbb { R } ^ { N \cdot 3 }$ , we obtain the CoM-free $\hat { x }$ by subtracting its CoM. This can be considered as a linear transformation:
441
+
442
+ $$
443
+ { \begin{array} { r } { { \hat { x } } = Q x , \ { \mathrm { w h e r e } } \ Q = I _ { 3 } \otimes \left( I _ { N } - { \frac { 1 } { N } } \mathbf { 1 } _ { N } \mathbf { 1 } _ { N } ^ { T } \right) } \end{array} }
444
+ $$
445
+
446
+ where $I _ { k }$ denotes the $k \times k$ identity matrix and ${ \bf 1 } _ { k }$ denotes the $k$ -dimensional vector filled with ones. It can be noted that $Q$ is a symmetric projection operator, i.e., $Q ^ { 2 } = Q$ and $Q ^ { T } = Q$ . And we also have that $\operatorname { r a n k } [ Q ] = ( N - 1 ) \cdot 3 .$ . Furthermore, let $U$ represent the space of CoM-free systems, we can easily have that $Q y = y$ for any $y \in U$ since the $\mathbf { { C o M } }$ of $y$ is already zero.
447
+
448
+ Formally, let $n = N \cdot 3$ and set $\mathbb { R } ^ { n }$ with an isotropic normal distribution $\rho = \mathscr { N } ( 0 , I _ { n } )$ , then the CoM-free density can be formally written as $\hat { \rho } = \mathrm { \mathcal { N } } ( 0 , Q I _ { n } Q ^ { T } ) = \mathcal { N } ( 0 , Q Q ^ { T } )$ . Thus, sampling from $\hat { \rho }$ can be trivially achieved by sampling from $\rho$ and then projecting with $Q$ . And $\hat { \rho } ( y )$ can be calculated by $\rho ( y )$ since for any $y \in U$ we have $\| y \| _ { 2 } ^ { 2 } = \| Q y \| _ { 2 } ^ { 2 }$ , and thus $\rho ( y ) = \hat { \rho } ( y )$ .
449
+
450
+ And in this paper, with the SE(3)-equivariant Markov kernels of the reverse process, any CoM-free system will transit to another CoM-free system. And thus we can induce a well-defined Markov chain on the subspace spanned by $Q$ .
451
+
452
+ # B OTHER RELATED WORK
453
+
454
+ Protein structure generation. There has also been many recent works working on protein structure folding. For example, Boltzmann generators Noé et al. (2019) use flow-based models to generate the structure of protein main chains. AlQuraishi (2019) uses recurrent networks to model the amino acid sequences. Ingraham et al. (2019) proposed neural networks to learn an energy simulator to infer the protein structures. Most recently, AlphaFold Senior et al. (2020); Jumper et al. (2021) has significantly improved the performance of protein structure generation. Nevertheless, proteins are mainly linear backbone structures while general molecules are highly branched with various rings, making protein folding approaches unsuitable for our setting.
455
+
456
+ Point cloud generation. Recently, some other works (Luo & Hu, 2021; Chibane et al., 2020) has also been proposed for 3D structure generation with diffusion-based models, but focus on the point cloud problem. Unfortunately, in general, point clouds are not considered as graphs with various atom and bond information, and equivariance is also not widely considered, making these methods fundamentally different from our model.
457
+
458
+ # C EXPERIMENT DETAILS
459
+
460
+ In this section, we introduce the details of our experiments. In practice, the means $\epsilon _ { \theta }$ are parameterized as compositions of both typical invariant MPNNs (Schütt et al., 2017) and the proposed equivariant GFNs in Sec. 4.2. As a default setup, the MPNNs for parameterizing the means $\epsilon _ { \theta }$ are all implemented with 4 layers, and the hidden embedding dimension is set as 128. After the MPNNs, we can obtain the informative invariant atom embeddings, which we denote as $\mathbf { h } ^ { 0 }$ . Then the embeddings $\mathbf { h } ^ { 0 }$ are fed into equivariant layers and updated with equation 5, equation 6, and equation 7 to obtain the equivariant output. For the training of GEODIFF, we train the model on a single Tesla V100 GPU with a learning rate of 0.001 until convergence and Adam (Kingma & Welling, 2013) as the optimizer. The practical training time is ${ \sim } 4 8$ hours. The other hyper-parameters of GEODIFF are summarized in Tab. 4, including highest variance level $\beta _ { T }$ , lowest variance level $\beta _ { T }$ , the variance schedule, number of diffusion timesteps $T$ , radius threshold for determining the neighbor of atoms $\tau$ , batch size, and number of training iterations.
461
+
462
+ Table 4: Additional hyperparameters of our GEODIFF.
463
+
464
+ <table><tr><td>Task</td><td>β1</td><td>T</td><td>β scheduler</td><td>T</td><td>T</td><td>Batch Size</td><td>Train Iter.</td></tr><tr><td>QM9</td><td>1e-7</td><td>2e-3</td><td>sigmoid</td><td>5000</td><td>10A</td><td>64</td><td>1M</td></tr><tr><td>Drugs</td><td>1e-7</td><td>2e-3</td><td>sigmoid</td><td>5000</td><td>10A</td><td>32</td><td>1M</td></tr></table>
465
+
466
+ # D ADDITIONAL EXPERIMENTS
467
+
468
+ # D.1 RESULTS FOR GEOM-QM9
469
+
470
+ The results on the GEOM-QM9 dataset are reported in Tab. 5.
471
+
472
+ Table 5: Results on the GEOM-QM9 dataset, without FF optimization.
473
+
474
+ <table><tr><td></td><td colspan="2">COV-R (%) ↑</td><td colspan="2">MAT-R(A)↓</td><td colspan="2">COV-P (%) ↑</td><td colspan="2">MAT-P (A) ↓</td></tr><tr><td>Models</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td></tr><tr><td>CVGAE</td><td>0.09</td><td>0.00</td><td>1.6713</td><td>1.6088</td><td>=</td><td>=</td><td>=</td><td></td></tr><tr><td>GRAPHDG</td><td>73.33</td><td>84.21</td><td>0.4245</td><td>0.3973</td><td>43.90</td><td>35.33</td><td>0.5809</td><td>0.5823</td></tr><tr><td>CGCF</td><td>78.05</td><td>82.48</td><td>0.4219</td><td>0.3900</td><td>36.49</td><td>33.57</td><td>0.6615</td><td>0.6427</td></tr><tr><td>CONFVAE</td><td>77.84</td><td>88.20</td><td>0.4154</td><td>0.3739</td><td>38.02</td><td>34.67</td><td>0.6215</td><td>0.6091</td></tr><tr><td>GEOMOL</td><td>71.26</td><td>72.00</td><td>0.3731</td><td>0.3731</td><td>=</td><td>=</td><td></td><td></td></tr><tr><td>CONFGF</td><td>88.49</td><td>94.31</td><td>0.2673</td><td>0.2685</td><td>46.43</td><td>43.41</td><td>0.5224</td><td>0.5124</td></tr><tr><td>GEODIFF-A</td><td>90.54</td><td>94.61</td><td>0.2104</td><td>0.2021</td><td>52.35</td><td>50.10</td><td>0.4539</td><td>0.4399</td></tr><tr><td>GEODIFF-C</td><td>90.07</td><td>93.39</td><td>0.2090</td><td>0.1988</td><td>52.79</td><td>50.29</td><td>0.4448</td><td>0.4267</td></tr></table>
475
+
476
+ Table 6: Additional results on the GEOM-Drugs dataset, without FF optimization.
477
+
478
+ <table><tr><td>Models</td><td colspan="2">COV-R (%) ↑</td><td colspan="2">MAT-R (A)↓</td><td colspan="2">COV-P (%) ↑</td><td colspan="2">MAT-P (A)↓</td></tr><tr><td></td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td><td>Mean</td><td>Median</td></tr><tr><td>GEODIFF (T=1000)</td><td>82.96</td><td>96.29</td><td>0.9525</td><td>0.9334</td><td>48.27</td><td>46.03</td><td>1.3205</td><td>1.2724</td></tr></table>
479
+
480
+ # D.2 ABLATION STUDY WITH FEWER DIFFUSION STEPS
481
+
482
+ We also test our method with fewer diffusion steps. Specifically, we test the setting with $T = 1 0 0 0$ , $\beta _ { 1 } = 1 \mathrm { e } \mathrm { - } 7$ and $\beta _ { T } = 9 \mathrm { e } { - 3 }$ . The results on the more challenging Drugs dataset are shown in Tab. 6. Compared with the results in Tab. 1, we can observe that when setting the diffusion steps as 1000, though slightly weaker than the performance with 5000 decoding steps, the model can already outperforms all existing baselines. Note that, the most competitive baseline CONFGF (Shi et al., 2021) also requires 5000 sampling steps, which indicates that our model can achieve better performance with fewer computational costs compared with the state-of-the-art method.
483
+
484
+ # E MORE VISUALIZATIONS
485
+
486
+ We provide more visualization of generated structures in Fig. 3. The molecules are chosen from the test split of GEOM-Drugs dataset.
487
+
488
+ ![](images/148b00e054deacd9fa43bd731b74da89c470b00613d93aae77ae2c18faffd574.jpg)
489
+ Figure 3: Visualization of drug-like conformations generated by GEODIFF.
md/dev/SrC-nwieGJ/SrC-nwieGJ.md ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RELATIVE REPRESENTATIONS ENABLE ZERO-SHOT LATENT SPACE COMMUNICATION
2
+
3
+ Luca Moschella1,∗ Valentino Maiorca1,∗ Marco Fumero1 Antonio Norelli1 Francesco Locatello2,† Emanuele Rodola\`1 1Sapienza University of Rome 2Amazon Web Services
4
+
5
+ # ABSTRACT
6
+
7
+ Neural networks embed the geometric structure of a data manifold lying in a high-dimensional space into latent representations. Ideally, the distribution of the data points in the latent space should depend only on the task, the data, the loss, and other architecture-specific constraints. However, factors such as the random weights initialization, training hyperparameters, or other sources of randomness in the training phase may induce incoherent latent spaces that hinder any form of reuse. Nevertheless, we empirically observe that, under the same data and modeling choices, the angles between the encodings within distinct latent spaces do not change. In this work, we propose the latent similarity between each sample and a fixed set of anchors as an alternative data representation, demonstrating that it can enforce the desired invariances without any additional training. We show how neural architectures can leverage these relative representations to guarantee, in practice, invariance to latent isometries and rescalings, effectively enabling latent space communication: from zero-shot model stitching to latent space comparison between diverse settings. We extensively validate the generalization capability of our approach on different datasets, spanning various modalities (images, text, graphs), tasks (e.g., classification, reconstruction) and architectures (e.g., CNNs, GCNs, transformers).
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Neural Networks (NN) learn to transform high dimensional data into meaningful representations that are helpful for solving downstream tasks. Typically, these representations are seen as elements of a vector space, denoted as latent space, which corresponds to the constrained output (explicitly or implicitly) of a key component of the NN, e.g., the bottleneck in an Autoencoder (AE), or the word embedding space in an NLP task. The underlying assumption is that the learned latent spaces should be an optimal encoding given the data distribution, the downstream task, and the network constraints.
12
+
13
+ In practice, however, the learned latent spaces are subject to changes even when the above assumptions remain fixed. We illustrate this phenomenon in Figure 1, where we show the latent spaces produced by an AE with a two-dimensional bottleneck, trained on the MNIST dataset several times from scratch. These spaces differ from one another, breaking the fundamental assumptions made above. The distribution of the latent embeddings is affected by several factors, such as the random initialization of the network weights, the data shuffling, hyperparameters, and other stochastic processes in the training phase. Although different, the learned representations in Figure 1 are intrinsically similar: the distances between the embedded representations are approximately the same across all spaces, even if their absolute coordinates differ. Indeed, the learned latent spaces are the same up to a nearly isometric transformation.1
14
+
15
+ This symmetry is a consequence of the implicit biases underlying the optimization process (Soudry et al., 2018) forcing the model to generalize and, therefore, to give similar representations to similar samples with respect to the task. There exist infinitely many spatial arrangements complying with these similarity constraints, each associated with a different isometry in the example of Figure 1.
16
+
17
+ ![](images/619f94407e8c5126c93d2d1328911bbfbc679f9eb3a3963834611b47b3859139.jpg)
18
+ Figure 1: Latent spaces learned by distinct trainings of the same AE on the MNIST dataset. The bottleneck has size 2, thus there is no dimensionality reduction involved in the visualization of the latent space. The stochasticity in the training phase induces intrinsically similar representations. As we show in Figure 5, this property holds even for high-dimensional latent spaces.
19
+
20
+ But while the resulting models will be equally good in terms of the task, one still encounters several practical problems. For example, it is notoriously challenging to compare latent spaces across different trainings or across different NNs; perhaps more importantly, re-using neural components trained on different embeddings of the same data becomes impossible, since they are incompatible. To overcome this, we propose adopting a local coordinate system defined by the data itself. Each data point becomes a set of coefficients that encode the point as a function of other data samples, instead of an independent point in $\mathbb { R } ^ { d }$ . The proposed relative representation directly encodes the intrinsic information underlying the data, and only depends on the angles between embeddings by construction. Remarkably, this enables a form of compositionality between learning models; it allows, for instance, to stitch together an encoder trained on ImageNet with a decoder trained on CIFAR, as we showcase in our experiments.
21
+
22
+ Our main contributions can be summarized as follows:
23
+
24
+ • We show that the representations learned by NNs are subject to change due to several training factors; nonetheless, the angles between latent embeddings are preserved. • We introduce a novel relative representation for latent embeddings, that is invariant by construction to the transformations induced by stochastic factors in the training process. • For the first time, we successfully demonstrate zero-shot stitching of neural components produced by distinct training regimens, e.g., due to different seeds or different neural architectures; we validate our findings on different data modalities (e.g. images, text). • Our framework also provides a quantitative measure of performance while training neural models, which is differentiable, does not need any labeled data, and is correlated with standard performance measures such as accuracy.
25
+
26
+ # 2 RELATED WORK
27
+
28
+ Representation similarity. Recently, there has been growing agreement that good networks learn similar representations across a variety of architectures, tasks and domains (Morcos et al., 2018; Li et al., 2016; Kornblith et al., 2019; Bonheme & Grzes, 2022; Tsitsulin et al., 2020; Barannikov et al., 2022; Vulic et al., 2020; Lample et al., 2018; Lenc & Vedaldi, 2015; Mikolov et al., 2013b; ´ Antonello et al., 2021), although this is still debated (Wang et al., 2018) and missing strong theoretical justifications. Similar observations have been made in the context of biological models Laakso & Cottrell (2000); Kriegeskorte et al. (2008); Raizada & Connolly (2012). Supported by the empirical evidence widely reported in these works, our method assumes that well-performing neural networks trained on similar tasks and data produce similar latent spaces, which allows us to define a representation that unifies all these spaces.
29
+
30
+ Model stitching. Lenc & Vedaldi (2015) introduced trainable stitching layers that allow swapping parts of different networks, while Bansal et al. (2021); Csiszarik et al. (2021) employed stitching ´ to quantitatively verify statements such as “good networks learn similar representations” and “more data, width or time is better”. Other works, such as Gygli et al. (2021); Biondi et al. (2021); Yaman et al. (2022); Bianchi et al. (2020), tried to directly produce compatible and reusable network components without stitching layers; more generally, stitching has been adopted in the literature to analyze neural networks. In our work, we sidestep the need for trainable stitching layers and propose zero-shot model stitching to effectively reuse models.
31
+
32
+ Relative information. The attention mechanism (Vaswani et al., 2017) and its variants (Kossen et al., 2021) exploit the relationship between features to extract meaningful representations. Prototypical Networks (Snell et al., 2017) learn a metric space where the classification can be performed by measuring the distances to prototype representations. Shalam & Korman (2022) proposed the Self Optimal Transport feature transform to enrich the sample representations with higher order relations between the instance features, while Alvarez-Melis et al. (2019) proposed a general formulation of the optimal transport that accounts for global invariances in the underlying feature spaces. Mathematically, our method bears resemblance to a kernel method (Hofmann et al., 2008) as it employs inner products of embedded features as a core ingredient. However, differently from kernel methods, we do not introduce learnable parameters and, crucially, we compute the representations explicitly without resorting to a kernel trick.
33
+
34
+ # 3 METHOD
35
+
36
+ Given a training set $\mathbb { X }$ , standard NNs learn an embedding function $E _ { \theta } : \mathbb { X } \mathbb { R } ^ { d }$ , parametrized by $\theta$ , which maps each sample $\pmb { x } ^ { ( i ) } \in \mathbb { X }$ to its latent representation, or absolute representation, $e _ { x ^ { ( i ) } } =$ $E _ { \theta } ( \pmb { x } ^ { ( i ) } )$ . This representation is then exploited to solve downstream tasks, such as classification, reconstruction or generation, optimizing over some objective function of the general form:
37
+
38
+ $$
39
+ \operatorname* { m i n } _ { \theta } \mathbb { E } _ { x \in \mathbb { X } } [ \mathcal { L } ( E _ { \theta } ( x ) ) + R e g ( \theta ) ] .
40
+ $$
41
+
42
+ Here, $\mathbb { E } _ { \mathbb { X } }$ denotes the expectation over the training distribution, and $R e g ( \theta )$ encodes additional constraints on the weights $\theta$ . As previously discussed, we argue that the learned weights $\theta ^ { * }$ are not only a function of $\mathbb { X }$ and of the specific loss appearing in Equation 1, but in practice they are also affected by the optimization process used to train the network due to weight initialization, data shuffling, hyperparameters, and other stochastic factors. We denote these factors collectively by $\phi$ . In particular, as shown in Figure 1, changing these factors induces a transformation $T$ over the latent space, i.e., $\phi \phi ^ { \prime }$ implies $E _ { \theta } ( \mathbf { x } ^ { ( i ) } ) T E _ { \theta } ( \mathbf { x } ^ { ( i ) } )$ . We make the core assumption that $T$ preserves the angles between elements of the latent space, namely $\angle ( e _ { { \pmb x } ^ { ( i ) } } , e _ { { \pmb x } ^ { ( j ) } } ) = \acute { \angle } ( T e _ { { \pmb x } ^ { ( i ) } } , T e _ { { \pmb x } ^ { ( j ) } } )$ for every $( \pmb { x } ^ { ( i ) } , \pmb { x } ^ { ( j ) } ) \in \mathbb { X }$ . While this assumption might seem too restrictive, in practice it arises in several real scenarios as we show in the following sections.
43
+
44
+ # 3.1 RELATIVE REPRESENTATIONS
45
+
46
+ To build our representation, we start by selecting a subset A of the training data $\mathbb { X }$ , which we denote as anchor samples. Every sample in the training distribution will be represented with respect to the embedded anchors $e _ { { \pmb a } ^ { ( j ) } } = E ( { \pmb a } ^ { ( j ) } )$ with $\pmb { a } ^ { ( j ) } \in \mathbb { A }$ . As a measure capturing the relation between the anchors and the other samples, we consider a generic similarity function $s i m : \mathbb { R } ^ { d } \times \mathbb { R } ^ { d } \mathbb { R }$ , yielding a scalar score $r$ between two absolute representations $r = s i m ( e _ { \pmb { x } ^ { ( i ) } } , e _ { \pmb { x } ^ { ( j ) } } )$ . Given the anchors A in an arbitrary ordering $a ^ { ( 1 ) } , \dots , a ^ { ( | \mathbb { A } | ) }$ , we define the relative representation of $\pmb { x } ^ { ( i ) } \in \mathbb { X }$ as:
47
+
48
+ $$
49
+ \pmb { r _ { x ^ { ( i ) } } } = \left( s i m ( \pmb { e _ { x ^ { ( i ) } } } , \pmb { e _ { a ^ { ( 1 ) } } } ) , s i m ( \pmb { e _ { x ^ { ( i ) } } } , \pmb { e _ { a ^ { ( 2 ) } } } ) , \dots , s i m ( \pmb { e _ { x ^ { ( i ) } } } , \pmb { e _ { a ^ { ( \mathrm { { \tiny { ( k ) } } } ) } } } ) \right) .
50
+ $$
51
+
52
+ Figure 2 illustrates the key differences between absolute and relative representations.
53
+
54
+ Choice of the anchors. Anchors directly affect the expressivity of the relative representation space, and are related to the task at hand. For example, in a classification task, we should sample anchors from each class in the training set, in order to well represent each data sample in $\mathbb { X }$ .
55
+
56
+ One case of interest arises when the data comes from different domains or modalities X, Y, and we are given a partial correspondence $\Gamma : P _ { \mathbb { X } } \mapsto P _ { \mathbb { Y } }$ mapping from a subset of $\mathbb { X }$ to a subset of $\mathbb { Y }$ . In this case, we can sample anchors $\mathbb { A } _ { \mathbb { X } } \subseteq P _ { \mathbb { X } }$ and obtain corresponding anchors on the other domain directly as $\Gamma ( \mathbb { A } )$ (Norelli et al., 2022). We refer to these as parallel anchors. We show an example of parallel anchors in Section 5.2, where $\mathbb { X }$ and $\mathbb { Y }$ are Amazon reviews in two different languages.
57
+
58
+ The choice of the anchors is not restricted to elements in the training distribution. Given an encoder pre-trained on a fixed training distribution, we can pick elements from a set $\tilde { \mathbb { A } }$ that is out-of-domain w.r.t. $\mathbb { X }$ , and build the relative representations on top of $\tilde { \mathbb { A } }$ . We refer to these as OOD anchors and exploit them, e.g., to solve domain adaptation tasks where we do not have access to a correspondence, and have scarce data labels. We refer again to the Sections 5.2 and 5.3 for real-world examples and to Appendix A.2 for a preliminary analysis of different selection strategies.
59
+
60
+ ![](images/7f86d70f8a968550f265f967c3bd25a626c52de7919905784d9ba112c7166e93.jpg)
61
+ Figure 2: Left: Three anchors (colored stars) are selected on the data manifold; given a point on the manifold (blue dot), we compute its similarity w.r.t. the three anchors, yielding a vector of dimensionality 3 (middle). Right: Each dimension is treated as coefficients in a coordinate system defined by the anchors. Anchors are orthogonal in this example only for visualization purposes.
62
+
63
+ Achieving latent invariance. In this work, we choose the cosine similarity as the similarity function due to the properties it induces on the relative representation. The cosine similarity $S _ { C }$ is the dot product of unit vectors, corresponding to the cosine of the angle $\theta$ between the two:
64
+
65
+ $$
66
+ \quad S _ { C } ( { \boldsymbol { \mathbf { a } } } , { \boldsymbol { \mathbf { b } } } ) = { \frac { \boldsymbol { \mathbf { a } } { \boldsymbol { \mathbf { b } } } } { | | { \boldsymbol { \mathbf { a } } } | | | | | { \boldsymbol { \mathbf { b } } } | | } } = \cos \theta .
67
+ $$
68
+
69
+ Importantly, $\cos \theta$ does not change if we apply the same angle-preserving transformation $\mathbf { T }$ to two vectors $^ { a }$ and $^ { b }$ , i.e., the cosine similarity is invariant to rotations, reflections, and rescaling. While this is not true for translations, NNs commonly employ normalization techniques (e.g., InstanceNorm (Ulyanov et al., 2016)) to center the latent spaces. Under this assumption, cosine similarity guarantees a relative representation $\mathbf { \Delta } r _ { \mathbf { \mathcal { X } } ^ { ( i ) } }$ invariant to angle-preserving transformations.
70
+
71
+ This means we have the freedom to change the embedding function $E _ { \theta }$ with any other function $\tilde { E }$ that produces different representations with same angles, i.e.:
72
+
73
+ $$
74
+ [ S _ { C } ( e _ { x ^ { ( i ) } } , e _ { a ^ { ( 1 ) } } ) , \dots , S _ { C } ( e _ { x ^ { ( i ) } } , e _ { a ^ { ( | k | ) } } ) = [ S _ { C } ( \tilde { e } _ { x ^ { ( i ) } } , \tilde { e } _ { a ^ { ( 1 ) } } ) , \dots , S _ { C } ( \tilde { e } _ { x ^ { ( i ) } } , \tilde { e } _ { a ^ { ( | k | ) } } ) ] ,
75
+ $$
76
+
77
+ where $\tilde { { \pmb e } } _ { { \pmb x } ^ { ( i ) } } = \tilde { E } ( { \pmb x } ^ { ( i ) } ) = { \pmb T } E ( { \pmb x } ^ { ( i ) } )$ and $\mathbf { T }$ is an arbitrary angle-preserving transformation. A practical application of this invariance is the possibility of comparing latent spaces across multiple trainings, and re-using models as demonstrated in Sections 4 and 5.
78
+
79
+ We remark that other choices of similarity function can be made to enforce different invariances into the representation. For example, one may impose invariance to non-isometric deformations with bounded distortion. We did not find this to be necessary in our experiments, as typically NNs that generalize sufficiently well can handle small perturbations. Nevertheless, this invariance can be enforced by design with vector quantization algorithms. Figure 7 shows a preliminary investigation, leaving further exploration to future work.
80
+
81
+ # 4 LATENT SPACE COMMUNICATION
82
+
83
+ In this section, we demonstrate how our relative representations can effectively be used to produce latent spaces that are stable under a variety of factors. Our main question is the following: Given two different learning models that are trained separately on different data, can we compare their latent embeddings? In asking this, we assume that the two models are trained on a similar phenomenon, e.g., on two different samplings of the English language or on two different modalities.
84
+
85
+ We answer in the positive, showing the gained invariance enables effective communication between different, but semantically equivalent latent spaces. In particular, we analyze how different word embedding spaces, once projected onto relative representations, are intrinsically the same (Section 4.1); we then show how the similarity between the relative counterparts of two or more embedding spaces is a surprisingly good predictor of model performance (Section 4.2); finally, we confirm that relative representations in the training phase are not detrimental to performance (Section 4.3).
86
+
87
+ # 4.1 WORD EMBEDDINGS
88
+
89
+ Experimental setting. We select two different word embeddings on the English language, namely FastText (Bojanowski et al., 2017) and Word2Vec (Mikolov et al., 2013a). Both models are pre-trained on different data, but partly share a vocabulary from which we extract $\approx 2 0 \mathrm { K }$ words. Using 300 randomly drawn parallel anchor, we convert each embedding space to a relative one. In Table 1 (left), we show the original and the relative embeddings. For each word $w$ , we consider its corresponding encodings $x$ and $y$ in the source and target space. We apply three different metrics to measure their similarity (in a setting similar to Vulic et al. (2020)): (i) ´ Jaccard: the discrete Jaccard similarity between the set of word neighbors of $x$ in source and target; (ii) Mean Reciprocal Rank: measures the (reciprocal) ranking of $w$ among the top- $\mathbf { \nabla } \cdot \mathbf { k }$ neighbors of $x$ in the target space; (iii) Cosine: measures the cosine similarity between $x$ and $y$ . Additional details in Appendix A.5.1
90
+
91
+ <table><tr><td></td><td>Source</td><td>Target</td><td> Jaccard ↑</td><td>MRR ↑</td><td>Cosine ↑</td></tr><tr><td rowspan="3">Jahsose</td><td>FT</td><td>FT</td><td>1.00 ±0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td>W2V</td><td>0.00±0.00</td><td>0.00±0.00</td><td>0.01± 0.00</td></tr><tr><td>W2V</td><td>FT W2V</td><td>0.00 ±0.00 1.00 ± 0.00</td><td>0.00±0.00 1.00 ±0.00</td><td>0.01 ±0.00 1.00 ±0.00</td></tr><tr><td rowspan="4">Rrialer</td><td>FT</td><td>FT</td><td>1.00 ±0.00</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td></tr><tr><td rowspan="3">W2V</td><td>W2V</td><td>0.34± 0.01</td><td>0.94±0.00</td><td>0.86 ±0.00</td></tr><tr><td>FT</td><td>0.39 ± 0.00</td><td>0.98 ±0.00</td><td>0.86 ± 0.00</td></tr><tr><td>W2V</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td><td>1.00 ±0.00</td></tr></table>
92
+
93
+ ![](images/e59864c5d260a1e1451d0a2703f2d079afb4d21f5558dc42f72f0166a6bc005a.jpg)
94
+ Table 1: Qualitative (left) and quantitative (right) comparisons of English word embeddings using absolute and relative representations. PCA is applied only for visualization. All metrics are calculated with $K = 1 0$ averaged over 20k words and across 10 different random seeds. See Figure 10 for other dimensionality reductions and Table 8 and fig. 11 for the same experiment on CIFAR-10.
95
+
96
+ Result analysis. Table 1 (left) highlights clusters of semantically similar words and shows that the absolute representations are incoherent across the two latent spaces, while the relative embeddings are highly similar. The average Jaccard distance reported in Table $1 \left( r i g h t \right)$ , says that the word neighborhoods of the relative representations are matched exactly $34 \%$ of the time in one direction, and $39 \%$ of the time in the other one (the missing $61 \%$ is due to semantic differences, that are not taken into account by the discrete nature of the Jaccard metric). By contrast, the absolute embeddings are never matched exactly (Jaccard score equal to zero); for a match to happen, it would mean that the FastText and Word2Vec embeddings of a given English word are almost the same, which is highly unlikely. MRR, close to a perfect score for the relative representations, shows that the most-similar word to a given one is usually itself, even if their cosine similarity doesn’t reach 1.
97
+
98
+ Overall, these results show that relative representations are preserved across different word embedding models, validating our assumptions.
99
+
100
+ # 4.2 LATENT DISTANCE AS A PERFORMANCE PROXY
101
+
102
+ Experimental setting. In this experiment, we consider a node classification task on the Cora graph dataset (Sen et al., 2008). We first train a reference model that achieves good accuracy on a validation set. Then, we train $\approx 2 0 0 0$ models with various combinations of seed, number of epochs, number of layers, dropout probability, activation functions, optimizer type, learning rate or type of graph embedder (Table 10). All the models are classically trained using absolute representations, which are converted to relative post-training by projecting the embeddings onto 300 randomly drawn but fixed anchors. For each model, we measure its classification accuracy and compute the similarity of its space with the reference one. This similarity is computed as the average cosine similarity between the node embeddings produced by a given model and the corresponding embeddings in the reference.
103
+
104
+ Result analysis. The scatter plot in Figure 3 (left) shows that better-performing models tend to be the ones with the latent spaces most similar to the reference. The performance-similarity correlation also holds over time, as shown in Figure 3 (right). Additional correlation examples are in Figure 9. Interestingly, this metric is differentiable, enabling an explicit supervision signal on the latent space, which does not require labeled data and could be readily exploited in a teacher-student framework.
105
+
106
+ ![](images/e645f6e5351e6453321f66c7913f05c50aa118db31f672176885ed47245563cd.jpg)
107
+ Figure 3: Graph node classification task on Cora. Left: Correlation between the performance of $\approx 2 0 0 0$ models and the similarity of their latent spaces with respect to a well-performing reference model. Right: The same correlation plotted over time. The mean Pearson correlation over all models is 0.955, after filtering out the models having best validation accuracy below 0.5.
108
+
109
+ Overall, these results suggest that the similarity between the relative representations of latent spaces is a remarkably good proxy to evaluate model performance.
110
+
111
+ # 4.3 TRAINING WITH ABSOLUTE VS. RELATIVE REPRESENTATIONS
112
+
113
+ Experimental setting. Finally, we compare architectures that do or do not employ the relative representation while training. In these experiments, the models vary slightly according to the dataset; however, the relative and absolute versions are always comparable in terms of architecture, number of learnable parameters and hyperparameters. We refer to the supplementary material and the open-source code for further details on their implementation. In this section we consider classification tasks on several datasets, spanning the image domain (Lecun et al., 1998; Xiao et al., 2017; Krizhevsky, 2009) and the graph domain (Yang et al., 2016).
114
+
115
+ Table 2: Performance comparison between relative and absolute representations on several image and graph datasets. The metric is the classification weighted F1 score $\pm$ std), over 6 seeds.
116
+
117
+ <table><tr><td rowspan="2"></td><td colspan="4">Image Classification</td><td colspan="3">Graph Node Classification</td></tr><tr><td>MNIST</td><td>F-MNIST</td><td>CIFAR-10</td><td>CIFAR-100</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td></tr><tr><td>Relative</td><td>97.91 ± 0.07</td><td>90.19 ±0.27</td><td>87.70±0.09</td><td>66.72±0.35</td><td>0.89 ±0.02</td><td>0.77±0.03</td><td>0.91±0.01</td></tr><tr><td>Absolute</td><td>97.95 ± 0.10</td><td>90.32±0.21</td><td>87.85±0.06</td><td>68.88±0.14</td><td>0.90 ±0.01</td><td>0.78±0.03</td><td>0.91 ±0.01</td></tr></table>
118
+
119
+ Result analysis. The results, reported in Table 2, show that relative representations, when used at training time, are not detrimental to performance in general. This is further shown in Tables 3 to 6 and 15 to 18, where a subset of the results compares the absolute and relative representations on a variety of domains, datasets and tasks.
120
+
121
+ Overall, these results show that relative representations are effective when involved in end-to-end training, without significant performance drops.
122
+
123
+ # 5 ZERO-SHOT MODEL STITCHING
124
+
125
+ In this section, we illustrate how the latent space communication demonstrated in Section 4 enables zero-shot interoperability of pre-trained neural components. In previous works, such as Lenc & Vedaldi (2015); Bansal et al. (2021), stitching layers are trainable linear projections that allow swapping parts of different networks. Instead, on relative representations unlocks the possibility of zero-shot stitching different neural components, treating them as frozen black-box modules.
126
+
127
+ We define a generic stitched model as the composition of an encoder, that embeds data, plus a relative decoder specialized in a downstream task (classification, reconstruction). The stitching operation is always performed without training or fine-tuning, in a zero-shot fashion. Hereafter, we showcase stitching capabilities across combinations of different stochasticity sources (Figure 4 and table 3), neural architectures (Tables 4 and 5) or datasets (Table 6). Finally, we present strong real-world applications in NLP (Section 5.2) and CV (Section 5.3), e.g. zero-shot predictions on novel languages. Additional implementation details are given in the supplementary materials.
128
+
129
+ ![](images/cbf4165bfb61c2392438cf4e3a31d23fe576c723ff1ea0d0580bdbad11ad8806.jpg)
130
+ Figure 4: Reconstruction examples. Each column is a different image, row pairs are different architectures. In each pair, we first report the non-stitched reconstructions, then the stitched ones.
131
+
132
+ # 5.1 IMAGE RECONSTRUCTION
133
+
134
+ Experimental setting. We perform zero-shot stitching with AEs and VAEs trained with relative representations end-to-end on several datasets. For each combination of model and dataset, we perform 5 trainings with different seeds, and zero-shot stitch together the resulting encoders and decoders.
135
+
136
+ Result analysis. In Figure 4 the stitched models that employ absolute representations $( A b s . )$ produce erroneous predictions, since the latent spaces obtained from distinct trainings are incompatible. Interestingly, although the absolute VAE does not produce compatible latent spaces, it is regularized, thus all embeddings produced by the encoders correspond to wrong but semantically meaningful reconstructions. Relative representations $( R e l . )$ exhibit almost indistinguishable reconstructions between the models trained end-to-end and the stitched ones. Quantitative results are in Table 3.
137
+
138
+ These results support our claim that relative representations are empirically invariant to training stochasticity.
139
+
140
+ Table 3: Stitching performance. The MSE $\pm$ std) between the ground truth $\mathbb { X }$ and the reconstructions is computed over 5 different seeds. Stitching with our relative representations yields an error up to two orders of magnitude less than the absolute counterpart.
141
+
142
+ <table><tr><td></td><td></td><td></td><td>MNIST</td><td>F-MNIST</td><td>CIFAR-10</td><td>CIFAR-100</td><td>MSE↓</td></tr><tr><td rowspan="4">E</td><td>&#x27;qead</td><td>Non-Stitch.</td><td>0.66±0.02</td><td>1.57 ± 0.03</td><td>1.94 ± 0.08</td><td>2.13±0.08</td><td>1.58 ± 0.05</td></tr><tr><td></td><td>Stitch.</td><td>97.79 ± 2.48</td><td>120.54 ± 6.81</td><td>86.74 ± 4.37</td><td>97.17 ± 3.50</td><td>100.56 ± 4.29</td></tr><tr><td></td><td>Non-Stitch.</td><td>1.18 ± 0.02</td><td>3.59 ± 0.04</td><td>2.83 ±0.13</td><td>3.50 ±0.08</td><td>2.78±0.07</td></tr><tr><td></td><td>Stitch.</td><td>2.83±0.20</td><td>6.37 ±0.29</td><td>5.39 ± 1.18</td><td>18.03 ± 12.46</td><td>8.16 ±3.53</td></tr><tr><td rowspan="4">E</td><td></td><td>Non-Stitch.</td><td>1.31 ± 0.04</td><td>4.38±0.03</td><td>2.68±0.06</td><td>3.00 ±0.03</td><td>2.84± 0.04</td></tr><tr><td></td><td>Stitch.</td><td>98.51 ± 1.49</td><td>118.96 ± 2.96</td><td>69.02 ± 1.54</td><td>78.57 ± 1.88</td><td>91.27 ± 1.97</td></tr><tr><td>&#x27;qePd</td><td>Non-Stitch.</td><td>2.97 ± 0.14</td><td>6.81 ±0.06</td><td>5.18 ±0.22</td><td>5.93 ± 0.14</td><td>5.22 ± 0.14</td></tr><tr><td></td><td>Stitch.</td><td>13.43 ±6.79</td><td>24.03 ± 13.15</td><td>11.20 ± 3.15</td><td>11.23 ± 2.38</td><td>14.97 ± 6.37</td></tr></table>
143
+
144
+ # 5.2 TEXT CLASSIFICATION
145
+
146
+ In this Section, we show practical examples of the use of parallel anchors (Sec 3.1).
147
+
148
+ Table 4: Cross-lingual stitching performance comparison. The table reports the mean weighted F1 $\pm$ std) and MAE on Amazon Reviews coarse-grained, across 5 seeds.
149
+
150
+ <table><tr><td></td><td></td><td colspan="2">Absolute</td><td colspan="4">Relative</td></tr><tr><td></td><td></td><td></td><td></td><td colspan="2">Translated</td><td colspan="2">Wikipedia</td></tr><tr><td>Decoder</td><td>Encoder</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td></tr><tr><td></td><td>en</td><td>91.54 ± 0.58</td><td>0.08 ±0.01</td><td>90.06 ± 0.60</td><td>0.10 ±0.01</td><td>90.45 ± 0.52</td><td>0.10 ±0.01</td></tr><tr><td>en</td><td>es</td><td>43.67 ± 1.09</td><td>0.56±0.01</td><td>82.78±0.81</td><td>0.17 ± 0.01</td><td>78.53 ± 0.30</td><td>0.21±0.00</td></tr><tr><td></td><td>fr</td><td>54.41 ± 1.61</td><td>0.45 ± 0.02</td><td>78.49 ±0.66</td><td>0.21± 0.01</td><td>70.41 ± 0.57</td><td>0.29 ±0.01</td></tr><tr><td></td><td>ja</td><td>48.72 ±0.90</td><td>0.51±0.01</td><td>65.72 ± 0.55</td><td>0.34±0.01</td><td>66.31 ± 0.80</td><td>0.34 ±0.01</td></tr></table>
151
+
152
+ Table 5: Cross-architecture stitching performance comparison. The table reports the mean weighted F1 $\pm$ std) for each dataset, across 5 different seeds.
153
+
154
+ <table><tr><td></td><td>TREC</td><td></td><td>DBpedia</td><td colspan="2">Amazon Reviews</td></tr><tr><td></td><td></td><td></td><td></td><td>Coarse</td><td>Fine</td></tr><tr><td></td><td>Non-Stitch</td><td>91.70 ± 1.39</td><td>98.62 ± 0.58</td><td>87.81 ± 1.58</td><td>55.35 ± 3.19</td></tr><tr><td>A</td><td>Stitch</td><td>21.49 ± 3.64</td><td>6.96 ± 1.46</td><td>49.58 ± 2.95</td><td>19.01 ± 2.04</td></tr><tr><td></td><td>Non-Stitch</td><td>88.08 ± 1.37</td><td>97.42 ± 2.05</td><td>85.08 ± 1.93</td><td>48.92 ± 3.57</td></tr><tr><td>3</td><td>Stitch</td><td>75.89 ± 5.38</td><td>80.47 ± 21.14</td><td>72.37 ± 7.32</td><td>33.24 ± 7.21</td></tr></table>
155
+
156
+ Experimental setting. We consider two different text classification settings.
157
+
158
+ Cross-lingual: given a review predict the associated star rating, done on multi-lingual data from the Amazon Reviews dataset (Keung et al., 2020). Following the original paper, we work on a binarized version of the task, with FScore and MAE as metrics. In the supplementary material, we report results on the fine-grained formulation. We adopt four different pre-trained languagespecific RoBERTa transformers (Liu et al., 2019) and evaluate their zero-shot stitching performance on languages never seen by the classifier. We use parallel anchors in two modalities: i) Translated: consider English reviews translated2 into the other languages; ii) Wikipedia: adopt an external corpus, WikiMatrix (Schwenk et al., 2021), providing parallel sentences extracted from Wikipedia.
159
+
160
+ Cross-architecture: assessed on three different datasets: TREC (coarse) (Hovy et al., 2001), DBpedia (Zhang et al., 2015), Amazon Reviews (English split). We adopt two different pretrained BERT (Devlin et al., 2019) transformers (cased and uncased version), ELECTRA (Clark et al., 2020) and RoBERTa.
161
+
162
+ Result analysis. Tables 4 and 5 show for the first time that it is possible to learn to solve a downstream task on a specific language or transformer and perform predictions on another.
163
+
164
+ Stitching with absolute representations yields performances comparable to random guessing across the board, proving that relative representations are a key element for the success of this kind of zero-shot stitching. Moreover, Table 4 highlights the robustness that relative representations have on the choice of anchors, even when they are noisy (Translated case), or their distribution differs from the one of the downstream task (Wikipedia case), as long as their encoding can be handled correctly by the encoder. In our case, the encoder is pre-trained to represent a variety of texts in a specific language, thus, even if WikiMatrix has a completely different domain from Amazon Reviews, the transformer still computes a meaningful and comparable representation with those of the reviews. We report in Tables 15 and 16 complete results on all languages combination, and in Table 17 the performance obtained by a multi-lingual transformer. To the best of our knowledge, it is the only alternative for obtainining compatible representations across languages.
165
+
166
+ According to these results, relative representations show invariance to different architectures and data distribution shifts (e.g., different train languages).
167
+
168
+ # 5.3 IMAGE CLASSIFICATION
169
+
170
+ In this Section, we show practical examples of the use of OOD anchors (Sec 3.1).
171
+
172
+ Table 6: Stitching performance comparison with different encoding techniques. The table reports the mean weighted F1 $\pm$ std) on CIFAR-100 coarse-grained and ImageNet1k, across 5 seeds.
173
+
174
+ <table><tr><td rowspan="2">Decoder</td><td rowspan="2">Encoder</td><td colspan="2">CIFAR-100</td><td colspan="2">ImageNet1k</td></tr><tr><td>Absolute</td><td>Relative</td><td>Absolute</td><td>Relative</td></tr><tr><td rowspan="4">rexnet-100</td><td>rexnet-100</td><td>82.06 ±0.15</td><td>80.22±0.28</td><td>73.78±0.29</td><td>72.61 ± 0.16</td></tr><tr><td>vit-base-patch16-224</td><td></td><td>54.98 ± 0.44</td><td></td><td>37.39 ±0.36</td></tr><tr><td>vit-base-resnet50-384</td><td></td><td>53.33 ± 0.37</td><td></td><td>42.36 ±0.36</td></tr><tr><td>vit-small-patch16-224</td><td></td><td>59.82 ±0.32</td><td>=</td><td>43.75 ±0.27</td></tr><tr><td rowspan="4">vit-base-patch16-224</td><td>rexnet-100</td><td></td><td>76.81 ± 0.49</td><td></td><td>30.78 ±0.81</td></tr><tr><td>vit-base-patch16-224</td><td>93.15 ±0.05</td><td>91.94 ± 0.10</td><td>80.91 ±0.29</td><td>78.86 ±0.33</td></tr><tr><td>vit-base-resnet50-384</td><td>6.21 ±0.33</td><td>81.42 ±0.38</td><td>0.07±0.05</td><td>44.72±0.57</td></tr><tr><td>vit-small-patch16-224</td><td></td><td>84.29 ±0.86</td><td></td><td>48.31 ± 0.72</td></tr><tr><td rowspan="4">vit-base-resnet50-384</td><td>rexnet-100</td><td></td><td>79.79 ± 0.43</td><td></td><td>53.46 ±0.68</td></tr><tr><td>vit-base-patch16-224</td><td>4.69 ± 0.07</td><td>84.46 ±0.19</td><td>0.08 ±0.04</td><td>62.21 ± 0.54</td></tr><tr><td>vit-base-resnet50-384</td><td>91.41 ± 0.09</td><td>90.77 ±0.16</td><td>82.55 ±0.30</td><td>81.88 ±0.16</td></tr><tr><td>vit-small-patch16-224</td><td></td><td>84.66±0.16</td><td>=</td><td>61.32 ±0.36</td></tr><tr><td rowspan="4">vit-small-patch16-224</td><td>rexnet-100</td><td></td><td>75.35 ± 0.41</td><td></td><td>37.58 ± 0.44</td></tr><tr><td>vit-base-patch16-224</td><td></td><td>81.23 ± 0.31</td><td></td><td>50.08 ±0.63</td></tr><tr><td>vit-base-resnet50-384</td><td></td><td>78.35 ± 0.69</td><td></td><td>45.45 ± 1.41</td></tr><tr><td>vit-small-patch16-224</td><td>90.07 ± 0.19</td><td>88.85±0.44</td><td>77.73 ± 0.41</td><td>76.36 ±0.40</td></tr></table>
175
+
176
+ Experimental setting. We consider a classification task on ImageNet1k and CIFAR-100 with coarse labels (20), and 4 different pre-trained image encoders: three variants of the ViT transformer (Dosovitskiy et al., 2021) and RexNet (Han et al., 2020).
177
+
178
+ Result analysis. The results in Table 6 highlight how the relative representations allow stitching modules with different encoding dimensionality, since the decoder receives a relative representation with guaranteed equal size. Further, the results demonstrate the ability to generalize and perform zero-shot stitching on CIFAR-100, although that data was never seen by the encoder since it is a frozen transformer trained on ImageNet1k. Interestingly, rexnet $- 1 0 0$ is the only transformer whose latent dimensionality is higher than the number of anchors, and the biggest drop in stitching performance happens when the decoder is trained on it. This suggests the number of anchors is an important hyperparameter; we refer to Figure 6 for a deeper analysis.
179
+
180
+ Overall, these results prove that relative representations can bridge general-purpose encoders and pre-trained task-specific decoders.
181
+
182
+ # 6 CONCLUSION
183
+
184
+ In this work, we introduced the concept of relative representations to enable zero-shot latent space communication, with several practical consequences as showcased in our discussion and experiments. Our work proves that a latent semantic correspondence between data domains, when present, can be exploited through a simple representation shift, without resorting to sophisticated processing or heavy training.
185
+
186
+ Limitations and future work. Our work is open to several follow-up directions. While in this paper we considered the cosine similarity, different functions can enforce additional invariances in the relative representation. The study of invariant latent spaces as a general direction has the potential to lead to further impact; in Figure 7 we showed preliminary results of this possibility. Another interesting line of research to improve the representation expressivity would be to estimate geodesic distances over the data manifold instead of adopting Euclidean approximations. Similarly, we believe that the connections between the composition of the anchors set A and the expressivity of relative representations demands additional research. For example, the training cost is directly affected by the number and update frequency of the anchors. Finally, the stitching procedure may be extended to multiple layers, promoting reusable network components.
187
+
188
+ # ACKNOWLEDGMENTS
189
+
190
+ The authors gratefully acknowledge the anonymous reviewers for the thoughtful remarks, and Luigi Gresele for the insightful discussions. This work is supported by the ERC Starting Grant No. 802554 (SPECGEO).
191
+
192
+ # REPRODUCIBILITY STATEMENT
193
+
194
+ We describe in detail the relative representation computation in Section 3.1. We describe the experimental settings for the various scenarios, and refer to the supplementary material for further implementation details (Appendix A.5). Moreover, we release a well-documented and modular codebase, with the relative representation layer being implemented as a stand-alone PyTorch module. All the checkpoints used in the experiments are versioned with DVC (Kuprieiev et al., 2023) to easily reproduce all the figures and tables. The stand-alone module allows the integration of the relative representations in any existing neural network effortlessly.
195
+
196
+ # REFERENCES
197
+
198
+ David Alvarez-Melis, Stefanie Jegelka, and Tommi S. Jaakkola. Towards optimal transport with global invariances. In Kamalika Chaudhuri and Masashi Sugiyama (eds.), The 22nd International Conference on Artificial Intelligence and Statistics, AISTATS 2019, 16-18 April 2019, Naha, Okinawa, Japan, volume 89 of Proceedings of Machine Learning Research, pp. 1870–1879. PMLR, 2019. URL http://proceedings.mlr.press/v89/alvarez-melis19a.html.
199
+
200
+ Richard Antonello, Javier S Turek, Vy Vo, and Alexander Huth. Low-dimensional structure in the space of language representations is reflected in brain responses. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, volume 34, pp. 8332–8344. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper/2021/file/ 464074179972cbbd75a39abc6954cd12-Paper.pdf.
201
+
202
+ Yamini Bansal, Preetum Nakkiran, and Boaz Barak. Revisiting model stitching to compare neural representations. In Marc’Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan (eds.), Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pp. 225–236, 2021. URL https://proceedings.neurips.cc/ paper/2021/hash/01ded4259d101feb739b06c399e9cd9c-Abstract.html.
203
+
204
+ Serguei Barannikov, Ilya Trofimov, Nikita Balabin, and Evgeny Burnaev. Representation topology divergence: A method for comparing neural network representations. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato (eds.), Proceedings of the 39th International Conference on Machine Learning, volume 162 of Proceedings of Machine Learning Research, pp. 1607–1626. PMLR, 2022. URL https://proceedings. mlr.press/v162/barannikov22a.html.
205
+
206
+ Federico Bianchi, Jacopo Tagliabue, Bingqing Yu, Luca Bigon, and Ciro Greco. Fantastic embeddings and how to align them: Zero-shot inference in a multi-shop scenario. ArXiv preprint, abs/2007.14906, 2020. URL https://arxiv.org/abs/2007.14906.
207
+
208
+ Lukas Biewald. Experiment tracking with weights and biases, 2020. URL https://www. wandb.com/. Software available from wandb.com.
209
+
210
+ Niccolo Biondi, Federico Pernici, Matteo Bruni, and Alberto Del Bimbo. Cores: Compatible representations via stationarity. ArXiv preprint, abs/2111.07632, 2021. URL https: //arxiv.org/abs/2111.07632.
211
+
212
+ Piotr Bojanowski, Edouard Grave, Armand Joulin, and Tomas Mikolov. Enriching word vectors with subword information. Transactions of the Association for Computational Linguistics, 5:135–146, 2017. doi: 10.1162/tacl a 00051. URL https://aclanthology.org/Q17-1010.
213
+
214
+ Lisa Bonheme and Marek Grzes. How do variational autoencoders learn? insights from representational similarity, 2022. URL https://arxiv.org/abs/2205.08399.
215
+
216
+ Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. ELECTRA: pretraining text encoders as discriminators rather than generators. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. URL https://openreview.net/forum?id $=$ r1xMH1BtvB.
217
+
218
+ Adrian Csisz ´ arik, P ´ eter K ´ or˝ osi-Szab ¨ o,´ Akos K. Matszangosz, Gergely Papp, and D ´ aniel Varga.´ Similarity and matching of neural network representations, 2021. URL https://arxiv. org/abs/2110.14633.
219
+
220
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://aclanthology.org/N19-1423.
221
+
222
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum? id $=$ YicbFdNTTy.
223
+
224
+ William Falcon and The PyTorch Lightning team. PyTorch Lightning, 2019. URL https:// github.com/Lightning-AI/lightning.
225
+
226
+ Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds, 2019.
227
+
228
+ GrokAI. nn-template bootstraps pytorch projects by advocating reproducibility & best practices in deep learning, 2021. URL https://github.com/grok-ai/nn-template. Software available from https://github.com/grok-ai/.
229
+
230
+ Michael Gygli, Jasper Uijlings, and Vittorio Ferrari. Towards reusable network components by learning compatible representations. AAAI, 35(9):7620–7629, 2021.
231
+
232
+ Dongyoon Han, Sangdoo Yun, Byeongho Heo, and YoungJoon Yoo. Rethinking channel dimensions for efficient model design. ArXiv preprint, abs/2007.00992, 2020. URL https://arxiv. org/abs/2007.00992.
233
+
234
+ Thomas Hofmann, Bernhard Scholkopf, and Alexander J Smola. Kernel methods in machine learn- ¨ ing. The annals of statistics, 36(3):1171–1220, 2008.
235
+
236
+ Eduard Hovy, Laurie Gerber, Ulf Hermjakob, Chin-Yew Lin, and Deepak Ravichandran. Toward semantics-based answer pinpointing. In Proceedings of the First International Conference on Human Language Technology Research, 2001. URL https://aclanthology.org/ H01-1069.
237
+
238
+ Phillip Keung, Yichao Lu, Gyorgy Szarvas, and Noah A. Smith. The multilingual Amazon reviews ¨ corpus. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 4563–4568, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.369. URL https://aclanthology.org/2020. emnlp-main.369.
239
+
240
+ Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey E. Hinton. Similarity of neural network representations revisited. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9- 15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 3519–3529. PMLR, 2019. URL http://proceedings.mlr.press/v97/ kornblith19a.html.
241
+
242
+ Jannik Kossen, Neil Band, Clare Lyle, Aidan N. Gomez, Tom Rainforth, and Yarin Gal. Selfattention between datapoints: Going beyond individual input-output pairs in deep learning, 2021. URL https://arxiv.org/abs/2106.02584.
243
+
244
+ Nikolaus Kriegeskorte, Marieke Mur, and Peter Bandettini. Representational similarity analysis - connecting the branches of systems neuroscience. Frontiers in Systems Neuroscience, 2, 2008. ISSN 1662-5137. doi: 10.3389/neuro.06.004.2008.
245
+
246
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. pp. 32–33, 2009. URL https://www.cs.toronto.edu/˜kriz/learning-features-2009-TR.pdf.
247
+
248
+ Ruslan Kuprieiev, skshetry, Dmitry Petrov, Peter Rowlands, Paweł Redzynski, Casper da Costa- ´ Luis, Alexander Schepanovski, Gao, David de la Iglesia Castro, Ivan Shcheklein, Batuhan Taskaya, Jorge Orpinel, Fabio Santos, Dave Berenbaum, daniele, Ronan Lamy, Aman Sharma, ´ Zhanibek Kaimuldenov, Dani Hodovic, Nikita Kodenko, Andrew Grigorev, Earl, Nabanita Dash, George Vyshnya, maykulkarni, Max Hora, Vera, and Sanidhya Mangal. Dvc: Data version control - git for data & models, 2023. URL https://doi.org/10.5281/zenodo.7646429.
249
+
250
+ Aarre Laakso and G. Cottrell. Content and cluster analysis: Assessing representational similarity in neural systems. Philosophical Psychology, 13:47 – 76, 2000.
251
+
252
+ Guillaume Lample, Alexis Conneau, Marc’Aurelio Ranzato, Ludovic Denoyer, and Herve J ´ egou. ´ Word translation without parallel data. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id $\equiv$ H196sainb.
253
+
254
+ Y Lecun, L Bottou, Y Bengio, and P Haffner. Gradient-based learning applied to document recognition. Proc. IEEE, 86(11):2278–2324, 1998.
255
+
256
+ Karel Lenc and Andrea Vedaldi. Understanding image representations by measuring their equivariance and equivalence. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pp. 991–999. IEEE Computer Society, 2015. doi: 10. 1109/CVPR.2015.7298701. URL https://doi.org/10.1109/CVPR.2015.7298701.
257
+
258
+ Quentin Lhoest, Albert Villanova del Moral, Yacine Jernite, Abhishek Thakur, Patrick von Platen, Suraj Patil, Julien Chaumond, Mariama Drame, Julien Plu, Lewis Tunstall, Joe Davison, Mario Saˇ sko, Gunjan Chhablani, Bhavitvya Malik, Simon Brandeis, Teven Le Scao, Victor Sanh, Can- ˇ wen Xu, Nicolas Patry, Angelina McMillan-Major, Philipp Schmid, Sylvain Gugger, Clement ´ Delangue, Theo Matussi ´ ere, Lysandre Debut, Stas Bekman, Pierric Cistac, Thibault Goehringer, \` Victor Mustar, Franc¸ois Lagunas, Alexander Rush, and Thomas Wolf. Datasets: A community library for natural language processing. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 175–184, Online and Punta Cana, Dominican Republic, 2021. Association for Computational Linguistics. doi: 10.18653/v1/ 2021.emnlp-demo.21. URL https://aclanthology.org/2021.emnlp-demo.21.
259
+
260
+ Yixuan Li, Jason Yosinski, Jeff Clune, Hod Lipson, and John E. Hopcroft. Convergent learning: Do different neural networks learn the same representations? In Yoshua Bengio and Yann LeCun (eds.), 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/ 1511.07543.
261
+
262
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. ArXiv preprint, abs/1907.11692, 2019. URL https://arxiv.org/abs/1907. 11692.
263
+
264
+ Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. Efficient estimation of word representations in vector space. ArXiv preprint, abs/1301.3781, 2013a. URL https://arxiv.org/ abs/1301.3781.
265
+
266
+ Tomas Mikolov, Quoc V. Le, and Ilya Sutskever. Exploiting similarities among languages for ma- ´ chine translation. CoRR, abs/1309.4168, 2013b. URL http://arxiv.org/abs/1309. 4168.
267
+
268
+ Ari S. Morcos, Maithra Raghu, and Samy Bengio. Insights on representational similarity in neural networks with canonical correlation. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolo Cesa-Bianchi, and Roman Garnett (eds.), \` Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, Canada ´ , pp. 5732–5741, 2018. URL https://proceedings.neurips.cc/paper/2018/hash/ a7a3d70c6d17a73140918996d03c014f-Abstract.html.
269
+
270
+ Antonio Norelli, Marco Fumero, Valentino Maiorca, Luca Moschella, Emanuele Rodola, and \` Francesco Locatello. Asif: Coupled data turns unimodal models to multimodal without training, 2022. URL https://arxiv.org/abs/2210.01738.
271
+
272
+ Christopher Olah. Visualizing representations: Deep learning and human beings. http: //colah.github.io/posts/2015-01-Visualizing-Representations/, 2015. Accessed: 2022-8-2.
273
+
274
+ Rajeev DS Raizada and Andrew C Connolly. What makes different people’s representations alike: neural similarity space solves the problem of across-subject fmri decoding. Journal of cognitive neuroscience, 24(4):868–877, 2012.
275
+
276
+ Holger Schwenk, Vishrav Chaudhary, Shuo Sun, Hongyu Gong, and Francisco Guzman. Wiki- ´ Matrix: Mining 135M parallel sentences in 1620 language pairs from Wikipedia. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pp. 1351–1361, Online, 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.115. URL https://aclanthology.org/2021. eacl-main.115.
277
+
278
+ Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina EliassiRad. Collective Classification in Network Data. AIMag., 29(3):93, 2008. ISSN 2371-9621. doi: 10.1609/aimag.v29i3.2157.
279
+
280
+ Daniel Shalam and Simon Korman. The self-optimal-transport feature transform. ArXiv preprint, abs/2204.03065, 2022. URL https://arxiv.org/abs/2204.03065.
281
+
282
+ Jake Snell, Kevin Swersky, and Richard S. Zemel. Prototypical networks for few-shot learning. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 4077–4087, 2017. URL https://proceedings.neurips.cc/ paper/2017/hash/cb8da6767461f2812ae4290eac7cbc42-Abstract.html.
283
+
284
+ Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, and Nathan Srebro. The implicit bias of gradient descent on separable data. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id $=$ r1q7n9gAb.
285
+
286
+ Anton Tsitsulin, Marina Munkhoeva, Davide Mottin, Panagiotis Karras, Alexander M. Bronstein, Ivan V. Oseledets, and Emmanuel Muller. The shape of data: Intrinsic distance for data distribu-¨ tions. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. URL https://openreview.net/ forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HyebplHYwB.
287
+
288
+ Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. ArXiv preprint, abs/1607.08022, 2016. URL https://arxiv. org/abs/1607.08022.
289
+
290
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 5998–6008, 2017. URL https://proceedings.neurips.cc/paper/2017/hash/ 3f5ee243547dee91fbd053c1c4a845aa-Abstract.html.
291
+
292
+ Ivan Vulic, Sebastian Ruder, and Anders Søgaard. Are all good word vector spaces isomor- ´ phic? In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 3178–3192, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.257. URL https://aclanthology.org/2020. emnlp-main.257.
293
+
294
+ Liwei Wang, Lunjia Hu, Jiayuan Gu, Zhiqiang Hu, Yue Wu, Kun He, and John E. Hopcroft. Towards understanding learning representations: To what extent do different neural networks learn the same representation. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolo Cesa-Bianchi, and Roman Garnett (eds.), \` Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, Canada ´ , pp. 9607–9616, 2018. URL https://proceedings.neurips.cc/paper/2018/hash/ 5fc34ed307aac159a30d81181c99847e-Abstract.html.
295
+
296
+ Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 38–45, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-demos.6. URL https: //aclanthology.org/2020.emnlp-demos.6.
297
+
298
+ Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017. URL https://arxiv.org/abs/1708.07747.
299
+
300
+ Muammer Y. Yaman, Sergei V. Kalinin, Kathryn N. Guye, David Ginger, and Maxim Ziatdinov. Learning and predicting photonic responses of plasmonic nanoparticle assemblies via dual variational autoencoders, 2022. URL https://arxiv.org/abs/2208.03861.
301
+
302
+ Zhilin Yang, William W. Cohen, and Ruslan Salakhutdinov. Revisiting semi-supervised learning with graph embeddings. In Maria-Florina Balcan and Kilian Q. Weinberger (eds.), Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, volume 48 of JMLR Workshop and Conference Proceedings, pp. 40–48. JMLR.org, 2016. URL http://proceedings.mlr.press/v48/yanga16.html.
303
+
304
+ Xiang Zhang, Junbo Jake Zhao, and Yann LeCun. Character-level convolutional networks for text classification. In Corinna Cortes, Neil D. Lawrence, Daniel D. Lee, Masashi Sugiyama, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 28: Annual Conference on Neural Information Processing Systems 2015, December 7-12, 2015, Montreal, Quebec, Canada, pp. 649–657, 2015. URL https://proceedings.neurips.cc/paper/ 2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html.
305
+
306
+ # A APPENDIX
307
+
308
+ # A.1 HIGH-DIMENSIONAL LATENT SPACES
309
+
310
+ In Figure 1, multiple trainings of the same two-dimensional AE produce intrinsically similar latent spaces; in Figure 5 we show this property also holds on AEs with a high-dimensional bottleneck. In the first row, PCA is fitted indipendently in each column, and since the PCA transformation produces the same output everywhere the latent spaces are intrinsically the same. In the second row, PCA is fitted only on the first latent space; since in this case the PCA transformation produces different outputs, the latent spaces, although intrinsically similar, are extrinsically different.
311
+
312
+ ![](images/2c1a4eb0cf0304a32cebd22f249fca81c45b6c3dc5d012d7e137fae56219f896.jpg)
313
+ Figure 5: Latent spaces learned by distinct trainings of the same high-dimensional AE on the MNIST dataset. Each column is the latent space obtained by the AE with a different seed. On the first row, the dimensionality reduction is performed through PCAs fitted independently on each latent space, meanwhile, on the second row PCA is fitted on the leftmost latent space and then applied to all of them.
314
+
315
+ # A.2 ANCHORS ANALYSIS
316
+
317
+ The cardinality of the anchors set A and the choice of specific anchors is crucial to the quality of the relative representations. At the extreme, selecting one single anchor or the same repeated data points for all anchors, will produce collapsed relative representations. We believe that additional research is required to obtain a better understanding on the optimal choice for A. Questions like “Are anchors set composed only by stopwords worse than the ones composed by meaningful and diverse words?” require empirical evidence and could help revealing the semantics of the latent space. Indeed, each anchor is associated with a dimension in a relative representation; one could inspect the anchor data point to get a sense of the meaning of that latent dimension.
318
+
319
+ Anchor number. Below, we report a preliminary study on the performance sensitivity against the cardinality of the anchors set. In Figure 6 we report the performance on the node classification task on Cora, with a model trained end-to-end adopting the relative representations while training, and on image classification tasks on CIFAR-100, with a frozen encoder. The performance improves monotonically as the number of anchors increase when the absolute representations are frozen (right). Differently, training models end-to-end proves to be more susceptible to model collapse and instabilities, as increasing the number of anchors does not always improve the performance (left). Further research on the relation between the absolute latent space dimensionality and the relative representation dimensionality (i.e., the number of anchors) is needed to clarify how the two quantities impact the performance, when training end-to-end or not.
320
+
321
+ Anchor selection. In Tables 7 and 8, we analyze different anchor selection strategies under an experimental setting analogous to the one described in Section 4.1:
322
+
323
+ ![](images/3d1122155d19339867df6f20cfcf7755116bf302af33428f509ce3716b1f12e3.jpg)
324
+ Figure 6: Accuracy vs Number of anchors. Each point is a trained model. Left: Trained embedder on Cora, node classification. Right: Frozen transformer on Cifar100 coarse-grained, image classification. Left is less stable because the absolute embeddings are trained, and we are working on a domain that is less stable (graphs). Some collapsed examples are not visualized.
325
+
326
+ • uniform The first selection strategy is the same adopted in the main manuscript. We randomly select the anchors with a uniform probability distribution over all the available samples;
327
+ • fps We select the anchors according to a farthest point sampling strategy;
328
+ • kmeans We select the anchors as the words more close to the centroids of K-means clustering with $K =$ number of anchors;
329
+ • $\mathbf { t o p } \{ k \}$ We select the anchors as the $k$ most frequent words, after skipping the first 400 which are mostly stopwords.
330
+
331
+ We expect strategies that better cover the absolute space with anchors to be the most effective ones. Indeed, the results are comparable across selection strategies, but fps reaches everywhere the best Jaccard and MRR scores while $\mathbf { k }$ -means the best Cosine ones. We attribute this behavior to their different nature: they both rely on the geometry of the latent spaces they are applied to, but $\mathbf { k } .$ - means also favors high-density regions, and this can become a negative bias for the task at hand. In general, the uniform sampling is the most straightforward to apply, since it does not require additional computation for the selection process, and still achieves good performances.
332
+
333
+ # A.3 INVARIANCE WITH GUARANTEED BOUNDS
334
+
335
+ In this section, we explore a slightly modified version of the similarity function adopted in the main paper. The experimental setting is the same as in Section 4.1. We want to measure the similarity between pairs of absolute embeddings and their relative counterparts. To get some kind of quantitative measure, we add a similarity score calculated as the pairwise cosine distance between the two embedding types, averaged. Therefore, a lower score indicates the spaces are more similar. On top of the standard relative representations, the ones computed with $s i m = S _ { C }$ , here we try to improve the similarity measure with guaranteed robustness to bounded distortion. In Figure 7 we report preliminary results that adopt this technique: a vector-quantized similarity function produces relative representations which are more similar (they have a lower score). The vector-quantization is done through agglomerative clustering on the absolute embeddings at various thresholds $t$ . We leave to future works the study of the trade-off between guaranteed invariance to arbitrary bounded distorsion and the expressiveness of the resulting representations.
336
+
337
+ # A.4 DATASET INFORMATION
338
+
339
+ In Table 9 we summarize the datasets utilized in our work, and for each one, we specify the number of classes, to give an idea about the classification difficulty.
340
+
341
+ ![](images/cbc9873d6fd2728f9a31abf76a66917ce194b186d1a33096e03038cf27a2fd5a.jpg)
342
+ Figure 7: The FastText and Word2Vec embeddings of a subset of the English dictionary. The score is the pairwise distance average between the two embedding types, thus a lower score indicates the spaces are more similar. The absolute representations appear very dissimilar meanwhile the relative representations yield almost identical spaces. Quantizing the absolute representations by performing agglomerative clustering with distance threshold $t$ produces even more similar spaces.
343
+
344
+ # A.5 IMPLEMENTATION DETAILS
345
+
346
+ In this Section, following the corresponing sections in the main paper, we report implementation details for all the experimental settings considered.
347
+
348
+ Tools & Technologies In all the experiments presented in this work, the following tools were used:
349
+
350
+ • NN-Template GrokAI (2021), to easily bootstrap the project and enforce best practices;
351
+ • PyTorch Lightning (Falcon & The PyTorch Lightning team, 2019), to ensure reproducible results while also getting a clean and modular codebase;
352
+ • Weights and Biases (Biewald, 2020), to log experiments and compare runs across huge sweeps;
353
+ • Transformers by HuggingFace (Wolf et al., 2020), to get ready-to-use transformers for both text and images;
354
+ • Datasets by HuggingFace (Lhoest et al., 2021), to access most of the NLP datasets and ImageNet for CV;
355
+ • DVC (Kuprieiev et al., 2023), for data versioning;
356
+ • PyTorch Geometric (Fey & Lenssen, 2019), to handle graph datasets and get ready-to-use GNN architectures.
357
+
358
+ # A.5.1 WORD EMBEDDINGS
359
+
360
+ For both the Figure and the Table in Section 4.1, the number of anchors is set to 300 for a fair comparison with the dimensionality of the original spaces. For visualization purposes, we needed the figure to both show an easy clusterable and restricted set of word embeddings. They are obtained by subsampling the shared vocabulary with the following procedure: we select 4 random pivot words, and for each of them we consider the top-200 words in their neighborhood. This results in a total of 800 points divided in 4 clusters, the ones used only for the visualization part. For the quantitative part (table results), we select 20K random words from the shared vocabulary with a fixed seed for reproducibility purposes.
361
+
362
+ For the computer vision counterpart (Figure 11 and table 8), the procedure is similar but with the following differences: i) the number of anchors is set to 500 to balance between the different encoding dimensions of the two transformers (384 for ViT-small and 768 for ViT-base); ii) the subsampling for visualization purposes is done by selecting 4 classes and randomly picking 200 samples for each of them;
363
+
364
+ Evaluation metrics Consider the set of $\approx 2 0 \mathrm { k }$ samples $\mathbb { S }$ (words for the NLP test, images for the CV one) and the source space $\mathbb { X }$ and target space $\mathbb { Y }$ and any sample $s \in \mathbb { S }$ , we compute its representation in $\mathbb { X }$ and $\mathbb { Y }$ through the functions $f _ { \mathbb { X } } : \mathbb { S } \to \mathbb { X }$ and $f _ { \mathbb { Y } } : \mathbb { S } \to \mathbb { Y }$ and define the metrics as follows:
365
+
366
+ $$
367
+ \begin{array} { c } { { \displaystyle \mathbf { J a c c a r d } ( \mathrm { s } ) = \frac { \vert \mathrm { K N N } _ { k } ^ { \mathbb { X } } ( f _ { \mathbb { X } } ( s ) ) \cap \mathrm { K N N } _ { k } ^ { \mathbb { Y } } ( f _ { \mathbb { X } } ( s ) ) \vert } { \vert \mathrm { K N N } _ { k } ^ { \mathbb { X } } ( f _ { \mathbb { X } } ( s ) ) \cup \mathrm { K N N } _ { k } ^ { \mathbb { Y } } ( f _ { \mathbb { X } } ( s ) ) \vert } } } \\ { { \displaystyle \mathbf { M R R } ( \mathrm { s } ) = \frac { 1 } { \mathrm { R a n k } _ { \mathbb { Y } } ( f _ { \mathbb { X } } ( s ) , f _ { \mathbb { Y } } ( s ) ) } } } \\ { { \displaystyle \mathbf { C o s i n e } ( \mathrm { s } ) = \frac { f _ { \mathbb { X } } ( s ) \cdot f _ { \mathbb { Y } } ( s ) } { \Vert f _ { \mathbb { X } } ( s ) \Vert \Vert f _ { \mathbb { Y } } ( s ) \Vert } } } \end{array}
368
+ $$
369
+
370
+ where $\mathrm { K N N } _ { k } ^ { \mathbb { A } } ( \pmb { v } )$ is a function that returns the $k$ -top similar samples (according to cosine similarity) to $\pmb { v }$ in the space A, and $\mathrm { R a n k } _ { \mathbb { A } } ( \pmb { v } , \pmb { u } )$ is a function that returns the index at which $\textbf { \em u }$ is found in the ordered $\mathrm { K N N } _ { k } ^ { \mathbb { A } } ( \pmb { v } )$ . The final score for each metric is the mean over each $s \in S$ .
371
+
372
+ # A.5.2 RELATIVE REPRESENTATION SPACE CORRELATIONS
373
+
374
+ In this section, we analyze how similarities in absolute and relative spaces are correlated. Let us consider two spaces alignable in the relative space. We denote elements of the spaces with $\mathbb { A } \in$ $\mathbb { R } ^ { m _ { 1 } \times n _ { 1 } }$ and $\bar { \mathbb { B } } \in \mathbb { R } ^ { m _ { 2 } \times n _ { 2 } }$ and corresponding relative embeddings with $\mathbb { C } \in \mathbb { R } ^ { m _ { 1 } \times d }$ , $\mathbb { D } \in \mathbb { R } ^ { m _ { 2 } \times d }$ . Examples of A and $\mathbb { B }$ can be the FastText and Word2Vec word embedding spaces. We already observed in Table 1 how the spaces A and $\mathbb { B }$ are well aligned in the relative space. We can go further and analyze how self similarities in each space are preserved by the relative transform. In Figure 8, we show that relative representations not only facilitate latent space communication, but also preserve the underlying (absolute) latent space metric up to a certain degree.
375
+
376
+ ![](images/3c9b19beeedacb969c65c3e55a511cca97facb70d0b63fa6a3f45cc4bb62d873.jpg)
377
+ Figure 8: Self similiarities correlations between each space, measured with the Pearson correlation coefficient. In blue, we denote the self similarities in the absolute spaces A, $\mathbb { B }$ of FastText and Word2Vec; in green we depict the relative spaces $\mathbb { C } , \mathbb { D }$ . The correlation in the vertical arrows indicate how much the underlying metric in the abolute space is preserved by the relative coordinate transformation.
378
+
379
+ # A.5.3 LATENT DISTANCE AS A PERFORMANCE PROXY
380
+
381
+ The hyperperameters used in Section 4.2 are summarized in Table 10.
382
+
383
+ A.5.4 TRAINING WITH ABSOLUTE VS. RELATIVE REPRESENTATIONS
384
+
385
+ The models trained on relative representations do not backpropagate through the anchors, which encourages a smoother optimization of the anchors’ representations.
386
+
387
+ Image Classification The architecture is a standard deep CNN. We run a sweep for each dataset where we vary only the random seed (over 10 possible in total). We then aggregate by dataset and encoding type to obtain the final results with their standard deviation.
388
+
389
+ Graph Classification We run a sweep identical to the one in Table 10 for the reference model, except that we sweep on the “Number of layers” with two values: 32 and 64. Each configuration is repeated with 10 different seeds, then we aggregate by dataset and encoding type to obtain the final results with their standard deviation.
390
+
391
+ # A.5.5 IMAGE RECONSTRUCTION
392
+
393
+ The relative and absolute models appearing in Figure 4 are vanilla AEs and VAEs, the same for all the datasets, and have a comparable number of trainable parameters. Their architecture is composed by simple convolutions, deconvolutions and mean squared error as reconstruction loss. The number of anchors is 500 and the latent dimensionality of the absolute representations is 500.
394
+
395
+ # A.5.6 TEXT CLASSIFICATION
396
+
397
+ We report in Tables 11 to 13 details on the transformers and anchors adopted in Section 5.2.
398
+
399
+ Preprocessing Following the original work in which the Amazon Reviews dataset was proposed (Keung et al., 2020), we utilize both the title and body of each review. We differ in not using the category and in how we merge them; namely, we add the title as prefix for the body and add a full stop as separator when needed (avoiding duplicates). To obtain a single latent encoding for each sample, with fixed shape, we take the last hidden state and select the representation corresponding to the [CLS] token.
400
+
401
+ Wikipedia anchors We use WikiMatrix, a corpus of sentences extracted from Wikipedia. The sentences are parallel between pairs of languages (i.e., same sentences translated in two languages), and since we are looking for a collection of parallel anchors between all 4 languages, we decided to use the English language as a pivot to compute the intersection. To get the final results, we considered only the sentences with margin score $\geq 1 . 0 6$ , getting high-quality sentence alignments. In Table 13 we show the total number of parallel sentences when computing the intersections. We randomly selected 768 samples to use as anchors.
402
+
403
+ # A.5.7 IMAGE CLASSIFICATION
404
+
405
+ The details of the transformers used in Section 5.3 are summarized in Table 14.
406
+
407
+ # A.6 ADDITIONAL RESULTS
408
+
409
+ In this section we report additional results on the correlation between latent similarity and performance in Figure 9, results on the multilingual stitching both with Amazon coarse-grained in Table 15 and fine-grained in Table 16, results on the image classification stitching on CIFAR-100 fine-grained in Table 18. Moreover, we evaluate the stitching performance of a multilingual transformer in Table 17.
410
+
411
+ ![](images/0a2972304e1e62c7354c7f8906a7a55b56b430b97aa274da7e57842f47ea0bc5.jpg)
412
+ Figure 9: Correlation plot between performance and latent similarity with the reference model for multiple different models, over time.
413
+
414
+ ![](images/1c403e8736ed1e51b29fe585da7450bcf3615a1199cda9a2b765b465d062cba6.jpg)
415
+ Figure 10: Same encodings as in Table 1 (left) but with tSNE (left) dimensionality reduction or visualizing only their first two dimensions (right).
416
+
417
+ Table 7: Extended results from Section 4.1 with different anchor selection strategies. The table reports the mean score for each metric and its std across 10 different seeds.
418
+
419
+ <table><tr><td>Mode</td><td>Type</td><td>Source</td><td>Target</td><td>Jaccard ↑</td><td>MRR ↑</td><td>Cosine ↑</td></tr><tr><td rowspan="7">uiojiun</td><td></td><td>FastText</td><td>FastText</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td></tr><tr><td>Jissorst</td><td></td><td>Word2Vec</td><td>0.00 ±0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td>Word2Vec</td><td>FastText</td><td>0.00 ± 0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td></tr><tr><td></td><td>FastText</td><td>FastText</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>0.34 ± 0.01</td><td>0.94± 0.00</td><td>0.86 ± 0.00</td></tr><tr><td>Rrler</td><td>Word2Vec</td><td>FastText Word2Vec</td><td>0.39 ± 0.00 1.00 ± 0.00</td><td>0.98± 0.00 1.00 ± 0.00</td><td>0.86±0.00 1.00 ±0.00</td></tr><tr><td rowspan="6">m</td><td></td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td><td>1.00 ± 0.00</td></tr><tr><td>Jinsarst</td><td>Word2Vec</td><td>FastText</td><td>0.00 ±0.00 0.00±0.00</td><td>0.00±0.00 0.00±0.00</td><td>0.01±0.00 0.01± 0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>Rraeler</td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00 0.34± 0.01</td><td>1.00 ± 0.00 0.94±0.00</td><td>1.00 ±0.00 0.81± 0.00</td></tr><tr><td></td><td>Word2Vec</td><td>FastText</td><td>0.41 ± 0.00</td><td>0.98± 0.00</td><td>0.83±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td rowspan="6">kaaees</td><td>Jansasse</td><td>FastText</td><td>FastText Word2Vec FastText</td><td>1.00 ± 0.00 0.00 ±0.00</td><td>1.00 ± 0.00 0.00±0.00</td><td>1.00 ± 0.00 0.01±0.00</td></tr><tr><td></td><td>Word2Vec</td><td></td><td>0.00 ±0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>Riaaer</td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00 0.35 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td>FastText</td><td>0.39 ± 0.00</td><td>0.94± 0.00</td><td>0.87±0.00 0.87±0.00</td></tr><tr><td></td><td>Word2Vec</td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>0.97± 0.00 1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td rowspan="6">000[d01</td><td>Jinsosst</td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td>Word2Vec</td><td>FastText</td><td>0.00 ±0.00 0.00 ±0.00</td><td>0.00±0.00 0.00±0.00</td><td>0.01± 0.00 0.01±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>Hriler</td><td>FastText</td><td>FastText</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>0.27±0.01</td><td>0.84±0.01</td><td>0.85 ±0.00</td></tr><tr><td></td><td>Word2Vec</td><td>FastText</td><td>0.35 ±0.01</td><td>0.97 ±0.00</td><td>0.85 ±0.00</td></tr><tr><td rowspan="6">000sdo1</td><td>Jinsorst</td><td>FastText</td><td>Word2Vec FastText</td><td>1.00 ± 0.00 1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00 1.00 ± 0.00</td></tr><tr><td></td><td></td><td>Word2Vec FastText</td><td>0.00 ±0.00</td><td>1.00 ± 0.00 0.00±0.00</td><td>0.01± 0.00</td></tr><tr><td></td><td>Word2Vec</td><td></td><td>0.00 ±0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>Hriler Jantsst</td><td></td><td></td><td>0.32 ± 0.00 0.38 ±0.00</td><td>0.92± 0.00 0.97 ±0.00</td><td>0.86 ± 0.00</td></tr><tr><td rowspan="6">0000[d01</td><td></td><td>Word2Vec</td><td>FastText</td><td></td><td></td><td>0.86±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td></td><td></td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td></tr><tr><td></td><td>FastText</td><td>FastText Word2Vec</td><td>1.00 ± 0.00 0.00 ±0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td></td><td>FastText</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="6"></td><td></td><td>Word2Vec</td><td>Word2Vec</td><td>0.00 ± 0.00</td><td>0.00±0.00</td><td>0.01±0.00</td></tr><tr><td></td><td></td><td></td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>Word2Vec</td><td>0.34 ± 0.00</td><td>0.93± 0.00</td><td>0.86 ± 0.00</td></tr><tr><td>Rriaaer</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="7"></td><td rowspan="7"></td><td>FastText</td><td>FastText</td><td>1.00 ± 0.00</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Word2Vec</td><td>FastText</td><td>0.39 ± 0.01</td><td>0.97 ±0.00</td><td></td><td>0.86±0.00</td></tr><tr><td></td><td></td><td>Word2Vec</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr></table>
420
+
421
+ Table 8: Generalization of the results from Section 4.1 on word embeddings to a different data modality, with different anchor selection strategies (See Appendix A.2 for their description). The dataset considered is CIFAR-10, and the table reports the mean score for each metric and its std across 10 different seeds.
422
+
423
+ <table><tr><td>Mode</td><td>Type</td><td>Source</td><td>Target</td><td>Jaccard ↑</td><td>MRR ↑</td><td>Cosine ↑</td></tr><tr><td rowspan="5">uojiun</td><td rowspan="2">Jisarre</td><td>ViT-base</td><td>ViT-base ViT-small</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00 1</td><td>1.00 ± 0.00 1</td></tr><tr><td>ViT-small</td><td>ViT-base</td><td></td><td></td><td>=</td></tr><tr><td rowspan="2">Rrler</td><td></td><td>ViT-small ViT-base</td><td>1.00 ± 0.00 1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>ViT-base</td><td>ViT-small</td><td>0.11 ± 0.00</td><td>1.00 ± 0.00 0.27± 0.01</td><td>1.00 ±0.00 0.97±0.00</td></tr><tr><td rowspan="3"></td><td rowspan="2">ViT-small</td><td>ViT-base</td><td>0.11 ± 0.00</td><td>0.30 ±0.01</td><td>0.97± 0.00</td></tr><tr><td>ViT-small</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td rowspan="2">ViT-base</td><td>ViT-base ViT-small</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00 =</td><td>1.00 ±0.00 -</td></tr><tr><td rowspan="2">Jirstrre</td><td rowspan="2">ViT-small</td><td>ViT-base</td><td></td><td></td><td>=</td></tr><tr><td>ViT-base</td><td>ViT-small 1.00 ± 0.00 ViT-base 1.00 ± 0.00</td><td>1.00 ± 0.00 1.00 ± 0.00</td><td>1.00 ± 0.00 1.00 ± 0.00</td></tr><tr><td rowspan="5">Traees</td><td rowspan="2">Rraaaer</td><td>ViT-small</td><td>ViT-small ViT-base</td><td>0.12 ±0.00 0.12 ±0.00</td><td>0.37 ± 0.01 0.39 ± 0.01</td><td>0.96 ±0.00 0.96 ±0.00</td></tr><tr><td></td><td>ViT-small</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td rowspan="2">Jasssrt</td><td rowspan="2">ViT-base</td><td>ViT-base</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td><td>1.00 ±0.00</td></tr><tr><td>ViT-small</td><td>=</td><td>=</td><td>=</td></tr><tr><td rowspan="4">Hraaaer</td><td rowspan="2"></td><td>ViT-small</td><td>ViT-base ViT-small</td><td>1.00 ± 0.00</td><td></td><td>=</td></tr><tr><td></td><td></td><td></td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td rowspan="2">ViT-small</td><td>ViT-base</td><td>ViT-base ViT-small</td><td>1.00 ± 0.00 0.11±0.00</td><td>1.00 ± 0.00</td><td>1.00 ± 0.00</td></tr><tr><td>ViT-base</td><td></td><td>0.10±0.00</td><td>0.25 ± 0.01 0.27± 0.00</td><td>0.97±0.00 0.97±0.00</td></tr></table>
424
+
425
+ Table 9: All the datasets utilized in our work with their number of classes.
426
+
427
+ <table><tr><td></td><td>Dataset</td><td>Number of Classes</td></tr><tr><td rowspan="5">ea</td><td>MNIST</td><td>10</td></tr><tr><td>Fashion MNIST</td><td>10</td></tr><tr><td>CIFAR-10</td><td>10</td></tr><tr><td>CIFAR-100</td><td>20 (coarse)—100 (fine)</td></tr><tr><td>ImageNet1k</td><td>1000</td></tr><tr><td rowspan="3">Cderg</td><td>Cora</td><td>7</td></tr><tr><td>CiteSeer</td><td>6</td></tr><tr><td>PubMed</td><td>3</td></tr><tr><td rowspan="3">1</td><td>TREC</td><td>6(coarse)—50 (fine)</td></tr><tr><td>DBpedia</td><td>14</td></tr><tr><td>Amazon I Reviews</td><td>2 (coarse)—5 (fine)</td></tr></table>
428
+
429
+ Table 10: The reference model and exhaustive hyperparameter combinations pertaining Section 4.2.
430
+
431
+ <table><tr><td>Hyperparameter</td><td>Reference Model</td><td>Sweep</td></tr><tr><td>Seed</td><td>1</td><td>0,1,2,3,4</td></tr><tr><td>Epochs</td><td>500</td><td>10,30,50</td></tr><tr><td>Number of layers</td><td>32</td><td>32,64</td></tr><tr><td>Dropout Probability</td><td>0.5</td><td>0.1,0.5</td></tr><tr><td>Hidden Activations</td><td>ReLU</td><td>ReLU,Tanh</td></tr><tr><td>Convolution Activation</td><td>ReLU</td><td>ReLU,Tanh</td></tr><tr><td>Optimizer</td><td>Adam</td><td>Adam, SGD</td></tr><tr><td>Learning Rate</td><td>0.02</td><td>0.01,0.02</td></tr><tr><td>Graph Embedder</td><td>GCNConv</td><td>GCNConv,GINConv</td></tr></table>
432
+
433
+ Table 11: The HuggingFace transformers employed in Section 5.2 to tackle the Cross-lingual setting.
434
+
435
+ <table><tr><td>Language</td><td>HuggingFace transformers name</td><td>Encoding Dim</td></tr><tr><td>English</td><td>roberta-base</td><td>768</td></tr><tr><td>Spanish</td><td>PlanTL-GOB-ES/roberta-base-bne</td><td>768</td></tr><tr><td>French</td><td>ClassCat/roberta-base-french</td><td>768</td></tr><tr><td>Japanese</td><td>nlp-waseda/roberta-base-japanese</td><td>768</td></tr></table>
436
+
437
+ Table 12: The HuggingFace transformers employed in Section 5.2 to tackle the Cross-architecture setting.
438
+
439
+ <table><tr><td>HuggingFace transformers name</td><td>Encoding Dim</td></tr><tr><td>bert-base-cased</td><td>768</td></tr><tr><td>bert-base-uncased</td><td>768</td></tr><tr><td>google/electra-base-discriminator</td><td>768</td></tr><tr><td>roberta-base</td><td>768</td></tr></table>
440
+
441
+ Table 13: WikiMatrix analysis. Each row shows the number of parallel sentences having a translation available in all the languages of that row. Since we consider all four languages, we have 3338 parallel sentences available.
442
+
443
+ <table><tr><td>Languages</td><td>Number of Sentences</td></tr><tr><td>en,es</td><td>2302527</td></tr><tr><td>en, ja</td><td>264259</td></tr><tr><td>en,fr</td><td>1682477</td></tr><tr><td>en, es,fr</td><td>23200</td></tr><tr><td>en, es, ja</td><td>147665</td></tr><tr><td>en, fr, ja</td><td>20990</td></tr><tr><td>en, es, fr, ja</td><td>3338</td></tr></table>
444
+
445
+ Table 14: Timm transformers used in Section 5.3.
446
+
447
+ <table><tr><td>Version</td><td>Timm model name</td><td>Encoding Dim</td><td>Training data</td></tr><tr><td>ViT</td><td>vit_base-patch16_224</td><td>768</td><td>JFT-300M, ImageNet</td></tr><tr><td>ViT</td><td>vit_small_patch16_224</td><td>384</td><td>ImageNet</td></tr><tr><td>ViT</td><td>vit_base_resnet50_384</td><td>768</td><td>ImageNet</td></tr><tr><td>RexNet</td><td>rexnet_100</td><td>1280</td><td>ImageNet</td></tr></table>
448
+
449
+ Table 15: Stitching performance comparison with different encodings techniques. The table reports the mean weighted F1 $\pm$ std) and MAE classification performance on Amazon Reviews coarsegrained, across 5 different seeds. All the language pairs are shown.
450
+
451
+ <table><tr><td></td><td></td><td colspan="2">Absolute</td><td colspan="4">Relative</td></tr><tr><td></td><td></td><td colspan="2"></td><td colspan="2">Translated</td><td colspan="2">Wikipedia</td></tr><tr><td>Decoder</td><td>Encoder</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td></tr><tr><td></td><td>en</td><td>91.54 ± 0.58</td><td>0.08 ±0.01</td><td>90.06 ±0.60</td><td>0.10 ± 0.01</td><td>90.45 ± 0.52</td><td>0.10 ±0.01</td></tr><tr><td>en</td><td>es</td><td>43.67 ± 1.09</td><td>0.56 ± 0.01</td><td>82.78 ±0.81</td><td>0.17 ± 0.01</td><td>78.53 ±0.30</td><td>0.21±0.00</td></tr><tr><td></td><td>fr</td><td>54.41 ± 1.61</td><td>0.45 ±0.02</td><td>78.49 ±0.66</td><td>0.21 ± 0.01</td><td>70.41 ± 0.57</td><td>0.29 ±0.01</td></tr><tr><td></td><td>ja</td><td>48.72 ±0.90</td><td>0.51 ± 0.01</td><td>65.72 ±0.55</td><td>0.34±0.01</td><td>66.31 ±0.80</td><td>0.34± 0.01</td></tr><tr><td></td><td>en</td><td>33.23 ±1.00</td><td>0.66 ±0.01</td><td>78.68± 2.74</td><td>0.21 ±0.03</td><td>76.65 ± 3.23</td><td>0.23 ±0.03</td></tr><tr><td></td><td>es</td><td>91.64 ± 1.02</td><td>0.08±0.01</td><td>89.96 ±0.77</td><td>0.10 ±0.01</td><td>89.62 ±0.94</td><td>0.10 ±0.01</td></tr><tr><td>es</td><td>fr</td><td>47.66 ±0.70</td><td>0.52 ± 0.01</td><td>78.57 ± 1.80</td><td>0.21±0.02</td><td>75.25 ±0.76</td><td>0.25 ±0.01</td></tr><tr><td></td><td>ja</td><td>53.10 ±2.27</td><td>0.46 ±0.02</td><td>67.69 ± 0.24</td><td>0.32 ±0.00</td><td>61.84 ± 0.61</td><td>0.38 ±0.01</td></tr><tr><td></td><td>en</td><td>51.00 ± 2.63</td><td>0.49±0.03</td><td>83.32 ± 1.80</td><td>0.17 ±0.02</td><td></td><td>0.24±0.00</td></tr><tr><td>fr</td><td>es</td><td>51.96 ± 2.81</td><td>0.48 ±0.03</td><td>82.50±0.83</td><td>0.17 ±0.01</td><td>75.55 ± 0.37 77.12 ±0.88</td><td>0.23 ±0.01</td></tr><tr><td></td><td>fr</td><td>88.22 ±0.75</td><td>0.12 ± 0.01</td><td>85.68 ± 1.37</td><td>0.14± 0.01</td><td>86.45 ±0.96</td><td>0.13 ±0.01</td></tr><tr><td></td><td>ja</td><td>50.32 ± 4.16</td><td>0.50 ±0.04</td><td>69.38 ±0.73</td><td>0.31 ±0.01</td><td>62.79 ±0.27</td><td>0.37±0.00</td></tr><tr><td></td><td>en</td><td></td><td>0.46 ±0.03</td><td></td><td>0.31 ±0.04</td><td></td><td></td></tr><tr><td></td><td>es</td><td>53.82 ± 2.62 44.91 ±2.21</td><td>0.55 ±0.02</td><td>68.66 ±3.62 70.37 ± 6.94</td><td>0.29 ±0.06</td><td>70.26 ± 3.16 58.54 ±1.21</td><td>0.29±0.03 0.41 ± 0.01</td></tr><tr><td>ja</td><td>fr</td><td>66.46 ± 1.30</td><td>0.34± 0.01</td><td>76.49 ± 1.13</td><td>0.23 ±0.01</td><td>63.94±2.70</td><td></td></tr><tr><td></td><td>ja</td><td>83.30± 0.67</td><td>0.17 ± 0.01</td><td>81.04 ±0.82</td><td>0.19 ± 0.01</td><td>80.80 ±1.25</td><td>0.36 ±0.02 0.19 ±0.01</td></tr></table>
452
+
453
+ Table 16: Stitching performance comparison with different encodings techniques. The table reports the mean weighted F1 ( $\pm$ std) and MAE classification performance on Amazon Reviews finegrained, across 5 different seeds. All the language pairs are shown.
454
+
455
+ <table><tr><td></td><td></td><td colspan="2">Absolute</td><td colspan="4">Relative</td></tr><tr><td></td><td></td><td></td><td></td><td colspan="2">Translated</td><td colspan="2">Wikipedia</td></tr><tr><td>Decoder</td><td>Encoder</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td></tr><tr><td></td><td>en</td><td>65.46 ± 2.89</td><td>0.38 ±0.02</td><td>61.18 ± 1.92</td><td>0.44± 0.02</td><td>62.36 ±2.23</td><td>0.43 ±0.02</td></tr><tr><td></td><td>es</td><td>22.70± 0.41</td><td>1.39 ± 0.03</td><td>51.67 ± 1.20</td><td>0.62 ± 0.01</td><td>45.40 ±0.68</td><td>0.76±0.01</td></tr><tr><td>en</td><td>fr</td><td>30.75 ±0.67</td><td>1.19 ± 0.02</td><td>49.18 ±0.83</td><td>0.69 ±0.02</td><td>40.29 ±0.90</td><td>0.91± 0.02</td></tr><tr><td></td><td>ja</td><td>24.85 ±0.91</td><td>1.37 ± 0.07</td><td>37.34 ± 1.49</td><td>0.99 ±0.02</td><td>37.73±0.70</td><td>1.01 ± 0.02</td></tr><tr><td></td><td>en</td><td>21.24 ± 0.81</td><td>1.43 ± 0.07</td><td>51.02 ± 2.54</td><td>0.68 ±0.05</td><td>47.70 ± 5.08</td><td>0.73 ±0.10</td></tr><tr><td></td><td>es</td><td>61.29 ±3.04</td><td>0.43 ±0.02</td><td>57.89 ±3.80</td><td>0.48 ±0.03</td><td>57.96 ± 4.40</td><td>0.48 ±0.03</td></tr><tr><td>es</td><td>fr</td><td>29.02 ±0.85</td><td>1.26 ± 0.05</td><td>48.40 ± 1.02</td><td>0.71 ±0.02</td><td>44.92 ±1.83</td><td>0.77 ±0.01</td></tr><tr><td></td><td>ja</td><td>29.23 ±1.32</td><td>1.22 ± 0.02</td><td>37.22 ± 1.56</td><td>1.03 ± 0.04</td><td>34.56 ± 0.87</td><td>1.08 ± 0.04</td></tr><tr><td></td><td>en</td><td>27.39 ± 1.22</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>es</td><td>29.47 ±3.68</td><td>1.23 ± 0.06 1.18 ± 0.07</td><td>45.55 ± 3.55 40.29 ±1.72</td><td>0.76 ±0.09 0.90 ±0.04</td><td>39.01 ±1.25 41.29 ± 2.01</td><td>0.88 ±0.06 0.83 ±0.04</td></tr><tr><td>fr</td><td>fr</td><td>56.40 ±1.89</td><td>0.51 ± 0.01</td><td>53.58 ±0.70</td><td>0.57 ± 0.01</td><td>54.23 ± 0.95</td><td>0.56 ±0.01</td></tr><tr><td></td><td>ja</td><td>25.92 ± 1.31</td><td>1.25 ± 0.05</td><td>38.60 ± 1.03</td><td>0.96 ±0.02</td><td>35.22 ±0.56</td><td>1.08 ± 0.02</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>en es</td><td>29.36 ±0.59 25.64 ± 1.77</td><td>1.17 ± 0.04 1.28 ± 0.04</td><td>38.19 ±2.28 34.23±2.62</td><td>0.88±0.03 1.00 ± 0.05</td><td>36.57 ± 1.72 33.16 ±2.28</td><td>0.98±0.02</td></tr><tr><td>ja</td><td></td><td>31.79 ± 1.91</td><td>1.06 ± 0.02</td><td>38.50 ±2.46</td><td>0.89 ±0.02</td><td></td><td>1.06 ± 0.03</td></tr><tr><td></td><td>fr ja</td><td>54.09 ± 1.35</td><td>0.60 ±0.02</td><td>50.89 ± 1.70</td><td>0.65 ±0.02</td><td>36.68 ± 3.14 51.64 ± 1.47</td><td>1.00 ± 0.05 0.65 ±0.02</td></tr></table>
456
+
457
+ Table 17: Stitching performance comparison on XLM-R, a multilingual model by design. The table reports the mean weighted F1 $\pm$ std) and MAE classification performance on Amazon Reviews fine-grained, across 5 different seeds.
458
+
459
+ <table><tr><td rowspan="2">Decoder</td><td rowspan="2">Encoder</td><td colspan="2">Absolute</td><td colspan="2">Relative</td></tr><tr><td>FScore</td><td>MAE</td><td>FScore</td><td>MAE</td></tr><tr><td rowspan="4">en</td><td>en</td><td>65.27 ± 0.94</td><td>0.41 ± 0.01</td><td>58.24 ±1.92</td><td>0.51± 0.03</td></tr><tr><td>es</td><td>59.55 ± 0.76</td><td>0.48 ± 0.01</td><td>52.81 ± 1.57</td><td>0.62 ± 0.02</td></tr><tr><td>fr</td><td>58.58 ± 1.04</td><td>0.49 ± 0.01</td><td>54.01 ± 1.34</td><td>0.59 ±0.02</td></tr><tr><td>ja</td><td>57.98 ± 0.77</td><td>0.52 ± 0.01</td><td>48.47 ± 2.67</td><td>0.71± 0.04</td></tr><tr><td rowspan="4">es</td><td>en</td><td>60.32 ± 1.50</td><td>0.47 ±0.01</td><td>45.69 ± 2.19</td><td>0.87±0.07</td></tr><tr><td>es</td><td>61.25 ± 1.74</td><td>0.44± 0.01</td><td>57.61 ± 0.73</td><td>0.51± 0.01</td></tr><tr><td>fr</td><td>59.50 ± 1.41</td><td>0.47 ± 0.01</td><td>45.16 ± 3.30</td><td>0.83 ± 0.09</td></tr><tr><td>ja</td><td>58.24 ± 1.31</td><td>0.51 ± 0.02</td><td>41.14 ± 1.76</td><td>0.99 ±0.05</td></tr><tr><td rowspan="4">fr</td><td>en</td><td>58.00± 4.21</td><td>0.49 ± 0.03</td><td>52.37 ± 1.66</td><td>0.66 ± 0.03</td></tr><tr><td>es</td><td>56.87 ± 3.79</td><td>0.49 ± 0.03</td><td>54.99 ± 0.46</td><td>0.57 ± 0.01</td></tr><tr><td>fr</td><td>57.99 ± 3.88</td><td>0.47 ± 0.02</td><td>57.00 ±0.90</td><td>0.52 ± 0.01</td></tr><tr><td>ja</td><td>55.83 ± 3.32</td><td>0.53 ± 0.03</td><td>39.15 ± 1.21</td><td>1.02 ± 0.03</td></tr><tr><td rowspan="4">ja</td><td>en</td><td>59.53 ± 1.73</td><td>0.48 ± 0.01</td><td>39.46 ± 2.34</td><td>1.04 ± 0.07</td></tr><tr><td>es</td><td>57.02 ± 1.36</td><td>0.51±0.00</td><td>40.74± 2.75</td><td>0.97 ±0.09</td></tr><tr><td>fr</td><td>57.48 ± 1.06</td><td>0.51 ± 0.01</td><td>43.36 ± 3.70</td><td>0.89 ±0.11</td></tr><tr><td>ja</td><td>61.43 ± 0.97</td><td>0.45 ± 0.01</td><td>57.67 ± 1.17</td><td>0.51± 0.01</td></tr></table>
460
+
461
+ Table 18: Stitching performance comparison with different encodings techniques. The table reports the mean weighted F1 $\pm$ std) classification performance on CIFAR-100 fine-grained, across 5 different seeds.
462
+
463
+ <table><tr><td>Decoder</td><td>Encoder</td><td>Absolute</td><td>Relative</td></tr><tr><td rowspan="4">rexnet-100</td><td>rexnet-100</td><td>72.77 ± 0.19</td><td>71.39 ± 0.18</td></tr><tr><td>vit-base-patch16-224</td><td></td><td>40.68 ± 0.50</td></tr><tr><td>vit-base-resnet50-384</td><td></td><td>38.18 ±0.24</td></tr><tr><td>vit-small-patch16-224</td><td></td><td>44.11 ± 0.84</td></tr><tr><td rowspan="4">vit-base-patch16-224</td><td>rexnet-100</td><td>=</td><td>57.81 ± 0.39</td></tr><tr><td>vit-base-patch16-224</td><td>88.69±0.14</td><td>87.05 ± 0.34</td></tr><tr><td>vit-base-resnet50-384</td><td>1.08 ± 0.19</td><td>66.65 ±1.79</td></tr><tr><td>vit-small-patch16-224</td><td></td><td>73.73 ± 0.60</td></tr><tr><td rowspan="4">vit-base-resnet50-384</td><td>rexnet-100</td><td></td><td>66.91 ± 0.79</td></tr><tr><td>vit-base-patch16-224</td><td>1.10 ± 0.09</td><td>75.70 ±0.68</td></tr><tr><td>vit-base-resnet50-384</td><td>85.85 ±0.18</td><td>85.04 ± 0.38</td></tr><tr><td>vit-small-patch16-224</td><td>=</td><td>75.52 ± 0.36</td></tr><tr><td rowspan="4">vit-small-patch16-224</td><td>rexnet-100</td><td></td><td>56.60 ± 0.39</td></tr><tr><td>vit-base-patch16-224</td><td></td><td>70.14 ± 0.46</td></tr><tr><td>vit-base-resnet50-384</td><td></td><td>62.85 ±1.22</td></tr><tr><td>vit-small-patch16-224</td><td>84.11 ± 0.14</td><td>83.24 ± 0.13</td></tr></table>
464
+
465
+ ![](images/dd8f634c1f27e078c6770f37f498f7df984c225f10599bdb80d1f3fdccd72ad3.jpg)
466
+ Figure 11: Different dimensionality reduction techniques applied to absolute and relative spaces on CIFAR-10. From left to right: PCA (Principal Component Analysis), tSNE, and visualizing only their first two dimensions. Only 800 randomly sampled points are shown, belonging to the classes ”bird”, ”ship”, ”cat”, and ”frog”.
md/dev/TJUNtiZiTKE/TJUNtiZiTKE.md ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Diffusion-based Molecule Generation with Informative Prior Bridges
2
+
3
+ Lemeng Wu⇤ University of Texas at Austin lmwu@cs.utexas.edu
4
+
5
+ Chengyue Gong⇤ University of Texas at Austin cygong@cs.utexas.edu
6
+
7
+ Xingchao Liu University of Texas at Austin xcliu@cs.utexas.edu
8
+
9
+ Mao Ye University of Texas at Austin my21@cs.utexas.edu
10
+
11
+ Qiang Liu University of Texas at Austin lqiang@cs.utexas.edu
12
+
13
+ # Abstract
14
+
15
+ AI-based molecule generation provides a promising approach to a large area of biomedical sciences and engineering, such as antibody design, hydrolase engineering, or vaccine development. Because the molecules are governed by physical laws, a key challenge is to incorporate prior information into the training procedure to generate high-quality and realistic molecules. We propose a simple and novel approach to steer the training of diffusion-based generative models with physical and statistics prior information. This is achieved by constructing physically informed diffusion bridges, stochastic processes that guarantee to yield a given observation at the fixed terminal time. We develop a Lyapunov function based method to construct and determine bridges, and propose a number of proposals of informative prior bridges for both high-quality molecule generation and uniformity-promoted 3D point cloud generation. With comprehensive experiments, we show that our method provides a powerful approach to the 3D generation task, yielding molecule structures with better quality and stability scores and more uniformly distributed point clouds of high qualities.
16
+
17
+ # 1 Introduction
18
+
19
+ As exemplified by the success of AlphafoldV2 [22] in solving protein folding, deep learning techniques have been creating new frontiers on molecular sciences [46]. In particular, the problem of building deep generative models for molecule design has attracted increasing interest with a magnitude of applications in physics, chemistry, and drug discovery [e.g., 2, 3, 26]. Recently, diffusion-based generative model have been applied to molecule generation problems [9, 19] and obtain superior performance. The idea of these methods is to corrupt the data with diffusion noise and learn a neural diffusion model to revert the corruption process to generate meaningful data from noise.
20
+
21
+ A key challenge in deep generative models for molecule and 3D point generation is to efficiently incorporate strong prior information to reflect the physical and problem-dependent statistical properties of the problems at hand. In fact, a recent fruitful line of research [11, 23, 37] have shown promising results by introducing inductive bias into the design of model architectures to reflect physical constraints such as SE(3) equivariance. In this work, we present a different paradigm of prior incorporation tailored to diffusion-based generative models, and leverage it to yield substantial improvement in both 1) high-quality and stable molecule generation and 2) uniformity-promoted point cloud generation. Our contributions are summarized as follows.
22
+
23
+ Prior Guided Learning of Diffusion Models. We introduce a simple and flexible framework for injecting informative problem-dependent prior and physical information when learning diffusionbased generative models. The idea is to elicit and inject prior information regarding how the diffusion process should look like for generating each given data point, and train the neural diffusion model to imitate the prior processes. The prior information is presented in the form of diffusion bridges which are diffusion processes that are guaranteed to generate each data point at the fixed terminal time. We provide a general Lyapunov approach for constructing and determining bridges and leverage it to develop a way to systematically incorporate prior information into bridge processes.
24
+
25
+ Physics-informed Molecule Generation. We apply our method to molecule generation. We propose a number of energy functions for incorporating physical and statistical prior information. Compared with existing physics-informed molecule generation methods [e.g., 9, 14, 29, 14], our method modifies the training process, rather than imposing constraints on the model architecture. Experiments show that our method achieves current state-of-the-art generation quality and stability on multiple test benchmarks of molecule generation.
26
+
27
+ Uniformity-promoting Point Generation. A challenging task in physical simulation, graphics, 3D vision is to generate point clouds for representing real objects [e.g., 1, 5, 28, 51]. A largely overlooked problem of existing approaches is that they tend to generate unevenly distributed points, which lead to unrealistic shapes and make the subsequent processing and applications, such as mesh generation, challenging and inefficient. In this work, we leverage our framework to introduce uniformity-promoting forces into the prior bridge of diffusion generative models. This yields a simple and efficient approach to generating regular and realistic point clouds in terms of both shape and point distribution.
28
+
29
+ # 2 Related works
30
+
31
+ Diffuse Bridge Process. Diffusion-based generative models [18, 40, 41, 44, 25] have achieved great successes in various AI generation tasks recently; these methods leverage a time reversion technique and can be viewed as learning variants auto-encoders with diffusion processes as encoders and decoders. Schrodinger bridges [7, 9, 45] have also been proposed for learning diffusion generative models that guarantee to output desirable outputs in a finite time interval, but these methods involve iterative proportional fittings and are computationally costly. Our framework of learning generative models with diffusion bridges is similar to that of [35], which learn diffusion models as a mixture of forward-time diffusion bridges to avoid the time-reversal technique of [43]. But our framework is designed to incorporate physical prior into bridges and develop a systematic approach for constructing a broad class of prior-informed bridges.
32
+
33
+ 3D Molecule Generation. Generating molecule in 3D space has been gaining increasing interest. A line of works [e.g. 30, 32, 38, 39, 48, 49, 50] consider conditional conformal generation, which takes the 2D SMILE structure as conditional input and generate the 3D molecule conformations condition on the input. Another series of works [e.g., 13, 19, 27, 37, 47] focus on directly generating the atom position and type for the molecule unconditionally. For these series of works, improvements usually come from architecture design and loss design. For example, G-Schnet [13] auto-regressively generates the atom position and type one by one after another; EN-Flow [37] and EDM [19] adopt E(n) equivariant graph neural network (EGNN) [37] to train flow-based model and diffusion model. These methods aim at generating valid and natural molecules in 3D space and outperform previous approaches by a large margin. Our work provides a very different approach to incorporating the physical information for molecule generation by injecting the prior information into the diffusion process, rather than neural network architectures.
34
+
35
+ Point Cloud Generation. A vast literature has been devoted to learning deep generative models for real-world 3D objects in the form of point clouds. [1] first proposed to generate the point cloud by generating a latent code and training a decoder to generate point clouds from the latent code. Build upon this approach, methods have been developed using flow-based generative models [51] and diffusion-base models [5, 28, 29]. However, the existing works miss a key important prior information: the points in a point cloud tend to distribute regularly and uniformly. Ignoring this information causes poor generation quality. By introducing uniformity-promoting forces in diffusion bridges, we obtain a simple and efficient approach to generating regular and realistic point clouds.
36
+
37
+ # 3 Method
38
+
39
+ We first introduce the definition of diffusion generative models and discuss how to learn these models with prior bridges. After introducing the training algorithm for deep diffusion generative models, we discuss the energy functions that we apply to molecules and point cloud examples.
40
+
41
+ # 3.1 Learning Diffusion Generative Models with Prior Bridges
42
+
43
+ Problem Definition. We aim at learning a generative model given a dataset $\{ x ^ { ( k ) } \} _ { k = 1 } ^ { n }$ drawn from an unknown distribution on . A diffusion model on time interval $[ 0 , 1 ]$ is
44
+
45
+ $$
46
+ \begin{array} { r } { \mathbb { P } ^ { \theta } \colon \quad \mathrm { d } Z _ { t } = s _ { t } ^ { \theta } ( Z _ { t } ) \mathrm { d } t + \sigma _ { t } ( Z _ { t } ) \mathrm { d } W _ { t } , \quad \forall t \in [ 0 , 1 ] , \quad Z _ { 0 } \sim \mu _ { 0 } , } \end{array}
47
+ $$
48
+
49
+ where $W _ { t }$ is a standard Brownian motion; $\sigma _ { t } \colon \mathbb { R } ^ { d } \to \mathbb { R } ^ { d \times d }$ is a positive definition covariance coefficient; $s _ { t } ^ { \theta } \colon { \mathbb { R } ^ { d } } \to { \mathbb { R } ^ { d } }$ is parameterized as a neural network with parameter $\theta$ , and $\mu _ { 0 }$ is the initialization. Here we use $\mathbb { P } ^ { \theta }$ to denote the distribution of the whole trajectory $Z = \{ Z _ { t } \colon t \in [ 0 , 1 ] \}$ , and $\mathbb { P } _ { t } ^ { \theta }$ the marginal distribution of $Z _ { t }$ at time $t$ . We want to learn the parameter $\theta$ such that the distribution $\mathbb { P } _ { 1 } ^ { \theta }$ of the terminal state $Z _ { 1 }$ equals the data distribution $\Pi ^ { * }$ .
50
+
51
+ Learning Diffusion Models. There are an infinite number of diffusion processes $\mathbb { P } ^ { \theta }$ that yield the same terminal distribution but have different distributions of latent trajectories $Z$ . Hence, it is important to inject problem-dependent prior information into the learning procedure to obtain a model $\mathbb { P } ^ { \theta }$ that simulate the data for the problem at hand fast and accurately. To achieve this, we elicit an imputation process $\mathbb { Q } ^ { x }$ for each $\bar { \boldsymbol { x } } \in \mathbb { R } ^ { d }$ , such that a draw $Z \sim \mathbb { Q } ^ { x }$ yields trajectories that 1) are consistent with $x$ in that $Z _ { 1 } = x$ deterministically, and 2) reflect important physical and statistical prior information on the problem at hand.
52
+
53
+ Formally, if $\mathbb { Q } ^ { x } ( Z _ { 1 } = x ) = 1$ , we call that $\mathbb { Q } ^ { x }$ is a bridge process pinned at end point $x$ , or simply an $x$ -bridge. Assume we first generate a data point $x \sim \Pi ^ { * }$ , and then draw a bridge $Z \sim \mathbb { Q } ^ { x }$ pinned at $x$ , then the distribution of $Z$ is a mixture of $\mathbb { Q } ^ { x }$ with $x$ drawn from the data distribution: $\begin{array} { r } { \mathbb { Q } ^ { \Pi ^ { * } } : = \int \mathbb { Q } ^ { x } ( \cdot ) \Pi ^ { * } ( \mathrm { d } x ) } \end{array}$ .
54
+
55
+ A key property of $\mathbb { Q } ^ { \Pi ^ { * } }$ is that its terminal distribution equals the data distribution, i.e., $\mathbb { Q } _ { 1 } ^ { \Pi ^ { * } } = \Pi ^ { * }$ . Therefore, we can learn the diffusion model $\mathbb { P } ^ { \theta }$ by fitting the trajectories drawn from $\mathbb { Q } ^ { \Pi ^ { * } }$ with the “backward” procedure above. This can be formulated by maximum likelihood or equivalently minimizing the KL divergence:
56
+
57
+ $$
58
+ \operatorname* { m i n } _ { \theta } \left\{ { \mathcal { L } } ( \theta ) : = K { \mathcal { L } } ( \mathbb { Q } ^ { \Pi ^ { * } } \mid | \mathbb { P } ^ { \theta } ) \right\} .
59
+ $$
60
+
61
+ Furthermore, assume that the bridge $\mathbb { Q } ^ { x }$ is a diffusion model of form
62
+
63
+ $$
64
+ \begin{array} { r } { \mathbb { Q } ^ { x } \colon \quad \mathrm { d } Z _ { t } = b _ { t } ( Z _ { t } \mid x ) \mathrm { d } t + \sigma _ { t } ( Z _ { t } ) \mathrm { d } W _ { t } , \quad Z _ { 0 } \sim \mu _ { 0 } , } \end{array}
65
+ $$
66
+
67
+ where $b _ { t } ( Z _ { t } \mid x )$ is an $x$ -dependent drift term need to carefully designed to both satisfy the bridge condition and incorporate important prior information (see Section 3.2). Assuming this is done, using Girsanov theorem [33], the loss function $\mathcal { L } ( \boldsymbol { \theta } )$ can be reformed into a form ofdenoised score matching loss of [e.g., 41, 43, 42]:
68
+
69
+ $$
70
+ \mathcal { L } ( \theta ) = \mathbb { E } _ { Z \sim \mathbb { Q } ^ { \mathrm { { n } ^ { * } } } } \left[ \frac { 1 } { 2 } \int _ { 0 } ^ { 1 } \left\| \sigma ( Z _ { t } ) ^ { - 1 } ( s _ { t } ^ { \theta } ( Z _ { t } ) - b _ { t } ( Z _ { t } \mid Z _ { 1 } ) ) \right\| _ { 2 } ^ { 2 } \mathrm { d } t \right] + \mathrm { c o n s t } ,
71
+ $$
72
+
73
+ which is a score matching term between $s ^ { \theta }$ and $b$ . The const term contains the log-likelihood for the initial distribution $\mu _ { 0 }$ , which is a const in our problem. Here $\theta ^ { * }$ is an global optimum of $\mathcal { L } ( \boldsymbol { \theta } )$ if
74
+
75
+ $$
76
+ s _ { t } ^ { \theta ^ { * } } ( z ) = \mathbb { E } _ { Z \sim \mathbb { Q } ^ { \mathrm { { n } ^ { * } } } } [ b _ { t } ( z | Z _ { 1 } ) \mid Z _ { t } = z ] .
77
+ $$
78
+
79
+ This means that the drift term $s _ { t } ^ { \theta }$ should be matched with the conditional expectation of $b _ { t } ( z | x )$ with $x = Z _ { 1 }$ conditioned on $Z _ { t } = z$ .
80
+
81
+ Remark 3.1. The SMLD can be viewed as a special case of this framework when we take $\mathbb { Q } ^ { x }$ to be $a$ time-scaled Brownian bridge process:
82
+
83
+ $$
84
+ \mathbb { Q } ^ { x , \mathrm { b b } } : \mathrm { d } Z _ { t } = \sigma _ { t } ^ { 2 } \frac { x - Z _ { t } } { \beta _ { 1 } - \beta _ { t } } \mathrm { d } t + \sigma _ { t } \mathrm { d } W _ { t } , Z _ { 0 } \sim \mathcal { N } ( x , \beta _ { 1 } ) ,
85
+ $$
86
+
87
+ where $\sigma _ { t } \in [ 0 , + \infty )$ and $\begin{array} { r } { \beta _ { t } = \int _ { 0 } ^ { t } \sigma _ { s } ^ { 2 } \mathrm { d } s } \end{array}$ . This can be seen by the fact that the time-reversed process $\tilde { Z } _ { t } : = Z _ { 1 - t }$ follows the simple time-scaled Brownian motion $\mathrm { d } \tilde { Z } _ { t } = \sigma _ { 1 - t } \mathrm { d } \tilde { W } _ { t }$ starting from the data point $\tilde { Z } _ { 0 } = x$ , where $\tilde { W } _ { t }$ is another standard Brownian motion. The Brownian bridge achieves $Z _ { 1 } = x$ because the magnitude of the drift force is increasing to infinite when $t$ is close to time 1.
88
+
89
+ However, the bridge of SMLD above is a relative simple and uninformative process and does not incorporate problem-dependent prior information into the learning procedure. This is also the case of the other standard diffusion-based models [43], such as denoising diffusion probabilistic models (DDPM) which can be shown to use a bridge constructed from an Ornstein–Uhlenbeck process. We refer the readers to [35], which provides a similar forward time bridge framework for learning diffusion models, and it recovers the bridges in SMLD and DDPM as a conditioned stochastic process derived using the $h$ -transform technique [10]. However, the $h$ -transform method is limited to elementary stochastic processes that have an explicit formula of the transition probabilities, and can not incorporate complex physical statistical prior information. Our work strikes to construct and use a broader class of more complex bridge processes that both reflect problem-dependent prior knowledge and satisfy the endpoint condition $\bar { \mathbb { Q } ^ { x } } ( Z _ { 1 } = x ) = 1$ . This necessitate systematic techniques for constructing a large family of bridges, as we pursuit in Section 3.2.
90
+
91
+ # 3.2 Designing Informative Prior Bridges
92
+
93
+ The key to realizing the general prior-informed learning framework above is to have a general and user-friendly technique to design $\mathbb { Q } ^ { x }$ in (1) to ensure the bridge condition $\mathbb { Q } ^ { x } ( Z _ { 1 } = x ) = 1$ while leaving the flexibility of incorporating rich prior information. To achieve this, we first develop a general criterion of bridges based on a Lyapunov function method which allows us to identify a very general form of bridge processes; we then propose a particularly simple family of bridges that we use in practice by introducing modification to Brownian bridges.
94
+
95
+ Definition 3.2 (Lyapunov Functions). A function $U _ { t } ( z )$ is said to be a Lyapunov function for set $A \subset { \mathbb { R } } ^ { d }$ at time $t = 1$ if $U _ { 1 } ( z ) \geq 0$ for $\forall z \in \mathbb { R } ^ { d }$ and $U _ { 1 } ( z ) = 0$ if and only if $z \in A$ .
96
+
97
+ Intuitively, a diffusion process $\mathbb { Q }$ is a bridge $A$ , i.e., $\mathbb { Q } ( Z _ { 1 } \in A ) = 1$ , if it (at least) approximately follows the gradient flow of a Lyapunov function and the magnitude (or step size) or the gradient flow should increase with a proper magnitude in order to ensure that $Z _ { t } \in A$ at the terminal time $t = 1$ . Therefore, we identify a general form of bridges to $A$ as follows:
98
+
99
+ $$
100
+ \mathbb { Q } ^ { A } : \quad \mathrm { d } Z _ { t } = ( - \alpha _ { t } \nabla _ { z } U _ { t } ( Z _ { t } ) + \nu _ { t } ( Z _ { t } ) ) \mathrm { d } t + \sigma _ { t } ( Z _ { t } ) \mathrm { d } W _ { t } , \qquad t \in [ 0 , 1 ] , ~ Z _ { 0 } \sim \mu _ { 0 } ,
101
+ $$
102
+
103
+ where $\alpha _ { t } > 0$ is the step size of the gradient flow of $U$ and $\nu$ is an extra perturbation term. The step size $\alpha _ { t }$ should increase to infinity as $t \to 1$ sufficiently fast to dominate the effect of the diffusion term $\sigma _ { t } \mathrm { d } W _ { t }$ and the perturbation $\nu _ { t } \mathrm { d } t$ term to ensure that $U$ is minimized at time $t = 1$ .
104
+
105
+ Proposition 3.3. Assume $U _ { t } ( z ) = U ( z , t )$ is a Lyapunov function of a measurable set $A$ at time 1 and $U ( \cdot , t ) \in C ^ { 2 } ( \mathbb R ^ { d } )$ and $U ( z , \cdot ) \in C ^ { 1 } ( [ 0 , 1 ] )$ . Then, $\mathbb { Q } ^ { A }$ in (4) is an bridge to $A$ , i.e., $\mathbb { Q } ^ { A } ( Z _ { 1 } \in A ) = 1$ , if the following holds:
106
+
107
+ $I ) U$ follows an (expected) Polyak-Lojasiewicz condition: $\mathbb { E } _ { \mathbb { Q } ^ { A } } [ U _ { t } ( Z _ { t } ) ] - \| \nabla _ { z } U _ { t } ( Z _ { t } ) \| ^ { 2 } ] \leq 0 , \forall t .$
108
+
109
+ 2) Let $\beta _ { t } = \mathbb { E } _ { \mathbb { Q } ^ { A } } [ \nabla _ { z } U _ { t } ( Z _ { t } ) ^ { \top } \nu _ { t } ( Z _ { t } ) ]$ , and $\begin{array} { r } { \gamma _ { t } = \mathbb { E } _ { \mathbb { Q } ^ { A } } [ \partial _ { t } U _ { t } ( Z _ { t } ) + \frac { 1 } { 2 } \mathrm { t r } ( \nabla _ { z } ^ { 2 } U _ { t } ( Z _ { t } ) \sigma _ { t } ^ { 2 } ( Z _ { t } ) ) ] , } \end{array}$ , and $\begin{array} { r } { \zeta _ { t } = \exp ( \int _ { 0 } ^ { t } \alpha _ { s } \mathrm { d } s ) } \end{array}$ . Then $\operatorname* { l i m } _ { t \uparrow 1 } \zeta _ { t } = + \infty$ , and $\begin{array} { r } { \operatorname* { l i m } _ { t \uparrow 1 } \frac { \zeta _ { t } } { \int _ { 0 } ^ { t } \zeta _ { s } ( \beta _ { s } + \gamma _ { s } ) \mathrm { d } s } = + \infty } \end{array}$ .
110
+
111
+ Brownian bridge can be viewed as the case when $U _ { t } ( z ) = \left\| x - z \right\| ^ { 2 } / 2$ and $\alpha _ { t } = \sigma _ { t } ^ { 2 } / ( \beta _ { 1 } - \beta _ { t } )$ , and $\nu = 0$ . Hence simply introducing an extra drift term into bridge bridge yields that a broad family of bridges to $x$ :
112
+
113
+ $$
114
+ \mathbb { Q } ^ { x , \mathrm { b b } , f } : \mathrm { ~ } \mathrm { ~ } \mathrm { ~ } \mathrm { ~ d ~ } Z _ { t } = \left( \sigma _ { t } f _ { t } ( Z _ { t } ) + \sigma _ { t } ^ { 2 } \frac { x - Z _ { t } } { \beta _ { 1 } - \beta _ { t } } \right) \mathrm { d } t + \sigma _ { t } \mathrm { d } W _ { t } , \quad Z _ { 0 } \sim \mu _ { 0 } .
115
+ $$
116
+
117
+ In Appendix A.4 and A.5, we show that $\mathbb { Q } ^ { x , \mathrm { b b } , f }$ is a bridge to $x$ if $\mathbb { E } _ { \mathbb { Q } ^ { x , \mathrm { b b } } } [ \left. f _ { t } ( Z _ { t } ) \right. ^ { 2 } ] < + \infty$ and $\sigma _ { t } > 0 , \forall t$ , which is very mild condition and is satisfied for most practical functions. The intuition is that the Brownian drift 2t xZt1 t is singular and grows to infinite as $t$ approaches 1. Hence, introducing an $f$ into the drift would not change of the final bridge condition, unless $f$ is also singular and has a magnitude that dominates the Brownian bridge drift as $t \to 1$ .
118
+
119
+ ![](images/fed0f1744fb6d9b7b796699236364764933dfcfc9b71cdbeb14b1192bec4fe55.jpg)
120
+ Figure 1: An overview of our training pipeline with molecule generation as an example. Initialized from a given distribution, we pass the data through the network multiple times, and finally get the meaningful output.
121
+
122
+ To make the model $\mathbb { P } ^ { \theta }$ compatible with the physical force $f$ , we assume the learnable drift has a form of $s _ { t } ^ { \theta } ( z ) = \alpha f _ { t } ( z ) \stackrel { . } { + } \tilde { s } _ { t } ^ { \theta } ( z )$ where $\tilde { s }$ is a neural network (typically a GNN) and $\alpha$ can be another learnable parameter or a pre-defined parameter. Please refer to algorithm 3.2 and Figure 1 for descriptions about our practical algorithm.
123
+
124
+ # Algorithm 1 Learning diffusion generative models.
125
+
126
+ Input: Given a dataset $\{ x ^ { ( k ) } \}$ , $\mathbb { Q } ^ { x }$ the bridge in (5), and a problem-dependent prior force $f , { \mathrm { v } }$ and a diffusion model $\mathbb { P } ^ { \theta }$ .
127
+ Training: Estimate $\theta$ by minimizing $\mathcal { L } ( \boldsymbol { \theta } )$ in (2) with stochastic gradient descent and time discretization.
128
+ Sampling: Simulate from $\mathbb { P } ^ { \theta }$ .
129
+
130
+ # 4 Molecule and 3D Generation with Informative Prior Bridges
131
+
132
+ We apply our method to the molecule generation as well as point cloud generation. Informative physical or statistical priors that reflects the underlying real physical structures can be particularly beneficial for molecule generation as we show in experiments.
133
+
134
+ In our problem, each data point $x$ is a collection of atoms of different types, more generally marked points, in 3D Euclidean space. In particular, we have $\boldsymbol { x } = [ x _ { i } ^ { r } , x _ { i } ^ { h } ] _ { i = 1 } ^ { \bar { m } }$ , where $x _ { i } ^ { r } \in \dot { \mathbb { R } } ^ { 3 }$ is the coordinate of the $i$ -th atom, and $x _ { i } ^ { h } \in \{ e _ { 1 } , \ldots , e _ { k } \}$ where each $e _ { i } = [ 0 \cdots 1 \cdot \cdot \cdot 0 ]$ is the $i \cdot$ -th basis vector of $\mathbb { R } ^ { k }$ , which indicates the type of the $i$ -th atom of $k$ categories. To apply the diffusion generative model, we treat $\boldsymbol { x } _ { i } ^ { h }$ as a continuous vector in $\mathbb { R } ^ { r }$ and round it to the closest basis vector when we want to output a final result or have computations that depend on atom types (e.g., calculating an energy function as we do in sequel). Specifically, for a continuous $x _ { i } ^ { h } \in \mathbb { R } ^ { k }$ , we denote by $\hat { x } _ { i } ^ { h } = \mathbb { I } ( x _ { i } ^ { h } = \operatorname* { m a x } ( x _ { i } ^ { h } ) )$ the discrete type rounded from it by taking the type with the maximum value. To incorporate priors, we design an energy function $E ( x )$ and incorporate $f _ { t } ( \cdot ) = - \nabla E ( \cdot )$ into the Brownian bridge (5) to guide the training process. We discuss different choices of $E$ in the following.
135
+
136
+ # 4.1 Prior Bridges for Molecule Generation
137
+
138
+ Previous prior guided molecule or protein 3D structure generation usually depends on pre-defined energy or force [30, 50]. We introduce our two potential energies. One is formulated inspired by previous works in biology, and the other is an $k$ nearest neighbour statistics directly obtained from the data.
139
+
140
+ AMBER Inspired Physical Energy. AMBER [12] is a family of force fields for molecule simulation. It is designed to provide a computationally efficient tool for modern chemistry-molecular dynamics and free energy calculations. It consists of a number of important forces, including the bond energy, angular energy, torsional energy, the van der Waals energy and the Coulomb energy. Inspired by AMBER, we propose to incorporate the following energy term into the bridge process:
141
+
142
+ $$
143
+ E ( x ) = E _ { b o n d } ( x ) + E _ { a n g l e } ( x ) + E _ { L J } ( x ) + E _ { C o u l o m b } ( x ) .
144
+ $$
145
+
146
+ • The bond energy is $\begin{array} { r } { E _ { b o n d } ( x ) \ = \ \sum _ { i j \in b o n d ( x ) } ( \operatorname { L e n } ( x _ { i j } ^ { r } ) \ - \ \ell ( \hat { x } _ { i } ^ { h } , \hat { x } _ { j } ^ { h } ) ) ^ { 2 } } \end{array}$ , where $\mathrm { L e n } ( x _ { i j } ^ { r } ) ~ =$ $\| x _ { i } ^ { r } - x _ { j } ^ { r } \|$ , and $b o n d ( x )$ denotes the set of bonds from $x$ , which is set to be the set of atom pairs with a distance smaller than 1.15 times the covalent radius; the $\ell ^ { 0 } ( r , c )$ denotes the expected bond length between atom type $r$ and $c$ , which we calculate as side information from the training data.
147
+
148
+ • The angle energy is $\begin{array} { r } { E _ { a n g l e } ( x ) = \sum _ { i j k \in a n g l e ( x ) } ( \operatorname { A n g } ( x _ { i j k } ^ { r } ) - \omega ^ { 0 } ( \hat { x } _ { i j k } ^ { h } ) ) ^ { 2 } } \end{array}$ , where angle $( x )$ denotes the set of angles between two neighbour bonds in $b o u n d ( x )$ , and $\mathrm { A n g } ( x _ { i j k } ^ { r } )$ denotes the angle formed by vector $x _ { i } ^ { r } - x _ { j } ^ { r }$ and $\boldsymbol { x } _ { k } ^ { r } - \boldsymbol { x } _ { j } ^ { r }$ , and $\omega ^ { 0 } ( \hat { x } _ { i j k } ^ { h } )$ is the expected angle between atoms of type $\hat { x } _ { i } ^ { h } , \hat { x } _ { j } ^ { h }$ , $\hat { x } _ { k } ^ { h }$ , which we calculate as side information from the training data.
149
+
150
+ • The Lennard-Jones (LJ) energy is defined by $\begin{array} { r } { E _ { L J } ( x ) = \sum _ { i \neq j } e ( \left| \left| x _ { i } ^ { r } - x _ { j } ^ { r } \right| \right| ) } \end{array}$ and $e ( \ell ) = ( \sigma / \ell ) ^ { 1 2 } -$ $2 ( \sigma / \ell ) ^ { 6 }$ . The parameter $\sigma$ is an approximation for average nucleus distance.
151
+
152
+ • The nuclei-nuclei repulsion (Coulomb) electromagnetic potential energy is $E _ { C o u l o m b } ( x ) \ =$ $\begin{array} { r l } { \kappa \sum _ { i j } q ( \hat { x } _ { i } ^ { h } ) q ( \hat { x } _ { j } ^ { h } ) / \left\| x _ { i } ^ { r } - x _ { j } ^ { r } \right\| } & { { } } \end{array}$ , where $\kappa$ is Coulomb constant and $q ( r )$ denotes the point charge of atom of type $r$ , which depends on the number of protons.
153
+
154
+ Statistical Energy. When accurate physic laws are unavailable, molecular geometric statistics, such as bond lengths, bond angles, and torsional angles, etc, can be directly calculated from the data and shed important insights on the system [e.g., 8, 21, 31]. We propose to design a prior energy function in bridges by directly calculate these statistics over the dataset.
155
+
156
+ Specifically, we assume that the lengths and angles of each type of bond follows a Gaussian distribution that we learn from the dataset, and define the energy function as the negative log-likelihood:
157
+
158
+ $$
159
+ E _ { s t a t } ( \boldsymbol { x } ) = \sum _ { i j \in k n n ( \boldsymbol { x } ) } \frac { 1 } { \hat { \sigma } _ { \hat { x } _ { i j } ^ { h } } ^ { 2 } } \left\| \mathrm { L e n } ( x _ { i j } ^ { r } ) - \hat { \mu } _ { \hat { x } _ { i j } ^ { h } } \right\| ^ { 2 } + \sum _ { i j , j k \in k n n ( \boldsymbol { x } ) } \frac { 1 } { \sigma _ { \hat { x } _ { i j k } ^ { h } } ^ { 2 } } \left\| \mathrm { A n g } ( x _ { i j k } ^ { r } ) - \mu _ { \hat { x } _ { i j k } ^ { h } } \right\| ^ { 2 } ,
160
+ $$
161
+
162
+ where $k n n ( x )$ denotes the $\mathrm { K }$ -nearest neighborhood graph constructed based on the distance matrix of $x$ ; for each pair of atom types $r , c \in [ k ]$ , $\hat { \mu } _ { r c }$ and $\hat { \sigma } _ { r c } ^ { 2 }$ denotes empirical mean and variance of length of $r c$ -edges in the dataset; for each triplet $r , c , r ^ { \prime } \in [ k ]$ , $\hat { \mu } _ { r c r ^ { \prime } }$ and $\hat { \sigma } _ { r c r ^ { \prime } } ^ { 2 }$ is the empirical mean and variance of angle betwen $r c$ and $c r ^ { \prime }$ bonds.
163
+
164
+ Intuitively, depending on the atom type and order of the nearest neighbour, we force the atom distance and angle to mimic the statistics calculated from the data. We thus implicitly capture different kinds of interaction forces. Compared with the AMBER energy, the statistical energy (7) is simpler and more adaptive to the dataset of interest.
165
+
166
+ # 4.2 Prior Bridges for Point Cloud Generation
167
+
168
+ We design prior forces for 3D point cloud generation, which is similar to molecule generation except that the points are un-typed so we only have the coordinates $\{ x _ { i } ^ { r } \}$ . One important aspect of point cloud generation is to distribute points uniformly on the surface, which is important for producing high-quality meshes and other post-hoc geometry applications and manipulations.
169
+
170
+ Riesz Energy. One idea to make the point distribute uniformly is adding a repulsive force to separate the points apart from each other [24, 15, 16]. We achieve this by minimizing the Riesz energy [17],
171
+
172
+ $$
173
+ E _ { \mathrm { R i e s z } } ( x ) = \frac { 1 } { 2 } \sum _ { j \neq i } | | x _ { i } ^ { r } - x _ { j } ^ { r } | | ^ { - 2 } .
174
+ $$
175
+
176
+ KNN Distance Energy. Similar to molecule design, we directly calculate the average distance between each point and its $\mathbf { k }$ nearest neighbour neighbour, and define the following energy:
177
+
178
+ $$
179
+ E _ { \mathrm { k n n } } ( x ) = \sum _ { i } \left( \mathrm { k n n - d i s t } _ { i } ( x ^ { r } ) - \mu _ { k n n } \right) ^ { 2 } ,
180
+ $$
181
+
182
+ where $\begin{array} { r } { \mathrm { k n n - d i s t } _ { i } ( x ) \ = \ \frac { 1 } { K } \sum _ { j \in { \mathcal N } _ { K } ( x _ { i } ; x ) } | | x _ { i } ^ { r } - x _ { j } ^ { r } | | ^ { 2 } } \end{array}$ denotes the average distance from $x _ { i }$ to its $K$ nearest neighbors, and $\mu _ { k n n }$ is the empirical mean of $\scriptstyle \mathrm { k n n - d i s t } _ { i } ( x )$ in the dataset. This would encourage the points to have similar average nearest neighbor distance and yield uniform distribution between points. In common geometric setups, the valence of the point on the surface is 4, which means we set $k = 4$ .
183
+
184
+ # 5 Experiment
185
+
186
+ We verify the advantages of our proposed method (Bridge with Priors) in several different domains. We first compare our method with advanced generators (e.g., diffusion model, normalizing flow, etc.) on molecule generation tasks. We then implement our method on point cloud generations, which targets producing generated samples in a higher quality. We directly compare the performance and also analyze the difference between our energy prior and other energies we discuss in Section 3.
187
+
188
+ # 5.1 Force Guided Molecule Generation
189
+
190
+ To demonstrate the efficiency and effectiveness of our bridge processes and physical energy, we conduct experiments on molecule and macro-molecule generation experiments. We follow [29] in settings and observe that our proposed prior bridge processes consistently improve the state-of-the-art performance. Diving deeper, we analyze the impact of different energy terms and hyperparameters.
191
+
192
+ Metrics. Following [19, 37], we use the atom and molecular stability score to measure the model performance. The atom stability is the proportion of atoms that have the right valency while the molecular stability stands for the proportion of generated molecules for which all atoms are stable. For visualization, we use the distance between pairs of atoms and the atom types to predict bond types, which is a common practice. we extracted 10,000 samples to calculate the above metrics.
193
+
194
+ Dataset Settings QM9 [36] molecular properties and atom coordinates for 130k small molecules with up to 9 heavy atoms with 5 different types of atoms. This data set contains small amino acids, such as GLY, ALA, as well as nucleobases cytosine, uracil, and thymine. We follow the common practice in [19] to split the train, validation, and test partitions, with 100K, 18K, and 13K samples. GEOM-DRUG [4] is a dataset that contains drug-like molecules. It features 37 million molecular conformations annotated by energy and statistical weight for over 450,000 molecules. Each molecule contains 44 atoms on average, with 5 different types of atoms. Following [19, 37], we retain the 30 lowest energy conformations for each molecule.
195
+
196
+ Training Configurations. On QM9, we train the EGNNs with 256 hidden features and 9 layers for 1100 epochs, a batch size 64, and a constant learning rate $1 0 ^ { - 4 }$ , which is the default training configuration. We use the polynomial noise schedule used in [19] which linearly decay from $1 0 ^ { - 2 } / \check { T }$ to 0. We linearly decay $\alpha$ from $1 0 ^ { - 3 } / T$ to $0 \ w . r . t .$ . time step. We set $k = 5$ (7) by default. On GEOM-DRUG, we train the EGNNs with 256 hidden features and 8 layers with batch size 64, a constant learning rate $1 0 ^ { - 4 }$ , and 10 epochs. It takes approximately 10 days to train the model on these two datasets on one Tesla V100-SXM2-32GB GPU. We provide E(3) Equivariant Diffusion Model (EDM) [19] and E(3) Equivariant Normalizing Flow (EN-Flow) [37] as our baselines. Both two are trained with the same configurations as ours.
197
+
198
+ Table 1: Results of our method and several baselines on QM9 and GEOM-DRUG. We evaluate the percentage of valid and unique molecules out of 12000 generated molecules.
199
+
200
+ <table><tr><td></td><td colspan="3">QM9</td><td colspan="2">GEOM-DRUG</td></tr><tr><td></td><td>Atom Sta (%)↑</td><td>Mol Sta (%)↑</td><td>Valid + Unique↑</td><td>Atom Sta (%)↑</td><td>Mol Sta (%)↑</td></tr><tr><td>EN-Flow [37]</td><td>85.0</td><td>4.9</td><td>0.349</td><td>75.0</td><td>0.0</td></tr><tr><td>GDM[19]</td><td>97.0</td><td>63.2</td><td>=</td><td>75.0</td><td>0.0</td></tr><tr><td>E-GDM[19]</td><td>98.7±0.1</td><td>82.0±0.4</td><td>0.902</td><td>81.3</td><td>0.0</td></tr><tr><td>Bridge</td><td>98.7±0.1</td><td>81.8±0.2</td><td>0.902</td><td>81.0±0.7</td><td>0.0</td></tr><tr><td>Bridge +Force (7)</td><td>98.8±0.1</td><td>84.6±0.3</td><td>0.907</td><td>82.4±0.8</td><td>0.0</td></tr></table>
201
+
202
+ ![](images/c9c7bf2a458b4cf079220b5f56d0df505339fdfbddbc9390fc32e45c7896e562.jpg)
203
+ Figure 2: Examples of molecules generated by our method on QM9 and GEOM-DRUG.
204
+
205
+ Results. We summarize our experimental results in Table 1. We observe that (1) our method generates molecules with better qualities than the others. On QM9, we notice that we improve the molecule stability score by a large margin (from 82.0 to 84.6) and slightly improve the atom stability score $\mathrm { f r o m 9 8 . 7 }$ to 98.8). It indicates that with the informed prior bridge helps improves the quality of the generated molecules. (2) On the GEOM-DRUG dataset, the atom stability is improved from 81.3 to 82.4, which shows that our method can work for macro-molecules. (3) We visualize and qualitatively evaluate our generate molecules. Figure 3 displays the trajectory on GEOM-DRUG and Figure 2 shows the samples on two datasets. (4) Bridge processes and E-GDM obtain comparable results on our tested benchmarks. (5) The computational load added by introducing prior bridges is small. Compared to EGM, we only introduce $8 \%$ additional cost in training and $3 \%$ for inference.
206
+
207
+ ![](images/190ef69721ea69d88210f0ae083932532ee7015b781155d1af58259024978e67.jpg)
208
+ Time Step
209
+ Figure 3: An example of generation trajectory following $\mathbb { P } ^ { \theta }$ of our method, trained on GEOM-DRUG.
210
+
211
+ Table 2: We compare w. and w/o force results with different discretization time steps.
212
+
213
+ <table><tr><td></td><td colspan="4">Time Step</td></tr><tr><td></td><td>50</td><td>100</td><td></td><td>500</td></tr><tr><td></td><td>Atom Stable (%) Mol Stable (%)</td><td>Atom Stable (%)</td><td>Mol Stable (%)</td><td>Atom Stable (%) Mol Stable (%)</td></tr><tr><td>EGM</td><td>97.0±0.1 66.4±0.2</td><td>97.3±0.1</td><td>69.8±0.2</td><td>98.5±0.1 81.2±0.1</td></tr><tr><td>Bridge +Force (7)</td><td>97.3±0.1</td><td>69.2±0.2 97.9±0.1</td><td>72.3±0.2</td><td>98.7±0.1 83.7±0.1</td></tr></table>
214
+
215
+ Result: Better With Fewer Time Steps. We display the performance of our method with fewer time steps in Table 2. We observe that (1) with fewer time steps, the baseline EGM method gets worse results than 1000 steps in Table 1. (2) with 500 steps, our method still keeps a consistently good performance. (3) with even fewer 50 or 100 steps, our method yields a worse result than 1000 steps in Table 1, but still outperforms the baseline method by a large margin.
216
+
217
+ Table 3: We compare EGM models trained with different force mentioned in Section 3.
218
+
219
+ <table><tr><td>Method</td><td>Atom Stable (%)</td><td>Mol Stable (%)</td><td>Method</td><td>Atom Stable (%)</td><td>Mol Stable (%)</td></tr><tr><td>Force (7),k=7</td><td>98.8±0.1</td><td>84.5±0.2</td><td>Force (6)</td><td>98.7±0.1</td><td>83.1±0.2</td></tr><tr><td>Force (7),k =5</td><td>98.8±0.1</td><td>84.6±0.3</td><td>Force (6) w/o.bond</td><td>98.7±0.1</td><td>82.5±0.1</td></tr><tr><td>Force (7), k = 3</td><td>98.8±0.1</td><td>83.9±0.3</td><td>Force (6) w/o.angle</td><td>98.7±0.1</td><td>82.4±0.2</td></tr><tr><td>Force (7), k =1</td><td>98.8±0.1</td><td>82.7±0.3</td><td>Force (6) w/o.Long-range</td><td>98.7±0.1</td><td>82.7±0.2</td></tr></table>
220
+
221
+ Ablation: Impacts of Different Energies. We apply several energies we discuss in Section 3, and compare them on the QM9 dataset. (1) We notice that our energy (7) gets better performance with larger $k$ when $k \leq 5$ . $k = 7$ achieves comparable performance as $k = 5$ . Larger $k$ also requires more computation time, which yields a trade-off between performance and efficiency. (2) For (6), once removing a typical term, the performance drops. (3) In all the cases, applying additional forces outperforms the bridge processes baseline w/o. force.
222
+
223
+ # 5.2 Force Guided Point Cloud Generation
224
+
225
+ We apply uniformity-promoting priors to point cloud generation. We apply our method based on the diffusion model for point cloud generation introduced by point cloud diffusion model [28] and compare it with the original diffusion model as well as the case of bridge processes w/o. force prior. We observe that our method yields better results in various evaluation metrics under different setups.
226
+
227
+ Dataset. We use the ShapeNet [6] dataset for point cloud generation. ShapeNet contains 55 categories. We select Airplane and Chair, which are the two most common categories to evaluate in recent point cloud generation works [5, 28, 51, 52]. We construct the point clouds following the setup in [28], split the train, valid and test dataset in $8 0 \%$ , $1 5 \%$ and $5 \%$ and samples 2048 points uniformly on the mesh surface.
228
+
229
+ Evaluation Metric. We evaluate the generated shape quality in two aspects following the previous works, including the minimum matching distance (MMD) and coverage score (COV). These scores are the two most common practices in the previous works. We use Chamfer Distance (CD) and Earth Mover’s Distance (EMD) as the distance metric to compute the MMD and COV.
230
+
231
+ Experiment Setup. We train the model with two different configurations. The first one uses exactly the same experiment setup configuration introduced in [28]. Thus, we use the same model architecture and train the model in 100 diffuse steps with a learning rate $2 \times 1 0 ^ { - 3 }$ , batch size 128, and linear noise schedule from 0.02 to $1 0 ^ { - 4 }$ . We initial $\alpha$ with 0.1 and jointly learn it with the network. For the second setup, to evaluate the better converge speed of our method, we decrease the diffuse step from 100 to 10 with other settings the same. For the diffusion model baseline, we reproduce the number by directly using the pre-trained model checkpoint and testing it on the test set provided by the official codebase.
232
+
233
+ ![](images/3919a2cd244bc92f1306b07ed27282b30134cec03c2435392a6b6063606a635c.jpg)
234
+ Figure 4: From left to right are examples of point clouds generated by [28], our method with uniformative bridge $f _ { t } = 0 ,$ ), bridge with Riesz energy $( f _ { t } = - \nabla E _ { \mathrm { { R i e s z } } } )$ and with KNN energy $( f _ { t } = - \nabla E _ { k n n } )$ . We see that the Riesz and KNN energies yield more uniformly distributed points. Riesz energy sometimes creates additional outlier points due to its repulsive nature.
235
+
236
+ Result. We show our experimental result in Table 4. We see that (1) In the 10 steps setup, all variants of our approach are clearly stronger than the diffusion model. With force added, our method with physical prior achieves nearly the same performance as the 100 steps setup. (2) In the 100 steps setup, adding energy potential as prior improves the bridge process performance and further let it beat the diffusion model baseline.(3) Since the test points are uniformly sampled on the surface, a better score indicates a closer point distribution to the reference set. Further, when compare with Riesz energy (8), statistic gap energy (9) performs better. One explanation is the Riesz energy pushes the points to some outlier position in sample generate samples, while statistic gap energy is more robust. We also show visualization samples in Figure 4.
237
+
238
+ Table 4: Point cloud generation results. CD is multiplied by $\mathrm { 1 0 ^ { 3 } }$ , EMD is multiplied by 10.
239
+
240
+ <table><tr><td></td><td></td><td colspan="4">10 Steps</td><td colspan="4">100 Steps</td></tr><tr><td></td><td></td><td colspan="2">MMD↓</td><td colspan="2">COV↑</td><td colspan="2">MMD↓</td><td colspan="2">COV↑</td></tr><tr><td></td><td></td><td>CD</td><td>EMD</td><td>CD</td><td>EMD</td><td>CD</td><td>EMD</td><td>CD</td><td>EMD</td></tr><tr><td rowspan="4">Chair</td><td>Diffusion [28]</td><td>14.01</td><td>3.23</td><td>32.72</td><td>29.36</td><td>12.32</td><td>1.79</td><td>47.41</td><td>47.59</td></tr><tr><td>Bridge</td><td>13.04</td><td>2.14</td><td>46.01</td><td>42.59</td><td>12.47</td><td>1.85</td><td>47.83</td><td>47.13</td></tr><tr><td>+Riesz</td><td>12.84</td><td>1.95</td><td>47.21</td><td>44.31</td><td>12.31</td><td>1.82</td><td>48.14</td><td>47.42</td></tr><tr><td>+ Statistic</td><td>12.65</td><td>1.84</td><td>47.58</td><td>45.23</td><td>12.25</td><td>1.78</td><td>48.39</td><td>47.56</td></tr><tr><td rowspan="4">Airplane</td><td rowspan="2">Diffusion [28] Bridge</td><td>3.71</td><td>1.31</td><td>43.12</td><td>39.94</td><td>3.28</td><td>1.04</td><td>48.74</td><td>46.38</td></tr><tr><td>3.44</td><td>1.24</td><td>46.90</td><td>43.46</td><td>3.37</td><td>1.08</td><td>47.11</td><td>46.17</td></tr><tr><td>+Riesz</td><td>3.39</td><td>1.20</td><td>47.11</td><td>43.12</td><td>3.24</td><td>1.09</td><td>48.62</td><td>46.23</td></tr><tr><td>+ Statistic</td><td>3.30</td><td>1.12</td><td>47.02</td><td>44.67</td><td>3.24</td><td>1.06</td><td>48.53</td><td>46.73</td></tr></table>
241
+
242
+ # 6 Conclusion and Limitations
243
+
244
+ We propose a framework to inject informative priors into learning neural parameterized diffusion models, with applications to both molecules and 3D point cloud generation. Empirically, we demonstrate that our method has the advantages such as better generation quality, less sampling time and easy-to-calculate potential energies. For future works, we plan to 1) study the relation between different types of forces for different domain of molecules, 2) study how to generate valid proteins in which the number of atoms is very large, and 3) apply our method to more realistic applications such as antibody design or hydrolase engineering.
245
+
246
+ In both energy functions in (7) and (6), we do not add torsional angle related energy [20] mainly because it is hard to verify whether four atoms are bonded together during the stochastic process. We plan to study how to include this for better performance in future works.
247
+
248
+ Another weakness of deep diffusion bridge processes are their computation time. Similar to previous diffusion models [29], it takes a long time to train a model. We attempted to speed the training up by using a large batch size (e.g., 512, 1024) but found a performance drop. An important future direction is to study methods to distribute and accelerate the training.
249
+
250
+ Acknowledgements Authors are supported in part by CAREER-1846421, SenSE-2037267, EAGER-2041327, and Office of Navy Research, and NSF AI Institute for Foundations of Machine Learning (IFML). We would like to thank the anonymous reviewers and the area chair for their thoughtful comments and efforts towards improving our manuscript.
251
+
252
+ References
253
+ [1] Panos Achlioptas, Olga Diamanti, Ioannis Mitliagkas, and Leonidas Guibas. Learning representations and generative models for 3d point clouds. In International conference on machine learning, pages 40–49. PMLR, 2018.
254
+ [2] Miguel Alcalde, Manuel Ferrer, Francisco J Plou, and Antonio Ballesteros. Environmental biocatalysis: from remediation with enzymes to novel green processes. TRENDS in Biotechnology, 24(6):281–287, 2006.
255
+ [3] Namrata Anand, Raphael Eguchi, Irimpan I Mathews, Carla P Perez, Alexander Derry, Russ B Altman, and Po-Ssu Huang. Protein sequence design with a learned potential. Nature communications, 13(1):1–11, 2022.
256
+ [4] Simon Axelrod and Rafael Gómez-Bombarelli. Geom, energy-annotated molecular conformations for property prediction and molecular generation. Scientific Data, 9(1):185, 2022.
257
+ [5] Ruojin Cai, Guandao Yang, Hadar Averbuch-Elor, Zekun Hao, Serge Belongie, Noah Snavely, and Bharath Hariharan. Learning gradient fields for shape generation. In European Conference on Computer Vision, pages 364–381. Springer, 2020.
258
+ [6] Angel X Chang, Thomas Funkhouser, Leonidas Guibas, Pat Hanrahan, Qixing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, et al. Shapenet: An information-rich 3d model repository. arXiv preprint arXiv:1512.03012, 2015.
259
+ [7] Tianrong Chen, Guan-Horng Liu, and Evangelos A Theodorou. Likelihood training of schr\" odinger bridge using forward-backward sdes theory. arXiv preprint arXiv:2110.11291, 2021.
260
+ [8] Wendy D Cornell, Piotr Cieplak, Christopher I Bayly, Ian R Gould, Kenneth M Merz, David M Ferguson, David C Spellmeyer, Thomas Fox, James W Caldwell, and Peter A Kollman. A second generation force field for the simulation of proteins, nucleic acids, and organic molecules. Journal of the American Chemical Society, 117(19):5179–5197, 1995.
261
+ [9] Valentin De Bortoli, James Thornton, Jeremy Heng, and Arnaud Doucet. Diffusion schrödinger bridge with applications to score-based generative modeling. Advances in Neural Information Processing Systems, 34, 2021.
262
+ [10] Joseph L Doob and JI Doob. Classical potential theory and its probabilistic counterpart, volume 549. Springer, 1984.
263
+ [11] Yuanqi Du, Tianfan Fu, Jimeng Sun, and Shengchao Liu. Molgensurvey: A systematic survey in machine learning models for molecule design. arXiv preprint arXiv:2203.14500, 2022.
264
+ [12] Yong Duan, Chun Wu, Shibasish Chowdhury, Mathew C Lee, Guoming Xiong, Wei Zhang, Rong Yang, Piotr Cieplak, Ray Luo, Taisung Lee, et al. A point-charge force field for molecular mechanics simulations of proteins based on condensed-phase quantum mechanical calculations. Journal of computational chemistry, 24(16):1999–2012, 2003.
265
+ [13] Niklas Gebauer, Michael Gastegger, and Kristof Schütt. Symmetry-adapted generation of 3d point sets for the targeted discovery of molecules. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 7566–7578. Curran Associates, Inc., 2019.
266
+ [14] Dwaraknath Gnaneshwar, Bharath Ramsundar, Dhairya Gandhi, Rachel Kurchin, and Venkatasubramanian Viswanathan. Score-based generative models for molecule generation. arXiv preprint arXiv:2203.04698, 2022.
267
+ [15] Chengyue Gong, Xingchao Liu, and Qiang Liu. Automatic and harmless regularization with constrained and lexicographic optimization: A dynamic barrier approach. Advances in Neural Information Processing Systems, 34:29630–29642, 2021.
268
+ [16] Chengyue Gong, Lemeng Wu, and Qiang Liu. How to fill the optimum set? population gradient descent with harmless diversity. arXiv preprint arXiv:2202.08376, 2022.
269
+ [17] Mario Götz. On the riesz energy of measures. Journal of Approximation Theory, 122(1):62–78, 2003.
270
+ [18] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
271
+ [19] Emiel Hoogeboom, Victor Garcia Satorras, Clément Vignac, and Max Welling. Equivariant diffusion for molecule generation in 3d. arXiv preprint arXiv:2203.17003, 2022.
272
+ [20] Bowen Jing, Gabriele Corso, Regina Barzilay, and Tommi S Jaakkola. Torsional diffusion for molecular conformer generation. In ICLR2022 Machine Learning for Drug Discovery, 2022.
273
+ [21] William L Jorgensen, David S Maxwell, and Julian Tirado-Rives. Development and testing of the opls all-atom force field on conformational energetics and properties of organic liquids. Journal of the American Chemical Society, 118(45):11225–11236, 1996.
274
+ [22] John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Zídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021.
275
+ [23] Shengchao Liu, Hanchen Wang, Weiyang Liu, Joan Lasenby, Hongyu Guo, and Jian Tang. Pre-training molecular graph representation with 3d geometry. arXiv preprint arXiv:2110.07728, 2021.
276
+ [24] Xingchao Liu, Xin Tong, and Qiang Liu. Profiling pareto front with multi-objective stein variational gradient descent. Advances in Neural Information Processing Systems, 34:14721– 14733, 2021.
277
+ [25] Xingchao Liu, Lemeng Wu, Mao Ye, and Qiang Liu. Let us build bridges: Understanding and extending diffusion generative models. arXiv preprint arXiv:2208.14699, 2022.
278
+ [26] Hongyuan Lu, Daniel J Diaz, Natalie J Czarnecki, Congzhi Zhu, Wantae Kim, Raghav Shroff, Daniel J Acosta, Bradley R Alexander, Hannah O Cole, Yan Zhang, et al. Machine learningaided engineering of hydrolases for pet depolymerization. Nature, 604(7907):662–667, 2022.
279
+ [27] Shitong Luo, Jiaqi Guan, Jianzhu Ma, and Jian Peng. A 3d molecule generative model for structure-based drug design. arXiv preprint arXiv:2203.10446, 2022.
280
+ [28] Shitong Luo and Wei Hu. Diffusion probabilistic models for 3d point cloud generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2021.
281
+ [29] Shitong Luo, Jiahan Li, Jiaqi Guan, Yufeng Su, Chaoran Cheng, Jian Peng, and Jianzhu Ma. Equivariant point cloud analysis via learning orientations for message passing. arXiv preprint arXiv:2203.14486, 2022.
282
+ [30] Shitong Luo, Chence Shi, Minkai Xu, and Jian Tang. Predicting molecular conformation via dynamic graph score matching. Advances in Neural Information Processing Systems, 34, 2021.
283
+ [31] M Riad Manaa, Laurence E Fried, Carl F Melius, Marcus Elstner, and Th Frauenheim. Decomposition of hmx at extreme conditions: A molecular dynamics simulation. The Journal of Physical Chemistry A, 106(39):9024–9029, 2002.
284
+ [32] Elman Mansimov, Omar Mahmood, Seokho Kang, and Kyunghyun Cho. Molecular geometry prediction using a deep generative graph neural network. Scientific reports, 9(1):1–13, 2019.
285
+ [33] Xuerong Mao. Stochastic differential equations and applications. Elsevier, 2007.
286
+ [34] B. Oksendal. Stochastic differential equations: an introduction with applications. Springer Science & Business Media, 6 edition, 2013.
287
+ [35] Stefano Peluchetti. Non-denoising forward-time diffusions, 2022.
288
+ [36] Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole Von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific data, 1(1):1–7, 2014.
289
+ [37] Victor Garcia Satorras, Emiel Hoogeboom, Fabian B Fuchs, Ingmar Posner, and Max Welling. E (n) equivariant normalizing flows. arXiv preprint arXiv:2105.09016, 2021.
290
+ [38] Chence Shi, Shitong Luo, Minkai Xu, and Jian Tang. Learning gradient fields for molecular conformation generation. In International Conference on Machine Learning, 2021.
291
+ [39] Gregor NC Simm and José Miguel Hernández-Lobato. A generative model for molecular distance geometry. arXiv preprint arXiv:1909.11459, 2019.
292
+ [40] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015.
293
+ [41] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
294
+ [42] Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum likelihood training of score-based diffusion models. Advances in Neural Information Processing Systems, 34, 2021.
295
+ [43] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
296
+ [44] Francisco Vargas, Pierre Thodoroff, Austen Lamacraft, and Neil Lawrence. Solving schrödinger bridges via maximum likelihood. Entropy, 23(9):1134, 2021.
297
+ [45] Gefei Wang, Yuling Jiao, Qian Xu, Yang Wang, and Can Yang. Deep generative learning via schrödinger bridge. In International Conference on Machine Learning, pages 10794–10804. PMLR, 2021.
298
+ [46] Sheng Wang, Siqi Sun, Zhen Li, Renyu Zhang, and Jinbo Xu. Accurate de novo prediction of protein contact map by ultra-deep learning model. PLoS computational biology, 13(1):e1005324, 2017.
299
+ [47] Fang Wu, Qiang Zhang, Xurui Jin, Yinghui Jiang, and Stan Z Li. A score-based geometric model for molecular dynamics simulations. arXiv preprint arXiv:2204.08672, 2022.
300
+ [48] Minkai Xu, Shitong Luo, Yoshua Bengio, Jian Peng, and Jian Tang. Learning neural generative dynamics for molecular conformation generation. arXiv preprint arXiv:2102.10240, 2021.
301
+ [49] Minkai Xu, Wujie Wang, Shitong Luo, Chence Shi, Yoshua Bengio, Rafael Gomez-Bombarelli, and Jian Tang. An end-to-end framework for molecular conformation generation via bilevel programming. In International Conference on Machine Learning, 2021.
302
+ [50] Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. Geodiff: A geometric diffusion model for molecular conformation generation. In International Conference on Learning Representations, 2022.
303
+ [51] Guandao Yang, Xun Huang, Zekun Hao, Ming-Yu Liu, Serge Belongie, and Bharath Hariharan. Pointflow: 3d point cloud generation with continuous normalizing flows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4541–4550, 2019.
304
+ [52] Linqi Zhou, Yilun Du, and Jiajun Wu. 3d shape generation and completion through point-voxel diffusion. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5826–5835, 2021.
md/dev/UPnJuDKqOfX/UPnJuDKqOfX.md ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HF-NeuS: Improved Surface Reconstruction Using High-Frequency Details
2
+
3
+ Yiqun Wang KAUST
4
+
5
+ Ivan Skorokhodov KAUST
6
+
7
+ Peter Wonka KAUST
8
+
9
+ # Abstract
10
+
11
+ Neural rendering can be used to reconstruct implicit representations of shapes without 3D supervision. However, current neural surface reconstruction methods have difficulty learning high-frequency geometry details, so the reconstructed shapes are often over-smoothed. We develop HF-NeuS, a novel method to improve the quality of surface reconstruction in neural rendering. We follow recent work to model surfaces as signed distance functions (SDFs). First, we offer a derivation to analyze the relationship between the SDF, the volume density, the transparency function, and the weighting function used in the volume rendering equation and propose to model transparency as a transformed SDF. Second, we observe that attempting to jointly encode high-frequency and low-frequency components in a single SDF leads to unstable optimization. We propose to decompose the SDF into base and displacement functions with a coarse-to-fine strategy to increase the high-frequency details gradually. Finally, we design an adaptive optimization strategy that makes the training process focus on improving those regions near the surface where the SDFs have artifacts. Our qualitative and quantitative results show that our method can reconstruct fine-grained surface details and obtain better surface reconstruction quality than the current state of the art. Code available at https://github.com/yiqun-wang/HFS.
12
+
13
+ # 1 Introduction
14
+
15
+ 3D reconstruction from a set of images is a fundamental challenge in computer vision [9]. In the recent past, the seminal framework NeRF [19] inspired a lot of follow up work by modeling 3D objects as a density function $\sigma ( x )$ and view-dependent color $c ( x , v )$ for each point $x \in R ^ { 3 }$ in the volume. The density function and view-dependent color function are implicit functions modeled by a neural network. The results of this approach are very strong and therefore NeRF inspired a large amount of follup up work, e.g. [18, 17, 24, 35, 20, 2].
16
+
17
+ In particular, one direction of work tries to constrain the density field to make it more consistent with a density field stemming from a surface. In the original formulation, almost arbitrary densities can be modeled by the neural network and there is no guarantee that a meaningful surface can be extracted from the density. Two noteworthy recent approaches, Neus [30] and VolSDF [32], proposed to embed a signed distance field in the volume rendering equation. Therefore, instead of modeling the density $\sigma$ with a neural network, these approaches model a signed distance function $f$ with a neural network. This leads to greatly improved surface reconstruction.
18
+
19
+ We build on this exciting recent work and seek further improvement in the quality of surfaces that are being reconstructed. To this end, we propose our method HF-NeuS consisting of three new building blocks. First, we analyze the relationship between the signed distance function on the one hand and the volume density, the transparency, and the weighting function on the other hand. We conclude from our derivation that it would be best to model a function that maps signed distances to the transparency and propose a class of functions that fulfill the theoretical requirements. Second, we observe that it is challenging to learn high-frequency details directly with a single signed distance function as shown in Fig. 2. We therefore propose to decompose the signed distance function into a base function and a displacement function following related work. We adapt this idea to the differentiable NeRF rendering framework and the NeRF training scheme. Third, the functions that translate distance to transparency can be chosen to have a parameter, which we call scale $s$ . It controls the slope of the function (or the deviation of the derivative), which further controls the localization precision of the surface and how much out-of-surface colors influence the result. In previous work, this parameter $s$ is set globally but is trainable, so it can change from iteration to iteration. We propose a novel spatially adaptive weighting scheme to influence this parameter, so that the optimization focuses more on problematic regions in the distance field. The three building blocks are the three main contributions of the paper. In the results, we can see that HF-NeuS has a clear improvement in surface reconstruction. On the 15 scene DTU benchmark we can improve from the current best values of 0.87 (NeuS) and 0.86 (VolSDF) to 0.77 the Chamfer distance (See Figs. 1 and 4 for a visual comparison). The benchmark as well as the metric were proposed by previous work.
20
+
21
+ ![](images/bd55e0371d31fb85b857dc5e4ee6291ef685ee518c3b45c3bb50132a4b8e13fa.jpg)
22
+ Figure 1: Qualitative evaluation on the Lego, Robot, and Ficus models. First column: reference images. Second to the fifth column: NeRF, VolSDF, NeuS, and OURS.
23
+
24
+ ![](images/c4ffae993a77aed4fe6f0f16e23186233ecd361a12e8e743c0655817011511e4.jpg)
25
+ Figure 2: The challenge of using high-frequencies directly in the NeuS framework. First column: reference image. Second to the fourth column: NeuS, NeuS with high-frequency details, and OURS.
26
+
27
+ # 2 Related Work
28
+
29
+ Multi-view 3D reconstruction. 3D reconstruction based on multiple views is a fundamental challenge in the field of 3D vision. Classical 3D reconstruction algorithms usually reconstruct discrete 3D representations. The methods can be roughly categorized into voxel-based methods and point-based methods. Voxel-based methods [6, 27, 14, 4, 11, 22] first discretize the threedimensional space uniformly into voxels, and then decide whether the surface occupies a particular voxel. Point-based methods [1, 7, 26, 25, 8] usually use the correlation between multiple views to reconstruct depth maps and fuse multiple depth maps into a point cloud. The point cloud needs to be subsequently reconstructed into a mesh model using explicit algorithms like ball-pivoting [3] and Delaunay trianglulation [15] or implicit algorithms like Poisson surface reconstruction [13].
30
+
31
+ Neural implicit surfaces. Recently, neural implicit representations have received a lot of attention. The corresponding methods aim to reconstruct continuous implicit function representations of shapes directly from 2D images. A required building block is differentiable rendering, which maps the 3D scene representation to a 2D image for a given camera pose. DVR [21] utilizes surface rendering to model the occupancy function of a 3D shape, which uses a root search approach to obtain the location of the surface and predicts a 2D image. IDR [33] models the signed distance function of the shape and uses a sphere tracking algorithm to render 2D images. A significant milestone in 3D reconstruction was the development of NeRF [19]. It uses volume rendering to map a 3D density field and a 3D directional color field to a 2D image. The proposed representation is flexible enough so that realistic images can be synthesized. To model more complex scenes, $_ \mathrm { N e R F + + }$ [35] proposes to model the background scene with an additional neural radiance field, which handles the foreground and background separately, and achieves better results for large scenes. However, the density function is not as easy to control as the occupancy function or the signed distance function, and it is difficult to guarantee the smoothness of the generated 3D shape. Subsequently, UNISURF [23] embeds the occupancy function into the volume rendering equation of NeRF. They use a decay strategy to control which region to sample around the surface during training without explicitly modeling volumetric density. Using signed distance functions, VolSDF [32] embeds a signed distance function into the density formulation and proposes a sampling strategy that satisfies a derived error bound on the transparency function. NeuS [30] derive an unbiased density function equation using logistic sigmoid functions and introduce a learnable parameter to control the function’s slope during rendering and sampling. Concurrent to our work, NeuralPatch [5] uses the homography matrix to warp the source patches adjacent to the reference image to constrain colors in the volume to come from closeby patches. However, the calculation of patch warping relies on the accurate surface normal, so it cannot be trained from scratch. Therefore, it is only used as a fine-tuning or post-processing method for other algorithms to optimize the surface. We consider VolSDF and NeuS as the current state of the art and we will compare to these two methods.
32
+
33
+ High-frequency detail reconstruction. It is generally difficult for neural networks to learn highfrequency information from raw signals. Inspired by the field of natural language processing, positional encoding [19, 29] is used to guide the network to reconstruct high-frequency details. Positional encoding spreads the original signal into different frequency bands using sine and cosine functions of different frequency. Subsequently, SIREN [28] proposes to use the sin function as activation function in the network. MipNeRF [2] presents an integrated positional encoding to control frequency in different scales. Park et al. [24] proposed to use a coarse-to-fine learning strategy to gradually increase high-frequency information, which was subsequently used for pose estimation [17]. Hertz et al. [10] further propose a spatially adaptive progressive coding strategy. For surface reconstruction, implicit displacement fields were proposed for single-view 3D reconstruction [16]. Based on the supervision of ground truth SDF values of sampled points, the method utilizes separate networks to model the base SDF and implicit displacement fields. Subsequently, Wang et al. [34] utilize the SIREN network to learn the base implicit function and implicit displacement function, respectively, for point cloud reconstruction tasks. In contrast to our proposed algorithm, these methods require 3D supervision. Further, they do not involve the NeRF formulation or volume rendering. In our work, we build on these ideas to develop a new state-of-the-art algorithm for multi-view reconstruction.
34
+
35
+ # 3 Method
36
+
37
+ As input we consider a set of $N$ images $I = \{ I _ { 1 } , I _ { 2 } . . . I _ { N } \}$ , and their corresponding intrinsic and extrinsic camera parameters $\Pi = \left\{ \pi _ { 1 } , \pi _ { 2 } . . . \pi _ { N } \right\}$ . HF-NeuS aims to reconstruct the representation of 3D surface $S$ as implicit functions. Specifically, we encode surfaces as signed distance fields. We will explain our method in three parts: 1) First, we show how to embed the signed distance function into the formulation of volume rendering and discuss how to model the relationship between distance and transparency. 2) Then, we propose to utilize an additional displacement signed distance function to add high-frequency details to the base signed distance function. 3) Finally, we observe that the function that maps signed distances to transparency is controlled by a parameter $s$ that determines the slope of the function. We propose a scheme to set this parameter $s$ in a spatially varying manner depending on the gradient norm of the distance field, rather than keeping it constant for the complete volume within a single training iteration.
38
+
39
+ # 3.1 Modeling transparency as transformed SDF
40
+
41
+ We first review the integral formula for volume rendering and derive a relationship between transparency and the weighting function (the product between density and transparency). Based on this analysis, we discuss the criteria for functions that are suitable to map signed distances to transparency and propose a class of functions that fulfill the theoretical requirements.
42
+
43
+ Given a ray $\mathbf { r } ( t ) = \mathbf { o } + \mathbf { t d }$ , the volume rendering equation is used to calculate the radiance $C$ of the pixel corresponding to the ray $\mathbf { r }$ . The volume rendering equation is an integral along the ray and involves the following quantities defined for each point in the volume: the volume density $\sigma$ and the (directional) color c. In addition, the volume has compact support and the boundaries of the volume are encoded by $t _ { n }$ and $t _ { f }$ .
44
+
45
+ $$
46
+ C ( { \bf r } ) = \int _ { t _ { n } } ^ { t _ { f } } T ( t ) \sigma ( { \bf r } ( t ) ) { \bf c } ( { \bf r } ( t ) , { \bf d } ) d t
47
+ $$
48
+
49
+ The transparency $T ( t )$ is derived from the volume density as explained below. The function $T ( t )$ denotes the accumulated transmittance along the ray from $t _ { n }$ to $t$
50
+
51
+ $$
52
+ T ( t ) = \exp \left( - \int _ { t _ { n } } ^ { t } \sigma ( \mathbf { r } ( s ) ) d s \right) ,
53
+ $$
54
+
55
+ and $T ( t )$ is a monotonic decreasing function with a starting value of $T ( t _ { n } ) = 1$ . The product $T ( t ) \sigma ( \mathbf { r } ( t ) )$ can be regarded as a weighting function $w \left( t \right)$ in the volume rendering equation as in Eq. (1).
56
+
57
+ In order to involve a signed distance function $f$ , we have to define a function $\Psi$ to transform a signed distance function so that it can be used to compute the density related terms in the rendering equation. One way is to directly model a density function $\sigma ( \mathbf { r } ( t ) ) \dot { = } \Psi \left( f \left( \mathbf { r } ( t ) \right) \right)$ as proposed by VOLSDF [32]. Taking this approach, a sampling method is required to satisfy an error bound of the sampling to make it less than an error threshold by gradually reducing the scale parameter. Another way is to model the weighting function $w ( ( t ) ) = \dot { \Psi } \bar { ( } f \left( \mathbf { r } ( t ) \right) )$ as proposed by NeuS. The NeuS paper showcases a complex derivation to get the expression for the density function $\sigma$ .
58
+
59
+ We rethink this problem to obtain a simplified derivation by focusing on transparency instead of the weighting function and also a better understanding of the problem, as follows:
60
+
61
+ $$
62
+ \frac { d \left( T ( t ) \right) } { d t } = - T ( t ) \sigma ( \mathbf { r } ( t ) )
63
+ $$
64
+
65
+ An interesting observation is that the derivative of the transparency function $T ^ { \prime } ( t )$ is the negative weighting function. The weighting function has the property of having a maximum on the surface. We take the derivative of the weighting function and set it to 0 to find the extrema (maxima), as follows.
66
+
67
+ $$
68
+ { \frac { d \left( T ( t ) \sigma ( \mathbf { r } ( t ) ) \right) } { d t } } = - { \frac { d ^ { 2 } \left( T ( t ) \right) } { d t ^ { 2 } } } = - { \frac { d \left( T ^ { \prime } ( t ) \right) } { d t } } = 0
69
+ $$
70
+
71
+ Assuming a planar surface and a single ray-plane intersection, we can see that the extremum point, denoted as $t _ { s }$ , of the weighting function $w ( t )$ will also be the extremum point of the derivative of the transparency function $T ^ { \prime } ( t )$ . The point $t _ { s }$ is expected to be the intersection of the ray and the surface. Therefore, we consider defining the transparency function directly as $T ( t ) = \Psi \left( f \left( \mathbf { r } ( t ) \right) \right)$ . If the transparency function is designed in such a way that its derivative $T ^ { \prime } ( t )$ reaches a minimum on the surface, it follows that the weighting function has a maximum on the surface. Therefore, one can directly model a transparency function under the condition that its derivative has a minimum on the surface. This is conceptually simpler than modeling the weighting function $w ( t )$ as proposed by NeuS. We compute the derivative of $\Psi \left( f \left( \mathbf { r } ( t ) \right) \right)$ as follows.
72
+
73
+ $$
74
+ { \frac { d \left( \Psi \left( f \left( \mathbf { r } ( t ) \right) \right) \right) } { d t } } = \Psi ^ { \prime } \left( f \left( \mathbf { r } ( t ) \right) \right) { \frac { d f } { d \mathbf { r } } } { \frac { d \mathbf { r } } { d t } } = \Psi ^ { \prime } \left( f \left( \mathbf { r } ( t ) \right) \right) \nabla f \left( \mathbf { r } ( t ) \right) \cdot \mathbf { d }
75
+ $$
76
+
77
+ where $\nabla f \left( \mathbf { r } ( t ) \right) \cdot \mathbf { d }$ is the product of the surface normal and the ray direction, which is a constant in case of a planar surface and a single ray-plane intersection. The signed distance function is zero on the surface. Hence $\Psi ^ { \prime }$ has an extremum at $f = 0$ . This also means $\Psi$ has the steepest slope at the surface of the shape. On the other hand, the signed distance function is positive outside of the object, and negative when entering the interior of the object. We generally assume that $t = t _ { n }$ is outside so that the signed distance starts positive and decays to a negative value along a ray, which is a monotonic decreasing function. According to the characteristics of transparency $T ( t ) = \Psi \left( f \left( \mathbf { r } ( t ) \right) \right)$ , the transparency starts at 1 at $t = t _ { n }$ and is a monotonic decreasing function to 0 inside the object. This inverse property results in the $\Psi$ function being a monotonic increasing function from 0 to 1. Therefore, we have our design criteria for $\Psi \colon \Psi$ should be a monotonic increasing function from 0 to 1, with the steepest slope at 0.
78
+
79
+ ![](images/1499af90f1e0ea79f856832ea558d49566a09e544f423f80c13dff51d5d15123.jpg)
80
+ Figure 3: Comparing NeuS and VolSDF with our transparency model. Ground truth is on the top left. For each method, the left shows the reconstructed image and the right the reconstructed surface.
81
+
82
+ A very intuitive idea to satisfy this criteria is to use a sigmoid function and normalize the function to have an output in the interval $[ 0 , 1 ]$ . We simply use the logistic sigmoid function proposed by NeuS [30] for a fair comparison. However, our idea is more general and other sigmoid functions could be used. Our designed transparency function is as follows,
83
+
84
+ $$
85
+ T ( t ) = \Psi _ { s } \left( f \left( \mathbf { r } ( t ) \right) \right) = \frac { 1 } { 1 + e ^ { - s f \left( \mathbf { r } ( t ) \right) } } ,
86
+ $$
87
+
88
+ where $\Psi _ { s }$ is the logistic sigmoid function with parameter $s$ controlling the slope of the function. Note that the parameter $s$ is also the standard deviation of the function $\Psi _ { s } ^ { \prime }$ . We will use this fact later when discussing the adaptive version of the framework.
89
+
90
+ Given the differentiable transparency function $T ( t )$ , the volume density $\sigma$ can be easily calculated following Eq. 3.
91
+
92
+ $$
93
+ \sigma ( \mathbf { r } ( t ) ) = - { \frac { T ^ { \prime } ( t ) } { T ( t ) } }
94
+ $$
95
+
96
+ For discretization, we bring Eq. 5 and Eq. 6 into Eq.7, and take advantage of the properties of the derivative of the logistic sigmoid function $\Psi _ { s } ^ { \prime } = s \Psi _ { s } ( 1 - \Psi _ { s } )$ . We can get the $\sigma$ formula for the discretization computation:
97
+
98
+ $$
99
+ \sigma ( \mathbf { r } ( t _ { i } ) ) = s \left( \boldsymbol { \Psi } _ { s } \left( f \left( \mathbf { r } ( t _ { i } ) \right) \right) - 1 \right) \nabla f \left( \mathbf { r } ( t _ { i } ) \right) \cdot \mathbf { d }
100
+ $$
101
+
102
+ Then the volume rendering integral can be approximated using $\alpha$ -composition, where $\alpha _ { i } = 1 -$ $e x p \left( - \sigma _ { i } \left( t _ { i + 1 } - t _ { i } \right) \right)$ . For multiple surface intersections, we follow the same strategy as NeuS [30], where $\alpha _ { i } = c l a m p \left( \alpha _ { i } , 0 , 1 \right)$ . Compared with NeuS, we obtain a simpler formula for the density $\sigma$ for the discretization computation, reducing the numerical problems caused by division in NeuS. Furthermore, our approach does not need to involve two different sampling points, namely section points and mid-points, which makes it easier to satisfy the unbiased weighting function. Since there is no need to calculate the SDF and the color separately for the two different point sets, the color and the geometry are more consistent compared to NeuS. Compared to VolSDF [32], since the transparency function is explicit, our method can use an inverse distribution sampling computed with the inverse CDF to satisfy the approximation quality. Thus no complex sampling scheme as in VolSDF is required. A visual comparison is shown in Fig. 3.
103
+
104
+ # 3.2 Implicit displacement field without 3D supervision
105
+
106
+ In order to enable a multi-scale fitting framework, we propose to model the signed distance function as a combination of a base distance function and a displacement function [34, 16] along the normal of the base distance function. The implicit displacement function is an additional implicit function. The reason for this design is that it is difficult for a single implicit function to learn low-frequency and high-frequency information at the same time. The implicit displacement function can complement the base implicit function, so that it is easier to learn high-frequency information.
107
+
108
+ Compared with the task of learning implicit functions from point clouds, reconstructing 3D shapes from multiple images makes it more difficult to learn high-frequency content. We propose to use neural networks to learn frequencies at multiple scales, and to gradually increase the frequency content in a coarse-to-fine manner.
109
+
110
+ Suppose $f$ is the combined implicit function that represents the surface we want to obtain. The function $f _ { b }$ is the base implicit function that represents the base surface. Following [34], the displacement implicit function $f _ { d ^ { \prime } }$ is used to map the point $x _ { b }$ on the base surface to the surface point $x$ along the normal $n _ { b }$ and vice versa $f _ { d }$ is used to map the point $x$ on the base surface to the surface point $x _ { b }$ along the normal $n _ { b }$ , thus $f _ { d ^ { \prime } } ( \mathbf { x } _ { b } ) = f _ { d } ( \mathbf { x } )$ . Because of the nature of implicit functions, the relationship between the two functions can be expressed as follows,
111
+
112
+ $$
113
+ f _ { b } ( \mathbf { x } _ { b } ) = f ( \mathbf { x } _ { b } + f _ { d ^ { \prime } } \left( \mathbf { x } _ { b } \right) \mathbf { n } _ { b } ) = 0
114
+ $$
115
+
116
+ where xb = ∇fb(xb)∥∇fb(xb)∥ , is the normal of xb on the base surface. To compute the expression for the implicit function $f$ , we bring the formula $\mathbf { x } _ { b } = \mathbf { x } - f _ { d ^ { \prime } } \left( \mathbf { x } _ { b } \right) \mathbf { n } _ { b }$ into the Eq. (9) and obtain the expression for the combined implicit function:
117
+
118
+ $$
119
+ f ( \mathbf { x } ) = f _ { b } ( \mathbf { x } - f _ { d } \left( \mathbf { x } \right) \mathbf { n } _ { b } )
120
+ $$
121
+
122
+ Therefore, we can use the base implicit function and the displacement implicit function to represent the combined implicit function. However, two challenges arise. First, the Eq. 10 is only satisfied if the point $x$ is on the surface. Second, the normal at the point $\mathbf { x } _ { b }$ is difficult to estimate when only knowing the position $\mathbf { x }$ . We rely on two assumptions to solve the problem. One assumption is that this deformation can be applied to all iso-surfaces, i.e. $f _ { b } ( \mathbf { x } _ { b } ) = \mathcal { \bar { f } } ( \mathbf { x } _ { b } + f _ { d ^ { \prime } } \left( \mathbf { x } _ { b } \right) \mathbf { n } _ { b } ) \stackrel { \cdot } { = } \mathrm { c }$ . In this way the equation is assumed to be valid for all points in the volume and not only on the surface. Another assumption is that $\mathbf { x } _ { b }$ and $\mathbf { x }$ are not too far away, thus ${ \bf n } _ { b }$ can be replaced with normal $\mathbf { n }$ on the point $\mathbf { x }$ in the Eq. (10). We control the magnitude of the implicit displacement function using a displacement constraint $4 \Psi _ { s } ^ { \prime } ( f _ { b } )$ .
123
+
124
+ To precisely control the frequency, we use positional encoding to encode the base implicit function and the displacement implicit function separately. We would like to note some differences to [34]. We use positional encoding instead of Siren [28], so that the frequency can be explicitly controlled by a coarse-to-fine strategy rather than simply using two Siren networks with two different frequency levels. This is useful when 3D supervision is not given. More details are shown in the supplementary. Positional encoding decomposes the input position $\mathbf { x }$ into multiple selected frequency bands.
125
+
126
+ $$
127
+ \gamma ( \mathbf { x } ) = [ \gamma _ { 0 } ( \mathbf { x } ) , \gamma _ { 1 } ( \mathbf { x } ) , . . . , \gamma _ { L - 1 } ( \mathbf { x } ) ]
128
+ $$
129
+
130
+ where each component consists of a sin and a cos function with different frequency.
131
+
132
+ $$
133
+ \gamma _ { j } ( \mathbf { x } ) = \left[ \sin \left( 2 ^ { j } \pi \mathbf { x } \right) , \cos \left( 2 ^ { j } \pi \mathbf { x } \right) \right]
134
+ $$
135
+
136
+ Directly learning high-frequency positional encoding makes the network susceptible to noise, because wrongly learned high-frequencies hinder the learning of low frequencies. This problem is less pronounced if 3D supervision is available, however high-frequency information of images is easily introduced into the surface generation as noise. We use the coarse-to-fine strategy proposed by Park et al. [24] to gradually increase the frequency of the positional encoding.
137
+
138
+ $$
139
+ \gamma _ { j } ( \mathbf { x } , \alpha ) = \omega _ { j } \left( \alpha \right) \gamma _ { j } ( \mathbf { x } ) = \frac { \left( 1 - \cos { \left( c l a m p \left( \alpha L - j , 0 , 1 \right) \pi \right) } \right) } { 2 } \gamma _ { j } ( \mathbf { x } )
140
+ $$
141
+
142
+ where $\alpha \in [ 0 , 1 ]$ is the parameter to control the frequency information involved. In each iteration, $\alpha$ is increased by $\mathrm { { \bar { 1 } / n _ { \mathrm { m a x } } } }$ until it touches 1, where $n _ { \mathrm { m a x } }$ is the maximum number of iterations.
143
+
144
+ We utilize two kinds of positional encoding $\gamma ( \mathbf { x } , \alpha _ { b } ) , \gamma ( \mathbf { x } , \alpha _ { d } )$ with different parameter $\alpha _ { b }$ and $\alpha _ { d }$ . We set $\alpha _ { b } = 0 . 5 \alpha _ { d }$ and only control $\alpha _ { d }$ for simplicity. We also use two MLP functions $M L P _ { b } , M L P _ { d }$ for fitting the base and displacement functions.
145
+
146
+ $$
147
+ f ( \mathbf { x } ) = M L P _ { b } ( \gamma ( \mathbf { x } , \alpha _ { b } ) - 4 \Psi _ { s } ^ { \prime } ( f _ { b } ) M L P _ { d } \left( \gamma ( \mathbf { x } , \alpha _ { d } ) \right) \mathbf { n } ) ,
148
+ $$
149
+
150
+ where $\begin{array} { r l r } { \mathbf { n } } & { { } = } & { \frac { \nabla f _ { b } ( \mathbf { x } ) } { \left\| \nabla f _ { b } ( \mathbf { x } ) \right\| } } \end{array}$ that can be computed by the gradient of $M L P _ { b }$ and $\begin{array} { r l } { \Psi _ { s } ^ { \prime } ( f _ { b } ) } & { { } = } \end{array}$ $\Psi _ { s } ^ { \prime } ( M L P _ { b } ( \gamma ( \mathbf { x } , \overset { \cdot \cdot } { \alpha _ { b } } ) ) )$ . The $s$ of the displacement constraint should be clamped during training. We show how to control the adaptive $s$ in the supplemental materials.
151
+
152
+ We bring this implicit function into Eq. (6) for calculating the transparency so that the radiance (color) $\hat { C } _ { s }$ of images can be computed by the volume rendering equation.
153
+
154
+ To train the network, we employ the loss function $\mathcal { L } = \mathcal { L } _ { r a d } + \mathcal { L } _ { r e g }$ , which includes the radiance loss and the Eikonal regularization loss of the signed distance functions. For the regularization loss, we constrain both the base implicit function and the detailed implicit function.
155
+
156
+ $$
157
+ \mathcal { L } = \frac { 1 } { M } \sum _ { s } \left\| \hat { C } _ { s } - C _ { s } \right\| _ { 1 } + \frac { 1 } { N } \sum _ { k } \left[ \left( \left\| \nabla f _ { b } ( \mathbf { x } _ { k } ) \right\| _ { 2 } - 1 \right) ^ { 2 } + \left( \left\| \nabla f ( \mathbf { x } _ { k } ) \right\| _ { 2 } - 1 \right) ^ { 2 } \right]
158
+ $$
159
+
160
+ # 3.3 Modeling an adaptivate transparency function
161
+
162
+ In previous subsections, the transparency function is parametrized as a sigmoid function controlled by the scale $s$ . This parameter controls the slope of the sigmoid function and it is also the standard deviation of the derivative. We can also say that it controls the smoothness of the function. When $s$ is large, the value of the sigmoid function drops sharply as the position moves away from the surface. On the contrary, the value decreases smoothly when $s$ is small. However, choosing a single parameter $s$ per iteration gives the same behavior at all spatial locations in the volume.
163
+
164
+ Since two signed distance functions need to be reconstructed, especially after the high frequency is superimposed, it is easy to break the Eikonal constraint, i.e., make the SDF’s gradient norm deviate from 1 in some positions. Even with the regularization loss, it is impossible to avoid this problem.
165
+
166
+ We propose to use the gradient norm of the signed distance field to weight the parameter $s$ in a spatially varying manner, increasing $s$ when the gradient norm along the ray direction is larger than 1. The intuition is that the implicit function with the larger gradient norm undergoes more abrupt changes, which indicates a region that should be improved. Making $s$ larger in such regions makes the distance function more precise by magnifying its errors, especially near the surface. In order to adaptively modify the scale $s$ , we propose the following equation:
167
+
168
+ $$
169
+ T ( t ) = \left( 1 + e ^ { - s \exp \Big ( \sum _ { i = 1 } ^ { K } \omega _ { i } \| \nabla f _ { i } \| - 1 \Big ) f ( \mathbf { r } ( t ) ) } \right) ^ { - 1 } ,
170
+ $$
171
+
172
+ where $\nabla f$ is the gradient of the signed distance function, and $K$ is the number of sampling points, $\omega _ { i }$ is the normalized $\Psi _ { s } ^ { \prime } ( f _ { i } )$ as the weight and $\sum _ { i = 1 } ^ { K } \omega _ { i } = 1$ .
173
+
174
+ While this method can be used to control the transparency function, it can also be used for the hierarchical sampling stage proposed by standard NeRF [19]. By locally increasing $s$ , more samples will be generated near the surface where the signed distance values change more rapidly. This mechanism also helps to optimization to focus on these regions in the volume.
175
+
176
+ # 4 Experiments
177
+
178
+ Baselines. We compare HF-NeuS to the following three state-of-the-art baselines: (1)NeuS [30] is the most relevant baseline for our work. We consider it to be the best published method. (2)VolSDF [32] is concurrent work to NeuS. We consider it to be the second best published method. Overall it also performs very well. (3)NeRF focuses on image synthesis and is included for completeness. NeRF is not really a surface reconstruction method and does not reconstruct high-quality surfaces, but it is very good in image-based metrics. We use a threshold of 25 (as proposed by NeuS [30]) to extract surfaces for the comparisons. For all three methods, we use the default parameters and the number of iterations recommended in their respective papers. We do not include older methods in the comparison, such as UNISURF [23] or IDR [33], because NeuS and VolSDF have better results.
179
+
180
+ Table 1: Quantitative results on the DTU dataset.
181
+
182
+ <table><tr><td>Metric</td><td>Method</td><td>24</td><td>37</td><td>40</td><td>55</td><td>63</td><td>65</td><td>69</td><td>83</td><td>97</td><td>105</td><td>106</td><td>110</td><td>114</td><td>118</td><td>122</td><td>Mean</td></tr><tr><td rowspan="4">Fidelity</td><td>NeRF</td><td>1.90</td><td>1.60</td><td>1.85</td><td>0.58</td><td>2.28</td><td>1.27</td><td>1.47</td><td>1.67</td><td>2.05</td><td>1.07</td><td>0.88</td><td>2.53</td><td>1.06</td><td>1.15</td><td>0.96</td><td>1.49</td></tr><tr><td>VOLSDF</td><td>1.14</td><td>1.26</td><td>0.81</td><td>0.49</td><td>1.25</td><td>0.70</td><td>0.72</td><td>1.29</td><td>1.18</td><td>0.70</td><td>0.66</td><td>1.08</td><td>0.42</td><td>0.61</td><td>0.55</td><td>0.86</td></tr><tr><td>NeuS</td><td>1.37</td><td>1.21</td><td>0.73</td><td>0.40</td><td>1.20</td><td>0.70</td><td>0.72</td><td>1.01</td><td>1.16</td><td>0.82</td><td>0.66</td><td>1.69</td><td>0.39</td><td>0.49</td><td>0.51</td><td>0.87</td></tr><tr><td>OURS</td><td>0.76</td><td>1.32</td><td>0.70</td><td>0.39</td><td>1.06</td><td>0.63</td><td>0.63</td><td>1.15</td><td>1.12</td><td>0.80</td><td>0.52</td><td>1.22</td><td>0.33</td><td>0.49</td><td>0.50</td><td>0.77</td></tr><tr><td rowspan="4">PSNR</td><td>NeRF</td><td>26.24</td><td>25.74</td><td>26.79</td><td>27.57</td><td>31.96</td><td>31.50</td><td>29.58</td><td>32.78</td><td>28.35</td><td>32.08</td><td>33.49</td><td>31.54</td><td>31.0</td><td>35.59</td><td>35.51</td><td>30.65</td></tr><tr><td>VOLSDF</td><td>26.28</td><td>25.61</td><td>26.55</td><td>26.76</td><td>31.57</td><td>31.50</td><td>29.38</td><td>33.23</td><td>28.03</td><td>32.13</td><td>33.16</td><td>31.49</td><td>30.33</td><td>34.90</td><td>34.75</td><td>30.38</td></tr><tr><td>NeuS</td><td>28.20</td><td>27.10</td><td>28.13</td><td>28.80</td><td>32.05</td><td>33.75</td><td>30.96</td><td>34.47</td><td>29.57</td><td>32.98</td><td>35.07</td><td>32.74</td><td>31.69</td><td>36.97</td><td>37.07</td><td>31.97</td></tr><tr><td>OURS</td><td>29.15</td><td>27.33</td><td>28.37</td><td>28.88</td><td>32.89</td><td>33.84</td><td>31.17</td><td>34.83</td><td>30.06</td><td>33.37</td><td>35.44</td><td>33.09</td><td>32.12</td><td>37.13</td><td>37.32</td><td>32.33</td></tr></table>
183
+
184
+ ![](images/98c61b59a5644217128a5aba4284096f9ab9f90754c13674fc296cfffdb21432.jpg)
185
+ Figure 4: Qualitative evaluation on DTU (first and third rows) and BlendedMVS (second row).
186
+
187
+ Datasets. We conduct experiments on the DTU dataset [12]. We follow previous work and choose the same 15 models for comparison. DTU is a multi-view stereo dataset. Each scene consists of 49 or 64 views with $1 6 0 0 \times 1 2 0 0$ resolution. We further choose 9 challenging scenes from other datasets: 6 scenes from the NeRF-synthetic dataset [19] and 3 scenes from BlendedMVS [31](CC-4 License). The image resolution of NeRF synthetic dataset [19] is $8 0 0 \times 8 0 0$ and 100 views are provided for each scene. The dataset contains objects with very obvious detailed and sharp features, such as the Lego and Microphone scenes. We chose this dataset for the analysis of reconstructions of high-frequency details. The BlendedMVS dataset is similar to the DTU dataset, but with a richer background. This dataset provides image resolution of $7 6 8 \times 5 7 6$ . We also select models with high-frequency details or sharp features which are difficult to reconstruct. In all three datasets, ground truth surfaces and camera poses are provided.
188
+
189
+ Evaluation metrics. To evaluate the quality of the reconstruction, we follow previous work and used Chamfer distance (lower values are better) and PSNR (higher values are better). For the DTU dataset, we use the official evaluation protocol, which means computing the mean of accuracy (distance from the reconstructed surface to the ground truth surface) and completeness (distance from the ground truth surface to the reconstructed surface). For DTU and BlendedMVS, the background is not part of the ground truth surface. Therefore, we remove the background for computing the Chamfer distance, following previous work. The NeRF-synthetic dataset [19] has no background, so we only remove disconnected parts for all competing methods.
190
+
191
+ Table 2: Quantitative results on NeRF-synthetic and BlendedMVS datasets.
192
+
193
+ <table><tr><td>Metric(10-2)</td><td>Method</td><td>Chair</td><td>Ficus</td><td>Lego</td><td>Materials</td><td>Mic</td><td>Ship</td><td>Mean</td><td>Bread</td><td>Dog</td><td>Robot</td><td>Mean</td></tr><tr><td rowspan="4">Fidelity</td><td>NeRF</td><td>2.12</td><td>5.17</td><td>3.05</td><td>1.51</td><td>4.77</td><td>3.54</td><td>3.36</td><td>0.102</td><td>0.693</td><td>2.325</td><td>1.07</td></tr><tr><td>VOLSDF</td><td>1.26</td><td>1.54</td><td>2.83</td><td>1.35</td><td>3.62</td><td>2.92</td><td>2.37</td><td>0.074</td><td>0.354</td><td>1.453</td><td>0.63</td></tr><tr><td>NeuS</td><td>0.74</td><td>1.21</td><td>2.35</td><td>1.30</td><td>3.89</td><td>2.33</td><td>1.97</td><td>0.068</td><td>0.173</td><td>1.036</td><td>0.43</td></tr><tr><td>OURS</td><td>0.69</td><td>1.12</td><td>0.94</td><td>1.08</td><td>0.72</td><td>2.18</td><td>1.12</td><td>0.065</td><td>0.155</td><td>0.922</td><td>0.38</td></tr><tr><td rowspan="4">PSNR</td><td>NeRF</td><td>33.00</td><td>30.15</td><td>32.54</td><td>29.62</td><td>32.91</td><td>28.34</td><td>31.09</td><td>31.27</td><td>27.46</td><td>25.33</td><td>28.02</td></tr><tr><td>VOLSDF</td><td>25.91</td><td>24.41</td><td>26.99</td><td>28.83</td><td>29.46</td><td>25.65</td><td>26.86</td><td>31.05</td><td>28.24</td><td>25.46</td><td>28.25</td></tr><tr><td>NeuS</td><td>27.95</td><td>25.79</td><td>29.85</td><td>29.36</td><td>29.89</td><td>25.46</td><td>28.05</td><td>31.32</td><td>28.71</td><td>25.87</td><td>28.63</td></tr><tr><td>OURS</td><td>28.69</td><td>26.46</td><td>30.72</td><td>29.87</td><td>30.35</td><td>25.87</td><td>28.66</td><td>31.89</td><td>29.42</td><td>26.15</td><td>29.15</td></tr></table>
194
+
195
+ Table 3: Ablation study results.
196
+
197
+ <table><tr><td colspan="8">Chamfer Distance</td><td colspan="6">PSNR</td></tr><tr><td>Datasets</td><td>Base</td><td>Base+H</td><td>Base+C2F IDF+HI</td><td></td><td>IDF+C2F</td><td>FULL</td><td>Base</td><td>Base+H</td><td>Base+C2F IDF+H</td><td></td><td>IDF+C2F</td><td>FULL</td></tr><tr><td>DTU</td><td>1.08</td><td>1.20</td><td>1.07</td><td>1.25</td><td>0.89</td><td>0.78</td><td>31.77</td><td>32.73</td><td>32.56</td><td>32.69</td><td>32.13</td><td>32.49</td></tr><tr><td>NeRF-Synthetic</td><td>2.51</td><td>3.61</td><td>2.95</td><td>2.83</td><td>1.35</td><td>0.91</td><td>28.39</td><td>30.52</td><td>30.63</td><td>30.12</td><td>29.88</td><td>30.31</td></tr><tr><td>BlendedMVS</td><td>0.43</td><td>fail</td><td>0.63</td><td>0.47</td><td>0.41</td><td>0.38</td><td>28.63</td><td>fail</td><td>27.35</td><td>28.20</td><td>28.95</td><td>29.15</td></tr></table>
198
+
199
+ Implementation details. We use MLPs to model two signed distance functions $f _ { b }$ and $f _ { d }$ . Each MLP consists of 8 layers. Related work like NeuS [30] and IDR [33] also use MLPs with 8 layers. We use Adam with learning rate $5 e ^ { - 4 }$ for the network training using NVIDIA TITAN A100 40GB graphics cards. For adaptive sampling, we first uniformly sample 64 points on the ray, then calculate the SDF and its gradient at these points. We utilize the Eq. 16 to calculate the gain of the $s$ parameter, and then adaptively update the weight according to the gain and sample an additional 64 points. For the coarse-to-fine strategy, we observe that using $\alpha _ { d } ^ { 0 } = \overline { { 0 } }$ at the beginning for surface reconstruction produces smoothed results. We utilize $\alpha _ { d } ^ { 0 } = 0 . 5$ and $\alpha _ { b } ^ { 0 } = 0 . 5 \alpha _ { d } ^ { 0 } = 0 . 2 5$ for both signed distance functions. We set $L = 1 6$ for the parameter of the frequency band of positional encoding. For other parameter settings, please see the supplemental materials.
200
+
201
+ Comparison. In table 1, we show quantitative results with other competitors on 15 scenes of the DTU dataset [12]. The values shown in the upper part of the table measure the fidelity of the surface reconstruction, the Chamfer distance. The numbers indicate that HF-NeuS significantly outperforms NeRF. In most scenes, HF-NeuS is better than VolSDF and NeuS so that the overall average distance is also improved. In the lower part of the table we show the PSNR values. It can be seen that our PSNR surpasses all other methods. We further compare the visual quality achieved by different methods. As shown in Fig. 4, HF-NeuS can reconstruct high-frequency details. For example, the windows have better geometric details, and the feathers of the bird are more distinct.
202
+
203
+ Most of the scenes in the DTU dataset have smooth surfaces, and high-frequency details are not obvious. We selected 9 challenging models from the NeRF-synthetic dataset [19] and BlendedMVS dataset [31], which have more high-frequency details. For example, the Lego model has uneven repeating bumps, and the power cord of the Mic model has a very thin structure (Fig. 1). The robot model has richer edge and corner features (Fig. 4 second row). As shown in Table 2, the gap between our surface reconstruction quality and that of all other methods widens. This shows that HF-NeuS is especially advantageous for surface reconstructions with high-frequency information. We can also observe that NeRF is very good in the image-based metric (PSNR) while performing poorly in the surface reconstruction metric (Chamfer distance). This observation is consistent with previous work. Compared with the NeRF-Synthetic dataset, the BlendedBMS dataset has a more complex background, this also restricts the performance of NeRF to a certain extent. Besides outperforming other baselines in terms of quantitative error, we also achieve better results in terms of qualitative visual effects. As shown in Fig. 1, HF-NeuS can more accurately reconstruct the details of each Lego block and even some of the tiny holes that are not reconstructed by any other method. For the Robot scene, HF-NeuS can reconstruct more accurate facial contours and sharper horns. Finally, for the Mic model, HF-NeuS can clearly reconstruct the power cord, while other methods will mess up this structure.
204
+
205
+ Ablation study. We verify the influence of different modules on the reconstruction results, including the coarse-to-fine module, the implicit displacement function module, and the position-adaptive s control module. In Table 3, “Base ”refers to the baseline method, which is NeuS. "H" means we use high-frequency positional encoding. Here we set $_ { \mathrm { L = 1 6 } }$ to represent high frequencies. "C2F" refers to the coarse-to-fine optimization strategy with high-frequency positional encoding. We set the initial $\alpha$ to 0.5. "IDF" represents using the implicit displacement function in reconstruction. For each dataset, we chose the mean of the three scenes as the quantitative metric. From the results of the BlendedMVS dataset, we can observe that the divergence of network training can be prevented based on the coarse-to-fine strategy. From the DTU and NeRF-synthetic datasets, introducing high-frequency directly can easily lead to overfitting on these datasets. This means that an increase in PSNR cannot guarantee the improvement of the fidelity of surface reconstruction. Although the coarse-to-fine module can alleviate this mismatch to some degree, it is difficult to further improve the performance. However, adding the implicit displacement function component improves the fidelity of the surface reconstruction and PSNR at the same time. During reconstruction, the network with adaptive $s$ can help to improve the reconstruction quality upon more complex scenes.
206
+
207
+ Limitation. As shown in Fig. 5, our method still has challenges. We show a reference ground truth image, our corresponding reconstructed image, and our reconstructed surface. For the grid of ropes of the ship, some overfitting to ground-truth radiance is still observed. Specifically, the grid of ropes is visible in the image, but the surface is not reconstructed accurately. Another limitation is that the individual thin ropes are missing. We also visualize a bad case of Table 1 where the error is larger than that of the other methods as shown in Fig. 14 DTU Bunny in the supplementary material. In this case, the lighting of this model varies and the texture is not as pronounced, thus it is difficult to reconstruct the details of the belly. Further, integrating our proposed IDF increases computation time.
208
+
209
+ ![](images/3d08854868ce78c4bf494610d4a06d307b269946ac4f3f38252af1509968e495.jpg)
210
+ Figure 5: Limitation. First column: the reference ground truth images. Second column: our synthetic images. Last column: our reconstructed surface.
211
+
212
+ # 5 Conclusion
213
+
214
+ We introduce HF-NeuS, a new method for multi-view surface reconstruction with high-frequency details. We propose a new derivation to explain the relationship between signed distance and transparency and propose a class of functions that can be used. By decomposing the signed distance field into a combination of two independent implicit functions, and using adaptive scale constraints to focus on optimizing the regions where the implicit function distribution is not ideal, a more refined surface can be reconstructed compared to previous work. The experimental results show that the method outperforms the current state of the art in terms of quantitative metrics and visual inspection. An interesting direction for future work is to explore the reconstruction of scenes under different lighting modalities. Finally, we do not expect negative social impacts that will be directly linked to our research. Negative social impacts of surface reconstruction in general are possible though.
215
+
216
+ # Acknowledgements
217
+
218
+ We would like to acknowledge support from the SDAIA-KAUST Center of Excellence in Data Science and Artificial Intelligence and the NSFC No.62202076.
219
+
220
+ References
221
+ [1] C. Barnes, E. Shechtman, A. Finkelstein, and D. B. Goldman. Patchmatch: A randomized correspondence algorithm for structural image editing. ACM Trans. Graph., 28(3):24, 2009.
222
+ [2] J. T. Barron, B. Mildenhall, M. Tancik, P. Hedman, R. Martin-Brualla, and P. P. Srinivasan. Mip-nerf: A multiscale representation for anti-aliasing neural radiance fields. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5855–5864, 2021.
223
+ [3] F. Bernardini, J. Mittleman, H. Rushmeier, C. Silva, and G. Taubin. The ball-pivoting algorithm for surface reconstruction. IEEE transactions on visualization and computer graphics, 5(4):349–359, 1999.
224
+ [4] A. Broadhurst, T. W. Drummond, and R. Cipolla. A probabilistic framework for space carving. In Proceedings eighth IEEE international conference on computer vision. ICCV 2001, volume 1, pages 388–393. IEEE, 2001.
225
+ [5] F. Darmon, B. Bascle, J.-C. Devaux, P. Monasse, and M. Aubry. Improving neural implicit surfaces geometry with patch warping. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6260–6269, 2022.
226
+ [6] J. S. De Bonet and P. Viola. Poxels: Probabilistic voxelized volume reconstruction. In Proceedings of International Conference on Computer Vision (ICCV), pages 418–425, 1999.
227
+ [7] Y. Furukawa and J. Ponce. Accurate, dense, and robust multiview stereopsis. IEEE transactions on pattern analysis and machine intelligence, 32(8):1362–1376, 2009.
228
+ [8] S. Galliani, K. Lasinger, and K. Schindler. Gipuma: Massively parallel multi-view stereo reconstruction. Publikationen der Deutschen Gesellschaft für Photogrammetrie, Fernerkundung und Geoinformation e. V, 25(361-369):2, 2016.
229
+ [9] R. Hartley and A. Zisserman. Multiple view geometry in computer vision. Cambridge university press, 2003.
230
+ [10] A. Hertz, O. Perel, R. Giryes, O. Sorkine-Hornung, and D. Cohen-Or. Sape: Spatially-adaptive progressive encoding for neural optimization. In Advances in Neural Information Processing Systems, 2021.
231
+ [11] S. Izadi, D. Kim, O. Hilliges, D. Molyneaux, R. Newcombe, P. Kohli, J. Shotton, S. Hodges, D. Freeman, A. Davison, et al. Kinectfusion: real-time 3d reconstruction and interaction using a moving depth camera. In Proceedings of the 24th annual ACM symposium on User interface software and technology, pages 559–568, 2011.
232
+ [12] R. Jensen, A. Dahl, G. Vogiatzis, E. Tola, and H. Aanæs. Large scale multi-view stereopsis evaluation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 406–413, 2014.
233
+ [13] M. Kazhdan, M. Bolitho, and H. Hoppe. Poisson surface reconstruction. In Proceedings of the fourth Eurographics symposium on Geometry processing, volume 7, 2006.
234
+ [14] K. N. Kutulakos and S. M. Seitz. A theory of shape by space carving. International journal of computer vision, 38(3):199–218, 2000.
235
+ [15] P. Labatut, J.-P. Pons, and R. Keriven. Efficient multi-view reconstruction of large-scale scenes using interest points, delaunay triangulation and graph cuts. In 2007 IEEE 11th international conference on computer vision, pages 1–8. IEEE, 2007.
236
+ [16] M. Li and H. Zhang. D2im-net: Learning detail disentangled implicit fields from single images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10246– 10255, 2021.
237
+ [17] C.-H. Lin, W.-C. Ma, A. Torralba, and S. Lucey. Barf: Bundle-adjusting neural radiance fields. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5741–5751, 2021.
238
+ [18] L. Liu, J. Gu, K. Zaw Lin, T.-S. Chua, and C. Theobalt. Neural sparse voxel fields. Advances in Neural Information Processing Systems, 33:15651–15663, 2020.
239
+ [19] B. Mildenhall, P. P. Srinivasan, M. Tancik, J. T. Barron, R. Ramamoorthi, and R. Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. In European conference on computer vision, pages 405–421. Springer, 2020.
240
+ [20] M. Niemeyer and A. Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11453–11464, 2021.
241
+ [21] M. Niemeyer, L. Mescheder, M. Oechsle, and A. Geiger. Differentiable volumetric rendering: Learning implicit 3d representations without 3d supervision. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3504–3515, 2020.
242
+ [22] M. Nießner, M. Zollhöfer, S. Izadi, and M. Stamminger. Real-time 3d reconstruction at scale using voxel hashing. ACM Transactions on Graphics (ToG), 32(6):1–11, 2013.
243
+ [23] M. Oechsle, S. Peng, and A. Geiger. Unisurf: Unifying neural implicit surfaces and radiance fields for multi-view reconstruction. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5589–5599, 2021.
244
+ [24] K. Park, U. Sinha, J. T. Barron, S. Bouaziz, D. B. Goldman, S. M. Seitz, and R. Martin-Brualla. Nerfies: Deformable neural radiance fields. International Conference on Vomputer Vision, 2021.
245
+ [25] J. L. Schonberger and J.-M. Frahm. Structure-from-motion revisited. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4104–4113, 2016.
246
+ [26] J. L. Schönberger, E. Zheng, J.-M. Frahm, and M. Pollefeys. Pixelwise view selection for unstructured multi-view stereo. In European Conference on Computer Vision, pages 501–518. Springer, 2016.
247
+ [27] S. M. Seitz and C. R. Dyer. Photorealistic scene reconstruction by voxel coloring. International Journal of Computer Vision, 35(2):151–173, 1999.
248
+ [28] V. Sitzmann, J. Martel, A. Bergman, D. Lindell, and G. Wetzstein. Implicit neural representations with periodic activation functions. Advances in Neural Information Processing Systems, 33:7462–7473, 2020.
249
+ [29] M. Tancik, P. Srinivasan, B. Mildenhall, S. Fridovich-Keil, N. Raghavan, U. Singhal, R. Ramamoorthi, J. Barron, and R. Ng. Fourier features let networks learn high frequency functions in low dimensional domains. Advances in Neural Information Processing Systems, 33:7537–7547, 2020.
250
+ [30] P. Wang, L. Liu, Y. Liu, C. Theobalt, T. Komura, and W. Wang. Neus: Learning neural implicit surfaces by volume rendering for multi-view reconstruction. Advances in Neural Information Processing Systems, 2021.
251
+ [31] Y. Yao, Z. Luo, S. Li, J. Zhang, Y. Ren, L. Zhou, T. Fang, and L. Quan. Blendedmvs: A large-scale dataset for generalized multi-view stereo networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1790–1799, 2020.
252
+ [32] L. Yariv, J. Gu, Y. Kasten, and Y. Lipman. Volume rendering of neural implicit surfaces. Advances in Neural Information Processing Systems, 34, 2021.
253
+ [33] L. Yariv, Y. Kasten, D. Moran, M. Galun, M. Atzmon, B. Ronen, and Y. Lipman. Multiview neural surface reconstruction by disentangling geometry and appearance. Advances in Neural Information Processing Systems, 33:2492–2502, 2020.
254
+ [34] W. Yifan, L. Rahmann, and O. Sorkine-hornung. Geometry-consistent neural shape representation with implicit displacement fields. In International Conference on Learning Representations, 2022.
255
+ [35] K. Zhang, G. Riegler, N. Snavely, and V. Koltun. Nerf++: Analyzing and improving neural radiance fields. arXiv preprint arXiv:2010.07492, 2020.
256
+
257
+ # Checklist
258
+
259
+ 1. For all authors...
260
+
261
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
262
+ (b) Did you describe the limitations of your work? [Yes]
263
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
264
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
265
+
266
+ 2. If you are including theoretical results...
267
+
268
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
269
+
270
+ 3. If you ran experiments...
271
+
272
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
273
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
274
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
275
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] see Section 4
276
+
277
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
278
+
279
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
280
+ (b) Did you mention the license of the assets? [Yes] See Section4
281
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
282
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] All datasets are public.
283
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Section 5
284
+
285
+ 5. If you used crowdsourcing or conducted research with human subjects...
286
+
287
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
288
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
289
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/aKXBrj0DHm/aKXBrj0DHm.md ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bridging the Gap between Object and Image-level Representations for Open-Vocabulary Detection
2
+
3
+ Hanoona Rasheed1,\*, Muhammad Maaz1,\*, Muhammad Uzair Khattak1, Salman Khan1,2, Fahad Shahbaz Khan1,3 1Mohamed bin Zayed University of AI, UAE
4
+ 2Australian National University, Australia 3Linköping University, Sweden
5
+
6
+ # Abstract
7
+
8
+ Existing open-vocabulary object detectors typically enlarge their vocabulary sizes by leveraging different forms of weak supervision. This helps generalize to novel objects at inference. Two popular forms of weak-supervision used in openvocabulary detection (OVD) include pretrained CLIP model and image-level supervision. We note that both these modes of supervision are not optimally aligned for the detection task: CLIP is trained with image-text pairs and lacks precise localization of objects while the image-level supervision has been used with heuristics that do not accurately specify local object regions. In this work, we propose to address this problem by performing object-centric alignment of the language embeddings from the CLIP model. Furthermore, we visually ground the objects with only imagelevel supervision using a pseudo-labeling process that provides high-quality object proposals and helps expand the vocabulary during training. We establish a bridge between the above two object-alignment strategies via a novel weight transfer function that aggregates their complimentary strengths. In essence, the proposed model seeks to minimize the gap between object and image-centric representations in the OVD setting. On the COCO benchmark, our proposed approach achieves $3 6 . 6 \mathrm { A P } _ { 5 0 }$ on novel classes, an absolute 8.2 gain over the previous best performance. For LVIS, we surpass the state-of-the-art ViLD model by 5.0 mask AP for rare categories and 3.4 overall. Code: https://github.com/hanoonaR/object-centric-ovd.
9
+
10
+ # 1 Introduction
11
+
12
+ Open-vocabulary detection (OVD) aims to generalize beyond the limited number of base classes labeled during the training phase. The goal is to detect novel classes defined by an unbounded (open) vocabulary at inference. Owing to the challenging nature of the OVD task, different forms of weak-supervision for novel categories are typically used, e.g., extra image-caption pairs to enlarge the vocabulary [1], image-level labels on classification datasets [2] and pretrained open-vocabulary classification models like CLIP [3]. The use of weak-supervision to enlarge the vocabulary is intuitive as the cost of annotating large-category detection datasets is monumental while the image-text/label pairs are readily available via large classification datasets [4] or internet sources [3, 5].
13
+
14
+ One of the major challenges with enlarging vocabulary via image-level supervision (ILS) or pretrained models learned using ILS is the inherent mis-match between region and image-level cues. For instance, pretrained CLIP embeddings used in the existing OVD models [6, 2] do not perform well in locating object regions [7] since the CLIP model is trained with full scale images. Similarly, weak supervision on images using caption descriptions or image-level labels does not convey the precise object-centric information. For label grounding in images, the recent literature explores expensive pretraining with auxiliary objectives [1] or use heuristics such as, the max-score or max-size boxes [2].
15
+
16
+ In this paper, we set out to bridge the gap between object and image-centric representations within the OVD pipeline. To this end, we propose to utilize high-quality class-agnostic and class-specific object proposals via the pretrained multi-modal vision transformer (ViT) [8]. The class-agnostic object proposals are then used to distill region-specific information in the CLIP visual embeddings, making them suitable for local objects. Furthermore, the class-specific proposal set allows us to visually ground a larger vocabulary, thereby aiding in generalization to novel categories. Next, the final and important question is how to make visual-language (VL) mapping amenable to local object-centric information. For this purpose, we introduce a region-conditioned weight transfer process which closely ties together image and region VL mapping. In a nut-shell, the proposed approach connects the image, region and language representations to generalize better to novel open-vocabulary objects.
17
+
18
+ The major contributions of this work include:
19
+
20
+ • We propose region-based knowledge distillation to adapt image-centric CLIP embeddings for local regions, thereby improving alignment between region and language embeddings. We show that the resulting well-aligned representations aid in improving the overall performance of our text driven OVD pipeline. • In order to visually ground weak image labels, our approach performs pseudo-labeling using the high-quality object proposals from pretrained multi-modal ViTs. This helps in enlarging the class vocabulary and therefore generalizes better to new object classes. The above contributions mainly target the visual domain. In order to preserve the benefits of object-centric alignment in the language domain, we also propose to explicitly condition the (pseudo-labeled) image-level VL mapping on the region-level VL mapping via a novel weight transfer function. In this manner, we are the first to simultaneously integrate objectcentric visual and language alignment within a single architecture for OVD. • Our extensive experiments demonstrate the improved OVD capability of the proposed approach. On COCO and LVIS benchmarks, our method achieves absolute gains of 8.2 and 5.0 AP on novel and rare classes over the current SOTA methods. Further generalizability is demonstrated by our cross-dataset evaluations performed on COCO, OpenImages and Objects365, leading to consistent improvements compared to existing methods.
21
+
22
+ # 2 Related Work
23
+
24
+ Zero-shot Object Detection (ZSD): This setting involves detecting novel class objects at inference, for which no visual examples are available during training. Zhu et al. [9] use semantic information with visual features to get proposals for both seen and unseen classes. Bensal et al. [10] show that learning a good separation between background and foreground is critical in ZSD and propose to use multiple latent classes for modeling background during training. Rahman et al. [11] propose a polarity loss to solve the ambiguity between background and unseen classes. DELO [12] focuses on generating good proposals for unseen classes by synthesizing visual features for unseen objects using a generative model. Gupta et al. [13] benefits from the contemporary cues in semantic and visual space ensuring better class separation for ZSD. Other works use additional learning signals, including unlabeled images from target domain [14] and raw textual descriptions from the internet [15]. Although significant progress has been made on this topic [14, 15, 13], the inherent complexity of the task makes it challenging for the ZSD models to generalize well to unseen object classes.
25
+
26
+ Weakly-supervised Object Detection (WSOD): In this setting, only image-level labels are used to approach object detection [16, 17, 18, 19, 20], or are used alongside the detection dataset to enlarge the detector vocabulary [21, 22, 23]. Bilen et al. [24] proposed a weakly-supervised deep detection network (WSDNN) that uses off-the-shelf region proposals [25, 26] and computes objectness and recognition scores for each proposal using separate subnetworks. Cap2Det [27] operates in a similar setting and uses raw text captions to generate pseudo-labels to guide image-level supervision. Li et al. [28] uses segmentation-detection collaborative network (SDCN) for accurate detection under weakly-supervised setting using only image labels. PCL [29] proposes to cluster the spatially adjacent proposals and then assign image labels to each cluster. CASD [30] argues that the detectors trained only with image-level labels are prone to detect boxes around salient objects and propose feature attention along with self-distillation to address the issue. YOLO9000 [31] and DLWL [32] augments the detection training by assigning image-level labels to the max-score proposal. Detic [2] shows that using max-size proposal is an optimal choice for assigning image-level labels as it does not rely on the predictions of the network being optimized and provides better signals for the novel classes.
27
+
28
+ ![](images/4075312b8811c77d5c9f7196f22bdd4c5a4a6bb284b1eb970834d715a948581d.jpg)
29
+ Figure 1: An overview of our proposed object-centric framework for OVD. We pair a two-stage object detector with fixed language embeddings from a pretrained visual-language (VL) model, CLIP [3]. Our proposed pseudo-labeling strategy $\mathcal { Q } _ { \mathrm { p s e u d o } }$ uses pretrained multi-modal ViTs to obtain high-quality class-agnostic and class-specific proposals. The overall pipeline follows a stage-wise learning strategy. First, we introduce region-based knowledge distillation (RKD) to adapt image-centric CLIP embeddings for local regions. Using the pretrained VL image encoder as a teacher model, we train the detector to induce point-wise and interembedding relationship alignment with our region embeddings using class-agnostic proposals from $\mathcal { Q } _ { \mathrm { p s e u d o } }$ Next, we utilize a weakly-supervised learning framework by combining instance-level labels from detection dataset and image-level labels from classification dataset which are visually grounded using $\mathcal { Q } _ { \mathrm { p s e u d o } }$ . This weaksupervision helps in enlarging the class vocabulary and generalizes the detector to novel classes. To preserve the benefits of object-centric alignment in the language domain learned via RKD, we explicitly condition the image-level VL mapping $W _ { P }$ , on the learned region-level VL mapping $W _ { D }$ via a novel weight transfer function.
30
+
31
+ We also operate in a similar WSOD setting and use high-quality object proposals from pretrained multi-modal ViT [8] to enlarge detector vocabulary and generalize towards novel object categories.
32
+
33
+ Open-vocabulary Object Detection (OVD): In OVD, the objective is to detect target class objects not present in the training/base class vocabulary. A typical solution of the problem is to replace the classifier weights with text embeddings of the target vocabulary (e.g., GloVe [33], BERT [34], CLIP [3]). OVR-RCNN [1] uses BERT embeddings as classifier weights and proposes to use openvocabulary captions to learn the vision-to-language mapping. It surpasses the ZSD approaches by a large margin. ViLD [6] uses pretrained CLIP [3] to distill knowledge into a two-stage object detector [35] and replaces the classifier weights with CLIP text embeddings obtained by ensembling multiple text prompts (e.g., a {category}, a photo of a {category}). Gao et al. [36] generate pseudo bounding-box labels using pretrained VL models for training open-vocabulary detector. All these methods use carefully designed manual prompts for generating text embeddings. DetPro [37] and PromptDet [38] replace these manual prompts with learnable tokens and achieve competitive results on novel/rare categories. However, in our work, we use fixed manual prompts and instead focus on improving the object-centric representations for open-vocabulary object detection.
34
+
35
+ # 3 Object-centric Open-Vocabulary Detection
36
+
37
+ Here, we first present a brief overview of the proposed open-vocabulary detection (OVD) framework. As discussed earlier, existing OVD methods use different forms of weak supervision that employ image-centric representations, making them less suited for the end detection task. Our proposed method aims to bridge the gap between image and object-centric visual-language (VL) representations. We summarize the architectural overview of our method in Fig. 1. The proposed design has three main elements. 1) Our region-based knowledge distillation (refer Sec. 3.2) adapts image-centric language representations to be object-centric. A VL mapping learns to align the local region representations of the detector to the language representations by distilling the detector’s region representations with region representations from a VL model (CLIP). 2) Given weak image-level supervision, we use pseudo-labeling from pretrained multi-modal ViTs (refer Sec. 3.3) to improve generalization of the detector to novel classes. 3) For an efficient combination of the above two proposed components, we condition the VL mapping learned during the weak supervision on the VL mapping learned with region-based distillation via a novel weight transfer function (refer Sec. 3.4). Specifically, we follow a stage-wise learning strategy to first align the region and language embeddings using RKD, and use this distilled VL mapping for object-centric visual and language alignment in the subsequent stage.
38
+
39
+ # 3.1 Detection Pipeline: Preliminaries
40
+
41
+ In the open-vocabulary detection problem, we have access to an object detection dataset where the training set, $\mathcal { D } _ { \mathrm { d e t } }$ , comprises samples from the set of base object categories, $\mathcal { C } _ { \mathrm { B } }$ . The images of $\mathcal { D } _ { \mathrm { d e t } }$ are exhaustively annotated with bounding-box labels and corresponding class labels $y _ { r } \in \mathcal { C } _ { \mathrm { B } }$ , for the different objects in the image. Given an image $I \in \mathbb { R } ^ { H \times W \times \mathbf { \dot { 3 } } }$ , we design an open-vocabulary object detector to solve two subsequent problems: (1) effectively localize all objects in the image, (2) classify the detected region into one of the class label of $\mathcal { C } _ { \mathrm { t e s t } }$ , which is provided by the user at test time. The categories during test time also include novel categories $\mathcal { C } _ { \mathrm { N } }$ beyond the closed set of base categories seen during the training phase, i.e., $\mathcal { C } _ { \mathrm { t e s t } } = \mathcal { C } _ { \mathrm { B } } \cup \mathcal { C } _ { \mathrm { N } }$ .
42
+
43
+ We convert a generic two-stage object detector [35] to an open-vocabulary detector by replacing the learnable classifier head with fixed language embeddings, $\tau$ corresponding to the category names of $\mathcal { C } _ { \mathrm { t e s t } }$ , that are obtained using a large-scale pretrained VL model. Following [6], we use the text embeddings from CLIP text encoder [3] for classification, where only the embeddings of $\mathcal { C } _ { \mathrm { B } }$ categories, $\mathcal { T } _ { C _ { \mathrm { B } } }$ are used during training. Specifically, we generate the text embeddings offline, by processing the prompts corresponding to each category with a template of $\mathbf { \dot { a } } _ { }$ photo of {category}’ through the CLIP text encoder. The RoI [35] head computes pooled feature representations $\phi ( r )$ of the proposals $r$ generated by the region proposal network (RPN). These feature embeddings are projected to a common feature space shared by the text embedding $\tau$ using a linear layer $f ( \cdot )$ , which we represent as region embeddings, $\mathcal { R } = f ( \dot { \phi } ( r ) ) \in \mathbb { R } ^ { D }$ . For classification, we compute the cosine similarity between the region embeddings and text embeddings to find the matching pairs. During training, the regions that do not match with any of the ground-truths are assigned to the background category represented by a fixed all zero embedding. We compute the cosine similarity by comparing each region to each base class, $\mathcal { V } = s i m ( r , b ) = \bar { \cos \left( \mathcal { R } ( r ) , \mathcal { T } _ { b } \right) } \forall b \in \mathcal { C } _ { \mathrm { B } }$ . The classification loss is a softmax cross-entropy (CE) where the logits are the cosine similarity scores,
44
+
45
+ $$
46
+ \mathcal { L } _ { c l s } = \frac { 1 } { N } \sum _ { r } \mathcal { L } _ { C E } \left( \mathsf { s o f t m a x } \Big ( \frac { \mathcal { V } } { \tau } \Big ) , y _ { r } \right) , y _ { r } \in \mathcal { C } _ { \mathrm { B } } .
47
+ $$
48
+
49
+ where $\tau$ is the temperature, $N$ is the total number of proposals per image, and $r$ represents a single proposal with the ground-truth label $y _ { r }$ .
50
+
51
+ # 3.2 Region-based Knowledge Distillation
52
+
53
+ In the OVD setting, we assume that $f ( \cdot )$ learns a VL mapping and aligns the output region embeddings of the detector with the corresponding CLIP text embeddings. However, the performance on novel categories is not comparable to what CLIP encoded embeddings would provide (refer Appendix B for details). We hypothesize that this performance gap is mainly due to two reasons, i) the data that has been used for training CLIP model consist of scene-centric images, making it less suitable for region classification, e.g., in our case where object-centric tightly bounded proposals are used, ii) the zero-shot generalization ability of the pair-wise trained CLIP image and text embeddings cannot be fully utilized due to the mismatch between regions representations from CLIP image encoder and our detector. Based on these insights, we propose a region-based knowledge distillation (RKD).
54
+
55
+ The proposed RKD uses distillation in the detection pipeline by distilling region embeddings from high-quality class-agnostic proposals $( \tilde { r } )$ obtained from a pretrained multi-modal ViT (MViT) [8]. Note that we obtain both class-agnostic (used in RKD) and class-specific (refer Sec. 3.3) object proposals using this pseudo-labeling process, which we refer to as $\mathcal { Q } _ { \mathrm { p s e u d o } }$ . This is possible via using intuitive text queries to interact with the MViT model that can locate generic objects and provides the corresponding set of candidate proposals. The queries can be generic or targeted, based on the task, e.g., ‘all objects’ to generate class-agnostic proposals, or ‘every dog’ for a specific class.
56
+
57
+ For RKD, we compute class agnostic proposals on $\mathcal { D } _ { \mathrm { d e t } }$ using simple text query, ‘all objects’ and select top- $\mathbf { K }$ proposals (Fig. 3b). CLIP embeddings $\mathcal { T } ( \tilde { r } )$ are then computed offline using the CLIP image encoder $\boldsymbol { \mathcal { T } } ( \cdot )$ . With the detector region embeddings and the corresponding CLIP region representations, we propose to use two types of distillation losses to improve the alignment.
58
+
59
+ (1) Point-wise embedding matching loss: The $\mathcal { L } _ { 1 }$ loss matches the individual region embeddings $\tilde { \mathcal { R } } = f ( \phi ( \tilde { r } ) )$ with the CLIP region representations $\mathcal { T } ( \tilde { r } )$ ,
60
+
61
+ $$
62
+ \mathcal { L } _ { 1 } = \frac { 1 } { K } \sum _ { \tilde { r } } \parallel \tilde { \mathcal { R } } - \mathcal { I } ( \tilde { r } ) \parallel _ { 1 } .
63
+ $$
64
+
65
+ ![](images/d8a6f4afcbec02ed0e5dd6ab93c1b94761a9788dc203be548286eff104bbb2f9.jpg)
66
+ Figure 2: Top-row: Similarity matrices computed on the CLIP $( S _ { I } )$ and detector $( S _ { R } )$ region embeddings for COCO novel classes. A subset of 100 randomly selected samples per category form a batch represented by a column are grouped together. Our region-based distillation enforces the similarity patterns in the RKD model to be closer to the teacher model, CLIP, indicated by the bright colors along diagonals. Bottom-row: t-SNE plots of CLIP and detector region embeddings on novel COCO categories. The CLIP aligned RKD and weight transfer detector embeddings shows improved separability among novel class features as compared to the supervised detector region embeddings (figure best viewed in-zoom).
67
+
68
+ Using this criteria, our visual encoder, along with the VL projection layer $f ( \cdot )$ , approximates the CLIP image encoder and consequently aligns our region embeddings with the CLIP text embeddings.
69
+
70
+ (2) Inter-embedding relationship matching loss (IRM): It is a knowledge distillation based loss $\mathcal { L } _ { i r m }$ that instills inter-embedding relationships within our region representations to be consistent to the CLIP region representations [39]. Instilling such inter-embedding relations would be beneficial as we know that the teacher model $\mathcal { T } ( \cdot )$ , and the student model (our detector), are different in nature with respect to their training methods (Fig. 2). The IRM loss is defined on pairwise similarity matrices of the two different sets of embeddings. Specifically, with the top- $\mathbf { K }$ proposals computed from $\mathcal { Q } _ { \mathrm { p s e u d o } }$ , we compose $K \times K$ similarity matrices for $\mathcal { T } ( \tilde { r } )$ and $\tilde { \mathcal { R } }$ denoted by $S _ { I }$ and $S _ { R }$ respectively. Notably, these matrices are normalized by L2 norm applied row-wise. The IRM loss is a Frobenius norm $\| \cdot \| _ { F }$ , over the mean element-wise squared difference between $S _ { \mathcal { I } }$ and $S _ { R }$ ,
71
+
72
+ $$
73
+ \begin{array} { c } { \displaystyle S _ { R } = \frac { \tilde { \mathcal { R } } \cdot \tilde { \mathcal { R } } ^ { T } } { \parallel \tilde { \mathcal { R } } \cdot \tilde { \mathcal { R } } ^ { T } \parallel _ { 2 } } , ~ \displaystyle S _ { \mathcal { T } } = \frac { \mathcal { T } ( \tilde { r } ) \cdot \mathcal { T } ( \tilde { r } ) ^ { T } } { \parallel \mathcal { T } ( \tilde { r } ) \cdot \mathcal { T } ( \tilde { r } ) ^ { T } \parallel _ { 2 } } , } \\ { \displaystyle \mathcal { L } _ { i r m } = \frac { 1 } { K ^ { 2 } } \parallel S _ { R } - S _ { \mathcal { T } } \parallel _ { F } ^ { 2 } . } \end{array}
74
+ $$
75
+
76
+ We weight the $\mathcal { L } _ { 1 }$ and $\mathcal { L } _ { i r m }$ losses by factors $\beta _ { 1 }$ and $\beta _ { 2 }$ , respectively. Together with the standard twostage detector losses; RPN loss $( \mathcal { L } _ { r p n } )$ , regression loss $( \mathcal { L } _ { r e g } )$ and classification loss $( \mathcal { L } _ { c l s } )$ [35, 40]; the overall training objective with RKD can be expressed as,
77
+
78
+ $$
79
+ \begin{array} { r } { \mathcal { L } _ { R K D } = \mathcal { L } _ { r p n } + \mathcal { L } _ { r e g } + \mathcal { L } _ { c l s } + \beta _ { 1 } \mathcal { L } _ { 1 } + \beta _ { 2 } \mathcal { L } _ { i r m } . } \end{array}
80
+ $$
81
+
82
+ # 3.3 Image-level Supervision with Pseudo Box Labels
83
+
84
+ In the open-vocabulary setting, a fundamental challenge is to generalize the detector to novel classes. However, due to the daunting task of densely locating all objects in natural scenes, the existing detection datasets are of relatively smaller magnitude compared to the classification datasets, which are easier to annotate. To this end, Zhou et al. [2] proposed to take advantage of a large-scale image classification dataset during training to expand the detector’s vocabulary. However, an important question is how to effectively associate the region proposals of novel objects with the corresponding labels. We note that the existing approach uses heuristics such as selecting the whole image as a single box, or just the maximum sized box from the RPN, which can ignore potential objects (Fig. 3a).
85
+
86
+ We propose a weakly-supervised method to generalize the detector to novel categories by using pseudo-box labels from pretrained MViT [8]. We follow [2] to train the detector with a combination of detection and classification dataset. A batch of data is prepared by combining data from the detection dataset $\mathcal { D } _ { \mathrm { d e t } }$ that are exhaustively annotated with bounding-box and class labels, with data from a classification dataset $\mathcal { D } _ { \mathrm { c l s } }$ that only contains image-level labels. With $\mathcal { Q } _ { \mathrm { p s e u d o } }$ , we obtain the pseudo-box labels on this classification dataset, which we use for image-level supervision (ILS). Specifically, consider a sample image $I \in \mathcal { D } _ { \mathrm { c l s } }$ , which has a total of $N$ ground-truth class labels, we generate object proposals offline with the use of MViT corresponding to these weak labels. Specifically, we construct $N$ class-specific text queries $\{ t _ { n } \} _ { n = 1 } ^ { N }$ with template ‘every {category}’, and obtain $K$ proposals $\{ \tilde { r } _ { k } \} _ { k = 1 } ^ { K }$ and corresponding confidence scores $\{ \hat { \tilde { s } } _ { k } \} _ { k = 1 } ^ { K }$ for each query,
87
+
88
+ ![](images/da789f327daab04ed55e7072c1fa6d2e2ae5dcb4e7a71733d0cd0f9b437492e9.jpg)
89
+ (a) Class-specific Proposals
90
+
91
+ Figure 3: (a) Class-specific Proposals: A visual comparison of heuristic methods (left) used for visual grounding in image-level supervision [2] with our proposed method (right). Using heuristic based approaches like selecting maximum sized box from the RPN can ignore local objects in the scene. In our method, we design class-specific text queries with known class labels for pseudo-labeling potential objects. (b) Class-agnostic Proposals: In region-based knowledge distillation (RKD), we induce better region-level alignment with fewer high-quality proposals from a generalized class-agnostic proposal generator [8]. We compare top-K RPN proposals (left) with top-K multi-modal ViTs proposals used in a class-agnostic manner (right).
92
+
93
+ $$
94
+ [ ( \tilde { r _ { 1 } } , \tilde { s _ { 1 } } ) , ( \tilde { r _ { 2 } } , \tilde { s _ { 2 } } ) , \cdot \cdot \cdot ( r _ { K } , s _ { K } ) ] = \mathcal { Q } _ { \mathrm { p s e u d o } } ( I , t _ { n } ) ; I \in \mathcal { D } _ { \mathrm { c l s } } , n \in N .
95
+ $$
96
+
97
+ We select the top-1 proposal with the highest confidence score, as the pseudo-box label for a particular category. This gives us $N$ high-quality pseudo-box labels for each image, corresponding to its $N$ image-level category labels (Fig. 3a). We compute the region embeddings $\tilde { \mathcal { R } }$ for proposals $\tilde { r }$ as,
98
+
99
+ $$
100
+ \tilde { \mathcal { R } } _ { n } = f ( \phi ( \tilde { r } _ { \hat { k } } ) ) , \hat { k } = \mathrm { a r g m a x } _ { k } ( \tilde { s _ { k } } ) .
101
+ $$
102
+
103
+ In the case of $\mathcal { D } _ { \mathrm { d e t } }$ , the training follows the standard two-stage RCNN training recipe. However, for $\mathcal { D } _ { \mathrm { c l s } }$ , only the classification loss is updated. We call this pseudo-max score, $\mathcal { L } _ { p m s }$ loss.
104
+
105
+ $$
106
+ \mathcal { L } _ { p m s } = \frac { 1 } { N } \sum _ { n } B C E ( \nu , y _ { \tilde { r } } ) , \mathrm { w h e r e } \mathcal { V } = \cos \big ( \tilde { \mathcal { R } } _ { n } , \mathcal { T } \big ) .
107
+ $$
108
+
109
+ We weight $\mathcal { L } _ { p m s }$ by a factor $\alpha$ and the overall training objective with our ILS can be expressed as,
110
+
111
+ $$
112
+ \mathcal { L } _ { I L S } = \left\{ \begin{array} { l l } { \mathcal { L } _ { r p n } + \mathcal { L } _ { r e g } + \mathcal { L } _ { c l s } , } & { \mathrm { i f } \quad I \in \mathcal { D } _ { \mathrm { d e t } } } \\ { \alpha \mathcal { L } _ { p m s } , } & { \mathrm { i f } \quad I \in \mathcal { D } _ { \mathrm { c l s } } . } \end{array} \right.
113
+ $$
114
+
115
+ # 3.4 Weight Transfer Function
116
+
117
+ To combine the alignment from region-based distillation (Sec. 3.2) with the benefits from weak supervision with pseudo-box labels (Sec. 3.3), a naive approach would be to train the detector with a combination of losses: $\mathcal { L } _ { 1 }$ (1), $\mathcal { L } _ { i r m }$ (2) and $\mathcal { L } _ { p m s }$ (4). However, we demonstrate that a simple combination of the two approaches does not lead to complimentary benefits, instead they compete with each other (Table 2). The additional supervision from pseudo-labels improves the generalization of the detector, while the region-based distillation works towards object-centric alignment in the language domain, thereby improving the overall performance of the detector. We aim to incorporate the benefits from the two approaches and preserve the object-centric alignment in the language domain. To this end, we use a weight transfer mechanism [41] from VL projection used in regionbased distillation to the weak supervision by learning a weight transfer function, $\mathcal { W } _ { T } ( \cdot )$ . In other words, the VL projection function $f ( \cdot )$ used during the weak image-level supervision is explicitly conditioned on the mapping function used for alignment in the distillation process. This way, both the transformations are tied together to reinforce mutual representation capability and avoid any conflict in the learned function mapping. Let the weights of the projection layer in RKD and weak image-level supervision be represented as $W _ { D }$ and $W _ { P }$ respectively. The weight transfer operation is given by,
118
+
119
+ $$
120
+ W _ { P } = { \mathcal { W } } _ { { \mathcal { T } } } ( W _ { D } ) = { \Big ( } W _ { \theta _ { 2 } } \rho ( W _ { \theta _ { 1 } } W _ { D } ) { \Big ) } ; \qquad \ \mathcal { W } _ { { \mathcal { T } } } : \ W _ { D } \to W _ { P } .
121
+ $$
122
+
123
+ Here, $W _ { D }$ is kept frozen and we design $\mathcal { W } _ { T }$ as a 2-layer MLP, $W _ { \theta _ { 1 } }$ followed by $W _ { \theta _ { 2 } }$ a with LeakyReLU $( \rho )$ activation with a negative slope of 0.1. Further, we use a skip connection across $W _ { P }$ by projecting the original representations using a separate 2-layer MLP (Fig. 1). The total loss here is a combination of $\mathcal { L } _ { R K D }$ (Eq. 3) and $\mathcal { L } _ { I L S }$ (Eq. 5) loss, given by,
124
+
125
+ $$
126
+ \mathcal { L } = \mathcal { L } _ { r p n } + \mathcal { L } _ { r e g } + \mathcal { L } _ { c l s } + \beta _ { 1 } \mathcal { L } _ { 1 } + \beta _ { 2 } \mathcal { L } _ { i r m } + \alpha \mathcal { L } _ { p m s } .
127
+ $$
128
+
129
+ # 4 Experiments
130
+
131
+ # 4.1 Datasets
132
+
133
+ We conduct our experiments on COCO [42] and LVIS v1.0 [43] under OVD setting. For evaluation, we use the generalized ZSD setting where the classifier contains both base and novel categories. Table 1 summarizes all the datasets used in our work. Following [2, 1], we use a subset of ImageNet-21K having 997 overlapping LVIS categories and COCO captions dataset for ILS in LVIS and COCO experiments respectively (refer
134
+
135
+ <table><tr><td>Dataset</td><td>Dataset Type</td><td>Task</td><td>#images</td></tr><tr><td rowspan="3">COCO LVIS v1.0 ImageNet-21K*</td><td>Detection</td><td>OVD</td><td>118K</td></tr><tr><td>Detection</td><td>OVD</td><td>100K</td></tr><tr><td>Classification Image-captioning</td><td>ILS in LVIS ILS in COCO</td><td>1.4M 118K</td></tr><tr><td rowspan="2">LMDet</td><td>Flickr30, GQA &amp;</td><td>MViT</td><td rowspan="2">1.1M</td></tr><tr><td>Visual Genome</td><td>Pretraining</td></tr><tr><td rowspan="2">$LMDet</td><td>LMDet</td><td>MViT</td><td rowspan="2">0.8M</td></tr><tr><td>(excluding any overlap with novel categories)</td><td>Pretraining</td></tr></table>
136
+
137
+ Table 1: Summary of the datasets used in our experiments.
138
+
139
+ Appendix. A for more details). For the pseudo-labeling process $\mathcal { Q } _ { \mathrm { p s e u d o } }$ , we use the MViT pretrained on a Large-scale Modulated Detection (LMDet) dataset [8]. We ensure that MViT pretraining dataset has no overlap with any of the evaluation datasets in our work. Additionally, in all our experiments we use a pretrained MViT that we train using the author’s provided code on filtered LMDet (‡LMDet) dataset by entirely restricting any exposure to the novel/rare classes in evaluation.
140
+
141
+ COCO OVD: We use COCO-2017 dataset for training and validation. We follow the ZS splits proposed in [10], in which 48 categories are selected as base and 17 are selected as novel classes.
142
+
143
+ LVIS OVD: LVIS contains 1203 categories which are further split into frequent, common and rare categories. Inline with [6, 2], we combine the frequent and common categories to form base classes and keep all rare classes as novel, resulting in 866 base and 337 rare classes.
144
+
145
+ Cross-transfer Datasets: To validate the adaptability of our method, we evaluate and compare results of our LVIS trained model on OpenImages[44] and Objects365 [45] and COCO [42] datasets.
146
+
147
+ # 4.2 Implementation details
148
+
149
+ We conduct COCO experiments using Faster R-CNN [35] with ResNet-50 backbone. We train the supervised-base model on 48 base classes $( \mathcal { C } _ { \mathrm { B } } )$ for 1x schedule ( ${ \sim } 1 2$ COCO epochs) and report box $\mathrm { { A P } _ { 5 0 } }$ . For RKD, we finetune this model for another 1x schedule using box labels from $\mathcal { C } _ { \mathrm { B } }$ and class-agnostic proposals from the pretrained MViT [8]. This model is further finetuned for $1 \mathbf { x }$ schedule with ILS and the associated weight transfer function using class labels from COCO captions and corresponding class-specific proposals from MViT. This sums to an overall $3 \mathbf { x }$ training schedule.
150
+
151
+ For LVIS experiments, we use Mask R-CNN [40] with federated loss [46] and sigmoid cross-entropy, and report mask AP. For RKD and weight transfer, we use the same training schedules as of COCO and report the average over three runs. For comparison with Detic [2], we apply our proposed method on their strong CenterNetV2 [46] baseline under the same settings. It uses ImangeNet21K pretrained backbone with $4 \mathbf { x }$ schedule using large scale jittering (LSJ) [47] augmentations. All of our models are trained using 8 A100 GPUs with an approximate training time of 9 and 6 hours for $1 \mathbf { x }$ schedule of COCO and LVIS respectively.
152
+
153
+ In our experiments, we use SGD optimizer with a weight decay of $1 e ^ { - 4 }$ and a momentum of 0.9. We train for $1 \mathbf { x }$ schedule with batch size of 16 and an initial learning rate of 0.02 which drops by a factor of 10 at the $8 ^ { t h }$ and $1 1 ^ { t h }$ epoch. We set temperature $\tau$ to 50. Our longer schedules experiments use 100-1280 LSJ [47]. We use $\alpha$ of 0.1 to weight $\mathcal { L } _ { p m s }$ . For computing CLIP embeddings we use the
154
+
155
+ CLIP model ViT-B/32 [3], with input size of $2 2 4 \times 2 2 4$ . We use the query ‘a photo of a {category}’ for to compute the text embeddings for the classifier. For distillation, we use top 5 proposals from the pretrained MViT [8] evaluated with generic query, ‘all objects’, generating class-agnostic proposals. We refer to Appendix D for additional details on the approach we use to generate class-agnostic and class-specific proposals from MViT. In COCO experiments, we set weights $\beta _ { 1 }$ and $\beta _ { 2 }$ to 0.15. In LVIS, we set $\beta _ { 1 }$ to 0.15 and $\beta _ { 2 }$ to 0.25. We choose these values using a randomized hyper-parameter search on the corresponding held-out datasets. The 2-layer MLP in our weight transfer function has a hidden dim of 512, and a hidden dim of 1024 is used in the MLP skip connection across $W _ { P }$ in Fig. 1 (refer to Appendix C for more details).
156
+
157
+ # 4.3 Our Approach: Main results
158
+
159
+ Table 2 shows the contribution of individual components in our proposed approach. Building on top of the supervised-base model, our region-based knowledge distillation (RKD) shows an absolute gain of 19.5 and $1 . 5 \mathrm { A P }$ for COCO novel and base classes respectively, indicating the adaptability of image-centric CLIP embeddings for local regions. With pseudo-box labeled weak image-level supervision (PIS), novel class AP improves by 28.7, demonstrating generalization to novel classes and thus enlarging the detector’s vocabulary. Naively combining the two approaches shows improvement, but struggles to maintain the gains from the individual components. In contrast, our weight transfer method suitably combines the complimentary benefits of both components (Fig. 2), achieving 36.6 AP on novel classes while maintaining performance on base classes.
160
+
161
+ Table 2: Effect of individual components in our method. Our weight transfer method provides complimentary gains from RKD and ILS, achieving superior results as compared to naively adding both components.
162
+
163
+ <table><tr><td>Method</td><td>APnovel</td><td>APbase</td><td>AP</td></tr><tr><td>1: Supervised (Base)</td><td>1.7</td><td>53.2</td><td>39.6</td></tr><tr><td>2: Base + Region based ditillation (RKD)</td><td>21.2</td><td>54.7</td><td>45.9</td></tr><tr><td>3: Base + ILS with pseudo-box (PIS)</td><td>30.4</td><td>52.6</td><td>46.8</td></tr><tr><td>4: RKD +PIS</td><td>31.5</td><td>52.8</td><td>47.2</td></tr><tr><td>5: RKD + PIS + Weight-transfer (Ours)</td><td>36.6</td><td>54.0</td><td>49.4</td></tr></table>
164
+
165
+ Open-vocabulary Detection - COCO: We compare our OVD results with previously established methods in Table 3. OVR-CNN learns a vision-to-language mapping with expensive pretraining. Detic uses ILS to improve detection on novel classes. We use a novel weight transfer function to perform object-centric VL alignment and achieve $5 4 . 0 \mathrm { A P }$ on the base classes, surpassing OVR-CNN and Detic by 8.0 AP and 0.2 AP respectively. On novel classes our method achieves 36.6 AP, the highest novel AP achieved over all methods. In comparison with ViLD, which trains for ${ 8 } \mathbf { { x } }$ schedule $\sim 9 6$ epochs), our method with the same schedule provides 56.6 base AP, lagging by 2.9.
166
+
167
+ <table><tr><td>Method</td><td>Supervision</td><td>APbase APnovel</td><td>AP</td></tr><tr><td>WSDDN$ [24] Cap2Det8[27]</td><td>image-level labels for CB U CN</td><td>19.6 19.7 20.1 20.3</td><td>19.6 20.1</td></tr><tr><td>OVR-CNN [1]</td><td>pretraining with captions CB U CN box-level labels in CB</td><td>46.0 22.8</td><td>39.9</td></tr><tr><td>ViLD† [6]</td><td>internet sourced image-text pairs box-level labels in CB</td><td>59.5</td><td>27.6 51.3</td></tr><tr><td>RegionCLIP [7]</td><td>internet sourced image-text pairs pretraining with pseudo box-level labels box-level labels in CB</td><td>54.8</td><td>26.8 47.5</td></tr><tr><td>Detic [2] Detic$</td><td>internet sourced image-text pairs image-level labels for CB U CN box-level labels in CB</td><td>47.1 53.8</td><td>27.8 45.0 28.4 47.2</td></tr><tr><td>Ours Ours t</td><td>internet sourced image-text pairs image-level labels for CB U CN pseudo-box labels in CN,box-level labels in CB</td><td>54.0 36.6 56.6 36.9</td><td>49.4 51.5</td></tr></table>
168
+
169
+ Table 3: OVD results on COCO. Here $\mathcal { C } _ { \mathrm { B } }$ and $\mathcal { C } _ { \mathrm { N } }$ represents the base and novel classes respectively. $\ S$ The results quoted from [1]. $\dagger \mathrm { V i L D }$ and our methods are trained for longer 8x schedule (shown in gray). $\ddagger \mathrm { W e }$ train detic for another 1x for a fair comparison with our method. For ViLD, we use their unified model that trains ViLD-text and ViLD-Image together. For Detic, we report their best model.
170
+
171
+ On novel classes, we achieve 36.9 AP surpassing ViLD by a gain of 9.3. In contrast to ViLD design, our weight transfer function allows both RKD and ILS to provide complimentary gains without any negative competition among the two methods [6].
172
+
173
+ Open-vocabulary Detection - LVIS: Table 4 (left) compares our results with ViLD [6] on LVIS benchmark. With $3 \mathbf { x }$ training schedule $\sim 3 6$ epochs) we perform reasonably well compared to ViLD $3 2 \mathbf { x }$ schedule $\sim 3 8 4$ epochs), already surpassing the rare AP by 1.0 while having slightly lower performance on frequent classes. Extending our model to ${ 8 } \mathbf { { x } }$ schedule fills the gap, surpassing ViLD by 0.8 in frequent and $5 . 0 \mathrm { A P }$ in rare classes respectively. In Table 4 (right), we compare our method with Detic by using their strong LVIS baseline that uses CenterNetV2 network. Following similar settings, we finetune their box-supervised model using our weight transfer method and show improvements.
174
+
175
+ <table><tr><td>Method</td><td>Epochs</td><td>APr</td><td>APc</td><td>APf</td><td>AP</td></tr><tr><td>ViLD [6]</td><td>384</td><td>16.1</td><td>20.0</td><td>28.3</td><td>22.5</td></tr><tr><td>Ours</td><td>36</td><td>17.1</td><td>21.4</td><td>26.7</td><td>22.8</td></tr><tr><td>Ours</td><td>96</td><td>21.1</td><td>25.0</td><td>29.1</td><td>25.9</td></tr></table>
176
+
177
+ Table 4: OVD results on LVIS. (Left): Comparison with prior work ViLD, using their unified model (ViLD-text $^ +$ ViLD-Image), show improvement across novel and base categories. (Right): We show the comparison with Detic, by building on their strong LVIS baseline using CenterNetV2 detector [2]
178
+
179
+ <table><tr><td>Method</td><td>APr</td><td>APc</td><td>APf</td><td>AP</td></tr><tr><td>Box-supervised [2]</td><td>16.3</td><td>31.0</td><td>35.4</td><td>30.0</td></tr><tr><td>Detic (Image + Captions)</td><td>24.6</td><td>32.5</td><td>35.6</td><td>32.4</td></tr><tr><td>Ours</td><td>25.2</td><td>33.4</td><td>35.8</td><td>32.9</td></tr></table>
180
+
181
+ Strict Open-vocabulary Setting: Inspired from Detic, we define our work under the weakly-supervised openvocabulary setting as it uses image-level labels for expanding the detector’s vocabulary. However in this setting, the complete target vocabulary set is unknown, i.e., only a selected number of novel and base categories are used for ILS from ImageNet-21K in LVIS. To evaluate our model in an extensive open-vocabulary setting, we modify our
182
+
183
+ <table><tr><td>Method</td><td>Epochs APrAPcAPfAP</td><td></td><td></td><td></td><td></td></tr><tr><td>ViLD [6]</td><td>384</td><td>16.1</td><td>20.0</td><td>28.3</td><td>22.5</td></tr><tr><td>Ours</td><td>36</td><td>16.0</td><td>20.2</td><td>26.3</td><td>21.8</td></tr></table>
184
+
185
+ Table 5: Performance on LVIS benchmark using a strict OVD setting.
186
+
187
+ ILS by considering a larger vocabulary. Specifically, we expand the vocabulary to five times its size in [2], by applying ILS from randomly sampled 5K categories from ImageNet-21k, in addition to the LVIS base classes. Table 5 compares our strict OVD setting results with ViLD where our performance slightly degrades showing sensitivity to ILS. However, we expect a gain with longer training as in Table 4. In addition to above two settings, we train our LVIS model under stricter OVD conditions in a non weakly-supervised setting by only using LVIS base categories for ILS. We achieve an overall 21.71 AP which is close to the model trained using ILS from 997 categories (22.75 AP).
188
+
189
+ Cross-dataset evaluation performance: We provide cross-dataset evaluation of our model in Table 6 and compare with prior OVD works. ViLD-text[6] and Detic-base[2] are box-supervised baseline models for ViLD and Detic respectively. Our method builds on top of Detic-base and shows favourable results when directly transferred to cross-datasets without any dataset-specific finetuning. We use our method trained on LVIS and report $\mathsf { A P } _ { 5 0 }$ on COCO [42], OpenImages [44] and Objects365 [45].
190
+
191
+ <table><tr><td>Method</td><td>COCO</td><td>OpenImages</td><td>Objects365</td></tr><tr><td>ViLD-text</td><td>43.4</td><td>-</td><td>11.1</td></tr><tr><td>Detic-baset</td><td>55.3</td><td>37.4</td><td>19.2</td></tr><tr><td>ViLD</td><td>55.6</td><td>1</td><td>18.2</td></tr><tr><td>Detict</td><td>56.3</td><td>42.2</td><td>21.7</td></tr><tr><td>Ours</td><td>56.6</td><td>42.9</td><td>22.3</td></tr></table>
192
+
193
+ Table 6: Cross-dataset evaluation. †The results evaluated using official implementation.
194
+
195
+ # 4.4 Analysis of RKD and ILS
196
+
197
+ Effect of Region-based Knowledge Distillation (RKD): We ablate the effect of $\mathcal { L } _ { 1 }$ (Eq. 1) and $\mathcal { L } _ { i r m }$ (Eq. 2) RKD approach on COCO (Table 7). The results show the importance of both loss functions, where using $\mathcal { L } _ { 1 }$ loss over base model with top-5 proposals from MViT [8] improves the base and novel class by 1.9 and 15.0 AP (row-1 vs 3). Using $\mathcal { L } _ { i r m }$ in row-4 further improves the overall and novel class AP. To show the importance of using quality proposals in RKD, we compare the model trained with $\mathcal { L } _ { 1 }$ loss using top-5 RPN vs MViT proposals (row-2 vs 3). All the models in rows 2-4 are finetuned on the base model.
198
+
199
+ Effect of Weak Image-level Supervision (ILS): We compare different choices of ILS in Table 8. Our $\mathcal { L } _ { p m s }$ loss (Eq. 4) is compared with previously adopted ILS approaches [31, 32, 2] (rows 2-3). In row-4, we generate class-agnostic object proposals using ‘all objects’ text query with multi-modal ViTs (MViTs) [8] and select max-size proposal for ILS. In row-5, our proposed ILS approach uses target specific ‘every {category}’ text query with MViT and selects top-1 proposal for each ILS category. Our method (row-5) shows better performance compared to other alternatives. Additionally, we present all ablations on LVIS dataset in Appendix C.
200
+
201
+ <table><tr><td>Method</td><td>APnovel</td><td>APbase</td><td>AP</td></tr><tr><td>1: Supervised (Base)</td><td>1.7</td><td>53.2</td><td>39.6</td></tr><tr><td>2: RPN proposals L1 loss</td><td>4.0</td><td>54.9</td><td>41.6</td></tr><tr><td>3: MViT prop - L1 loss</td><td>16.7</td><td>55.1</td><td>45.0</td></tr><tr><td> 4: L1 + IRM loss</td><td>21.2</td><td>54.7</td><td>45.9</td></tr></table>
202
+
203
+ Table 7: Analysis on our region-based KD.
204
+
205
+ <table><tr><td>Method</td><td>APnovel</td><td>APbase</td><td>AP</td></tr><tr><td>1: Supervised (Base)</td><td>1.7</td><td>53.2</td><td>39.6</td></tr><tr><td>2:Max-Score loss on RPN</td><td>15.9</td><td>48.2</td><td>39.7</td></tr><tr><td>3:Max-Size loss on RPN</td><td>25.9</td><td>51.1</td><td>44.5</td></tr><tr><td>4: Max-Size of MViT</td><td>28.9</td><td>50.7</td><td>45.0</td></tr><tr><td> 5: Pseudo-box on MViT</td><td>30.4</td><td>52.6</td><td>46.8</td></tr></table>
206
+
207
+ Table 8: Analysis on our weak IL supervision.
208
+
209
+ # 5 Qualitative Results
210
+
211
+ ![](images/1c3debbfb8a929e5a6b0909195f55c4afe5f7c7c65dc5414f4d95007ca4e0adf.jpg)
212
+ (b)LVIS Figure 4: Qualitative results on (a) COCO and (b) LVIS images. For COCO, base and novel categories are shown in purple and green colors respectively.
213
+
214
+ ![](images/cb0704ec30baaed3f0b66d5d6727ecd237e2d3a19f83cac0f68f1107036fe0d3.jpg)
215
+ (b) OpenImages
216
+ Figure 5: Qualitative results of cross-dataset transfer of our LVIS OVD model on (a) Objects365 and (b) OpenImages. Without any finetuning, our method provides high-quality detections.
217
+
218
+ # 6 Conclusion
219
+
220
+ This paper develops a novel framework to leverage the representation and generalization capability of pre-trained multi-modal models towards improved open-vocabulary detection (OVD). Specifically, we note that the existing OVD methods use weak supervision modes that are more image-centric, rather than object-centric for the end detection task. We proposed a novel knowledge distillation approach together with object-level pseudo-labeling to promote region-wise alignment between visual and language representations. Our weight transfer module provide an integration mechanism to combine the benefits of knowledge distillation and object-level pseudo-labeling. We demonstrate encouraging results on four popular OVD benchmarks, demonstrating sound generalization ability.
221
+
222
+ Acknowledgements: The computations were performed in the Berzelius resource provided by the Knut and Alice Wallenberg Foundation at the National Supercomputer Centre.
223
+
224
+ References
225
+ [1] Alireza Zareian, Kevin Dela Rosa, Derek Hao Hu, and Shih-Fu Chang. Open-vocabulary object detection using captions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
226
+ [2] Xingyi Zhou, Rohit Girdhar, Armand Joulin, Phillip Krähenbühl, and Ishan Misra. Detecting twentythousand classes using image-level supervision. arXiv preprint arXiv:2201.02605, 2022.
227
+ [3] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, 2021.
228
+ [4] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Ieee, 2009.
229
+ [5] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning. PMLR, 2021.
230
+ [6] Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. International Conference on Learning Representations, 2022.
231
+ [7] Yiwu Zhong, Jianwei Yang, Pengchuan Zhang, Chunyuan Li, Noel Codella, Liunian Harold Li, Luowei Zhou, Xiyang Dai, Lu Yuan, Yin Li, et al. Regionclip: Region-based language-image pretraining. arXiv preprint arXiv:2112.09106, 2021.
232
+ [8] Muhammad Maaz, Hanoona Rasheed, Salman Khan, Fahad Shahbaz Khan, Rao Muhammad Anwer, and Ming-Hsuan Yang. Multi-modal transformers excel at class-agnostic object detection. arXiv preprint arXiv:2111.11430, 2021.
233
+ [9] Pengkai Zhu, Hanxiao Wang, and Venkatesh Saligrama. Zero shot detection. IEEE Transactions on Circuits and Systems for Video Technology, 2019.
234
+ [10] Ankan Bansal, Karan Sikka, Gaurav Sharma, Rama Chellappa, and Ajay Divakaran. Zero-shot object detection. In The European Conference on Computer Vision, 2018.
235
+ [11] Shafin Rahman, Salman Khan, and Nick Barnes. Improved visual-semantic alignment for zero-shot object detection. In Association for the Advancement of Artificial Intelligence, 2020.
236
+ [12] Pengkai Zhu, Hanxiao Wang, and Venkatesh Saligrama. Don’t even look once: Synthesizing features for zero-shot detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020.
237
+ [13] Dikshant Gupta, Aditya Anantharaman, Nehal Mamgain, Vineeth N Balasubramanian, CV Jawahar, et al. A multi-space approach to zero-shot object detection. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, 2020.
238
+ [14] Shafin Rahman, Salman Khan, and Nick Barnes. Transductive learning for zero-shot object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
239
+ [15] Zhihui Li, Lina Yao, Xiaoqin Zhang, Xianzhi Wang, Salil Kanhere, and Huaxiang Zhang. Zero-shot object detection with textual descriptions. In Association for the Advancement of Artificial Intelligence, 2019.
240
+ [16] Yunhang Shen, Rongrong Ji, Yan Wang, Zhiwei Chen, Feng Zheng, Feiyue Huang, and Yunsheng Wu. Enabling deep residual networks for weakly supervised object detection. In The European Conference on Computer Vision, 2020.
241
+ [17] Yunhang Shen, Rongrong Ji, Yan Wang, Yongjian Wu, and Liujuan Cao. Cyclic guidance for weakly supervised joint detection and segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
242
+ [18] Fang Wan, Chang Liu, Wei Ke, Xiangyang Ji, Jianbin Jiao, and Qixiang Ye. C-mil: Continuation multiple instance learning for weakly supervised object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
243
+ [19] Ke Yang, Dongsheng Li, and Yong Dou. Towards precise end-to-end weakly supervised object detection network. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.
244
+ [20] Yuanyi Zhong, Jianfeng Wang, Jian Peng, and Lei Zhang. Boosting weakly supervised object detection with progressive knowledge transfer. In The European Conference on Computer Vision, 2020.
245
+ [21] Ziang Yan, Jian Liang, Weishen Pan, Jin Li, and Changshui Zhang. Weakly-and semi-supervised object detection with expectation-maximization algorithm. arXiv preprint arXiv:1702.08740, 2017.
246
+ [22] Bowen Dong, Zitong Huang, Yuelin Guo, Qilong Wang, Zhenxing Niu, and Wangmeng Zuo. Boosting weakly supervised object detection via learning bounding box adjusters. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2021.
247
+ [23] Shijie Fang, Yuhang Cao, Xinjiang Wang, Kai Chen, Dahua Lin, and Wayne Zhang. Wssod: A new pipeline for weakly-and semi-supervised object detection. arXiv preprint arXiv:2105.11293, 2021.
248
+ [24] Hakan Bilen and Andrea Vedaldi. Weakly supervised deep detection networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2016.
249
+ [25] Jasper RR Uijlings, Koen EA Van De Sande, Theo Gevers, and Arnold WM Smeulders. Selective search for object recognition. International Journal of Computer Vision, 104(2):154–171, 2013.
250
+ [26] C Lawrence Zitnick and Piotr Dollár. Edge Boxes: Locating Object Proposals from Edges. In The European Conference on Computer Vision. Springer, 2014.
251
+ [27] Keren Ye, Mingda Zhang, Adriana Kovashka, Wei Li, Danfeng Qin, and Jesse Berent. Cap2det: Learning to amplify weak caption supervision for object detection. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.
252
+ [28] Xiaoyan Li, Meina Kan, Shiguang Shan, and Xilin Chen. Weakly supervised object detection with segmentation collaboration. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.
253
+ [29] Peng Tang, Xinggang Wang, Song Bai, Wei Shen, Xiang Bai, Wenyu Liu, and Alan Yuille. Pcl: Proposal cluster learning for weakly supervised object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018.
254
+ [30] Zeyi Huang, Yang Zou, BVK Kumar, and Dong Huang. Comprehensive attention self-distillation for weakly-supervised object detection. Advances in Neural Information Processing Systems, 2020.
255
+ [31] Joseph Redmon and Ali Farhadi. Yolo9000: better, faster, stronger. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2017.
256
+ [32] Vignesh Ramanathan, Rui Wang, and Dhruv Mahajan. Dlwl: Improving detection for lowshot classes with weakly labelled data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020.
257
+ [33] Jeffrey Pennington, Richard Socher, and Christopher D Manning. Glove: Global vectors for word representation. In Conference on Empirical Methods in Natural Language Processing, 2014.
258
+ [34] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
259
+ [35] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. Advances in Neural Information Processing Systems, 28, 2015.
260
+ [36] Mingfei Gao, Chen Xing, Juan Carlos Niebles, Junnan Li, Ran Xu, Wenhao Liu, and Caiming Xiong. Towards open vocabulary object detection without human-provided bounding boxes. arXiv preprint arXiv:2111.09452, 2021.
261
+ [37] Yu Du, Fangyun Wei, Zihe Zhang, Miaojing Shi, Yue Gao, and Guoqi Li. Learning to prompt for open-vocabulary object detection with vision-language model. arXiv preprint arXiv:2203.14940, 2022.
262
+ [38] Chengjian Feng, Yujie Zhong, Zequn Jie, Xiangxiang Chu, Haibing Ren, Xiaolin Wei, Weidi Xie, and Lin Ma. Promptdet: Expand your detector vocabulary with uncurated images. arXiv preprint arXiv:2203.16513, 2022.
263
+ [39] Frederick Tung and Greg Mori. Similarity-preserving knowledge distillation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.
264
+ [40] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask R-CNN. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2017.
265
+ [41] Ronghang Hu, Piotr Dollár, Kaiming He, Trevor Darrell, and Ross Girshick. Learning to segment every thing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018.
266
+ [42] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In The European Conference on Computer Vision, 2014.
267
+ [43] Agrim Gupta, Piotr Dollar, and Ross Girshick. LVIS: A dataset for large vocabulary instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
268
+ [44] Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, et al. The open images dataset v4. International Journal of Computer Vision, 128(7):1956–1981, 2020.
269
+ [45] Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.
270
+ [46] Xingyi Zhou, Vladlen Koltun, and Philipp Krähenbühl. Probabilistic two-stage detection. arXiv preprint arXiv:2103.07461, 2021.
271
+ [47] Golnaz Ghiasi, Yin Cui, Aravind Srinivas, Rui Qian, Tsung-Yi Lin, Ekin D Cubuk, Quoc V Le, and Barret Zoph. Simple copy-paste is a strong data augmentation method for instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
272
+ [48] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 115(3):211–252, 2015.
273
+ [49] KJ Joseph, Salman Khan, Fahad Shahbaz Khan, and Vineeth N Balasubramanian. Towards open world object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
274
+ [50] Aishwarya Kamath, Mannat Singh, Yann LeCun, Gabriel Synnaeve, Ishan Misra, and Nicolas Carion. Mdetr-modulated detection for end-to-end multi-modal understanding. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
275
+
276
+ # Checklist
277
+
278
+ 1. For all authors...
279
+
280
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The abstract and introduction clearly reflects the main contributions and scope of the paper.
281
+ (b) Did you describe the limitations of your work? [Yes] We have discussed the limitations of our work. Please refer to Appendix E.
282
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] Please refer to Appendix F.
283
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] We have read the ethics review guidelines and discussed the ethical implications of our work in Appendix G.
284
+
285
+ 2. If you are including theoretical results...
286
+
287
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] Our findings and propositions are mainly based on experiments and empirical results. However, we have added relevant mathematical information in our theoretical formulations.
288
+ (b) Did you include complete proofs of all theoretical results? [N/A]
289
+
290
+ 3. If you ran experiments...
291
+
292
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We provide the code along with the instructions to reproduce our main experiments in the supplemental material.
293
+
294
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We have provided all the training details including the data splits and hyperparameter choices in our paper. Please refer to sections 4.1 and 4.2.
295
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to the limited availability of compute resources, we have not reported these statistics.
296
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] Yes we have provided these details in the main paper. Please refer to the section 4.2.
297
+
298
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
299
+
300
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We have cited all relevent existing works and assets which are related/used in our work.
301
+ (b) Did you mention the license of the assets? [Yes] We provide license details of the assets used in our work. Please refer to section H.
302
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We provide our code for reproducing main experiments of our work in the supplemental material.
303
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] We use publically available datasets for our experiments. We have not explicitly discussed such consent in the main paper, but we have checked and made sure that all used datasets are allowed to be used for research.
304
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] We discuss this in the supplemental material.
305
+
306
+ 5. If you used crowdsourcing or conducted research with human subjects...
307
+
308
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
309
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
310
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/bMYU8_qD8PW/bMYU8_qD8PW.md ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A Unified Model for Multi-class Anomaly Detection
2
+
3
+ Zhiyuan $\mathbf { V o u } ^ { 1 * }$ Lei $\mathbf { C u i ^ { 2 * } }$ Yujun Shen3 Kai Yang4 Xin Lu4 Yu Zheng1 Xinyi Le1†
4
+
5
+ 1Shanghai Jiao Tong University 2Tsinghua University 3CUHK 4SenseTime zhiyuanyou@foxmail.com, cuil19@mails.tsinghua.edu.cn, shenyujun0302@gmail.com {yangkai, luxin}@sensetime.com, yuzheng@sjtu.edu.cn, lexinyi@sjtu.edu.cn
6
+
7
+ # Abstract
8
+
9
+ Despite the rapid advance of unsupervised anomaly detection, existing methods require to train separate models for different objects. In this work, we present $U n i A D$ that accomplishes anomaly detection for multiple classes with a unified framework. Under such a challenging setting, popular reconstruction networks may fall into an “identical shortcut”, where both normal and anomalous samples can be well recovered, and hence fail to spot outliers. To tackle this obstacle, we make three improvements. First, we revisit the formulations of fully-connected layer, convolutional layer, as well as attention layer, and confirm the important role of query embedding (i.e., within attention layer) in preventing the network from learning the shortcut. We therefore come up with a layer-wise query decoder to help model the multi-class distribution. Second, we employ a neighbor masked attention module to further avoid the information leak from the input feature to the reconstructed output feature. Third, we propose a feature jittering strategy that urges the model to recover the correct message even with noisy inputs. We evaluate our algorithm on MVTec-AD and CIFAR-10 datasets, where we surpass the state-of-the-art alternatives by a sufficiently large margin. For example, when learning a unified model for 15 categories in MVTec-AD, we surpass the second competitor on the tasks of both anomaly detection (from $8 8 . 1 \%$ to $9 6 . 5 \%$ ) and anomaly localization (from $8 9 . 5 \%$ to $9 6 . 8 \%$ ). Code is available at https:// github.com/zhiyuanyou/UniAD.
10
+
11
+ # 1 Introduction
12
+
13
+ Anomaly detection has found an increasingly wide utilization in manufacturing defect detection [4], medical image analysis [17], and video surveillance [46]. Considering the highly diverse anomaly types, a common solution is to model the distribution of normal samples and then identify anomalous ones via finding outliers. It is therefore crucial to learn a compact boundary for normal data, as shown in Fig. 1a. For this purpose, existing methods [6, 11, 25, 27, 48, 49, 52] propose to train separate models for different classes of objects, like in Fig. 1c. However, such a one-class-one-model scheme could be memory-consuming especially along with the number of classes increasing, and also uncongenial to the scenarios where the normal samples manifest themselves in a large intra-class diversity (i.e., one object consists of various types).
14
+
15
+ In this work, we target a more practical task, which is to detect anomalies from different object classes with a unified framework. The task setting is illustrated in Fig. 1d, where the training data covers normal samples from a range of categories, and the learned model is asked to accomplish anomaly detection for all these categories without any fine-tuning. It is noteworthy that the categorical information (i.e., class label) is inaccessible at both the training and the inference stages, considerably easing the difficulty of data preparation. Nonetheless, solving such a task is fairly challenging. Recall that the rationale behind unsupervised anomaly detection is to model the distribution of normal data and find a compact decision boundary as in Fig. 1a. When it comes to the multi-class case, we expect the model to capture the distribution of all classes simultaneously such that they can share the same boundary as in Fig. 1b. But if we focus on a particular category, say the green one in Fig. 1b, all the samples from other categories should be considered as anomalies no matter whether they are normal (i.e., blue circles) or anomalous (i.e., blue triangles) themselves. From this perspective, how to accurately model the multi-class distribution becomes vital.
16
+
17
+ ![](images/b6232b853896a035f8a396234cfe67be2075d265ba691a7c3cd42f00cbab0b69.jpg)
18
+ Figure 1: Task setting of unified anomaly detection. (a) Existing methods learn separate decision boundaries for different object classes, while (b) our approach models the multi-class data distribution such that one boundary is enough to spot outliers regarding all categories. As a result, we escape from the conventional one-class-one-model paradigm in (c), and manage to accomplish anomaly detection for various classes with a unified framework in (d).
19
+
20
+ A widely used approach to learning the normal data distribution draws support from image (or feature) reconstruction [2, 5, 26, 39, 51], which assumes that a well-trained model always produces normal samples regardless of the defects within the inputs. In this way, there will be large reconstruction errors for anomalous samples, making them distinguishable from the normal ones. However, we find that popular reconstruction networks suggest unsatisfying performance on the challenging task studied in this work. They typically fall into an “identity shortcut”, which appears as returning a direct copy of the input disregarding its content.1 As a result, even anomalous samples can be well recovered with the learned model and hence become hard to detect. Moreover, under the unified case, where the distribution of normal data is more complex, the “identical shortcut” problem is magnified. Intuitively, to learn a unified model that can reconstruct all kinds of objects, it requires the model to work extremely hard to learn the joint distribution. From this perspective, learning an “identical shortcut” appears as a far easier solution.
21
+
22
+ To address this issue, we carefully tailor a feature reconstruction framework that prevents the model from learning the shortcut. First, we revisit the formulations of fully-connected layer, convolutional layer, as well as attention layer used in neural networks, and observe that both fully-connected layer and convolutional layer face the risk of learning a trivial solution. This drawback is further amplified under the multi-class setting in that the normal data distribution becomes far more complex. Instead, the attention layer is sheltered from such a risk, benefiting from a learnable query embedding (see Sec. 3.1). Accordingly, we propose a layer-wise query decoder to intensify the use of query embedding. Second, we argue that the full attention (i.e., every feature point relates to each other) also contributes to the shortcut issue, because it offers the chance of directly copying the input to the output. To avoid the information leak, we employ a neighbor masked attention module, where a feature point relates to neither itself nor its neighbors. Third, inspired by Bengio et al. [3], we propose a feature jittering strategy, which requires the model to recover the source message even with noisy inputs. All these designs help the model escape from the “identity shortcut”, as shown in Fig. 2b. Extensive experiments on MVTec-AD [4] and CIFAR-10 [23] demonstrate the sufficient superiority of our approach, which we call $U n i A D$ , over existing alternatives under the unified task setting. For instance, when learning a single model for 15 categories in MVTec-AD, we achieve state-of-the-art performance on the tasks of both anomaly detection and anomaly localization, boosting the AUROC from $8 8 . 1 \%$ to $9 6 . 5 \%$ and from $8 9 . 5 \%$ to $9 6 . 8 \%$ , respectively.
23
+
24
+ # 2 Related work
25
+
26
+ Anomaly detection. 1) Classical approaches extend classical machine learning methods for one-class classification, such as one-class support vector machine (OC-SVM) [38] and support vector data description (SVDD) [35, 41]. Patch-level embedding [48], geometric transformation [18], and elastic weight consolidation [33] are incorporated for improvement. 2) Pseudo-anomaly converts anomaly detection to supervised learning, including classification [25, 32, 45], image denoising [52], and hypersphere segmentation [27]. However, these methods partly rely on how well proxy anomalies match real anomalies that are not known [13]. 3) Modeling then comparison assumes that the pre-trained network is capable of extracting discriminative features for anomaly detection [11, 34]. PaDiM [11] and MDND [34] extract pre-trained features to model normal distribution, then utilize a distance metric to measure the anomalies. Nevertheless, these methods need to memorize and model all normal features, thus are computationally expensive. 4) Knowledge distillation proposes that the student distilled by a teacher on normal samples could only extract normal features [6, 13, 37, 44, 45]. Recent works mainly focus on model ensemble [6], feature pyramid [37, 44], and reverse distillation [13].
27
+
28
+ Reconstruction-based anomaly detection. These methods rely on the hypothesis that reconstruction models trained on normal samples only succeed in normal regions, but fail in anomalous regions [5, 8, 26, 36, 49]. Early attempts include Auto-Encoder (AE) [5, 9], Variational Auto-Encoder (VAE) [22, 26], and Generative Adversarial Net (GAN) [2, 30, 36, 51]. However, these methods face the problem that the model could learn tricks that the anomalies are also restored well. Accordingly, researchers adopt different strategies to tackle this issue, such as adding instructional information (i.e., structural [53] or semantic [39, 46]), memory mechanism [19, 20, 29], iteration mechanism [12], image masking strategy [47], and pseudo-anomaly [9, 32]. Recently, DRAEM [52] first recovers the pseudo-anomaly disturbed normal images for representation, then utilizes a discriminative net to distinguish the anomalies, achieving excellent performance. However, DRAEM [52] ceases to be effective under the unified case. Moreover, there is still an important aspect that has not been well studied, i.e., what architecture is the best reconstruction model? In this paper, we first compare and analyze three popular architectures including MLP, CNN, and transformer. Then, accordingly, we base on the transformer and further design three improvements, which compose our UniAD.
29
+
30
+ Transformer in anomaly detection. Transformer [42] with attention mechanism, first proposed in natural language processing, has been successfully used in computer vision [7, 16]. Some attempts try to utilize transformer for anomaly detection. InTra [31] adopts transformer to recover the image by recovering all masked patches one by one. VT-ADL [28] and AnoVit [50] both apply transformer encoder to reconstruct images. However, these methods directly utilize vanilla transformer, and do not figure out why transformer brings improvement. In contrast, we confirm the efficacy of the query embedding to prevent the shortcut, and accordingly design a layer-wise query decoder. Also, to avoid the information leak of the full attention, we employ a neighbor masked attention module.
31
+
32
+ # 3 Method
33
+
34
+ # 3.1 Revisiting feature reconstruction for anomaly detection
35
+
36
+ In Fig. 2, following the feature reconstruction paradigm [39, 49], we build an MLP, a CNN, and a transformer (with query embedding) to reconstruct the features extracted by a pre-trained backbone. The reconstruction errors represent the anomaly possibility. The architectures of the three networks are given in Appendix. The metric is evaluated every 10 epochs. Note that the periodic evaluation is impractical since anomalies are not available during training. As shown in Fig. 2a, after a period of training, the performances of the three networks decrease severely with the losses going extremely small. We attribute this to the problem of “identical shortcut”, where both normal and anomalous regions can be well recovered, thus failing to spot anomalies. This speculation is verified by the visualization results in Fig. 2b (more results in Appendix). However, compared with MLP and CNN, the transformer suffers from a much smaller performance drop, indicating a slighter shortcut problem. This encourages us to analyze as follows.
37
+
38
+ We denote the features in a normal image as $\pmb { x } ^ { + } \in \mathbb { R } ^ { K \times C }$ , where $K$ is the feature number, $C$ is the channel dimension. The batch dimension is omitted for simplicity. Similarly, the features in an anomalous image are denoted as $\pmb { x } ^ { - } \in \mathbb { R } ^ { K \times C }$ . The reconstruction loss is chosen as the MSE loss.
39
+
40
+ ![](images/f359d145336a151f892f300a30f2f84bdfa6df11e6012b50907c0ea33940f5a3.jpg)
41
+ Figure 2: Comparison among MLP, CNN, transformer, and our UniAD on MVTec-AD [4]. (a) Training loss (blue) as well as the testing AUROC on anomaly detection (green) and localization (red). During the training of MLP, CNN, and transformer, the reconstruction error keeps going smaller on normal samples, but the performance on anomalies suffers from a severe drop after reaching the peak. This is caused by the model learning an “identical shortcut”, which tends to directly copy the input as the output regardless of whether it is normal or anomalous. (b) Visual explanation of the shortcut issue, where the anomalous samples can be well recovered and hence become hard to detect from normal ones. In contrast, UniAD overcomes such a problem and manages to reconstruct anomalies as normal samples. It is noteworthy that all models are learned for feature reconstruction and a separate decoder is employed to render images from features. This decoder is only used for visualization.
42
+
43
+ We provide a rough analysis using a simple 1-layer network as the reconstruction net, which is trained with ${ \pmb x } ^ { + }$ and tested to detect anomalous regions in ${ \pmb x } ^ { - }$ .
44
+
45
+ Fully-connected layer in MLP. Denote the weights and bias in this layer as $\pmb { w } \in \mathbb { R } ^ { C \times C } , \pmb { b } \in \mathbb { R } ^ { C }$ respectively, this layer can be represented as,
46
+
47
+ $$
48
+ \pmb { y } = \pmb { x } ^ { + } \pmb { w } + \pmb { b } \in \mathbb { R } ^ { K \times C } .
49
+ $$
50
+
51
+ With the MSE loss pushing $\textbf { { y } }$ to ${ \pmb x } ^ { + }$ , the model may take shortcut to regress $w \to I$ (identity matrix), $\mathbf b \to \mathbf 0$ . Ultimately, this model could also reconstruct ${ \pmb x } ^ { - }$ well, failing in anomaly detection.
52
+
53
+ Convolutional layer in CNN. A convolutional layer with $1 \times 1$ kernel is equivalent to a fullyconnected layer. Besides, An $n \times n$ $( n > 1 )$ ) kernel has more parameters and larger capacity, and can complete whatever $1 \times 1$ kernel can. Thus, this layer also has the chance to learn a shortcut.
54
+
55
+ Transformer with query embedding. In such a model, there is an attention layer with a learnable query embedding, $\mathbf { \bar { q } } \in \mathbb { R } ^ { \mathbf { \bar { K } } \times C }$ . When using this layer as the reconstruction model, it is denoted as,
56
+
57
+ $$
58
+ { \pmb y } = \mathrm { s o f t m a x } ( { \pmb q } ( { \pmb x } ^ { + } ) ^ { T } / \sqrt { C } ) { \pmb x } ^ { + } \in \mathbb { R } ^ { K \times C } .
59
+ $$
60
+
61
+ To push $\textbf { { y } }$ to ${ \pmb x } ^ { + }$ , the attention map, softmax $( \pmb q ( \pmb x ^ { + } ) ^ { T } / \sqrt { C } )$ , should approximate $\pmb { I }$ (identity matrix), so $\pmb q$ must be highly related to ${ \pmb x } ^ { + }$ . Considering that $\pmb q$ in the trained model is relevant to normal samples, the model could not reconstruct ${ \pmb x } ^ { - }$ well. The ablation study in Sec. 4.6 shows that without the query embedding, the performance of transformer drops dramatically by $1 8 . 1 \%$ and $1 3 . 4 \%$ in anomaly detection and localization, respectively. Thus the query embedding is of vital significance to model the normal distribution.
62
+
63
+ However, transformer still suffers from the shortcut problem, which inspires our three improvements. 1) According to that the query embedding can prevent reconstructing anomalies, we design a Layerwise Query Decoder (LQD) by adding the query embedding in each decoder layer rather than only the first layer in vanilla transformer. 2) We suspect that the full attention increases the possibility of the shortcut. Since one token could see itself and its neighbor regions, it is easy to reconstruct by simply copying. Thus we mask the neighbor tokens when calculating the attention map, called Neighbor Masked Attention (NMA). 3) We employ a Feature Jittering (FJ) strategy to disturb the input features, leading the model to learn normal distribution from denoising. Benefiting from these designs, our UniAD achieves satisfying performance, as illustrated in Fig. 2.
64
+
65
+ Relation between the “identical shortcut” problem and the unified case. In Fig. 2a, we aim to visualize the “identical shortcut” problem, where the loss becomes smaller yet the performance drops.
66
+
67
+ ![](images/855a91070ef894d03f297ec342fc74d6da14d6c832d1b9fae74b2b5c5c132187.jpg)
68
+ Figure 3: Framework of UniAD, consisting of a Neighbor Masked Encoder (NME) and a Layer-wise Query Decoder (LQD). Each layer in LQD employs a learnable query embedding to help model the complex training data distribution. The full attention in transformer is replaced by neighbor masked attention to avoid the information leak from the input to the output. The feature jittering strategy encourages the model to recover the correct message with noisy inputs. All the three improvements assist the model against learning the “identical shortcut” (see Sec. 3.1 and Fig. 2 for details).
69
+
70
+ ![](images/9f58a091d2fbbebc9f5f5e64eaa929c479d4670d2e4b40ad48e306edf6bab81f.jpg)
71
+ Figure 4: Comparison between the unified case and the separate case on the training curves of MLP. In the separate case, the curves are obtained by averaging all categories. Compared with the separate case, the unified case has a smaller reconstruction error but much worse performance, indicating a severer “identical shortcut” problem.
72
+
73
+ ![](images/35911b53aeeb2ecbe0d34d45c19e02807f12435599942b5c722a940a406f0045.jpg)
74
+ Figure 5: Illustration of neighbor masked attention, where a feature point relates to neither itself nor its neighbors.
75
+
76
+ We conduct the same experiment under the separate case on MLP. As shown in Fig. 4, the accuracy (green for detection and red for localization) keeps growing up along with the loss (blue) getting smaller. This helps reveal the relation between the “identical shortcut” problem and the unified case, which is that the unified case is more challenging and hence magnifies the “identical shortcut” problem. Therefore, since our approach is specially designed to solve the “identical shortcut” problem, our method can be effective in the unified case.
77
+
78
+ # 3.2 Improving feature reconstruction for unified anomaly detection
79
+
80
+ Overview. As shown in Fig. 3, our UniAD is composed of a Neighbor Masked Encoder (NME) and a Layer-wise Query Decoder (LQD). Firstly, the feature tokens extracted by a fixed pre-trained backbone are further integrated by NME to derive the encoder embeddings. Then, in each layer of LQD, a learnable query embedding is successively fused with the encoder embeddings and the outputs of the previous layer (self-fusion for the first layer). The feature fusion is completed by the Neighbor Masked Attention (NMA). The final outputs of LQD are viewed as the reconstructed features. Also, we propose a Feature Jittering (FJ) strategy to add perturbations to the input features, leading the model to learn normal distribution from the denoising task. Finally, the results of anomaly localization and detection are obtained through the reconstruction differences.
81
+
82
+ Neighbor masked attention. We suspect that the full attention in vanilla transformer [42] contributes to the “identical shortcut”. In full attention, one token is permitted to see itself, so it will be easy to reconstruct by simply copying. Moreover, considering that the feature tokens are extracted by a CNN backbone, the neighbor tokens must share lots of similarities. Therefore, we propose to mask the neighbor tokens when calculating the attention map, called Neighbor Masked Attention (NMA). Note that the neighbor region is defined in the 2D space, as shown in Fig. 5.
83
+
84
+ Neighbor masked encoder. The encoder follows the standard architecture in vanilla transformer. Each layer consists of an attention module and a Feed-Forward Network (FFN). However, the full attention is replaced by our proposed NMA to prevent the information leak.
85
+
86
+ Layer-wise query decoder. It is analyzed in Sec. 3.1 that the query embedding could help prevent reconstructing anomalies well. However, there is only one query embedding in the vanilla transformer. Therefore, we design a Layer-wise Query Decoder (LQD) to intensify the use of query embedding, as shown in Fig. 3. Specifically, in each layer of LQD, a learnable query embedding is first fused with the encoder embeddings, then integrated with the outputs of the previous layer (self-integration for the first layer). The feature fusion is implemented by NMA. Following the vanilla transformer, a 2-layer FFN is applied to handle these fused tokens, and the residual connection is utilized to facilitate the training. The final outputs of LQD serve as the reconstructed features.
87
+
88
+ Feature jittering. Inspired by Denoising Auto-Encoder (DAE) [3, 43], we add perturbations to feature tokens, guiding the model to learn knowledge of normal samples by the denoising task. Specifically, for a feature token, $\pmb { f } _ { t o k } \in \mathbb { R } ^ { C }$ , we sample the disturbance $D$ from a Gaussian distribution,
89
+
90
+ $$
91
+ D \sim N ( \mu = 0 , \sigma ^ { 2 } = ( \alpha \frac { | | \mathbf { f } _ { t o k } | | _ { 2 } } { C } ) ^ { 2 } ) ,
92
+ $$
93
+
94
+ where $\alpha$ is the jittering scale to control the noisy degree. Also, the sampled disturbance is added to $f _ { t o k }$ with a fixed jittering probability, $p$ .
95
+
96
+ # 3.3 Implementation details
97
+
98
+ Feature extraction. We adopt a fixed EfficientNet-b4 [40] pre-trained on ImageNet [14] as the feature extractor. The features from stage-1 to stage-4 are selected. Here the stage means the combination of blocks that have the same size of feature maps. Then these features are resized to the same size, and concatenated along channel dimension to form a feature map, $\mathbf { \Delta } f _ { o r g } \in \mathbb { R } ^ { C _ { o r g } \times H \times W }$ .
99
+
100
+ Feature reconstruction. The feature map, $f _ { o r g }$ , is first tokenized to $H \times W$ feature tokens, followed by a linear projection to reduce $C _ { o r g }$ to a smaller channel, $C$ . Then these tokens are processed by NME and LQD. The learnable position embeddings [15, 16] are added in attention modules to inform the spatial information. Afterward, another linear projection is used to recover the channel from $C$ to $C _ { o r g }$ . After reshape, the reconstructed feature map, $\mathbf { \bar { f } } _ { r e c } \in \mathbb { R } ^ { C _ { o r g } \times H \times W }$ , is finally obtained.
101
+
102
+ Objective function. Our model is trained with the MSE loss as,
103
+
104
+ $$
105
+ \mathcal { L } = \frac { 1 } { H \times W } | | \mathbf { f } _ { o r g } - \mathbf { f } _ { r e c } | | _ { 2 } ^ { 2 } .
106
+ $$
107
+
108
+ Inference for anomaly localization. The result of anomaly localization is an anomaly score map, which assigns an anomaly score for each pixel. Specifically, the anomaly score map, $s$ , is calculated as the L2 norm of the reconstruction differences as,
109
+
110
+ $$
111
+ \pmb { s } = | | \pmb { f } _ { o r g } - \pmb { f } _ { r e c } | | _ { 2 } \in \mathbb { R } ^ { H \times W } .
112
+ $$
113
+
114
+ Then $\pmb { s }$ is up-sampled to the image size with bi-linear interpolation to obtain the localization results.
115
+
116
+ Inference for anomaly detection. Anomaly detection aims to detect whether an image contains anomalous regions. We transform the anomaly score map, $\pmb { s }$ , to the anomaly score of the image by taking the maximum value of the averagely pooled $\pmb { s }$ .
117
+
118
+ # 4 Experiment
119
+
120
+ # 4.1 Datasets and metrics
121
+
122
+ MVTec-AD [4] is a comprehensive, multi-object, multi-defect industrial anomaly detection dataset with 15 classes. For each anomalous sample in the test set, the ground-truth includes both image label and anomaly segmentation. In the existing literature, only the separate case is researched. In this paper, we introduce the unified case, where only one model is used to handle all categories.
123
+
124
+ Table 1: Anomaly detection results with AUROC metric on MVTec-AD [4]. All methods are evaluated under the unified / separate case. In the unified case, the learned model is applied to detect anomalies for all categories without fine-tuning.
125
+
126
+ <table><tr><td colspan="2">Category</td><td>US [6]</td><td>PSVDD[48] PaDiM[11] CutPaste [25] MKD [37] DRAEM [52]]</td><td></td><td></td><td></td><td></td><td>Ours</td></tr><tr><td rowspan="10">Object</td><td>Bottle Cable</td><td>184.0/ 99.0</td><td>85.5/98.6</td><td>97.9 / 99.9</td><td>67.9/98.2</td><td>98.7/99.4</td><td>97.5/99.2</td><td>99.7 ± 0.04 /100</td></tr><tr><td></td><td>60.0 / 86.2</td><td>64.4 /90.3</td><td>70.9 / 92.7</td><td>69.2 / 81.2</td><td>78.2 / 89.2</td><td>57.8 /91.8</td><td>95.2 ± 0.84 / 97.6</td></tr><tr><td>Capsule</td><td>57.6/ 86.1</td><td>61.3 / 76.7</td><td>73.4 / 91.3</td><td>63.0 / 98.2</td><td>68.3 / 80.5</td><td>65.3 / 98.5</td><td>86.9 ± 0.73 / 85.3</td></tr><tr><td>Hazelnut</td><td>95.8/ 93.1</td><td>83.9 / 92.0</td><td>85.5/92.0</td><td>80.9/ 98.3</td><td>97.1/98.4</td><td>93.7/100</td><td>99.8 ± 0.10 / 99.9</td></tr><tr><td>Metal Nut</td><td>62.7/ 82.0</td><td>80.9 /94.0</td><td>88.0 / 98.7</td><td>60.0 / 99.9</td><td>64.9 / 73.6</td><td>72.8 /98.7</td><td>99.2 ± 0.09 / 99.0</td></tr><tr><td>Pill</td><td>56.1 / 87.9</td><td>89.4 / 86.1</td><td>68.8 / 93.3</td><td>71.4 / 94.9</td><td>79.7 / 82.7</td><td>82.2 /98.9</td><td>93.7 ± 0.65 / 88.3</td></tr><tr><td>Screw</td><td>66.9 / 54.9</td><td>80.9 / 81.3</td><td>56.9 / 85.8</td><td>85.2/88.7</td><td>75.6 /83.3</td><td>92.0 / 93.9</td><td>87.5 ± 0.57 / 91.9</td></tr><tr><td>Toothbrush</td><td>57.8 / 95.3</td><td>99.4 /100</td><td>95.3 / 96.1</td><td>63.9 / 99.4</td><td>75.3 / 92.2</td><td>90.6 /100</td><td>94.2 ± 0.20 /95.0</td></tr><tr><td>Transistor</td><td>61.0 / 81.8</td><td>77.5 / 91.5</td><td>86.6 /97.4</td><td>57.9 / 96.1</td><td>73.4 /85.6</td><td>74.8 /93.1</td><td>99.8 ± 0.09 /100</td></tr><tr><td>Zipper</td><td>78.6 /91.9</td><td>77.8 / 97.9</td><td>79.7 / 90.3</td><td>93.5 / 99.9</td><td>87.4 / 93.2</td><td>98.8 / 100</td><td>95.8 ± 0.51/ 96.7</td></tr><tr><td rowspan="5">Texture</td><td>Carpet</td><td>86.6 / 91.6</td><td>63.3 / 92.9</td><td>93.8/ 99.8</td><td>93.6 /93.9</td><td>69.8 / 79.3</td><td>98.0 /97.0</td><td>99.8 ± 0.02 / 99.9</td></tr><tr><td>Grid</td><td>69.2/ 81.0</td><td>66.0 /94.6</td><td>73.9 / 96.7</td><td>93.2/100</td><td>83.8 /78.0</td><td>99.3 / 99.9</td><td>98.2±0.26/98.5</td></tr><tr><td>Leather</td><td>97.2 / 88.2</td><td>60.8 / 90.9</td><td>99.9 /100</td><td>93.4/100</td><td>93.6 / 95.1</td><td>98.7 /100</td><td>100 ± 0.00 /100</td></tr><tr><td>Tile</td><td>93.7 / 99.1</td><td>88.3 /97.8</td><td>93.3 /98.1</td><td>88.6 /94.6</td><td>89.5 /91.6</td><td>99.8 / 99.6</td><td>99.3 ± 0.14 / 99.0</td></tr><tr><td>Wood</td><td>90.6 / 97.7</td><td>72.1/ 96.5</td><td>98.4 /99.2</td><td>80.4 / 99.1</td><td>93.4 / 94.3</td><td>99.8 / 99.1</td><td>98.6 ± 0.08 / 97.9</td></tr><tr><td colspan="2">Mean</td><td>74.5 / 87.7</td><td>76.8 /92.1</td><td>84.2 /95.5</td><td>77.5 / 96.1</td><td>81.9 / 87.8</td><td>88.1/98.0</td><td>96.5±0.08/96.6</td></tr></table>
127
+
128
+ CIFAR-10 [23] is a classical image classification dataset with 10 categories. Existing methods [6, 24, 37] evaluate CIFAR-10 mainly in the one-versus-many setting, where one class is viewed as normal samples, and others serve as anomalies. Semantic AD [1, 10] proposes a many-versus-one setting, treating one class as anomalous and the remaining classes as normal. Different from both, we propose a unified case (many-versus-many setting), which is detailed in Sec. 4.4.
129
+
130
+ Metrics. Following prior works [4, 6, 52], the Area Under the Receiver Operating Curve (AUROC) is used as the evaluation metric for anomaly detection.
131
+
132
+ # 4.2 Anomaly detection on MVTec-AD
133
+
134
+ Setup. Anomaly detection aims to detect whether an image contains anomalous regions. The anomaly detection performance is evaluated on MVTec-AD [4]. The image size is selected as $2 2 4 \times 2 2 4$ , and the size for resizing feature maps is set as $1 4 \times 1 4$ . The feature maps from stage-1 to stage-4 of EfficientNet-b4 [40] are resized and concatenated together to form a 272-channel feature map. The reduced channel dimension is set as 256. AdamW optimizer [21] with weight decay $1 \times 1 0 ^ { - 4 }$ is used. Our model is trained for 1000 epochs on 8 GPUs (NVIDIA Tesla V100 16GB) with batch size 64. The learning rate is $1 \times 1 0 ^ { - 4 }$ initially, and dropped by 0.1 after 800 epochs. The layer numbers of the encoder and decoder are both 4. The neighbor size, jittering scale, and jittering probability are set as $7 \times 7$ , 20, and 1, respectively. The evaluation is run with 5 random seeds. In both the separate case and the unified case, the reconstruction models are trained from the scratch.
135
+
136
+ Baselines. Our approach is compared with baselines including: US [6], PSVDD [48], PaDiM [11], CutPaste [25], MKD [37], and DRAEM [52]. Under the separate case, the baselines’ metric is reported in their papers except the metric of US borrowed from [52]. Under the unified case, US, PSVDD, PaDiM, CutPaste, MKD, and DRAEM are run with the publicly available implementations.
137
+
138
+ Quantitative results of anomaly detection on MVTec-AD [4] are shown in Tab. 1. Though all baselines achieve excellent performances under the separate case, their performances drop dramatically under the unified case. The previous SOTA, DRAEM, a reconstruction-based method trained by pseudo-anomaly, suffers from a drop of near $10 \%$ . For another strong baseline, CutPaste, a pseudo-anomaly approach, the drop is as large as $1 8 . 6 \%$ . However, our UniAD has almost no performance drop from the separate case $( 9 6 . 6 \% )$ to the unified case $( 9 6 . 5 \% )$ . Moreover, we beat the best competitor, DRAEM, by a dramatically large margin $( 8 . 4 \% )$ , demonstrating our superiority.
139
+
140
+ Table 2: Anomaly localization results with AUROC metric on MVTec-AD [4]. All methods are evaluated under the unified / separate case. In the unified case, the learned model is applied to detect anomalies for all categories without fine-tuning.
141
+
142
+ <table><tr><td colspan="2">Category Bottle</td><td>US [6]</td><td></td><td></td><td></td><td></td><td>PSVDD [48] PaDiM[11] FCDD [27] MKD [37] DRAEM[52]</td><td>Ours</td></tr><tr><td rowspan="6">Object</td><td rowspan="10">Cable Capsule Hazelnut Metal Nut Pill</td><td>67.9 /97.8 78.3 /91.9</td><td>86.7 /98.1 62.2 /96.8</td><td>96.1/ 98.2 81.0 /96.7</td><td>56.0 /97</td><td>91.8 / 96.3</td><td>87.6 / 99.1</td><td>[98.1 ± 0.04 / 98.1</td></tr><tr><td></td><td></td><td></td><td>64.1/90</td><td>89.3 /82.4</td><td>71.3 /94.7</td><td>97.3 ± 0.10 / 96.8</td></tr><tr><td>85.5 /96.8</td><td>83.1/95.8</td><td>96.9 /98.6</td><td>67.6 /93</td><td>88.3 / 95.9</td><td>50.5 / 94.3</td><td>98.5 ± 0.01 / 97.9</td></tr><tr><td>93.7 /98.2</td><td>97.4 /97.5</td><td>96.3 / 98.1</td><td>79.3 /95</td><td>91.2 /94.6</td><td>96.9 /99.7</td><td>98.1 ± 0.10 / 98.8</td></tr><tr><td>76.6/97.2</td><td>96.0 / 98.0</td><td>84.8 /97.3</td><td>57.5 /94</td><td>64.2 /86.4</td><td>62.2 /99.5</td><td>94.8 ± 0.09 / 95.7</td></tr><tr><td>80.3/96.5</td><td>96.5 / 95.1</td><td>87.7 /95.7</td><td>65.9 /81</td><td>69.7 / 89.6</td><td>94.4 /97.6</td><td>95.0 ± 0.16 / 95.1</td></tr><tr><td>Screw 90.8/97.4</td><td>74.3 /95.7</td><td>94.1/ 98.4</td><td>67.2/86</td><td>92.1/96.0</td><td>95.5 /97.6</td><td>98.3 ± 0.08 / 97.4</td></tr><tr><td>Toothbrush 86.9 / 97.9</td><td>98.0 /98.1</td><td>95.6 /98.8</td><td>60.8 /94</td><td>88.9 /96.1</td><td>97.7/98.1</td><td>98.4 ± 0.03 / 97.8</td></tr><tr><td>Transistor 68.3/ 73.7</td><td>78.5/97.0</td><td>92.3/97.6</td><td>54.2/88</td><td>71.7 /76.5</td><td>64.5 /90.9</td><td>97.9 ± 0.19 / 98.7</td></tr><tr><td>Zipper 84.2/95.6</td><td>95.1 /95.1</td><td>94.8 / 98.4</td><td>63.0 /92</td><td>86.1/93.9</td><td>98.3 / 98.8</td><td>96.8 ± 0.24 / 96.0</td></tr><tr><td rowspan="4">Texture</td><td>Carpet Grid</td><td>88.7 /93.5 78.6 / 92.6</td><td>97.6 / 99.0</td><td>68.6/96</td><td>95.5 / 95.6</td><td>98.6 / 95.5</td><td>98.5±0.01/98.0</td></tr><tr><td>Leather</td><td>64.5 /89.9</td><td>70.8/96.2 71.0 / 97.1</td><td>65.8 /91</td><td>82.3 /91.8</td><td>98.7 / 99.7</td><td>96.5 ± 0.04 / 94.6</td></tr><tr><td>Tile</td><td>95.4 /97.8 93.5 / 97.4</td><td>84.8 /99.0</td><td>66.3 /98</td><td>96.7 /98.1</td><td>97.3 /98.6</td><td>98.8 ± 0.03 / 98.3</td></tr><tr><td>Wood</td><td>82.7 /92.5 92.1 / 91.4</td><td>80.5 /94.1</td><td>59.3 /91</td><td>85.3 /82.8</td><td>98.0 / 99.2</td><td>91.8 ± 0.10 / 91.8</td></tr><tr><td colspan="2">Mean</td><td>83.3 / 92.1 81.8 /93.9</td><td>80.7 /90.8 85.6/95.7</td><td>89.1 /94.1 89.5 / 97.4</td><td>53.3 /88 63.3/92</td><td>80.5 /84.8 84.9 /90.7</td><td>96.0 / 96.4 87.2 / 97.3</td><td>93.2 ± 0.08 / 93.4 [96.8 ± 0.02 / 96.6</td></tr><tr><td colspan="8">Normal Anomaly Recon GT Pred Normal Anomaly Recon 9 (b)</td><td>GT Pred</td></tr><tr><td colspan="2">(a)</td><td colspan="6">800</td><td></td></tr><tr><td colspan="2">(c)</td><td colspan="6"></td></tr></table>
143
+
144
+ # 4.3 Anomaly localization on MVTec-AD
145
+
146
+ Setup and baselines. Anomaly localization aims to localize anomalous regions in an anomalous image. MVTec-AD [4] is chosen as the benchmark dataset. The setup is the same as that in Sec. 4.2. Besides the competitors in Sec. 4.2, FCDD [27] is included, whose metric under the separate case is reported in its paper. Under the unified case, we run FCDD with the implementation: FCDD.
147
+
148
+ Quantitative results of anomaly localization on MVTec-AD [4] are reported in Tab. 2. Similar to Sec. 4.2, switching from the separate case to the unified case, the performance of all competitors drops significantly. For example, the performance of US, an important distillation-based baseline, decreases by $1 2 . 1 \%$ . FCDD, a pseudo-anomaly approach, suffers from a dramatic drop of $2 8 . 7 \%$ , reflecting the pseudo-anomaly is not suitable for the unified case. However, our UniAD even gains a slight improvement from the separate case $( 9 6 . 6 \% )$ to the unified case $( 9 6 . 8 \% )$ , proving the suitability of our UniAD for the unified case. Moreover, we significantly surpass the strongest baseline, PaDiM, by $7 . 3 \%$ . This significant improvement reflects the effectiveness of our model.
149
+
150
+ Qualitative results for anomaly localization on MVTec-AD [4] are illustrated in Fig. 6. For both global (Fig. 6a) and local (Fig. 6b) structural anomalies, both scattered texture perturbations (Fig. 6c) and multiple texture scratches (Fig. 6d), our method could successfully reconstruct anomalies to their corresponding normal samples, then accurately localize anomalous regions through reconstruction differences. More qualitative results are given in Appendix.
151
+
152
+ # 4.4 Anomaly detection on CIFAR-10
153
+
154
+ Setup. To further verify the effectiveness of our UniAD, we extend CIFAR-10 [23] to the unified case, which consists of four combinations. For each combination, five categories together serve as normal samples, while other categories are viewed as anomalies. The class indices of the four combinations are $\lbrace 0 1 2 3 4 \rbrace$ , $\{ 5 6 7 8 9 \}$ , $\{ 0 2 4 6 8 \}$ , $\lbrace 1 3 5 7 9 \rbrace$ . Here, $\lbrace 0 1 2 3 4 \rbrace$ means the normal samples include images from class $0 , 1 , 2 , 3 , 4$ , and similar for others. Note that the class index is obtained by sorting the class names of 10 classes. The setup of the model is detailed in Appendix.
155
+
156
+ Table 3: Anomaly detection results with AUROC metric on CIFAR-10 [23] under the unified case. Here, $\lbrace 0 1 2 3 4 \rbrace$ means samples from class $0 , 1 , 2 , 3 , 4$ are borrowed as the normal ones.
157
+
158
+ <table><tr><td>Normal Indices</td><td>US [6]</td><td>FCDD [27]</td><td>FCDD+OE [27]</td><td>PANDA [33]</td><td>MKD [37]</td><td>Ours</td></tr><tr><td>{01234}</td><td>51.3</td><td>55.0</td><td>71.8</td><td>66.6</td><td>64.2</td><td>84.4 ± 0.02</td></tr><tr><td>{56789}</td><td>51.3</td><td>50.3</td><td>73.7</td><td>73.2</td><td>69.3</td><td>80.9 ± 0.02</td></tr><tr><td>{02468}</td><td>63.9</td><td>59.2</td><td>85.3</td><td>77.1</td><td>76.4</td><td>93.0 ± 0.03</td></tr><tr><td>{13579}</td><td>56.8</td><td>58.5</td><td>85.0</td><td>72.9</td><td>78.7</td><td>90.6 ± 0.09</td></tr><tr><td>Mean</td><td>55.9</td><td>55.8</td><td>78.9</td><td>72.4</td><td>72.1</td><td>87.2 ± 0.03</td></tr></table>
159
+
160
+ Table 4: Performance comparison and architecture comparison between UniAD and transformerbased competitors on MVTec-AD [4]. All methods are evaluated under the unified / separate case.
161
+
162
+ <table><tr><td>Method</td><td>Det.</td><td>Loc.</td><td>1 query</td><td>Layer-wise query</td></tr><tr><td>InTra [31]</td><td>65.3/95.0</td><td>70.6 /96.6</td><td>X</td><td>X</td></tr><tr><td>VT-ADL [28]</td><td>55.4/ 78.7</td><td>64.4/ 82.0</td><td>X</td><td>×</td></tr><tr><td>AnoVit [50]</td><td>69.6/78</td><td>68.4/ 83</td><td>X</td><td>×</td></tr><tr><td>Ours (baseline)</td><td>87.6 / 94.7</td><td>92.8 / 95.8</td><td>√</td><td></td></tr><tr><td>Ours</td><td>96.5 / 96.6</td><td>96.8 / 96.6</td><td>×</td><td>X</td></tr></table>
163
+
164
+ Baselines. US [6], FCDD [27], $\mathrm { F C D D + O E }$ [27], PANDA [33], and MKD [37] serve as competitors.
165
+ US, FCDD, FCDD+OE, PANDA, and MKD are run with the publicly available implementations.
166
+
167
+ Quantitative results of anomaly detection on CIFAR-10 [23] are shown in Tab. 3. When five classes together serve as normal samples, two recent baselines, US and FCDD, almost lose their ability to detect anomalies. When utilizing 10000 images sampled from CIFAR-100 [23] as auxiliary Outlier Exposure (OE), $\mathrm { F C D D + O E }$ improves the performance by a large margin. We still stably outperform FCDD $\mathsf { \Pi } + \mathsf { O E }$ by $8 . 3 \%$ without the help of OE, indicating the efficacy of our UniAD.
168
+
169
+ # 4.5 Comparison with transformer-based competitors
170
+
171
+ As described in Sec. 2, some attempts [31, 28, 50] also try to utilize transformer for anomaly detection. Here we compare our UniAD with existing transformer-based competitors on MVTec-AD [4]. Recall that, we choose transformer as the reconstruction model considering its great potential in preventing the model from learning the “identical shortcut” (refer to Sec. 3.1). Concretely, we find that the learnable query embedding is essential for avoiding such a shortcut but is seldom explored in existing transformer-based approaches. As shown in Tab. 4, after introducing even only one query embedding, our baseline already outperforms existing alternatives by a sufficiently large margin in the unified setting. Our proposed three components further improve our strong baseline. Recall that all three components are proposed to avoid the model from directly outputting the inputs.
172
+
173
+ # 4.6 Ablation studies
174
+
175
+ To verify the effectiveness of the proposed modules and the selection of hyperparameters, we implement extensive ablation studies on MVTec-AD [4] under the unified case.
176
+
177
+ Layer-wise query. Tab. 5a verifies our assertion that the query embedding is of vital significance. 1) Without query embedding, meaning the encoder embeddings are directly input to the decoder, the performance is the worst. 2) Adding only one query embedding to the first decoder layer (i.e., vanilla transformer [42]) promotes the performance dramatically by $1 8 . 1 \%$ and $1 3 . 4 \%$ in anomaly detection and localization, respectively. 3) With layer-wise query embedding in each decoder layer, image-level and pixel-level AUROC is further improved by $7 . 4 \%$ and $3 . 7 \%$ , respectively.
178
+
179
+ Layer number. We conduct experiments to investigate the influence of layer number, as shown in Tab. 5b. 1) No matter with which combination, our model outperforms vanilla transformer by a large margin, reflecting the effectiveness of our design. 2) The best performance is achieved with a moderate layer number: $4 { \mathrm { E n c } } + 4 { \mathrm { D e c } }$ . A larger layer number like 6Enc+6Dec does not bring further promotion, which may be because more layers are harder to train.
180
+
181
+ Table 5: Ablation studies with AUROC metric on MVTec-AD [4]. Default settings are in blue. (a) Layer-wise query, NMA, & FJ (b) Layer Number of Encoder & Decoder
182
+
183
+ <table><tr><td>w/o q.</td><td>1q</td><td>Layer-wise q.</td><td>NMA</td><td>FJ</td><td>Det.</td><td>Loc.</td><td colspan="2"></td><td>Vanilla [42]</td><td colspan="2">Loc.</td><td>Ours</td></tr><tr><td>√</td><td>-</td><td></td><td>=</td><td></td><td>69.5</td><td>79.4</td><td colspan="2">#Enc,#Dec</td><td colspan="2">Det.</td><td>Det.</td><td>Loc.</td></tr><tr><td></td><td>【</td><td></td><td></td><td></td><td>87.6</td><td>92.8</td><td colspan="2">4,0</td><td>69.8</td><td>79.2</td><td>94.9</td><td>96.0</td></tr><tr><td>=</td><td></td><td>√</td><td>=</td><td></td><td>95.0</td><td>96.5</td><td colspan="2">0,4</td><td>80.5</td><td>88.3</td><td>96.1</td><td>96.3</td></tr><tr><td></td><td></td><td>1</td><td>【</td><td></td><td>96.1</td><td>96.3</td><td colspan="2">2,2</td><td>84.7</td><td>90.6</td><td>95.1</td><td>96.0</td></tr><tr><td></td><td></td><td></td><td></td><td>!</td><td>95.0</td><td>95.8</td><td colspan="2">4,4</td><td>87.6</td><td>92.8</td><td>96.5</td><td>96.8</td></tr><tr><td>=</td><td>-</td><td>√</td><td>√</td><td>【</td><td>96.5</td><td>96.8</td><td colspan="2">6,6</td><td>86.1</td><td>91.9</td><td>96.5</td><td>96.7</td></tr><tr><td colspan="2">(c) Neighbor Size in NMA</td><td></td><td colspan="3">(d) Where to Add NMA</td><td colspan="3">(e) Jitter Scale α in FJ</td><td colspan="3">(f) Jitter Prob.</td><td>p inFJ</td></tr><tr><td>Size</td><td>Det.</td><td>Loc.</td><td>Place</td><td>Det.</td><td>Loc.</td><td>a</td><td>Det.</td><td>Loc.</td><td></td><td>p</td><td>Det.</td><td>Loc.</td></tr><tr><td>1×1</td><td>94.6</td><td>96.3</td><td>Enc</td><td>95.8</td><td>96.3</td><td></td><td>5 96.1</td><td>96.7</td><td></td><td>0.25</td><td>95.6</td><td>96.5</td></tr><tr><td>5×5</td><td>96.4</td><td>96.8</td><td>Enc+Dec1</td><td>96.4</td><td>96.8</td><td></td><td>10 96.4</td><td>96.7</td><td></td><td>0.50</td><td>95.8</td><td>96.7</td></tr><tr><td>7x7</td><td>96.5</td><td>96.8</td><td>Enc+Dec2</td><td>96.5</td><td>96.7</td><td></td><td>20 96.5</td><td>96.8</td><td></td><td>0.75</td><td>96.3</td><td>96.7</td></tr><tr><td>9×9</td><td>96.3</td><td>96.7</td><td>All </td><td>96.5</td><td>96.8</td><td></td><td>30 95.7</td><td>96.6</td><td></td><td>1</td><td>96.5</td><td>96.8</td></tr></table>
184
+
185
+ Neighbor masked attention. 1) The effectiveness of NMA is proven in Tab. 5a. Under the case of one query embedding, adding NMA brings promotion by $8 . 5 \%$ for detection and $3 . 5 \%$ for localization. 2) The neighbor size of NMA is selected in Tab. 5c. $1 \times 1$ neighbor size is the worst, because $1 \times 1$ is too small to prevent the information leak, thus the recovery could be completed by copying neighbor regions. A larger neighbor size $( \geq 5 { \times } 5 )$ is obviously much better, and the best one is selected as $7 \times 7$ . 3) We also study the place to add NMA in Tab. 5d. Only adding NMA in the encoder (Enc) is not enough. The performance could be stably improved when further adding NMA in the first or second attention in the decoder $\mathbf { E n c + D e c l }$ , $_ \mathrm { E n c + D e c } 2$ ) or both (All). This reflects that the full attention of the decoder also contributes to the information leak.
186
+
187
+ Feature jittering. 1) Tab. 5a confirms the efficacy of FJ. With one query embedding as the baseline, introducing FJ could bring an increase of $7 . 4 \%$ for detection and $3 . 0 \%$ for localization, respectively. 2) According to Tab. 5e, the jittering scale, $\alpha$ , is chosen as 20. A larger $\alpha$ (i.e., 30) disturbs the feature too much, degrading the results. 3) In Tab. 5f, the jittering probability, $p$ , is studied. In essence, the task would be a denoising task with feature jittering, and be a reconstruction task without feature jittering. The results show that the full denoising task (i.e., $p = 1$ ) is the best.
188
+
189
+ # 5 Conclusion
190
+
191
+ In this work, we propose UniAD that unifies anomaly detection regarding multiple classes. For such a challenging task, we assist the model against learning an “identical shortcut” with three improvements. First, we confirm the effectiveness of the learnable query embedding and carefully tailor a layer-wise query decoder to help model the complex distribution of multi-class data. Second, we come up with a neighbor masked attention module to avoid the information leak from the input to the output. Third, we propose feature jittering that helps the model less sensitive to the input perturbations. Under the unified task setting, our method achieves state-of-the-art performance on MVTec-AD and CIFAR-10 datasets, significantly outperforming existing alternatives.
192
+
193
+ Discussion. In this work, different kinds of objects are handled without being distinguished. We have not used the category labels that may help the model better fit multi-class data. How to incorporate the unified model with category labels should be further studied. In practical uses, normal samples are not as consistent as those in MVTec-AD, often manifest themselves in some diversity. Our UniAD could handle all 15 categories in MVTec-AD, hence would be more suitable for real scenes. However, anomaly detection may be used for video surveillance, which may infringe personal privacy.
194
+
195
+ # Acknowledgments and Disclosure of Funding
196
+
197
+ Acknowledgement. This work is sponsored by the National Key Research and Development Program of China (2021YFB1716000) and National Natural Science Foundation of China (62176152).
198
+
199
+ References
200
+ [1] F. Ahmed and A. Courville. Detecting semantic anomalies. In Assoc. Adv. Artif. Intell., 2020.
201
+ [2] S. Akcay, A. Atapour-Abarghouei, and T. P. Breckon. GANomaly: Semi-supervised anomaly detection via adversarial training. In Asian Conf. Comput. Vis., 2018.
202
+ [3] Y. Bengio, L. Yao, G. Alain, and P. Vincent. Generalized denoising auto-encoders as generative models. In Adv. Neural Inform. Process. Syst., 2013.
203
+ [4] P. Bergmann, M. Fauser, D. Sattlegger, and C. Steger. MVTec AD–A comprehensive real-world dataset for unsupervised anomaly detection. In IEEE Conf. Comput. Vis. Pattern Recog., 2019.
204
+ [5] P. Bergmann, S. Löwe, M. Fauser, D. Sattlegger, and C. Steger. Improving unsupervised defect segmentation by applying structural similarity to autoencoders. In International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP), 2019.
205
+ [6] P. Bergmann, M. Fauser, D. Sattlegger, and C. Steger. Uninformed students: Student-teacher anomaly detection with discriminative latent embeddings. In IEEE Conf. Comput. Vis. Pattern Recog., 2020.
206
+ [7] N. Carion, F. Massa, G. Synnaeve, N. Usunier, A. Kirillov, and S. Zagoruyko. End-to-end object detection with transformers. In Eur. Conf. Comput. Vis., 2020.
207
+ [8] L. Chen, Z. You, N. Zhang, J. Xi, and X. Le. UTRAD: Anomaly detection and localization with Utransformer. Neural Networks, 2022.
208
+ [9] A.-S. Collin and C. De Vleeschouwer. Improved anomaly detection by training an autoencoder with skip connections on images corrupted with stain-shaped noise. In Int. Conf. Pattern Recog., 2021.
209
+ [10] L. Deecke, L. Ruff, R. A. Vandermeulen, and H. Bilen. Transfer-based semantic anomaly detection. In Int. Conf. Mach. Learn., 2021.
210
+ [11] T. Defard, A. Setkov, A. Loesch, and R. Audigier. PaDim: A patch distribution modeling framework for anomaly detection and localization. In Int. Conf. Pattern Recog., 2021.
211
+ [12] D. Dehaene, O. Frigo, S. Combrexelle, and P. Eline. Iterative energy-based projection on a normal data manifold for anomaly localization. In Int. Conf. Learn. Represent., 2019.
212
+ [13] H. Deng and X. Li. Anomaly detection via reverse distillation from one-class embedding. In IEEE Conf. Comput. Vis. Pattern Recog., 2022.
213
+ [14] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In IEEE Conf. Comput. Vis. Pattern Recog., 2009.
214
+ [15] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
215
+ [16] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In Int. Conf. Learn. Represent., 2021.
216
+ [17] T. Fernando, H. Gammulle, S. Denman, S. Sridharan, and C. Fookes. Deep learning for medical anomaly detection–a survey. ACM Computing Surveys (CSUR), 2021.
217
+ [18] I. Golan and R. El-Yaniv. Deep anomaly detection using geometric transformations. In Adv. Neural Inform. Process. Syst., 2018.
218
+ [19] D. Gong, L. Liu, V. Le, B. Saha, M. R. Mansour, S. Venkatesh, and A. v. d. Hengel. Memorizing normality to detect anomaly: Memory-augmented deep autoencoder for unsupervised anomaly detection. In Int. Conf. Comput. Vis., 2019.
219
+ [20] J. Hou, Y. Zhang, Q. Zhong, D. Xie, S. Pu, and H. Zhou. Divide-and-assemble: Learning block-wise memory for unsupervised anomaly detection. In Int. Conf. Comput. Vis., 2021.
220
+ [21] L. Ilya and H. Frank. Decoupled weight decay regularization. In Int. Conf. Learn. Represent., 2019.
221
+ [22] D. P. Kingma and M. Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
222
+ [23] A. Krizhevsky. Learning multiple layers of features from tiny images. Master’s thesis, University of Tront, 2009.
223
+ [24] G. Kwon, M. Prabhushankar, D. Temel, and G. AlRegib. Backpropagated gradient representations for anomaly detection. In Eur. Conf. Comput. Vis., 2020.
224
+ [25] C.-L. Li, K. Sohn, J. Yoon, and T. Pfister. CutPaste: Self-supervised learning for anomaly detection and localization. In IEEE Conf. Comput. Vis. Pattern Recog., 2021.
225
+ [26] W. Liu, R. Li, M. Zheng, S. Karanam, Z. Wu, B. Bhanu, R. J. Radke, and O. Camps. Towards visually explaining variational autoencoders. In IEEE Conf. Comput. Vis. Pattern Recog., 2020.
226
+ [27] P. Liznerski, L. Ruff, R. A. Vandermeulen, B. J. Franks, M. Kloft, and K.-R. Müller. Explainable deep one-class classification. In Int. Conf. Learn. Represent., 2021.
227
+ [28] P. Mishra, R. Verk, D. Fornasier, C. Piciarelli, and G. L. Foresti. VT-ADL: A vision transformer network for image anomaly detection and localization. In International Symposium on Industrial Electronics, 2021.
228
+ [29] H. Park, J. Noh, and B. Ham. Learning memory-guided normality for anomaly detection. In IEEE Conf. Comput. Vis. Pattern Recog., 2020.
229
+ [30] P. Perera, R. Nallapati, and B. Xiang. OCGAN: One-class novelty detection using GANs with constrained latent representations. In IEEE Conf. Comput. Vis. Pattern Recog., 2019.
230
+ [31] J. Pirnay and K. Chai. Inpainting transformer for anomaly detection. arXiv preprint arXiv:2104.13897, 2021.
231
+ [32] M. Pourreza, B. Mohammadi, M. Khaki, S. Bouindour, H. Snoussi, and M. Sabokrou. G2D: generate to detect anomaly. In IEEE Winter Conf. Appl. Comput. Vis., 2021.
232
+ [33] T. Reiss, N. Cohen, L. Bergman, and Y. Hoshen. Panda: Adapting pretrained features for anomaly detection and segmentation. In IEEE Conf. Comput. Vis. Pattern Recog., 2021.
233
+ [34] O. Rippel, P. Mertens, and D. Merhof. Modeling the distribution of normal data in pretrained deep features for anomaly detection. In Int. Conf. Pattern Recog., 2021.
234
+ [35] L. Ruff, R. Vandermeulen, N. Goernitz, L. Deecke, S. A. Siddiqui, A. Binder, E. Müller, and M. Kloft. Deep one-class classification. In Int. Conf. Mach. Learn., 2018.
235
+ [36] M. Sabokrou, M. Khalooei, M. Fathy, and E. Adeli. Adversarially learned one-class classifier for novelty detection. In IEEE Conf. Comput. Vis. Pattern Recog., 2018.
236
+ [37] M. Salehi, N. Sadjadi, S. Baselizadeh, M. H. Rohban, and H. R. Rabiee. Multiresolution knowledge distillation for anomaly detection. In IEEE Conf. Comput. Vis. Pattern Recog., 2021.
237
+ [38] B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. J. Smola, and R. C. Williamson. Estimating the support of a high-dimensional distribution. Neural Computation, 2001.
238
+ [39] Y. Shi, J. Yang, and Z. Qi. Unsupervised anomaly segmentation via deep feature reconstruction. Neurocomputing, 2021.
239
+ [40] M. Tan and Q. Le. EfficientNet: Rethinking model scaling for convolutional neural networks. In Int. Conf. Mach. Learn., 2019.
240
+ [41] D. M. Tax and R. P. Duin. Support vector data description. Machine Learning, 2004.
241
+ [42] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. In Adv. Neural Inform. Process. Syst., 2017.
242
+ [43] P. Vincent, H. Larochelle, Y. Bengio, and P.-A. Manzagol. Extracting and composing robust features with denoising autoencoders. In Int. Conf. Mach. Learn., 2008.
243
+ [44] G. Wang, S. Han, E. Ding, and D. Huang. Student-teacher feature pyramid matching for anomaly detection. Brit. Mach. Vis. Conf., 2021.
244
+ [45] S. Wang, L. Wu, L. Cui, and Y. Shen. Glancing at the patch: Anomaly localization with global and local feature comparison. In IEEE Conf. Comput. Vis. Pattern Recog., 2021.
245
+ [46] Y. Xia, Y. Zhang, F. Liu, W. Shen, and A. L. Yuille. Synthesize then compare: Detecting failures and anomalies for semantic segmentation. In Eur. Conf. Comput. Vis., 2020.
246
+ [47] X. Yan, H. Zhang, X. Xu, X. Hu, and P.-A. Heng. Learning semantic context from normal samples for unsupervised anomaly detection. In Assoc. Adv. Artif. Intell., 2021.
247
+ [48] J. Yi and S. Yoon. Patch SVDD: Patch-level SVDD for anomaly detection and segmentation. In Asian Conf. Comput. Vis., 2020.
248
+ [49] Z. You, K. Yang, W. Luo, L. Cui, Y. Zheng, and X. Le. ADTR: Anomaly detection transformer with feature reconstruction. arXiv preprint arXiv:2209.01816, 2022.
249
+ [50] L. Yunseung and K. Pilsung. AnoViT: Unsupervised anomaly detection and localization with vision transformer-based encoder-decoder. arXiv preprint arXiv:2203.10808, 2022.
250
+ [51] M. Z. Zaheer, J.-h. Lee, M. Astrid, and S.-I. Lee. Old is gold: Redefining the adversarially learned one-class classifier training paradigm. In IEEE Conf. Comput. Vis. Pattern Recog., 2020.
251
+ [52] V. Zavrtanik, M. Kristan, and D. Skocaj. DRAEM-A discriminatively trained reconstruction embedding ˇ for surface anomaly detection. In Int. Conf. Comput. Vis., 2021.
252
+ [53] K. Zhou, Y. Xiao, J. Yang, J. Cheng, W. Liu, W. Luo, Z. Gu, J. Liu, and S. Gao. Encoding structure-texture relation with P-Net for anomaly detection in retinal images. In Eur. Conf. Comput. Vis., 2020.
253
+
254
+ # Checklist
255
+
256
+ 1. For all authors...
257
+
258
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
259
+ (b) Did you describe the limitations of your work? [Yes] See Discussion in Sec. 5.
260
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Discussion in Sec. 5.
261
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
262
+
263
+ 2. If you are including theoretical results...
264
+
265
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
266
+
267
+ 3. If you ran experiments...
268
+
269
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Sec. 4 and Appendix. Also, we have released the code.
270
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Sec. 4.1 & Sec. 4.4 for data splits, and Sec. 4.6 for the choice of hyperparameters.
271
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Tab. 1, Tab. 2, and Tab. 3.
272
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Setup in Sec. 4.2.
273
+
274
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
275
+
276
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Sec. 4.1 and Baselines in Sec. 4.
277
+ (b) Did you mention the license of the assets? [N/A]
278
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
279
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
280
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
281
+
282
+ 5. If you used crowdsourcing or conducted research with human subjects...
283
+
284
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
285
+
286
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
287
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/cpDhcsEDC2/cpDhcsEDC2.md ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FILIP: FINE-GRAINED INTERACTIVE LANGUAGEIMAGE PRE-TRAINING
2
+
3
+ Lewei Yao $^ { 1 , 2 \ast }$ Runhui Huang3∗ Lu $\mathbf { H o u } ^ { 1 * }$ Guansong ${ { \bf L } } { \bf u } ^ { 1 }$ Minzhe Niu1 Hang $\mathbf { X } \mathbf { u } ^ { \mathrm { { 1 \dag } } }$ Xiaodan Liang 3† Zhenguo Li1 Xin Jiang1 Chunjing $\mathbf { X } \mathbf { u } ^ { 1 }$ 1Huawei Noah’s Ark Lab, 2Hong Kong University of Science and Technology 3Sun Yat-sen University
4
+
5
+ # ABSTRACT
6
+
7
+ Unsupervised large-scale vision-language pre-training has shown promising advances on various downstream tasks. Existing methods often model the crossmodal interaction either via the similarity of the global feature of each modality which misses sufficient information, or finer-grained interactions using cross/selfattention upon visual and textual tokens. However, cross/self-attention suffers from inferior efficiency in both training and inference. In this paper, we introduce a large-scale Fine-grained Interactive Language-Image Pre-training (FILIP) to achieve finer-level alignment through a cross-modal late interaction mechanism, which uses a token-wise maximum similarity between visual and textual tokens to guide the contrastive objective. FILIP successfully leverages the finergrained expressiveness between image patches and textual words by modifying only contrastive loss, while simultaneously gaining the ability to pre-compute image and text representations offline at inference, keeping both large-scale training and inference efficient. Furthermore, we construct a new large-scale image-text pair dataset called FILIP300M for pre-training. Experiments show that FILIP achieves state-of-the-art performance on multiple downstream vision-language tasks including zero-shot image classification and image-text retrieval. The visualization on word-patch alignment further shows that FILIP can learn meaningful fine-grained features with promising localization ability.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Large-scale Vision-Language Pre-training (VLP) models like CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) have recently demonstrated success across various downstream tasks. They learn visual and textual representations from millions of image-text pairs collected from the Internet and show superior zero-shot ability and robustness. The core technique of these models lies in the global contrastive alignment of the images and texts through a dual-stream model. Such architecture is inference-efficient for downstream tasks like retrieval because the encoders for the two modalities can be decoupled and the image or text representations can be pre-computed offline. However, CLIP and ALIGN model the cross-modal interaction via solely the similarity of the global feature of each modality, lacking the ability of capturing finer-level information like the relationship between visual objects and textual words. In this paper, we develop a simple yet efficient cross-modal finer-grained interaction mechanism for large-scale VLP.
12
+
13
+ To achieve finer-grained cross-modal interaction, previous methods mainly exploited two kinds of methods. (1) One line of work (Chen et al., 2020; Li et al., 2020b; Dong et al., 2021; Li et al., 2021b; Zhang et al., 2021; Zhan et al., 2021) uses a pre-trained object detector to extract region-of-interest (ROI) features from images, and then fuses it with the paired text through a VLP model. This design complicates the pre-training due to pre-computing and storing a large number of ROI features. In addition, the zero-shot ability of these approaches is usually limited by the predefined number of classes and their performance is also restricted by the quality of the detector. (2) Another line of work (Li et al., 2021a; Kim et al., 2021) enforces the token-wise or patch-wise representations from both modalities into the same space and models these finer-grained interactions via cross-attention (Li et al., 2021a) or self-attention (Kim et al., 2021). However, these methods are usually less efficient in terms of both training and inference. In particular, during training, cross-attention in (Li et al., 2021a) requires to be performed in an encoder-decoder structure, while the complexity of the self-attention (Kim et al., 2021) grows quadratically with the length of the prolonged concatenated sequences of both modalities. During inference, the data from both modalities are intertwined to compute the cross-attention or self-attention, and can not be pre-computed offline as dual-stream models like CLIP and ALIGN. This can be less efficient for downstream tasks like image/text retrieval and image classification.
14
+
15
+ In this paper, we propose a large-scale Fine-grained Interactive Language-Image Pre-training framework named FILIP to address these limitations. Inspired by Khattab & Zaharia (2020), we model the fine-grained semantic alignment through a novel cross-modal late interaction mechanism in the contrastive loss, instead of using cross or self-attention. Specifically, our fine-grained contrastive learning uses a token-wise maximum similarity between visual and textual tokens to guide the contrastive objective. In this way, FILIP successfully leverages the finer-grained expressiveness among image patches and textual words while simultaneously gaining the ability to pre-compute image and text representations offline. Unlike Khattab & Zaharia (2020), we discard the padded tokens and use average instead summation of token-wise maximum similarities when computing the image-text alignment, which enhances the cross-modal representation learning and stabilizes training. Furthermore, we construct a large-scale pre-training dataset named FILIP300M from the Internet. Data cleaning and image-text data augmentation are also explored and proved useful in this work.
16
+
17
+ Extensive experiments show that by effectively learning fine-grained representations, FILIP achieves state-of-the-art performance on multiple downstream tasks, including zero-shot image classification and image-text retrieval. For example, FILIP reaches $7 7 . 1 \%$ top-1 accuracy for zero-shot ImageNet classification, surpassing CLIP with less training data. Visualizations on word-patch alignment further show that FILIP learns meaningful finer-grained features with promising localization ability.
18
+
19
+ # 2 RELATED WORK
20
+
21
+ Vision-Language Pre-training Models. The pre-train-and-fine-tune scheme has achieved great success in the domains of natural language processing (Devlin et al., 2019; Brown et al., 2020) and computer vision (Dosovitskiy et al., 2020). It is then naturally extended to a joint cross-modal domain of Vision-and-Language Pre-training (VLP). The pre-training datasets of recent VLP models include publically available datasets like YFCC100M (Thomee et al., 2016) and CC12M (Changpinyo et al., 2021), as well as larger-scale datasets with more than 100M samples in CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021), which are shown to be even more powerful. The pretraining tasks of VLP models can be categorized into two categories: image-text contrastive learning task and Language Modeling (LM) based tasks: (i) CLIP (Radford et al., 2021), ALIGN (Jia et al., 2021) and UNIMO (Li et al., 2021b) make use of cross-modal contrastive learning which aligns the textual and visual information into a unified semantic space; (ii) VisualBERT (Li et al., 2019), UNITER (Chen et al., 2020), M6 (Lin et al., 2021), and DALL-E (Ramesh et al., 2021) employ LM-like objectives, including both masked LM (e.g., Masked Language/Region Modeling), and autoregressive LM (e.g., image captioning, text-grounded image generation). On the other hand, some methods rely on a pre-trained object detection model such as Faster-RCNN (Ren et al., 2015) to extract image regional features offline, which requires extra labeled bounding-box data and makes the approach less scalable. Recent efforts such as SOHO (Huang et al., 2021) and SimVLM (Wang et al., 2021) try to eliminate this burden via visual dictionary or PrefixLM (Raffel et al., 2020). In this paper, we directly learn fine-grained vision-language representations in an end-to-end and simpler manner while maintaining the benefit of inference efficiency.
22
+
23
+ Multi-Modality Interaction Mechanism. The core of vision-language pre-training models lies in modeling the interaction between the two modalities. There are mainly two types of cross-modal interaction architectures: Single-stream models like VisualBERT (Li et al., 2019) and ViLT (Kim et al., 2021) directly concatenate the patch-wise or regional visual features and textual embeddings and feed them to the transformer-based model. Dual-stream models such as ViLBERT (Lu et al., 2019) and CLIP (Radford et al., 2021) have separate encoders for different modalities. This allows flexible use of different models for different modalities, and efficient inference for downstream tasks like image-text retrieval, through the ability of decoupling the encoders and pre-compute image/text features offline. SCAN (Lee et al., 2018) considers latent alignments between image regions and words. However, it is based on Triplet loss with a bottom-Up attention via a Faster-RCNN to extract object features while we try to directly learn to localize fine-grained object from patches. In this paper, while following the dual-stream approach for its flexible and efficient inference, we further propose a new multi-modal interaction mechanism to capture the fine-grained representations.
24
+
25
+ ![](images/373e2fb4c6fe425ddf3adfaab03f61e1fbd3367bd06b47ed9be8c6e5665c5685.jpg)
26
+ Figure 1: Overall architecture of FILIP, a dual-stream model with Transformer-based image and text encoders. On top of the image and text encoders, the representations of textual tokens and visual tokens are linearly projected to the multi-modal joint space. A novel fine-grained contrastive learning equipped with cross-modal late interaction is proposed, which uses a token-wise maximum similarity between visual and textual tokens.
27
+
28
+ # 3 METHOD
29
+
30
+ In this paper, we propose a new cross-modal pre-training model that excels in fine-grained interaction between image encoder and text encoder for mining more detailed semantic alignment, named as FILIP, as shown in Figure 1. Particularly, FILIP is a dual-stream model with Transformer-based image and text encoders. For the visual modality, the image encoder is a Vision Transformer (Dosovitskiy et al., 2020) which takes the concatenation of an extra [CLS] token embedding and linearly projected image patches as input. For the textual modality, following Radford et al. (2021), we use the lower-cased byte pair encoding (BPE) (Sennrich et al., 2016b) with a vocabulary size of 49,408 to tokenize the text. Each text sequence starts with [BOS] token and ends with [EOS] token. After the word embedding layer, the token embeddings are fed into a modified decoder-only Transformer model as in (Radford et al., 2019). On top of the image and text encoders, the representations of textual tokens and visual tokens are linearly projected to the multi-modal common space, and are separately L2-normalized. Different from existing dual-stream models (e.g., CLIP and ALIGN) which models cross-modal interaction via only the global features of the entire image and text sequence, we introduce a novel fine-grained contrastive learning objective equipped with cross-modal late interaction which takes into account the fine-grained interaction between image patches and textual tokens, detailed in Section 3.1.
31
+
32
+ # 3.1 FINE-GRAINED CONTRASTIVE LEARNING
33
+
34
+ Contrastive representation learning has recently been found to learn better representations than its predictive counterpart in both visual (Tian et al., 2020) and vision-language cross-modal pre-training (Radford et al., 2021). Under a general formulation of cross-modal contrastive learning (Radford et al., 2021), we want to learn encoders $f _ { \theta }$ for image data $\mathcal { T }$ and $g _ { \phi }$ for text data $\tau$ such that, given an image $\pmb { x } ^ { I } \in \mathcal { I }$ , and a text $\pmb { x } ^ { T } \in \mathcal { T }$ , the encoded representations $f _ { \theta } ( \pmb { x } ^ { I } )$ and $g _ { \phi } ( \pmb { x } ^ { T } )$ are close if they are relateimage-text pairs t if not, und, For image a distance metric. in image-text pair i, g batch, we sample is its positive, whi $b$ $\{ \pmb { x } _ { k } ^ { I } , \pmb { x } _ { k } ^ { T } \} _ { k = 1 } ^ { b ^ { \ast } }$ $\boldsymbol { x } _ { k } ^ { I }$ $\{ x _ { k } ^ { I } , \pmb { x } _ { k } ^ { T } \}$ $\pmb { x } _ { k } ^ { T }$
35
+
36
+ the other texts will be used as in-batch negatives. The image-to-text contrastive loss $\mathcal { L } _ { k } ^ { I }$ for $\pmb { x } _ { k } ^ { I }$ can then be formulated as
37
+
38
+ $$
39
+ \mathcal { L } _ { k } ^ { I } ( \boldsymbol { x } _ { k } ^ { I } , \{ \boldsymbol { x } _ { j } ^ { T } \} _ { j = 1 } ^ { b } ) = - \frac { 1 } { b } \log \frac { e x p ( s _ { k , k } ^ { I } ) } { \sum _ { j } e x p ( s _ { k , j } ^ { I } ) } ,
40
+ $$
41
+
42
+ where $s _ { k , j } ^ { I }$ denotes the similarity of the $k$ -th image to the $j$ -th text. Similarly, the text-to-image contrastive loss for $\pmb { x } _ { k } ^ { T }$ is
43
+
44
+ $$
45
+ \mathcal { L } _ { k } ^ { T } ( \boldsymbol { x } _ { k } ^ { T } , \{ \boldsymbol { x } _ { j } ^ { I } \} _ { j = 1 } ^ { b } ) = - \frac { 1 } { b } \log \frac { e x p ( s _ { k , k } ^ { T } ) } { \sum _ { j } e x p ( s _ { j , k } ^ { T } ) } .
46
+ $$
47
+
48
+ The total loss of this mini-batch can be represented by
49
+
50
+ $$
51
+ \mathcal { L } = \frac { 1 } { 2 } \sum _ { k = 1 } ^ { b } ( \mathcal { L } _ { k } ^ { I } + \mathcal { L } _ { k } ^ { T } ) .
52
+ $$
53
+
54
+ # 3.1.1 CROSS-MODAL LATE INTERACTION
55
+
56
+ From the contrastive loss (1), the cross-modal interaction is reflected in how we compute the similarities $s _ { i , j } ^ { I }$ and $s _ { i , j } ^ { T }$ for the $i$ -th image and $j$ -th text. Previous methods like CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) simply encode each image or text separately to a global feature i.e., $f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) \in \mathbb { R } ^ { d }$ and $g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) \in \mathbb { R } ^ { d }$ , and compute these two similarities as
57
+
58
+ $$
59
+ s _ { i , j } ^ { I } = s _ { i , j } ^ { T } = f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ^ { \top } g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ,
60
+ $$
61
+
62
+ neglecting finer-grained interactions (e.g., word-patch alignment) between the two modalities. To alleviate this problem, while simultaneously maintain the training and inference efficiency of dualstream models, we apply a cross-modal late interaction inspired by Khattab & Zaharia (2020) to model the token-wise cross-modal interaction.
63
+
64
+ Specifically, denote $n _ { 1 }$ and $n _ { 2 }$ as the number of (non-padded) tokens of the $i$ -th image and $j$ -th text, respectively, and the corresponding encoded features are $f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) \in \mathbb { R } ^ { n _ { 1 } \times d }$ and $g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) \in \mathbb { R } ^ { n _ { 2 } \times d }$ . For the $k$ -th visual token, we compute its similarities with all textual tokens of $\pmb { x } _ { j } ^ { T }$ , and use the largest one
65
+
66
+ $$
67
+ \operatorname* { m a x } _ { 0 \leq r < n _ { 2 } } [ f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ] _ { k } ^ { \top } [ g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ] _ { r }
68
+ $$
69
+
70
+ as its token-wise maximum similarity with $\pmb { x } _ { j } ^ { T }$ . We then use the average token-wise maximum similarity of all non-padded tokens in the image (resp. text) as the similarity of an image to a text (resp. a text to an image). The similarity of the $i$ -th image to the $j$ -th text can thus be formulated as:
71
+
72
+ $$
73
+ s _ { i , j } ^ { I } ( \pmb { x } _ { i } ^ { I } , \pmb { x } _ { j } ^ { T } ) = \frac { 1 } { n _ { 1 } } \sum _ { k = 1 } ^ { n _ { 1 } } [ f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ] _ { k } ^ { \top } [ g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ] _ { m _ { k } ^ { I } } ,
74
+ $$
75
+
76
+ where $m _ { k } ^ { I } = \arg \operatorname* { m a x } _ { 0 \leq r < n _ { 2 } } [ f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ] _ { k } ^ { \top } [ g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ] _ { r }$ . Similarly, the similarity of the $j$ -th text to the $i$ -th image is
77
+
78
+ $$
79
+ s _ { i , j } ^ { T } ( \pmb { x } _ { i } ^ { I } , \pmb { x } _ { j } ^ { T } ) = \frac { 1 } { n _ { 2 } } \sum _ { k = 1 } ^ { n _ { 2 } } [ f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ] _ { m _ { k } ^ { T } } ^ { \top } [ g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ] _ { k } ,
80
+ $$
81
+
82
+ where $m _ { k } ^ { T } = \arg \operatorname* { m a x } _ { 0 \leq r < n _ { 1 } } [ f _ { \theta } ( \pmb { x } _ { i } ^ { I } ) ] _ { r } ^ { \top } [ g _ { \phi } ( \pmb { x } _ { j } ^ { T } ) ] _ { k }$ . Note that $s _ { i , j } ^ { I } ( \pmb { x } _ { i } ^ { I } , \pmb { x } _ { j } ^ { T } )$ in Equation (4) does not necessarily equal $s _ { i , j } ^ { T } ( \pmb { x } _ { i } ^ { I } , \pmb { x } _ { j } ^ { T } )$ in Equation (5).
83
+
84
+ Remark 1 Intuitively, the token-wise maximum similarity in Equation (3) means that for each image patch, we find its most similar textual token. Similarly, for each textual token, we also find its closest image patch. By applying this to the similarity calculation in (4) and (5) for contrastive loss (1), the dual-stream model learns fine-grained alignment between image patches and textual tokens.
85
+
86
+ The original late interaction mechanism in (Khattab & Zaharia, 2020) computes the relevance score of a document to a query padded with mask tokens, as a sum of token-wise maximum similarities, and is optimized via a pairwise softmax cross-entropy loss. Though inspired from Khattab & Zaharia (2020), our proposed cross-modal late interaction differs in several aspects. Firstly, we exclude the padded textual tokens when computing the similarity, as they harm the performance. We speculate that this is because these padded tokens also learn textual representations and will mislead the model to align image patches to these meaningless padded tokens rather than meaningful non-padded words. Secondly, when computing similarities (4) and (5), we use the average of the token-wise maximum similarities instead of summation in (Khattab & Zaharia, 2020). This is because the number of non-padded tokens varies from text to text, and this summation over all non-padded tokens can have quite different magnitudes, leading to less stabilized training and worse final performance. These two modifications are crucial to not only the downstream tasks’ performance, but also the quality of the word-patch alignment. A more detailed discussion can be found in Appendix A.7. Thirdly, we optimize the late interaction mechanism via a contrastive loss (1) which is found powerful vision-language pre-training (Radford et al., 2021) instead of the original pairwise loss in (Khattab & Zaharia, 2020).
87
+
88
+ Training Efficiency. Though the cross-modal late interaction is able to capture finer-grained features compared with the original loss, it relies on the token-wise representations of both modalities, and can be inefficient in terms of communication, memory and computation, especially when the batch size is large. To alleviate this problem, we utilize several methods. Firstly, we reduce the embedding size to 256. Besides, we reduce the precision of the last-layer features of both modalities from fp32 to fp16 before node communication in a distributed learning setting, and perform the multiplication in Equations (4) and (5) under the reduced precision. In addition, since the complexity of similarity calculation scales with the sequence length of textual tokens and image patches, for each image (resp. text), we select the $2 5 \%$ tokens with the highest token-wise maximum similarity score (Equation (3)) among all texts (resp. images) in the same local worker before node communication, based on the intuition that each sample can be represented by a few of the most representative tokens. Effects of these modifications are studied in Section 4.4.
89
+
90
+ # 3.1.2 PROMPT ENSEMBLE AND TEMPLATES
91
+
92
+ Due to the problem of polysemy and inconsistency with the pre-training process, following Radford et al. (2021), we also use prompt templates to augment the original label for some downstream tasks. For visualizations, for simplicity, we use only one prompt template across the paper, i.e. “a photo of a $\{ { \mathrm { l a b e l } } \}$ .” as Radford et al. (2021). For other experiments, we report results using prompt ensemble following Radford et al. (2021). When multiple prompts are allowed, the token-wise representations of different prompt templates for the same class label are different, and can not be summed together to form a mean textual representation as in (Radford et al., 2021). Thus, instead of ensembling different prompt templates by their mean textual representation, we ensemble them by their mean token-wise similarity. Specifically, suppose there are $C$ prompt templates, each label is augmented to $C$ different texts $\dot { { \pmb x } } _ { 1 } ^ { T } , \dot { { \pmb x } } _ { 2 } ^ { T } , \cdots , \dot { { \pmb x } } _ { C } ^ { T }$ . The similarity between an image $\boldsymbol { x } ^ { I }$ and this label is computed as $\begin{array} { r } { \frac { 1 } { C } \sum _ { c = 1 } ^ { C } s _ { \cdot , \cdot } ^ { I } ( \pmb { x } ^ { I } , \pmb { x } _ { c } ^ { T } ) } \end{array}$ , where $s _ { \cdot , \cdot } ^ { I }$ · is defined in Equation (4).
93
+
94
+ We use a unified rule-based method inspired by Radford et al. (2018) to construct prompt templates for image classification tasks. Specifically, each template consists of four components:
95
+
96
+ [prefix] $\{ { \mathrm { l a b e l } } \}$ , [category description]. [suffix].
97
+
98
+ Here, the “[prefix]” is an in-context description like “a photo of a” similar as Radford et al. (2021); “label” is a class label of the dataset; “[category description]” describes the category which is found helpful for some fine-grained image classification datasets (Radford et al., 2021), e.g., “ a type of pet” for dataset Oxford-IIIT Pets. An interesting finding is that, adding a suffix that includes the reference word “it” (e.g., “I like it.”) at the end of the prompt empirically improves the zero-shot classification performance of the proposed model. We speculate this is because the reference word “it” strengthens the fine-grained cross-modal alignment, as it can also be aligned to image patches of the target object. Detailed prompt templates for different datasets can be found in Appendix A.5.
99
+
100
+ # 3.2 IMAGE AND TEXT AUGMENTATION
101
+
102
+ To obtain better generalization and data-efficiency of the model, we perform data augmentation on both images and texts during the pre-training phase to construct more image-text pairs. We apply AutoAugment (Krizhevsky et al., 2012; Sato et al., 2015; Cubuk et al., 2019; Hoffer et al., 2020) for image augmentation, following the SOTA vision recognition methods (Touvron et al., 2021; Xie et al., 2020b). To ensure the augmented texts are semantically similar as the original one, for text augmentation, we rewrite the original text using back-translation (Xie et al., 2020a; Sennrich et al., 2016a). Specifically, the texts are first translated to the target language and then translated back to the source language. We choose German and Russian as the target language and get extra two texts for each image-text pair. When constructing a batch of image-text pairs during the pre-training, the text of each image-text pair is randomly sampled from the three candidate texts, i.e., the original text and two back-translated texts.
103
+
104
+ Table 1: Top-1 accuracy $\% )$ of zero-shot image classification on 12 datasets. Our FILIP can boost $3 \sim 5 \%$ accuracy on average.
105
+
106
+ <table><tr><td></td><td>CITAII</td><td>CEIRIIIO</td><td>[rreeaer</td><td>srrprits</td><td>TirreeiiG</td><td>[orPooI</td><td>163305</td><td></td><td>VTerirt</td><td>sTodpptit</td><td>BroAI</td><td>1aeeger</td><td>Jee</td></tr><tr><td>CLIP-ViT-B/32 FILIPbase-ViT-B/32</td><td>91.3 86.9</td><td>65.1 65.5</td><td>87.9 91.9</td><td>59.4 55.4</td><td>66.7 85.3</td><td>84.4 82.8</td><td>63.2 69.1</td><td>44.5 49.3</td><td>21.2 57.2</td><td>87.0 88.1</td><td>49.4 49.9</td><td>63.2 68.8</td><td>65.3 70.9+5.6</td></tr><tr><td>CLIP-ViT-L/14</td><td>96.2</td><td>77.9</td><td>92.6</td><td>77.3</td><td>78.7</td><td>92.9</td><td>67.7</td><td>55.3</td><td>36.1</td><td>93.5</td><td>59.9</td><td>75.3</td><td>75.3</td></tr><tr><td>FILIPlarge- ViT-L/14</td><td>95.7</td><td>75.3</td><td>93.0</td><td>70.8</td><td>90.1</td><td>92.2</td><td>73.1</td><td>60.7</td><td>60.2</td><td>92</td><td>59.2</td><td>77.1</td><td>78.3+3.0</td></tr></table>
107
+
108
+ # 3.3 PRE-TRAINING DATASET
109
+
110
+ A sufficiently large image-text dataset is a prerequisite for vision-language pre-training. Recent CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) construct datasets with 400M and 1800M image-text pairs, respectively. In this work, we also collect a large-scale dataset called FILIP300M from the Internet, which consists of 300M image-text pairs and covers board vision and language concepts. For image-based filtering, we remove the images whose shorter dimension is smaller than 200 pixels and the aspect ratio is larger than 3. For text-based filtering, we keep only English texts, and exclude the meaningless ones, e.g., img 0.jpg. We also discard image-text pairs whose texts are repeated for over 10 times. Besides, we also use 3 public datasets, including Conceptual Captions 3M (CC3M) (Sharma et al., 2018), Conceptual 12M (CC12M) (Changpinyo et al., 2021) and Yahoo Flickr Creative Commons 100M (YFCC100M) (Thomee et al., 2016). We apply the same filtering rules on YFCC100M. Finally, we use about 340M image-text pairs for pre-training. Despite using a smaller training dataset than CLIP and ALIGN, our models still outperform them in most down-steam tasks (see Section 4).
111
+
112
+ # 4 EXPERIMENTS
113
+
114
+ # 4.1 EXPERIMENTAL SETUP
115
+
116
+ Model Architectures. We train two models from scratch, i.e., ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ and $\mathrm { F I L I P _ { l a r g e } }$ . The model architectures follow CLIP (Radford et al., 2021), i.e., the image encoder is ViT-B/32 for ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ and ViT-L/14 for $\mathrm { F I L I P _ { l a r g e } }$ . More details can be found in Appendix A.3.
117
+
118
+ Pre-training Details. To save memory and scale up the batch size, automatic mixed-precision (Micikevicius et al., 2018) and gradient checkpoint (Griewank & Walther, 2000; Chen et al., 2016) are used The input images are resized to $2 2 4 \times 2 2 4$ resolution during pre-training and the maximum length of the text is limited to 77 tokens following Radford et al. (2021). The training is mainly conducted on Nvidia V100 GPUs and Ascend Cards. ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ is trained on 128 cards about 9 days and $\mathrm { F I L I P _ { l a r g e } }$ takes about 24 days to train on 192 cards. Unless otherwise specified, we use $\mathrm { F I L I P _ { l a r g e } }$ to compare with other methods and ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ for ablation. We train both models using the LAMB optimizer (You et al., 2020) and cosine learning rate schedule (Loshchilov & Hutter, 2016) with a linear warmup. Weight decay regularization is applied to all parameters except bias, layer normalization, token embedding, positional embedding and temperature in contrastive loss. Detailed values of hyperparameters for different datasets and models can be found in Appendix A.3.
119
+
120
+ # 4.2 IMAGE CLASSIFICATION
121
+
122
+ In this section, we compare our FILIP with CLIP (Radford et al., 2021) on 12 downstream image classification datasets.
123
+
124
+ Table 2: Results of zero-shot image-text retrieval on Flickr30K and MSCOCO datasets. The last two rows (marked with \*) report the zero-shot results on Flickr30K dataset of model fine-tuned on MSCOCO dataset, following the setting of ALBEF (Li et al., 2021a).
125
+
126
+ <table><tr><td></td><td colspan="6">Flickr30K</td><td colspan="6">MSCOCO</td></tr><tr><td></td><td colspan="3">image-to-text</td><td colspan="3">text-to-image</td><td colspan="3">image-to-text</td><td colspan="3">text-to-image</td></tr><tr><td></td><td></td><td>R@1 R@5 R@10</td><td></td><td></td><td></td><td></td><td>R@1 R@5 R@10 R@1 R@5 R@10 R@1 R@5 R@10</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Unicoder-VL</td><td>64.3</td><td>85.8</td><td>92.3</td><td>48.4</td><td>76.0</td><td>85.2</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ImageBERT</td><td>70.7</td><td>90.2</td><td>94.0</td><td>54.3</td><td>79.6</td><td>87.5</td><td>44.0</td><td>71.2</td><td>80.4</td><td>32.3</td><td>59.0</td><td>70.2</td></tr><tr><td>UNITER</td><td>83.6</td><td>95.7</td><td>97.7</td><td>68.7</td><td>89.2</td><td>93.9</td><td>1</td><td></td><td></td><td>一</td><td></td><td></td></tr><tr><td>CLIP</td><td>88.0</td><td>98.7</td><td>99.4</td><td>68.7</td><td>90.6</td><td>95.2</td><td>58.4</td><td>81.5</td><td>88.1</td><td>37.8</td><td>62.4</td><td>72.2</td></tr><tr><td>ALIGN</td><td>88.6</td><td>98.7</td><td>99.7</td><td>75.7</td><td>93.8</td><td>96.8</td><td>58.6</td><td>83.0</td><td>89.7</td><td>45.6</td><td>69.8</td><td>78.6</td></tr><tr><td>FILIP</td><td>89.8</td><td>99.2</td><td>99.8</td><td>75.0</td><td>93.4</td><td>96.3</td><td>61.3</td><td>84.3</td><td>90.4</td><td>45.9</td><td>70.6</td><td>79.3</td></tr><tr><td>ALBEF*</td><td>94.1</td><td>99.5</td><td>99.7</td><td>82.8</td><td>96.3</td><td>98.1</td><td>一</td><td></td><td>1</td><td>一</td><td>1</td><td>1</td></tr><tr><td>FILIP*</td><td>95.4</td><td>99.8</td><td>100.0</td><td>84.7</td><td>97.0</td><td>98.7</td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
127
+
128
+ Zero-shot Classification. As in Section 3.1.2, we apply a set of prompts (Appendix A.5) for each dataset and ensemble them to get the final results. Table 1 shows the results on 12 datasets. Despite using less training data (340M vs. 400M), both ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ and $\mathrm { F I L I P _ { l a r g e } }$ considerably outperform their CLIP counterparts in terms of average top-1 accuracy over 12 datasets, i.e., achieving absolute improvements of $5 . 6 \%$ and $3 . 0 \%$ , respectively. In particular, our FILIP surpasses CLIP on ImageNet, the largest dataset among 12 datasets. FILIP also achieves substantial performance gains on some domain-specific datasets like Aircrafts. We speculate this is because, unlike CLIP which aggregates the information of the whole image into the [CLS] token, our proposed FILIP focuses more on the target object by directly aligning the image patches of the target object with the textual tokens corresponding to the class label (visualizations of word-patch alignment are in Section 4.5).
129
+
130
+ Linear Probe. Table 14 in Appendix A.6 shows the linear probe results, and FILIP again outperforms CLIP by $1 . 2 { \sim } 1 . 8 \%$ points on average. More details can be found in Appendix A.6.
131
+
132
+ # 4.3 IMAGE-TEXT RETRIEVAL
133
+
134
+ Image-text retrieval consists of two sub-tasks: image-to-text retrieval and text-to-image retrieval. We evaluate our FILIP model on two retrieval benchmark datasets: Flickr30K (Plummer et al., 2015) and MSCOCO (Lin et al., 2014), under both zero-shot and fine-tuned settings. More details of experimental setting can be found in Appendix A.3.
135
+
136
+ Tables 2 and 3 show the results of zero-shot and fine-tuned image-text retrieval, respectively. We compare our FILIP model against methods with complex attention layers including Unicoder-VL (Li et al., 2020a), ImageBERT (Qi et al., 2020), UNITER (Chen et al., 2020), VILLA (Gan et al., 2020), ERNIE-ViL (Yu et al., 2021), Oscar (Li et al., 2020b), VinVL (Zhang et al., 2021), ALBEF (Li et al., 2021a), and methods trained on larger-scale image-text datasets including CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021). As we can see, FILIP achieves state-of-the-art performances under all metrics on both Flickr30K and MSCOCO datasets, except for zero-shot text-to-image retrieval on Flickr30K, where FILIP achieves competitive performance with SOTA. For zero-shot image-to-text retrieval on MSCOCO dataset, the absolute $\mathbb { R } \ @ 1$ of our proposed FILIP is $2 . 7 \%$ higher than ALIGN, which is trained on a much larger dataset.
137
+
138
+ # 4.4 ABLATION STUDY
139
+
140
+ Effectiveness of Each Component. We study the effectiveness of each component in FILIP, i.e., image/text augmentations and cross-modal late interaction. Experiments are conducted on ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ , with a filtered subset of YFCC100M as the training dataset (as described in Section 3.3), on both zero-shot retrieval and classification tasks. We measure models’ performance on MSCOCO zeroshot image-text retrieval and ImageNet zero-shot classification, which are two effective indicators for the quality of the learned vision-language representations.
141
+
142
+ Table 4 reports the results. As can be seen, all three components are beneficial for both tasks. Despite the simple design, cross-modal late interaction brings significant performance improvements over the baseline (the vanilla CLIP ViT-B/32), with an absolute $\mathbf { R } \ @ 1$ gain of $5 . 5 \%$ (resp. $3 . 8 \%$ ) for image-to-text (resp. text-to-image) retrieval on MSCOCO and an absolute top-1 accuracy gain of $3 . 9 \%$ for zero-shot classification on ImageNet. Further improvements are observed when all components are combined together.
143
+
144
+ Table 3: Results of fine-tuned image-text retrieval on Flickr30K and MSCOCO datasets.
145
+
146
+ <table><tr><td></td><td colspan="6">Flickr30K</td><td colspan="6">MSCOCO</td></tr><tr><td></td><td></td><td>image-to-text</td><td></td><td></td><td>text-to-image</td><td></td><td></td><td>image-to-text</td><td></td><td></td><td>text-to-image</td><td></td></tr><tr><td></td><td>R@1</td><td>R@5</td><td>R@10</td><td>R@1</td><td>R@5</td><td>R@10</td><td>R@1</td><td>R@5</td><td>R@10</td><td>R@1</td><td>R@5</td><td>R@10</td></tr><tr><td>Unicoder-VL</td><td>86.2</td><td>96.3</td><td>99.0</td><td>71.5</td><td>90.9</td><td>94.9</td><td>62.3</td><td>87.1</td><td>92.8</td><td>48.4</td><td>76.7</td><td>85.9</td></tr><tr><td>ImageBERT</td><td>87.0</td><td>97.6</td><td>99.2</td><td>73.1</td><td>92.6</td><td>96.0</td><td>66.4</td><td>89.8</td><td>94.4</td><td>50.5</td><td>78.7</td><td>87.1</td></tr><tr><td>UNITER</td><td>87.3</td><td>98.0</td><td>99.2</td><td>75.6</td><td>94.1</td><td>96.8</td><td>65.7</td><td>88.6</td><td>93.8</td><td>52.9</td><td>79.9</td><td>88.0</td></tr><tr><td>VILLA</td><td>87.9</td><td>97.5</td><td>98.8</td><td>76.3</td><td>94.2</td><td>96.8</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>ERNIE-ViL</td><td>88.1</td><td>98.0</td><td>99.2</td><td>76.7</td><td>93.6</td><td>96.4</td><td></td><td></td><td></td><td></td><td></td><td>一</td></tr><tr><td>Oscar</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>73.5</td><td>92.2</td><td>96.0</td><td>57.5</td><td>82.8</td><td>89.8</td></tr><tr><td>VinVL</td><td>1</td><td></td><td>一</td><td>一</td><td>一</td><td>1</td><td>75.4</td><td>92.9</td><td>96.2</td><td>58.8</td><td>83.5</td><td>90.3</td></tr><tr><td>ALIGN</td><td>95.3</td><td>99.8</td><td>100.0</td><td>84.9</td><td>97.4</td><td>98.6</td><td>77.0</td><td>93.5</td><td>96.9</td><td>59.9</td><td>83.3</td><td>89.8</td></tr><tr><td>ALBEF</td><td>95.9</td><td>99.8</td><td>100.0</td><td>85.6</td><td>97.5</td><td>98.9</td><td>77.6</td><td>94.3</td><td>97.2</td><td>60.7</td><td>84.3</td><td>90.5</td></tr><tr><td>Our FILIP</td><td>96.6</td><td>100.0</td><td>100.0</td><td>87.1</td><td>97.7</td><td>99.1</td><td>78.9</td><td>94.4</td><td>97.4</td><td>61.2</td><td>84.3</td><td>90.6</td></tr></table>
147
+
148
+ Table 4: Ablation study of different components on pre-training subset of YFCC100M. I2T and T2I are abbreviations for image-to-text and text-to-image retrieval, respectively. “ZS” means zero-shot performance. Underlined numbers have the highest improvements for the corresponding metrics.
149
+
150
+ <table><tr><td rowspan="2">Model</td><td colspan="4">MSCOCO</td><td rowspan="2">ImageNet ZS Top1</td></tr><tr><td>I2TR@1</td><td>I2T R@5</td><td>T2I R@1</td><td>T2IR@5</td></tr><tr><td>Baseline (ViT-B/32)</td><td>25.0</td><td>49.5</td><td>14.7</td><td>34.7</td><td>30.4</td></tr><tr><td>w/ image augmentation</td><td>26.1</td><td>51.8</td><td>16.5</td><td>37.5</td><td>32.5</td></tr><tr><td>w/back translation</td><td>29.2</td><td>55.0</td><td>17.9</td><td>39.8</td><td>33.9</td></tr><tr><td>w/ cross-modal late interaction</td><td>30.5</td><td>55.3</td><td>18.5</td><td>40.0</td><td>34.3</td></tr><tr><td>Our FILIPbase</td><td>33.4</td><td>60.1</td><td>23.0</td><td>46.2</td><td>37.8</td></tr></table>
151
+
152
+ Table 5: Efficiency study of the cross-modal late interaction. “orig” and “late” stand for the contrastive loss based on the original cosine similarity in CLIP and our proposed cross-modal late interaction, respectively. “ZS” means zero-shot performance. We report results for ViT-B/32 trained on filtered YFCC100M with 8 V100 GPUs, with a batch size of 512 per GPU. Training time and memory consumption are tested using the same gradient checkpoint configuration. \* denotes our final setting used in other experiments.
153
+
154
+ <table><tr><td>Loss</td><td>Embed dim</td><td>Embed precision</td><td>Token %</td><td>Training time (sec/iter)</td><td>Memory (MB)</td><td>ImageNet ZS Top1</td></tr><tr><td>orig (baseline)</td><td>512</td><td>fp32</td><td>1</td><td>1.31</td><td>14300</td><td>30.4</td></tr><tr><td>late</td><td>512</td><td>fp32</td><td>100%</td><td>2.85</td><td>26000</td><td>34.6</td></tr><tr><td>late</td><td>512</td><td>fp16</td><td>100%</td><td>2.67</td><td>23468</td><td>34.5</td></tr><tr><td>late</td><td>256</td><td>fp16</td><td>100%</td><td>2.31</td><td>22382</td><td>35.2</td></tr><tr><td>late</td><td>256</td><td>fp16</td><td>50%</td><td>1.61</td><td>16336</td><td>34.5</td></tr><tr><td>late*</td><td>256</td><td>fp16</td><td>25%</td><td>1.39</td><td>16100</td><td>34.3</td></tr></table>
155
+
156
+ Efficiency Study of Cross-modal Late Interaction. Since the late interaction mechanism in Section 3.1.1 requires to calculate the similarity between all visual and textual tokens, its efficiency can be a problem when employed in large-scale distributed training. As described in Section 3.1.1, we make several attempts to address the issue. Table 5 shows the efficiency improvement on zero-shot classification on ImageNet when these attempts are applied. As can be seen, these attempts improve the efficiency of late interaction without accuracy drop. Combining all three attempts achieves only slightly slower training and larger memory consumption than the original loss in CLIP.
157
+
158
+ # 4.5 VISUALIZATION OF FINE-GRAINED ALIGNMENT
159
+
160
+ In this section, we visualize FILIP’s capability of capturing fine-grained cross-modal correspondence using the method of word-patch alignment. To make a fair comparison, we use our FILIPbase trained on YFCC100M and CLIP’s ViT-B/32, which are of the same size, for visualization. Each image is patchified to $7 \times 7$ image patches. More visualization results can be found in Appendix A.4.
161
+
162
+ ![](images/ac03918fdbcf8c481cbca69053abf9c08404a9d6a22fe1e112eaf3f50e56731c.jpg)
163
+ Figure 2: Visualizations of word-patch alignment for 4 classes of the ImageNet dataset and “a photo of a $\{ { \mathrm { l a b e l } } \}$ .” is the prompt. Numbers in the parentheses after the class label indicate the location indices of the class label in the tokenized textual sequence. The correct predictions are highlighted by opaque patches with the class label indices in red.
164
+
165
+ Visualization Method. The word-patch alignment is performed based on the token-wise similarity between the image patches and textual tokens. Specifically, for the $k$ -th image patch, the location index of textual token with the largest similarity with it $\overset { \cdot } { m } _ { k } ^ { I }$ in Equation (4)) is considered as its predicted label, and is placed at the center of it. Take class “balloon” as an example. There are 8 tokens in the tokenized textual sequence “[BOS] a photo of a balloon. [EOS]”, and the location index of the class label “balloon” is $\mathbf { \Delta } ^ { 6 6 } 5 ^ { , 9 }$ . Note that one class label may be tokenized to more than one token. Location indices of textual tokens corresponding to the class label are highlighted in red, while the others are marked in white. A desired model that learns fine-grained representations would predict image patches of the target object to red indices.
166
+
167
+ Observations. Figure 2 shows the word-patch alignment results for FILIP and CLIP on 4 classes from the ImageNet dataset. As can be seen, FILIP exhibits the finer-grained understanding of an image in the following aspects. (i) A single object: From the visualization of class “small white butterfly”, the image patches covering the object are all classified correctly; (ii) Same object in different shapes: From the visualizations of class “balloon” and “lifeboat”, image patches corresponding to all target objects with different shapes and locations are correctly classified; (iii) Key Components of an object: For class “electric locomotive”, there are two key components crucial to correctly classifying the image, i.e., “electric” and “locomotive”, whose corresponding textual token indices are $\mathbf { \bar { \Psi } } ^ { 6 6 } 5 ^ { \mathrm { , } }$ and $\because 6 ^ { , }$ , respectively. As can be seen, image patches matching these two key components are respectively correctly classified. On the other hand, CLIP can not correctly align image patches with corresponding textual tokens. Compared with Kim et al. (2021) which uses an extra optimal transport to align the textual word and image patch distributions, the word-patch alignment can be simply automatically learned by our method.
168
+
169
+ # 5 CONCLUSION AND FUTURE WORK
170
+
171
+ This paper introduces FILIP, a simple yet generic framework towards fine-grained vision-language pre-training. By using a token-wise maximum similarity, our method learns fine-grained representation for patches in the images and words in the sentences. While it achieves competitive results against several large-scale multi-modal pre-training on various downstream tasks, both its architecture and training procedure can still be optimized to improve its performance. In the future, a more advanced image encoder as well as a well-designed interaction layer can be used to boost the performance. Furthermore, we can further add more masked language/image loss to support more generation tasks. To this end, we hope to extend FILIP as a generic and unified interface for solving a large variety of vision-language tasks.
172
+
173
+ # REFERENCES
174
+
175
+ Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. In Advances in neural information processing systems, 2020.
176
+
177
+ Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. Conceptual 12M: Pushing webscale image-text pre-training to recognize long-tail visual concepts. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
178
+
179
+ Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. preprint arXiv:1604.06174, 2016.
180
+
181
+ Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. Uniter: Universal image-text representation learning. In European conference on computer vision, pp. 104–120. Springer, 2020.
182
+
183
+ Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation strategies from data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 113–123, 2019.
184
+
185
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Annual Conference of the North American Chapter of the Association for Computational Linguistics, 2019.
186
+
187
+ Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, et al. Cogview: Mastering text-to-image generation via transformers. arXiv preprint arXiv:2105.13290, 2021.
188
+
189
+ Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE international conference on computer vision, pp. 1422–1430, 2015.
190
+
191
+ Xiao Dong, Xunlin Zhan, Yangxin Wu, Yunchao Wei, Xiaoyong Wei, Minlong Lu, and Xiaodan Liang. M5product: A multi-modal pretraining benchmark for e-commercial product downstream tasks. Preprint arXiv:2109.04275, 2021.
192
+
193
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2020.
194
+
195
+ Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. arXiv preprint arXiv:2006.06195, 2020.
196
+
197
+ Andreas Griewank and Andrea Walther. Algorithm 799: revolve: an implementation of checkpointing for the reverse or adjoint mode of computational differentiation. ACM Transactions on Mathematical Software (TOMS), 26(1):19–45, 2000.
198
+
199
+ Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8129–8138, 2020.
200
+
201
+ Zhicheng Huang, Zhaoyang Zeng, Yupan Huang, Bei Liu, Dongmei Fu, and Jianlong Fu. Seeing out of the box: End-to-end pre-training for vision-language representation learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12976–12985, 2021.
202
+
203
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pp. 448–456. PMLR, 2015.
204
+
205
+ Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V Le, Yunhsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, 2021.
206
+
207
+ Omar Khattab and Matei Zaharia. Colbert: Efficient and effective passage search via contextualized late interaction over bert. In International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 39–48, 2020.
208
+
209
+ Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision. In International Conference on Machine Learning, 2021.
210
+
211
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, volume 25, pp. 1097–1105, 2012.
212
+
213
+ Kuang-Huei Lee, Xi Chen, Gang Hua, Houdong Hu, and Xiaodong He. Stacked cross attention for image-text matching. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 201–216, 2018.
214
+
215
+ Gen Li, Nan Duan, Yuejian Fang, Ming Gong, and Daxin Jiang. Unicoder-vl: A universal encoder for vision and language by cross-modal pre-training. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 11336–11344, 2020a.
216
+
217
+ Junnan Li, Ramprasaath R. Selvaraju, Akhilesh Deepak Gotmare, Shafiq Joty, and Steven Xiong, Caiming andHoi. Align before fuse: Vision and language representation learning with momentum distillation. Technical Report arXiv:2107.07651, 2021a.
218
+
219
+ Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. Preprint arXiv:1908.03557, 2019.
220
+
221
+ Wei Li, Can Gao, Guocheng Niu, Xinyan Xiao, Hao Liu, Jiachen Liu, Hua Wu, and Haifeng Wang. Unimo: Towards unified-modal understanding and generation via cross-modal contrastive learning. In Annual Meeting of the Association for Computational Linguistics, 2021b.
222
+
223
+ Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In European Conference on Computer Vision, pp. 121–137. Springer, 2020b.
224
+
225
+ Junyang Lin, Rui Men, An Yang, Chang Zhou, Ming Ding, Yichang Zhang, Peng Wang, Ang Wang, Le Jiang, Xianyan Jia, et al. M6: A chinese multimodal pretrainer. Preprint arXiv:2103.00823, 2021.
226
+
227
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ European conference on computer vision, pp. 740–755. Springer, 2014.
228
+
229
+ I. Loshchilov and F. Hutter. Sgdr: Stochastic gradient descent with warm restarts. ICLR 2017 (5th International Conference on Learning Representations), 2016.
230
+
231
+ Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. Vilbert: pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In International Conference on Neural Information Processing Systems, pp. 13–23, 2019.
232
+
233
+ Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. In International Conference on Learning Representations, 2018.
234
+
235
+ Fabian Pedregosa, Gael Varoquaux, Alexandre Gramfort, Vincent Michel, Bertrand Thirion, Olivier ¨ Grisel, Mathieu Blondel, Peter Prettenhofer, Ron Weiss, Vincent Dubourg, et al. Scikit-learn: Machine learning in python. the Journal of machine Learning research, 12:2825–2830, 2011.
236
+
237
+ Bryan A Plummer, Liwei Wang, Chris M Cervantes, Juan C Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer imageto-sentence models. In IEEE international conference on computer vision, pp. 2641–2649, 2015.
238
+
239
+ Di Qi, Lin Su, Jia Song, Edward Cui, Taroon Bharti, and Arun Sacheti. Imagebert: Cross-modal pre-training with large-scale weak-supervised image-text data. arXiv preprint arXiv:2001.07966, 2020.
240
+
241
+ Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
242
+
243
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
244
+
245
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. Preprint arXiv:2103.00020, 2021.
246
+
247
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21:1–67, 2020.
248
+
249
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. Preprint arXiv:2102.12092, 2021.
250
+
251
+ Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28: 91–99, 2015.
252
+
253
+ Ikuro Sato, Hiroki Nishimura, and Kensuke Yokoi. Apac: Augmented pattern classification with neural networks. Technical Report arXiv:1505.03229, 2015.
254
+
255
+ Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. In IEEE international conference on computer vision, pp. 618–626, 2017.
256
+
257
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Improving neural machine translation models with monolingual data. In Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 86–96, 2016a.
258
+
259
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1715–1725, 2016b.
260
+
261
+ Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2556–2565, 2018.
262
+
263
+ Bart Thomee, David A Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. Yfcc100m: The new data in multimedia research. Communications of the ACM, 59(2):64–73, 2016.
264
+
265
+ Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. In Computer Vision–ECCV 2020: 16th European Conference, pp. 776–794. Springer, 2020.
266
+
267
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. In ´ International Conference on Machine Learning, pp. 10347–10357. PMLR, 2021.
268
+
269
+ Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao. Simvlm: Simple visual language model pretraining with weak supervision. Preprint arXiv:2108.10904, 2021.
270
+
271
+ Qizhe Xie, Zihang Dai, Eduard Hovy, Thang Luong, and Quoc Le. Unsupervised data augmentation for consistency training. In Advances in Neural Information Processing Systems, volume 33, 2020a.
272
+
273
+ Qizhe Xie, Minh-Thang Luong, Eduard Hovy, and Quoc V Le. Self-training with noisy student improves imagenet classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10687–10698, 2020b.
274
+
275
+ Yang You, Jing Li, Sashank Reddi, Jonathan Hseu, Sanjiv Kumar, Srinadh Bhojanapalli, Xiaodan Song, James Demmel, Kurt Keutzer, and Cho-Jui Hsieh. Large batch optimization for deep learning: Training bert in 76 minutes. In International Conference on Learning Representations, 2020.
276
+
277
+ Fei Yu, Jiji Tang, Weichong Yin, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. Ernie-vil: Knowledge enhanced vision-language representations through scene graphs. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 3208–3216, 2021.
278
+
279
+ Xunlin Zhan, Yangxin Wu, Xiao Dong, Yunchao Wei, Minlong Lu, Yichi Zhang, Hang Xu, and Xiaodan Liang. Product1m: Towards weakly supervised instance-level product retrieval via crossmodal pretraining. In International Conference on Computer Vision, 2021.
280
+
281
+ Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. Vinvl: Revisiting visual representations in vision-language models. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5579–5588, 2021.
282
+
283
+ # A APPENDIX
284
+
285
+ # A.1 ETHICAL ISSUES IN DATA COLLECTION
286
+
287
+ When collecting the large-scale image-text pairs from the Internet, we perform person-name substitutions as in Changpinyo et al. (2021), in order to protect the privacy of the individuals appearing in the text. Specifically, we replace each person name appeared in the text with a special $< p e r s o n >$ token. Besides, we also disgard image-text pairs whose text contains sensitive words.
288
+
289
+ # A.2 DATASETS SUMMARY
290
+
291
+ Table 6 shows the number of image-text pairs of each datasets used in different pre-training methods.
292
+
293
+ Table 6: Number of image-text pairs used in the pre-training of FILIP, CLIP and ALIGN.
294
+
295
+ <table><tr><td rowspan="2"></td><td colspan="4">FILIP</td><td rowspan="2">CLIP (Radford et al. 2021)</td><td rowspan="2">ALIGN (Jia et al., 2021)</td></tr><tr><td>CC3M</td><td>CC12M</td><td>YFCC100M</td><td>FILIP300M</td></tr><tr><td>#</td><td>3M</td><td>10M</td><td>26M</td><td>300M</td><td>400M</td><td>1800M</td></tr></table>
296
+
297
+ # A.3 DETAILED EXPERIMENTAL SETTINGS
298
+
299
+ Table 7: The architecture parameters for FILIP models.
300
+
301
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Embedding dimension</td><td rowspan="2">Input resolution</td><td colspan="3">Image Encoder</td><td colspan="3">Text Encoder</td></tr><tr><td>#layers</td><td>width</td><td>#heads</td><td>#layers</td><td>width</td><td>#heads</td></tr><tr><td>FILIPbase</td><td>256</td><td>224× 224</td><td>12</td><td>768</td><td>12</td><td>12</td><td>512</td><td>8</td></tr><tr><td>FILIPlarge</td><td>256</td><td>224× 224</td><td>24</td><td>1024</td><td>16</td><td>12</td><td>768</td><td>12</td></tr></table>
302
+
303
+ Model Architectures. We follow the same architecture design as CLIP, for both ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ and $\mathrm { F I L I P _ { l a r g e } }$ , except that we reduce the embedding dimension from 512/768 to 256 for the efficiency of loss computation. Table 7 describes the details of architectures.
304
+
305
+ Details for Pre-training and Hyperparameters. For the implementation of the contrastive loss, following CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021), we also set the temperature in the softmax function to be a learnable parameter and initialize it as 0.07. For the pre-training, we use the LAMB optimizer implemented by the cybertronai’s open-source repository (https: //github.com/cybertronai/pytorch-lamb). For the learning rate scheduler, we first assign a base learning rate and then linearly warm it up to the peak learning rate according to the effective total batch size by a square root strategy, $p e a k \_ l r = b a s e \_ l r \times \sqrt { \frac { t o t a l \_ b s } { 5 1 2 } }$ . We note that a large weight decay is crucial to stabilize training and improve generalization. Specifically, we found that the training stability is a challenging issue when applying mix-precision training to large-scale models, i.e., the training is extremely unstable and the NaN loss easily happens. Recent works
306
+
307
+ Table 8: Common hyperparameters used for FILIP pre-training.
308
+
309
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Vocabulary size Initial temperature</td><td>49408</td></tr><tr><td>LAMB β1</td><td>0.07 0.9</td></tr><tr><td>LAMB β2</td><td>0.999</td></tr><tr><td>LAMB e</td><td>10-4</td></tr><tr><td>Warm-up iters</td><td>3000</td></tr><tr><td>Training epochs</td><td>30</td></tr></table>
310
+
311
+ Table 9: Model- and dataset-specific hyperparameters used for FILIP pre-training. Numbers in batch size represent the total batch size across all workers and are calculated as: batch size per GPU $\times$ #GPUs. FILIP340M is the combination of FILIP300M, YFCC100M, CC12M and CC3M.
312
+
313
+ <table><tr><td>Model</td><td>Dataset</td><td>Batch size</td><td>Base LR</td><td>Weight decay</td></tr><tr><td>FILIPbase</td><td>YFCC100M</td><td>1024×8</td><td>6×10-3</td><td>3e-2</td></tr><tr><td>FILIPbase</td><td>FILIP340M</td><td>320 ×128</td><td>2×10-3</td><td>3e-3</td></tr><tr><td>FILIPlarge</td><td>FILIP340M</td><td>160×192</td><td>1.5 ×10-3</td><td>3e-3</td></tr></table>
314
+
315
+ DALL-E (Ramesh et al., 2021) and Cogview (Ding et al., 2021) also notice this issue and provide their solutions. However, we found that simply increasing the weight decay and applying the trick of removing the weight decay of specific parameters as described in Section 4.1 work for our case. The base learning rate and weight decay are selected manually via observing the performance at the early training stage. Table 8 summarizes the common hyperparameters and Table 9 shows the model- and dataset-specific hyperparameters for FILIP pre-training.
316
+
317
+ Details for Image-text Retrieval. Following previous works (Jia et al., 2021; Li et al., 2021a), for Flickr30K, we test on the 1K test set with or without fine-tuning on the 30K training set, while for MSCOCO, we test on the 5K test set with or without fine-tuning on the 113K training set. We use the similarity between image and text for ranking and use the contrastive loss for fine-tuning. Since there are multiple texts for each image in these two datasets, we change the ground-truth label of contrastive loss to consider multiple positives, by assigning a probability of 1/#positive to each positive following ALBEF (Li et al., 2021a). Besides, we also use prompts during evaluation for both datasets, see Appendix A.5 for details. Table 10 shows the hyperparameters for image-text retrieval fine-tuning.
318
+
319
+ Table 10: Hyperparameters used for image-text retrieval fine-tuning.
320
+
321
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Image size</td><td>392 × 392</td></tr><tr><td>Training epochs</td><td>3 LAMB</td></tr><tr><td>Optimizer Batch size</td><td>5120</td></tr><tr><td>Base LR</td><td>2×10-4</td></tr><tr><td></td><td></td></tr><tr><td>Weight decay</td><td>3×10-4</td></tr></table>
322
+
323
+ # A.4 MORE VISUALIZATIONS OF WORD-PATCH ALIGNMENT AND GRAD-CAM HEATMAPS
324
+
325
+ In Figure 3, we visualize the cross-modal alignment of the proposed method for more images, in terms of both word-patch alignment as described in Section 4.5 and Grad-CAM heatmaps (Selvaraju et al., 2017). We compute the Grad-CAM heatmaps based on the average self-attention maps over the image patches classified to targeted textual tokens (i.e., the textual token(s) corresponding to the class label in the ImageNet dataset) in the last layer of the image encoder. We average the heatmaps over all attention heads. As can be seen, our proposed model learns meaningful alignment between image patches and textual tokens.
326
+
327
+ # A.5 PROMPT TEMPLATES FOR DOWNSTREAM TASKS
328
+
329
+ Image Classification. Table 11 shows the prompt templates for different image classification datasets in the form of “ [prefix] $\{ { \mathrm { l a b e l } } \}$ , [category description]. [suffix]. ” in Equation (6). There are three components to be determined in the template, i.e., the prefix, the category description and the suffix. For each component, we select several well-performed ones for each dataset. Then we use the full combinations of all three components as the set of prompt templates for ensemble. For instance, we use 5 prefixes, no category descriptions, and 6 suffixes for dataset ImageNet. Then the total number of prompt templates for this dataset is: $5 \times 1 \times 6 = 3 0$ .
330
+
331
+ ![](images/20fbe4e2808cbe21836a966ce2b5bca908857a06e2de03675b55cc628fd8d423.jpg)
332
+ Figure 3: More visualizations on different classes of ImageNet dataset. Numbers in the parentheses after the class label indicate the location indices of class label in the tokenized textual sequence.
333
+
334
+ Table 11: Prompt templates used for 12 downstream image classification tasks.
335
+
336
+ <table><tr><td rowspan=1 colspan=1>Dataset</td><td rowspan=1 colspan=1>Prefix</td><td rowspan=1 colspan=1>Categorydescription</td><td rowspan=1 colspan=1>Suffix</td></tr><tr><td rowspan=1 colspan=1>CIFAR10</td><td rowspan=1 colspan=1>“a photo of a&quot;,“a jpeg photo ofa”,&quot;a painting ofa”,&quot;itap of a”,“graffiti of a”,“a cartoon”,“adoodle”</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>None,“It&#x27;s common in daily life”,“It&#x27;s cute&quot;,“It&#x27;s ugly”,“It&#x27;s weird”,&quot;Hope you like it”</td></tr><tr><td rowspan=1 colspan=1>CIFAR100</td><td rowspan=1 colspan=1>“a jpeg photo of a”,“a painting of a”,“a good photo of a”,&quot;abad photo of a”,“a photo of a”,“itap of a”,“a rendering of a”</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>None,“It&#x27;s common in dailylife&quot;,“It&#x27;sbeautiful&quot;,“It&#x27;sugly”,&quot;I like it”,“T take it to-day”</td></tr><tr><td rowspan=1 colspan=1>Caltech101</td><td rowspan=1 colspan=1>“a photo of a”,“a cropped photo of a”,“a good photo ofa&quot;,&quot;a bad photo of a”</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>None,“I like it”,“I hate it&quot;,&quot;It&#x27;s ugly”,&quot;It&#x27;s cute&quot;</td></tr><tr><td rowspan=1 colspan=1>Stanford-Car</td><td rowspan=1 colspan=1>“a photo of a”,“a close-upphoto of a&quot;,“a good photo ofa”,“a bad photo of a”</td><td rowspan=1 colspan=1>“a type of car”,“a type of auto-mobile”</td><td rowspan=1 colspan=1>“I like it”,“It belongs to myfriend’,“It&#x27;s brand new”,“It’&#x27;s popular recently”,“It&#x27;s impor-tant to me”,“I take it today”</td></tr><tr><td rowspan=1 colspan=1>Flowers102</td><td rowspan=1 colspan=1>“a photo of a (many)”,“a ren-dering of a (many)”, “itap of a(many)”</td><td rowspan=1 colspan=1>“a type offlower&quot;,&quot;a typeof bloom”</td><td rowspan=1 colspan=1>“It&#x27;s beautiful”,“It&#x27;s from mybest friend”,“It gives out a sweet perfume/fragrance</td></tr><tr><td rowspan=1 colspan=1>ImageNet</td><td rowspan=1 colspan=1>“a photo of a&quot;,&quot;a good photo ofa”,&quot;a bad photo of a”,“a close-up photo of a”,“itap of a”</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>“I like it”,“It&#x27;s common indaily life&quot;,“It&#x27;s not common in daily life”,“It&#x27;s ugly”,“It&#x27;scute&quot;,&quot;It&#x27;s beautiful&quot;</td></tr><tr><td rowspan=1 colspan=1>Food101</td><td rowspan=1 colspan=1>“a photo of my”,“a close-up photo of my”,“itap of my”</td><td rowspan=1 colspan=1>“atypeoffood”,“a typeof nourish-ment”</td><td rowspan=1 colspan=1>“I made it today”,“I like it”,“I hate it”,&quot;It&#x27;s delicious&quot;,&quot;It&#x27;swith nice flavour”,“It&#x27;s withterrible flavour&quot;,“It&#x27;s popularrecently”</td></tr><tr><td rowspan=1 colspan=1>SUN397</td><td rowspan=1 colspan=1>“a photo of a”,“a good photo ofa&quot;,“a bad photo of a”,“a bright photo of a&quot;,a dark photo of a”,“a black and white photo of a&quot;,“a nice scene of a”,“a terriblescene of a”</td><td rowspan=1 colspan=1>None</td><td rowspan=1 colspan=1>None,“I like it”,“I hate it”,“It&#x27;s beautiful”,“It&#x27;s commonin daily life&quot;,&quot;It&#x27;s important tome”</td></tr><tr><td rowspan=1 colspan=1>DTD</td><td rowspan=1 colspan=1>“itap of a”,“a close-up photo ofa”</td><td rowspan=1 colspan=1>“texture”,“surface&quot;,“material”</td><td rowspan=1 colspan=1>None,“It&#x27;s out of style”,“It&#x27;s popular in old days”,“It&#x27;sugly”,&quot;It&#x27;s beautiful”</td></tr><tr><td rowspan=1 colspan=1>Aircrafts</td><td rowspan=1 colspan=1>“a photo of the”,“a close-up photo of the&quot;,&quot;a good photo ofthe”,&quot;a pixelated photo of the”</td><td rowspan=1 colspan=1>“a typeof plane”,“a typeof aircraft”,“atype of airliner”</td><td rowspan=1 colspan=1>None,&quot;I like it”,“It&#x27;s important to me”,“I take it today”,“Hopeyou like it”</td></tr><tr><td rowspan=1 colspan=1>Oxford Pet</td><td rowspan=1 colspan=1>“a photo of my”,“a low reso-lution photo of my”,“a goodphoto of my”</td><td rowspan=1 colspan=1>“a type of pet”,“a type of dogor cat”</td><td rowspan=1 colspan=1>None,“It&#x27;s cute”,“It&#x27;s impor-tant to me”,“I like it”,“It’sbeautiful&quot;</td></tr><tr><td rowspan=1 colspan=1>EuroSAT</td><td rowspan=1 colspan=1>“a photo of a”,“apainting of a”,&quot;a cropped photo of a”,&quot;a good photo of a”,“a blurry photo ofa”</td><td rowspan=1 colspan=1>None,“an ex-ample of aerialor satellite im-ages”</td><td rowspan=1 colspan=1>None,“I like it”,“It&#x27;s takenfrom an aircraft or some flying object”,&quot;It&#x27;s collected by imag-ing satellites”</td></tr></table>
337
+
338
+ Table 12: Prompt templates used for zero-shot image-text retrieval on Flickr30K and MSCOCO datasets.
339
+
340
+ <table><tr><td rowspan=1 colspan=1>Dataset</td><td rowspan=1 colspan=1>Task</td><td rowspan=1 colspan=1>Prefix</td><td rowspan=1 colspan=1>Suffix</td></tr><tr><td rowspan=1 colspan=1>Flickr30K</td><td rowspan=1 colspan=1>image-to-text retrievaltext-to-image retrieval</td><td rowspan=1 colspan=1>“a good photo of the”“a good photo of”</td><td rowspan=1 colspan=1>“I hate it.”None</td></tr><tr><td rowspan=1 colspan=1>MSCOCO</td><td rowspan=1 colspan=1>image-to-text retrievaltext-to-image retrieval</td><td rowspan=1 colspan=1>“a good photo of”None</td><td rowspan=1 colspan=1>“It is ugly.”None</td></tr></table>
341
+
342
+ Image-text Retrieval. Following CLIP (Radford et al., 2021), we use prompt in zero-shot imagetext retrieval for both Flickr30K and MSCOCO datasets. The prompt is selected by the same rule as described in Section 3.1.2, except that we do not use “[category description]” here. Table 12 shows the prompt templates for zero-shot image-text retrieval on Flickr30K and MSCOCO datasets.
343
+
344
+ # A.6 LINEAR PROBE ON IMAGE CLASSIFICATION
345
+
346
+ In this section, we evaluate FILIP on the linear probe for image classification. Following common linear probe setting, we freeze the whole backbone network and only finetune the last linear classifier. Since we remove the “[CLS]” token in our vision encoder, we apply a mean pooling over all the other visual tokens to aggregate them into a global image representation which is then fed into the linear classifier.
347
+
348
+ Setting. Following CLIP, we train the logistic regression classifier using scikit-learn’s L-BFGS implementation (Pedregosa et al., 2011), with maximum 1,000 iterations on those 11 datasets except ImageNet. For ImageNet, we use a pytorch-based codebase to accelerate the training with GPU. Following Doersch et al. (2015), we adopt a Batch Normalization (Ioffe & Szegedy, 2015) layer before the linear classifier which is beneficial to stabilize the mixed-precision training. Random resized crop and horizontal flipping are used to augment training data. We use the cosine learning rate scheduler with a linear warmup of 10 epochs. More hyperparameters used in linear probe on ImageNet are shown in Table 13.
349
+
350
+ Table 13: Hyperparameters used for linear probe image classification on ImageNet.
351
+
352
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Image size</td><td>224 × 224</td></tr><tr><td>Training epochs</td><td>90</td></tr><tr><td>Optimizer</td><td>SGD</td></tr><tr><td>Batch size</td><td>4096</td></tr><tr><td>Base LR</td><td>0.1</td></tr><tr><td>Weight decay</td><td>0</td></tr></table>
353
+
354
+ Results. Table 14 compares the linear probe performance of our proposed FILIP with CLIP over 12 datasets. Our ${ \mathrm { F I L I P } } _ { \mathrm { b a s e } }$ (resp. ${ \mathrm { F I L I P } } _ { \mathrm { l a r g e } }$ ) achieves $8 5 . 5 \%$ (resp. $9 1 . 0 \% )$ average Top-1 accuracy over 12 downstream tasks, which provides noticeable improvements, i.e., $1 . 8 \%$ (resp. $1 . 2 \%$ ) higher, compared to its CLIP’s counterpart. This implies that our FILIP learns more powerful vision features which may potentially facilitate border downstream vision tasks.
355
+
356
+ # A.7 COMPARISON WITH KHATTAB & ZAHARIA (2020)
357
+
358
+ As is stated in Section 3.1, compared to Khattab & Zaharia (2020), besides being the first to apply the late interaction to contrastive learning for vision-language pre-training, we make two other modifications, i.e., removing padded tokens and using average over non-padded tokens instead of summation. In the following, we show that these two modifications are crucial to the performance, and the quality of finer-granular word-patch alignment.
359
+
360
+ For comparison, we replace the proposed cross-modal late interaction in FILIPbase with the original late interaction in Khattab & Zaharia (2020). Following the setting in Section 4.4, we pre-train on
361
+
362
+ Table 14: Top-1 accuracy $( \% )$ of linear probe on image classification on 12 datasets. Our FILIP outperforms CLIP by $1 . 2 { \sim } 1 . 8 \%$ points on average.
363
+
364
+ <table><tr><td></td><td>CIRIIIO</td><td>CEIRIIIO</td><td>srrprrrets [Erleaer</td><td>TiroTenIG</td><td></td><td>[o1poo</td><td>L6610S</td><td></td><td>Viririt</td><td>siorprttrt</td><td>JoIA aneee</td><td>Aaee</td></tr><tr><td>CLIP-ViT-B/32 FILIPbase</td><td>95.1 95.3</td><td>80.5 80.3</td><td>93.0 95.0</td><td>81.8 78.6</td><td>96.6 98.7</td><td>88.8 86.2</td><td>76.6 77.9</td><td>76.5 78.1</td><td>52.0 76.6</td><td>90.0 88.0</td><td>97.0 76.1 95.9 75.8</td><td>83.7 85.5+1.8</td></tr><tr><td>CLIP-ViT-L/14 FILIPlarge</td><td>98.0 97.9</td><td>87.5 87.0</td><td>96.5 97.2</td><td>90.9 89.0</td><td>99.2 99.6</td><td>95.2 94.6</td><td>81.8 82.1 83.2</td><td>69.4 83.9 84.8</td><td>95.1 93.5</td><td>98.2 97.3</td><td>83.9 84.5</td><td>89.8 91.0+1.2</td></tr></table>
365
+
366
+ the filtered YFCC100M with mixed-precision using 8 V100 GPUs. The batch size per GPU is 512 and the dimension of the token feature is 256. We report results with the top $2 5 \%$ tokens (selected using the method in Section 3.1) during training. Note that the original late interaction in Khattab & Zaharia (2020) is sensitive to the temperature in the softmax function, and we report the best result among several initialization values of the temperature.
367
+
368
+ Effect to Performance. Table 15 shows the comparison on zero-shot ImageNet classification. When these two modifications are removed, the zero-shot Top-1 accuracy of ImageNet drops from 34.3 to 32.7.
369
+
370
+ Table 15: Comparison of Top-1 Accuracy $\%$ between the proposed cross-modal late interaction loss and Khattab & Zaharia (2020) on zero-shot ImageNet classification.
371
+
372
+ <table><tr><td>ours</td><td>late interaction in Khattab &amp; Zaharia (2020)</td></tr><tr><td>34.3</td><td>32.7</td></tr></table>
373
+
374
+ Effect to the Word-patch Alignment In Figure 4, we compare the word-patch alignment using the models trained with the proposed cross-modal late interaction and the late interaction in Khattab & Zaharia (2020). According to the visualizations, using the original late interaction in Khattab & Zaharia (2020) leads to less accurate word-patch alignment. Specifically, the object patches are often aligned to the padded tokens instead of class names. We speculate this is because the padded tokens learn similar representations as existing key textual tokens, similar to the finding in Section 3.2 of Khattab & Zaharia (2020) that padding with masked tokens (which is called “query augmentation” in Khattab & Zaharia (2020)) tend to “re-weigh existing terms based on their importance for matching the query”.
375
+
376
+ # A.8 ABLATION ON THE FULL PRE-TRAINING DATASET
377
+
378
+ In Table 16, we compare the proposed cross-modal late interaction loss with the original CLIP loss (Radford et al., 2019) on the full pre-training dataset introduced in Section 3.3. In Table 16, CLIP denotes the results reported by CLIP paper, ${ \mathrm { C L I P } } _ { \mathrm { r e p } }$ is our reproduced CLIP version with the original contrastive loss using exactly the same architecture on the same pre-training dataset as $\mathrm { F I L I P _ { b a s e } }$ . As can be seen, the $\mathrm { F I L I P _ { b a s e } }$ has 6.7 points higher average accuracy than the ${ \mathrm { C L I P } } _ { \mathrm { r e p } }$ over 12 datasets. This further verifies that the performance gain of FILIP comes from the proposed cross-modal late interaction, rather than the data or architecture.
379
+
380
+ # A.9 INFERENCE TIME OF IMAGE-TEXT RETRIEVAL
381
+
382
+ Setting. In this section, we test the inference time of both image retrieval and text retrieval on the test set of Flickr30K and MSCOCO. We compare our proposed model $\mathrm { F I L I P _ { l a r g e } }$ against SCAN (Lee et al., 2018) and CLIP (ViT-L/14) (Radford et al., 2021) . We test the inference time of CLIP and SCAN using their released code. For image retrieval, we precompute the image features and report the inference time for one text query, which contains (i) the time to extract the feature of one text query, and (ii) the time of similarity calculation with all images and ranking. Similarly, for text retrieval, we precompute the text features and report the inference time for one image query, which contains (i) the time to extract the feature of one image query, and (ii) the time of similarity calculation with all texts and ranking. The test set of Flickr30k contains 1000 images and 5000 texts, while the test set of COCO contains 5000 images and 25000 texts. The time is averaged over 1000 runs.
383
+
384
+ ![](images/a5708b0450ce3bc341085d20067e241dfa3db9047c48f75fee7bd4b01f5c1f76.jpg)
385
+ Figure 4: Comparison of word-patch alignment between the proposed cross-modal late interaction and that in ColBERT (Khattab & Zaharia, 2020). “a photo of a $\{ { \mathrm { l a b e l } } \}$ .” is the prompt. Numbers in the parentheses after the class label indicate the location indices of the class label in the tokenized textual sequence. The correct predictions to the class labels are highlighted by opaque patches with the class label indices in red. Incorrect predictions to the padded tokens are highlighted by opaque patches with the padded token indices in blue.
386
+
387
+ Table 16: Top-1 accuracy $\textcircled{9}$ on image classification on 12 datasets. ${ \mathrm { C L I P } } _ { \mathrm { r e p } }$ is our reproduced CLIP trained with the same training data and evaluated with the same prompts as our FILIP. With the same backbone architecture, our FILIP significantly improves the zero-shot Top-1 average accuracy over 12 datasets.
388
+
389
+ <table><tr><td></td><td>CIIIII</td><td>CEIRII</td><td>GErreaaer</td><td>srrprrtts</td><td>Tirsoii</td><td>TO1poo0</td><td>163305</td><td></td><td>Sirit</td><td>sodpptrr JHtoII</td><td>1ne</td><td>eee</td></tr><tr><td>CLIP</td><td>91.3</td><td>65.1</td><td>87.9</td><td>59.4</td><td>66.7</td><td>84.4</td><td>63.2</td><td>44.5</td><td>21.2</td><td>87</td><td>49.4 63.2</td><td>65.3</td></tr><tr><td>CLIPrep</td><td>82.0</td><td>57.5</td><td>89.9</td><td>45.1</td><td>80.7</td><td>75.1</td><td>63.6 46.7</td><td>33.7</td><td>82.7</td><td>49.0</td><td>64.2</td><td>64.2</td></tr><tr><td>FILIPbase</td><td>86.9</td><td>65.5</td><td>91.9</td><td>55.4</td><td>85.3</td><td>82.8 69.1</td><td>49.3</td><td>57.2</td><td>88.1</td><td>49.9</td><td>68.8</td><td>70.9</td></tr></table>
390
+
391
+ Table 17: Comparison on performance and inference time of image-text retrieval on Flickr30K and MSCOCO datasets.
392
+
393
+ <table><tr><td></td><td colspan="10">Flickr30K</td><td colspan="6">Inference time</td></tr><tr><td></td><td>image-&gt;text</td><td colspan="3"></td><td colspan="3"></td><td colspan="5">MSCOCO</td><td colspan="3">Flickr30K</td><td colspan="2">MSCOCO</td></tr><tr><td>R@1</td><td></td><td>R@5</td><td>R@10</td><td>R@1</td><td>text-&gt;image R@5</td><td>R@10</td><td>R@1</td><td>image-&gt;text R@5</td><td>R@10</td><td>R@1</td><td>text-&gt;image R@5</td><td>R@10</td><td>i-to-t</td><td>t-to-i</td><td>i-to-t</td><td>t-to-i</td></tr><tr><td>SCAN</td><td>67.4</td><td>90.3</td><td>95.8</td><td>48.6</td><td>77.7</td><td>85.2</td><td>50.4</td><td>82.2</td><td>90.0</td><td>38.6</td><td>69.3</td><td>80.4</td><td></td><td></td><td></td><td>21.3s</td><td>26ms</td></tr><tr><td>CLIP</td><td>88.0</td><td>98.7</td><td>99.4</td><td>68.7</td><td>90.6</td><td>95.2</td><td></td><td>58.4 81.5</td><td>88.1</td><td>37.8</td><td>62.4</td><td></td><td>72.2</td><td>4.47s 23ms</td><td>7ms 8ms</td><td>24ms</td><td>9ms</td></tr><tr><td>FILIP</td><td>96.6</td><td>100.0</td><td>100.0</td><td>87.1</td><td>97.7</td><td>99.1</td><td>78.9</td><td>94.4</td><td>97.4</td><td>61.2</td><td>84.3</td><td>90.6</td><td></td><td>24ms</td><td>8ms</td><td>26ms</td><td>9ms</td></tr></table>
394
+
395
+ Results. The inference time of retrieval is shown in Table 17. Benefitting from the efficiency optimizations (i.e., FP16 quantization and reduced feature dimension) in Section 3.1, the inference time of FILIP is close to CLIP. In image retrieval, SCAN is slightly faster than FILIP on Flickr30K with 1000 images, because SCAN uses a lightweight GRU as the text encoder. However, SCAN is much slower than FILIP (i.e., about $1 7 \mathrm { m s }$ slower per query) on MSCOCO with more (i.e., 5000) images because of the slower computation involved in the two-stage stacked cross-attention when computing the similarity. For text retrieval, SCAN is much slower than FILIP and its own image retrieval, mainly due to three reasons: (i) the image encoder is a Faster RCNN which is more expensive than the lightweight GRU text encoder; (ii) the text candidates are 5 times more than the image candidates in image retrieval; and (ii) the similarity computation of SCAN relies on the cross-attention computation, which is not straightforward to be paralleled, even in their official code; while our FILIP’s similarity computation is simply a matrix multiplication and is readily optimized on most modern hardwares.
md/dev/pkh8bwJbUbL/pkh8bwJbUbL.md ADDED
@@ -0,0 +1,698 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FAIR REPRESENTATION LEARNING THROUGH IMPLICIT PATH ALIGNMENT
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We considered a fair representation learning perspective, where optimal predictors, on top of the data representation, are ensured to be invariant with respect to different subgroups. Specifically, we formulated the problem as a bi-level optimization, where the representation is learned in the outer-level, and invariant optimal group predictors are updated in the inner-level. To avoid the high computational and memory cost of differentiating in the inner-level optimization, we proposed the implicit path alignment algorithm, which only relies on the solution of inner optimization and the implicit differentiation rather than the exact optimization path. Moreover, the proposed bi-level objective is demonstrated to fulfill the sufficiency rule, which is desirable in various practical scenarios but was not commonly studied in fair representation learning. We further analyzed the error gap of the implicit approach and empirically validated the proposed method in both classification and regression settings. Experimental results show the consistently better trade-off in prediction performance and fairness measurement.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Machine learning has been widely adopted in the real world decision-making practice such as job candidate screening (Raghavan et al., 2020) and credit application. However, it has been observed that learning algorithms treated some groups of population unfavorably, for example, denying credit on the grounds of gender, age or ethnicity (Hardt et al., 2016). To this end, algorithmic fairness that is to mitigate the prediction bias for different subgroups has recently received tremendous attentions.
12
+
13
+ With the rapid advancement of representation learning (LeCun et al., 2015), learning a fair embedding (Zemel et al., 2013) has been recently highlighted. Specifically, the learned fair representation can easily transfer the unbiased prior knowledge to the downstream tasks, with various successful applications in computer vision (Kim et al., 2019; Kehrenberg et al., 2020), language understanding (Chang et al., 2019; Ethayarajh, 2020) and artificial intelligence for health (Fletcher et al., 2021). Typically, the fair representation learning is achieved by adding various statistical fair metrics during the training process.
14
+
15
+ Based on this, most existing fair representation approaches in classification or regression principally aim to meet the independence or separation rule, e.g., (Madras et al., 2018; Song et al., 2019; Chzhen et al., 2020). However, in various realworld scenarios, the sufficiency rule is preferable. For example, health systems rely on commercial algorithms to identify and help patients with complex health needs. The algorithm outputs a healthcare need score, where a higher score indicates the patient is sicker and requires more healthcare. Obermeyer et al. (2019) revealed that a widely
16
+
17
+ $$
18
+ \begin{array} { r } { - \nabla _ { h } \mathcal { L } _ { 0 } ( h , \lambda ) \mathrm { ~ } } \\ { h ^ { ( 0 ) } \mathrm { ~ } ^ { \bullet } \xrightarrow { \prime ^ { { - - } } \mathrm { ~ \bullet ~ } h _ { 1 } ^ { \star } } \mathrm { ~ } \bullet \mathrm { ~ } h } \\ { \widehat { h } ^ { ( 0 ) } \mathrm { ~ } ^ { \bullet } \xrightarrow { \prime ^ { } \sim \mathrm { ~ \sigma ~ } _ { \sim _ { \mathrm { ~ \sigma ~ } _ { - } } } } \hat { - } \hat { \nabla _ { h } } \hat { \mathcal { L } } _ { 0 } ( \bar { h } , \bar { \lambda } ) ^ { \ast } } \end{array} \cdot \mathrm { ~ } h _ { 0 } ^ { \star }
19
+ $$
20
+
21
+ Figure 1: Unfair representation leads to different optimization path and non-invariant optimal predictors on the latent space $\mathcal { Z }$ .
22
+
23
+ used algorithm, typical of this industry-wide approach and affecting millions of patients, exhibits significant racial bias. At a given predicted healthcare need score $\hat { Y } = t$ , Black patients are considerably sicker than White patients $( \mathbb { E } _ { \mathrm { b l a c k } } [ Y | \hat { Y } = t ] > \mathbb { E } _ { \mathrm { w h i t e } } [ Y | \hat { Y } = t ] )$ ). Obermeyer et al. (2019) also pointed out that remedying the disparity would increase the percentage of Black patients receiving additional healthcare from 17.7 to $4 6 . 5 \%$ . Moreover, it has been theoretically justified (Barocas et al., 2019) that the Sufficiency rule is generally not compatible with Independence and Separation. Thus learning the fair representation w.r.t. the sufficiency rule is promising in both the algorithmic design and real-world applications.
24
+
25
+ ![](images/59b264099889fd63960229092740356be151d866cb61205afe025424a10c07e0.jpg)
26
+ Figure 2: Explicit and Implicit path alignment. (a) The considered fair representation learning criteria lies in ensuring the invariant optimal predictor w.r.t. different subgroups on $\mathcal { Z }$ $( h _ { 0 } ^ { \star } = h _ { 1 } ^ { \star }$ ). Since the gradient based approach is adopted to optimize $h$ , the explicit path alignment aims to learn a representation $\lambda$ to enforce the identical optimization path w.r.t. $h$ . (b) The proposed implicit path alignment only requires the last iteration point and approximate the gradient w.r.t. $\lambda$ from the last update of $h$ (the brown arrow).
27
+
28
+ In this paper, we address the sufficiency rule by considering the following intuition: given a fixed representation function, if the optimal predictor that learned on the embedding space are invariant from different sub-groups, then the corresponding representation function is fair. Fig. 1 provides an illustrative example. when the representation function $\lambda : \mathcal { X } \to \mathcal { Z }$ is unfair and we adopt gradient descent to learn the predictor $h : \mathcal { Z } R$ . The optimal predictors of different subgroups (blue, red) are not invariant, resulting in biased predictions. We will later demonstrate such an intuition ensures the learned representation satisfying the sufficiency rule (Liu et al., 2019; Chouldechova, 2017).
29
+
30
+ The aforementioned intuition can be naturally formulated as a bi-level optimization problem, where we aim to adjust the representation $\lambda$ (in the outer-level) to satisfy the invariant optimal predictor $h$ (in the inner-level). Thus, when we adopt the gradient-based approach in solving the bi-level objective, a straightforward solution is to learn the representation $\lambda$ to fulfill the identical explicit gradient-descent directions in learning predictor $h ^ { \star }$ of different groups, shown in Fig. 2(a). Intuitively, if the inner gradient descent step of each sub-group is identical, their final predictors (as the approximation of $h ^ { \star }$ ) will be invariant. However, the corresponding algorithmic realization is challenging in deep learning: 1) It requires storing the whole gradient steps, which induces a high memory burden. 2) the embedding function $\lambda$ is optimized via backpropagation from the whole gradient optimization path, which induces a high computational complexity.
31
+
32
+ To this end, we propose an implicit path alignment, shown in Fig. 2(b). Notably, we only consider the final $t$ -th) update of the predictor $h ^ { ( t ) }$ , then we update representation function $\lambda$ by approximating its gradient at point $h ^ { ( \bar { t } ) }$ through the implicit function (Bengio, 2000). By using the gradient approximation, it is no more required to store the whole gradient step and conduct the backpropagation through the entire path. Overall, the highlights in this paper are as follows:
33
+
34
+ Fair-representation learning to satisfy the sufficiency rule Instead of enforcing the independence or separation rule, the considered fair-representation criteria is proved to satisfy the sufficiency rule in both classification and regression. We also find such a criteria is intrinsically consistent with the recent Invariant Risk Minimization (IRM) (Arjovsky et al., 2019; Buhlmann, 2020), which aims to ¨ eliminate suspicious correlations while keeping robust correlations that are invariant across different environments. Intuitively, reducing the correlation w.r.t. the protected attributes enables the fair representation.
35
+
36
+ Principled and efficient algorithm We proposed a novel implicit path alignment algorithm to learn the fair representation, which addressed the prohibitive memory and computational cost in the original bi-level objective. Besides, we analyzed the approximation error gap of the proposed implicit algorithm, which induces a trade-off between the correct gradient estimation and fairness measures.
37
+
38
+ Improved fairness in classification and regression We evaluated the implicit algorithm in both classification and regression with tabular, computer vision and NLP datasets. Compared to the baselines, the implicit algorithm effectively improved the fairness with a smaller sufficiency gap.
39
+
40
+ # 2 PRELIMINARIES
41
+
42
+ We suppose the input $X \in { \mathcal { X } }$ , the ground truth label $Y \in \mathcal { D }$ , and the algorithmic output $\hat { Y } \in$ $\mathcal { V }$ . Throughout the paper, we only consider binary sensitive attribute (i.e, two sub-groups) with distributions $\mathcal { D } _ { 0 }$ and $\mathcal { D } _ { 1 }$ . Then based on (Liu et al., 2019), the sufficiency rule is defined as:
43
+
44
+ $$
45
+ \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | \hat { Y } = t ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | \hat { Y } = t ] , \forall t \in \mathcal { Y }
46
+ $$
47
+
48
+ To measure the fairness w.r.t. the sufficiency rule, we propose the sufficiency gap as the metric. Since we aim to evaluate the fairness in both binary classification $( Y \in \{ - 1 , 1 \} )$ and regression $( Y \in \mathbb { R }$ ), the metric is separately defined on these two scenarios.
49
+
50
+ Sufficiency gap in binary classification Based on the sufficiency rule, the sufficiency gap in binary classification is naturally defined as:
51
+
52
+ $$
53
+ \Delta \mathrm { S u f } _ { C } = \sum _ { y \in \{ - 1 , 1 \} } | \mathcal { D } _ { 0 } ( Y = y | \hat { Y } = y ) - \mathcal { D } _ { 1 } ( Y = y | \hat { Y } = y ) |
54
+ $$
55
+
56
+ $\Delta \mathrm { S u f } _ { C }$ encourages the two subgroups with identical Positive predicted value (PPV) and Negative predicted value (NPV). On the practical side, considering the healthcare evaluation system outputs either High Risk or Low Risk, Obermeyer et al. (2019) essentially revealed ${ \mathcal { D } } _ { \mathrm { b l a c k } } ( Y =$ High $\mathrm { R i s k } | \hat { Y } = \mathrm { L o w } \mathrm { R i s k } ) > \mathcal { D } _ { \mathrm { w h i t e } } ( Y = \mathrm { H i g h } \mathrm { R i s k } | \hat { Y } = \mathrm { L o w } \mathrm { R i s k } )$ : the severity of Black patients is actually underestimated. Thus if $\Delta \mathrm { S u f } _ { C }$ is small, the racial discrimination can be remedied.
57
+
58
+ Sufficiency gap in regression Based on the sufficiency rule and (Kuleshov et al., 2018), the sufficiency gap in regression is defined as:
59
+
60
+ $$
61
+ \Delta \mathrm { S u f } _ { R } = \int _ { t \in \mathcal { V } } | \mathcal { D } _ { 0 } ( Y \leq t | \hat { Y } \leq t ) - \mathcal { D } _ { 1 } ( Y \leq t | \hat { Y } \leq t ) | d t
62
+ $$
63
+
64
+ $\Delta \mathsf { S u f } _ { R } \in [ 0 , 1 ]$ is an approximation of $| \mathcal { D } _ { 0 } ( Y = y | \hat { Y } = y ) - \mathcal { D } _ { 1 } ( Y = y | \hat { Y } = y ) |$ , $\forall y \in \mathbb { R }$ , since the latter is difficult to estimate. From the practical aspect, assuming the health system outputs a realvalue healthcare score $\hat { Y } = t$ (higher indicates sicker), Obermeyer et al. (2019); Sjoding et al. (2020) observed $\mathcal { D } _ { \mathrm { b l a c k } } ( Y > t | \hat { Y } \leq t ) > \mathcal { D } _ { \mathrm { w h i t e } } ( Y > t | \hat { Y } \leq t )$ : for the patients whose predicted healthcare score is less than $t$ , the actual proportion of sicker $( Y > t )$ ) in Black patients is considerably higher than White patients. Therefore a small $\Delta \mathsf { S u f } _ { R }$ suggests an improved disparity.
65
+
66
+ # 3 PROBLEM SETUP
67
+
68
+ We denote the representation function $\lambda$ that maps the input $X$ into the latent variable $Z$ , the prediction function $h$ such that $h : \mathcal { Z } \mathbb { R }$ for regression and $h : \mathcal { Z } \{ - 1 , 1 \}$ for binary classification. We then denote the prediction loss as $\ell$ , the prediction loss on subgroup $\mathcal { D } _ { 0 } , \mathcal { D } _ { 1 }$ is expressed as:
69
+
70
+ $$
71
+ \mathscr { L } _ { 0 } ( h , \lambda ) = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { 0 } } \ell ( h \circ \lambda ( x ) , y ) , \mathscr { L } _ { 1 } ( h , \lambda ) = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { 1 } } \ell ( h \circ \lambda ( x ) , y )
72
+ $$
73
+
74
+ According to the intuition, we aim to solve the following bi-level objective:
75
+
76
+ $$
77
+ \mathrm { ~ : . t . ~ } h _ { 0 } ^ { \star } = h _ { 1 } ^ { \star } , \ h _ { 0 } ^ { \star } \in \operatorname * { a r g m i n } _ { h } \mathcal { L } _ { 0 } ( h , \lambda ) , \ h _ { 1 } ^ { \star } \in \operatorname * { a r g m i n } _ { h } \mathcal { L } _ { 1 } ( h , \lambda ) .
78
+ $$
79
+
80
+ Specifically, in the outer level, we aim to find a representation $\lambda$ for minimizing the prediction error, given the optimal predictor $( h _ { 0 } ^ { \star } , h _ { 1 } ^ { \star } )$ on the embedding space $\mathcal { Z }$ . As for the inner level, given a fixed representation $\lambda$ , $h _ { 0 } ^ { \star }$ , $h _ { 1 } ^ { \star }$ are the optimal predictor for each sub-group. The constraints $h _ { 0 } ^ { \star } = h _ { 1 } ^ { \star }$ additionally encourage the invariant optimal predictors from $\mathcal { D } _ { 0 } , \mathcal { D } _ { 1 }$ .
81
+
82
+ Relation to the explicit path alignment In deep learning we adopt the gradient-based approach to minimize the loss, therefore $h ^ { \star }$ in the inner level is approximated as $h ^ { ( t + 1 ) }$ , the $t$ -th update in the gradient descent: $\begin{array} { r } { h _ { 0 } ^ { \star } \approx h ^ { ( 0 ) } - \sum _ { t } \nabla _ { h } \mathcal { L } _ { 0 } \big ( h ^ { ( t ) } , \lambda \big ) , h _ { 1 } ^ { \star } \approx \bar { h } ^ { ( 0 ) } - \sum _ { t } \nabla _ { h } \mathcal { L } _ { 1 } \big ( h ^ { ( t ) } , \lambda \big ) . } \end{array}$ , where $h ^ { ( 0 ) }$ is the common initialization. Thus the invariant optimal predictor is equivalent to:
83
+
84
+ $$
85
+ \sum _ { t } \nabla _ { h } \mathcal { L } _ { 0 } ( h ^ { ( t ) } , \lambda ) = \sum _ { t } \nabla _ { h } \mathcal { L } _ { 1 } ( h ^ { ( t ) } , \lambda ) .
86
+ $$
87
+
88
+ The aforementioned equation suggests learning a representation $\lambda$ that ensures the identical optimization path w.r.t. $h$ for each sub-group, which recovers the explicit path alignment.
89
+
90
+ Relation to the Sufficiency rule We further demonstrate the relation between the bi-level objective and Sufficiency rule.
91
+
92
+ Proposition 1. If we specify the prediction loss $\ell$ as logistic regression loss in the classification $\log ( 1 + \exp ( - y h ( z ) ) )$ with $\mathcal { V } = \{ - 1 , 1 \}$ and the square loss in the regression $( h ( z ) - \dot { y } ) ^ { 2 }$ with $\mathcal { V } \subset \mathbb { R } .$ . Then minimizing the inner-level loss is equivalent to:
93
+
94
+ $$
95
+ \begin{array} { r } { \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y \vert Z = z ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y \vert Z = z ] , \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y \vert \hat { Y } = h ^ { \star } ( z ) ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y \vert \hat { Y } = h ^ { \star } ( z ) ] , } \end{array}
96
+ $$
97
+
98
+ where $h ^ { \star } = h _ { 0 } ^ { \star } = h _ { 1 } ^ { \star }$ and $z = \lambda ( x )$ .
99
+
100
+ Proposition 1 reveals that the objective of inner-level loss is to encourage the sufficiency rule.
101
+
102
+ # 4 PRACTICAL ALGORITHMS
103
+
104
+ In this section, we propose an implicit alignment in deep learning, where $\lambda$ and $h$ are implemented by the neural network. We also reformulate as the original objective through Lagrangian relaxation:
105
+
106
+ $$
107
+ \begin{array} { r l } & { \displaystyle \operatorname* { m i n } _ { \lambda } ~ \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) + \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) + \frac { \kappa } { 2 } \| h _ { 0 } ^ { \star } - h _ { 1 } ^ { \star } \| _ { 2 } ^ { 2 } } \\ & { \displaystyle \mathrm { s . t . } ~ h _ { 0 } ^ { \star } \in \mathop { \mathrm { a r g m i n } } _ { h } \mathcal { L } _ { 0 } ( h , \lambda ) , ~ h _ { 1 } ^ { \star } \in \mathop { \mathrm { a r g m i n } } _ { h } \mathcal { L } _ { 1 } ( h , \lambda ) , } \end{array}
108
+ $$
109
+
110
+ where $\kappa > 0$ is the coefficient to control the fairness. Then we will drive the approximated gradient w.r.t. $\lambda$ , which contains the following key elements.
111
+
112
+ Solving the inner optimization Given a fixed representation $\lambda$ , we find $h _ { 0 } ^ { \epsilon } , h _ { 1 } ^ { \epsilon }$ such that:
113
+
114
+ $$
115
+ \begin{array} { r } { \| h _ { 0 } ^ { \star } - h _ { 0 } ^ { \epsilon } \| \leq \epsilon , \quad \| h _ { 1 } ^ { \star } - h _ { 1 } ^ { \epsilon } \| \leq \epsilon , } \end{array}
116
+ $$
117
+
118
+ where $\epsilon$ is the optimization tolerance. Besides, $h _ { 1 } ^ { \star }$ and $h _ { 1 } ^ { \epsilon }$ are essentially the function of $\lambda$ , i.e., $h _ { 1 } ^ { \epsilon }$ depends on the predefined representation function $\lambda$ .
119
+
120
+ Computing the gradient of $\lambda$ Given the approximate solution $h _ { 0 } ^ { \epsilon } , h _ { 1 } ^ { \epsilon }$ , we can compute the gradient w.r.t. $\lambda$ (referred as ˜ grad $( \lambda )$ ) 1 in the outer-level:
121
+
122
+ $$
123
+ \begin{array} { r l } & { \mathrm { g } \tilde { \mathrm { r a d } } ( \lambda ) = \nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) + \left( \nabla _ { \lambda } h _ { 0 } ^ { \epsilon } \right) ^ { T } \left( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) + \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) \right) } \\ & { \quad \quad \quad + \nabla _ { \lambda } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) + \left( \nabla _ { \lambda } h _ { 1 } ^ { \epsilon } \right) ^ { T } \left( \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) - \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) \right) . } \end{array}
124
+ $$
125
+
126
+ Where $\nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda )$ is the partial derivative in the loss w.r.t. the first term (about $h _ { 0 }$ ), evaluated at $h _ { 0 } ^ { \epsilon }$ . Also $\nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda )$ is the partial derivative w.r.t. the second term (about $\lambda$ ).
127
+
128
+ Implicit function for approximating the gradient In order to compute $\tilde { \mathrm { g r a d } } ( \lambda )$ in autograd, we need to estimate $\nabla _ { \lambda } h _ { 0 } ^ { \epsilon }$ and $\nabla _ { \lambda } h _ { 1 } ^ { \epsilon }$ . We herein adopt the implicit function (Bengio, 2000) to approximate $\nabla _ { \lambda } h _ { 0 } ^ { \epsilon }$ , which has been adopted in the hyperparameter optimization (Pedregosa, 2016) and meta-learning (Rajeswaran et al., 2019).
129
+
130
+ Concretely, if the prediction loss is smooth and there exist stationary points to achieve optimal, we have: $\begin{array} { r } { \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( \bar { h } _ { 0 } ^ { \star } ( \lambda ) , \lambda ) = 0 , \nabla _ { h _ { 1 } } \mathcal { L } _ { 0 } ( h _ { 1 } ^ { \star } ( \lambda ) , \lambda ) = 0 . } \end{array}$ . Then differentiating w.r.t. $\lambda$ will induce: $\begin{array} { r } { \mathbf { d } \left( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } ( \lambda ) , \lambda ) \right) / \mathbf { d } \lambda = \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) \nabla _ { \lambda } h _ { 0 } ^ { \star } + \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) = 0 } \end{array}$ .2 Thus we have $\nabla _ { \lambda } h _ { 0 } ^ { \star } =$ $- \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \ast } , \lambda ) \right) ^ { - 1 } \left( \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \ast } , \lambda ) \right)$ , where the Hessian matrix $\nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { * } , \lambda )$ is assumed to be invertible.
131
+
132
+ Through the implicit function, we can approximate $\nabla _ { \lambda } h _ { 0 } ^ { \epsilon }$ as:
133
+
134
+ $$
135
+ \nabla _ { \lambda } h _ { 0 } ^ { \epsilon } \approx - \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \right) ^ { - 1 } \left( \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \right)
136
+ $$
137
+
138
+ As for $\nabla _ { \lambda } h _ { 1 } ^ { \epsilon }$ , we have the similar result: $\nabla _ { \lambda } h _ { 1 } ^ { \epsilon } \approx - \left( \nabla _ { h _ { 1 } } ^ { 2 } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) \right) ^ { - 1 } ( \nabla _ { \lambda } \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) ) .$
139
+
140
+ # Algorithm 1 Implicit Path Alignment Algorithm
141
+
142
+ Ensure: Representation function $\lambda$ , predictor $h _ { 0 } , h _ { 1 }$ , datasets from two sub-groups $\mathcal { D } _ { 0 } , \mathcal { D } _ { 1 }$ .
143
+ 1: for mini-batch of samples from $( \mathcal { D } _ { 0 } , \mathcal { D } _ { 1 } )$ do
144
+ 2: Solving the inner-level optimization with tolerance $\epsilon$ . Obtaining $h _ { 0 } ^ { \epsilon } , h _ { 1 } ^ { \epsilon }$ .
145
+ 3: Solving Eq. (4) with tolerance $\delta$ . Obtaining $\mathbf { p } _ { 0 } ^ { \delta }$ and $\mathbf { p } _ { 1 } ^ { \delta }$ .
146
+ 4: Computing ˜ grad $^ { \mathfrak { s } } ( \lambda )$ (gradient of representation $\lambda$ )
147
+ 5: Updating $\lambda$ through autograd: $\lambda \lambda - \mathrm { g r a d } ^ { \delta } ( \lambda )$
148
+ 6: end for
149
+ 7: return $\lambda , h _ { 0 } ^ { \epsilon } , h _ { 1 } ^ { \epsilon }$
150
+
151
+ Efficient and numerical stable gradient estimation Plugging in the approximations, the gradient w.r.t $\lambda$ is approximated as:
152
+
153
+ $$
154
+ \begin{array} { r } { \tilde { \ r \mathrm { a d } } ( \lambda ) \approx \overset \star { \nabla _ { \lambda } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) - \big ( \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \big ) ^ { T } \underset { \mathbb { P } _ { 0 } } { \underbrace { \big ( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \big ) ^ { - 1 } \big ( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) + \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) \big ) } } } \\ { + \nabla _ { \lambda } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) - \big ( \nabla _ { \lambda } \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) \big ) ^ { T } \underset { \mathbb { P } _ { 1 } } { \underbrace { \big ( \nabla _ { h _ { 1 } } ^ { 2 } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) \big ) ^ { - 1 } \big ( \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) - \kappa \big ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } \big ) \big ) } } } \end{array}
155
+ $$
156
+
157
+ However, the current form is still computationally expensive due to the computation of inverse Hessian matrix. To this end, we denote $\mathbf { p } _ { 0 }$ and $\mathbf { p } _ { 1 }$ as the inverse-Hessian vector product. Then computing $\mathbf { p } _ { 0 }$ and $\mathbf { p } _ { 1 }$ is equivalent to solve the following quadratic programming (QP):
158
+
159
+ $$
160
+ \begin{array} { r l } & { \mathrm { a r g m i n } _ { \hat { \mathbf { p } } _ { 0 } } \frac { 1 } { 2 } \hat { \mathbf { p } } _ { 0 } ^ { T } \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \right) \hat { \mathbf { p } } _ { 0 } - \hat { \mathbf { p } } _ { 0 } ^ { T } \left( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) + \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) \right) } \\ & { \mathrm { a r g m i n } _ { \hat { \mathbf { p } } _ { 1 } } \frac { 1 } { 2 } \hat { \mathbf { p } } _ { 1 } ^ { T } \left( \nabla _ { h _ { 1 } } ^ { 2 } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) \right) \hat { \mathbf { p } } _ { 1 } - \hat { \mathbf { p } } _ { 1 } ^ { T } \left( \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) - \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) \right) } \end{array}
161
+ $$
162
+
163
+ Since it is a typical QP problem and we adopt conjugate gradient method (Concus et al., 1985; Rajeswaran et al., 2019), which can be updated efficiently through autograd via computing the Hessian-vector product. We additionally suppose the optimization error in the QP as $\delta$ , i.e.: $\| \mathbf { p } _ { 0 } - \mathbf { \alpha }$ $\mathbf { p } _ { 0 } ^ { \delta } \rVert \le \delta$ , $\lVert \mathbf { p } _ { 1 } - \mathbf { p } _ { 1 } ^ { \delta } \rVert \leq \delta$ , then the gradient w.r.t representation $\lambda$ can be finally expressed as:
164
+
165
+ $\mathbf { g } \tilde { \mathbf { r a d } } ^ { \delta } ( \lambda ) = \nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) - \left( \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \right) ^ { T } \mathbf { p } _ { 0 } ^ { \delta } + \nabla _ { \lambda } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) - \left( \nabla _ { \lambda } \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) \right) ^ { T } \mathbf { p } _ { 1 } ^ { \delta }$ The ˜ grad $\dot { \mathbf { \eta } } ( \lambda )$ can be also efficiently estimated through Hessian vector product via autograd without explicitly computing the Hessian matrix.
166
+
167
+ Proposed algorithm Based on the key elements, the proposed algorithm is shown in Algo. 1.
168
+
169
+ 4.1 THE COST OF IMPLICIT ALGORITHM: APPROXIMATION-FAIR TRADE-OFF
170
+
171
+ Theorem 1 (Approximation Error Gap). Suppose that $( l )$ Smooth Predictive Loss. The first-order derivatives and second-order derivatives of $\mathcal { L }$ are Lipschitz continuous; (2) Non-singular Hessian matrix. We assume $\nabla _ { h _ { 0 } , h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } , \lambda ) , \nabla _ { h _ { 1 } , h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } , \lambda )$ , the Hessian matrix of the inner optimization problem, are invertible. (3) Bounded representation and predictor function. We assume the λ and $h$ are bounded, i.e., $\| \lambda \| , \| h \|$ are upper bounded by the predefined positive constants. Then the approximation error between the ground truth and algorithmic estimated gradient w.r.t. the representation is be upper bounded by:
172
+
173
+ $$
174
+ \lVert g r a d ( \lambda ) - g \tilde { r a d } ^ { \delta } ( \lambda ) \rVert = \mathcal { O } ( \kappa \epsilon + \epsilon + \delta ) .
175
+ $$
176
+
177
+ The proof is delegated in Appendix B. We also discuss the assumptions to guarantee the convergence of Algorithm 1, shown in Appendix $\textrm { C }$ .
178
+
179
+ Theorem 1 reveals that the gradient approximation error depends on the two-level optimization tolerance , $\delta$ and the coefficient of fair constraints $\kappa$ . Specifically, the error gap reveals the inherent trade-off in accurate gradient estimation and fair-representation learning. If we fix the optimization tolerance $\epsilon$ and $\delta$ , a smaller $\kappa$ indicates a better approximation of the gradient, which yields weak fair constraints. Thus the implicit alignment introduces a trade-off in the prediction performance (i.e., correct approximation of the gradient) and fairness measurement.
180
+
181
+ # 5 RELATED WORK
182
+
183
+ Fair Machine Learning Below we only list the most related work in the fairness and refer to the survey paper (Mehrabi et al., 2021) for details in the algorithmic fairness. In the classification, various methods in learning fair representations have been proposed. Specifically, a common strategy is to introduce the statistical constraints as the regularization during the training, e.g., demographic parity (DP) (Zhang et al., 2018; Madras et al., 2018; Song et al., 2019; Jiang et al., 2020; Kehrenberg et al., 2020) or equalized odds (EO) (Song et al., 2019; Gupta et al., 2021) as the proxy of the separation and independence rule. Another direction is to disentangle the data for factorizing meaningful representations such as (Locatello et al., 2019). Intuitively, the disentangled embedding is independent of the sensitive attribution, thus reflecting a fair representation w.r.t. the independence rule, which can be potentially problematic when the label distributions of subgroups vary dramatically (Zhao et al., 2019).
184
+
185
+ Fairness has also been extended to the fields beyond classification. For instance, in the regression problem (Komiyama et al., 2018; Agarwal et al., 2019), the bounded group loss has been proposed as the fair measure: if prediction loss in each subgroup is smaller than $\epsilon$ , the regression is $\epsilon$ -level fair. In fact, the fair criteria in our paper is not equivalent to $\epsilon$ -fair. Given a fixed $\lambda$ , the $\epsilon$ -level fair does not guarantee the optimal and invariant predictor for each subgroup and vice versa.
186
+
187
+ The sufficiency rule has also been discussed in the previous work. Notably, Chouldechova (2017); Liu et al. (2019) proposed the sufficiency gap in classification for measuring fairness w.r.t. the sufficiency rule. Liu et al. (2019) also discussed the inequivalence between the sufficiency gap and probabilistic calibration (Guo et al., 2017) (referred as calibration gap). According to Pleiss et al. (2017), the calibration rule is a stronger condition than sufficiency rule while it simultaneously hurts the prediction performance. Throughout this paper, we only consider the sufficiency rule. The triple trade-off between the calibration rule, sufficiency rule, and prediction performance will be left as future work.
188
+
189
+ Invariant Risk Minimization The analyzed fair-representation criteria shares a quite similar spirit to the IRM (Arjovsky et al., 2019; Buhlmann, 2020; Creager et al., 2021), where an algorithm ¨ IRM v1 is proposed to enable the out-of-distribution (OOD) generalization. The key difference between our work and (Arjovsky et al., 2019) lies in the algorithmic aspect: it has been theoretically justified that the originally proposed IRM v1 does not necessarily capture the invariance (Rosenfeld et al., 2020). By contrast, we directly solve the bi-level objective in the context of deep-learning and propose an efficient practical algorithm with better empirical performance than IRM v1. Besides, based on Chen et al. (2021), the proposed algorithm does not provably guarantee the OOD generalization property due to the limited subgroups $N = 2$ ) considered within the paper.
190
+
191
+ # 6 EXPERIMENTS
192
+
193
+ # 6.1 EXPERIMENTAL SETUP
194
+
195
+ In the paper, we adopt the sufficiency gap as fair metrics, where $\hat { Y }$ is denoted as:
196
+
197
+ $$
198
+ \hat { Y } = \left\{ \begin{array} { l l } { h _ { 0 } ^ { \epsilon } \circ \lambda ( X ) , } & { X \in \mathcal { D } _ { 0 } } \\ { h _ { 1 } ^ { \epsilon } \circ \lambda ( X ) , } & { X \in \mathcal { D } _ { 1 } } \end{array} \right.
199
+ $$
200
+
201
+ Then in the binary classification, we can estimate $\Delta \mathrm { S u f } _ { C } =$ $\begin{array} { r } { \sum _ { y \in \{ - 1 , + 1 \} } | \mathcal { D } _ { 0 } ( Y = y | \hat { Y } = y ) - \mathcal { D } _ { 1 } ( Y = y | \hat { Y } = y ) | } \end{array}$ from the data.
202
+
203
+ ![](images/0782c5f773cdc4c89edc62f1ca5492d98ad3694f8940bcbfbf15ed3b92501ea5.jpg)
204
+ Figure 3: Sufficiency gap $( \Delta \mathsf { S u f } _ { R } )$ in regression
205
+
206
+ As for regression, the sufficiency gap $\begin{array} { r l } { \Delta \mathsf { S u f } _ { R } } & { { } = } \end{array}$ $\begin{array} { r } { \int _ { t } | \mathcal { D } _ { 0 } ( Y ~ \le ~ t | \hat { Y } ~ \le ~ t ) - \mathcal { D } _ { 1 } ( Y ~ \le ~ t | \hat { Y } ~ \le ~ t ) | } \end{array}$ (shown in Fig. 3, the orange region) is difficult to estimate due to the integration. To address this, we sample multiple values $\{ t _ { 1 } , \ldots , t _ { m } \}$ and compute its average difference as the approximation of the integration. $\Delta \mathsf { S u f } _ { R } \approx$ $\begin{array} { r } { \frac { 1 } { m } \sum _ { i = 1 } ^ { m } | \mathcal { D } _ { 0 } ( \dot { Y } \leq t _ { i } | \hat { Y } \leq t _ { i } ) - \mathcal { D } _ { 1 } ( Y \leq t _ { i } | \hat { Y } \leq t _ { i } ) | } \end{array}$
207
+
208
+ Table 1: Toxic comments dataset. Accuracy and $\Delta \mathrm { S u f } _ { C }$ in different approaches.
209
+
210
+ <table><tr><td>Method</td><td>Accuracy (↑)</td><td>△Sufc (↓)</td></tr><tr><td>ERM (I)</td><td>0.768 ± 0.004</td><td>0.173 ± 0.008</td></tr><tr><td>Adv_debias (II) Mixup (III)</td><td>0.760 ± 0.008</td><td>0.291 ± 0.006</td></tr><tr><td>IRM_v1 (IV)</td><td>0.758 ± 0.003 0.753 ± 0.004</td><td>0.343 ± 0.022 0.057 ± 0.015</td></tr><tr><td>One_step (V)</td><td>0.755 ± 0.007</td><td>0.048 ± 0.008</td></tr><tr><td>Implicit</td><td>0.760 ± 0.007</td><td></td></tr><tr><td></td><td></td><td>0.051 ± 0.012</td></tr></table>
211
+
212
+ ![](images/f4ab58b444b7e8f8f5ed7dbf99542b1a296cdfb0f0f735478ce2363f32ddbae8.jpg)
213
+ Figure 4: Toxic. Accuracy-Fair Trade-off
214
+
215
+ Concretely, for a given $t _ { i }$ in each group, we compute the percentile $( \hat { Y } _ { 0 } )$ at point $t$ : $\mathcal { D } _ { 0 } ( \hat { Y } _ { 0 } \leq t _ { i } )$ , then we compute the corresponding ground truth cumulative distribution $( Y )$ at the same point $t _ { i }$ : $\mathcal { D } ( Y \leq t _ { i } | \hat { Y } \leq t _ { i } )$ . Through the aforementioned approximation, we can compute $| \mathcal { D } _ { 0 } ( Y \leq t _ { i } | \hat { Y } \leq$ $t _ { i } ) - \mathcal { D } _ { 1 } ( Y \leq t _ { i } | \hat { Y } \leq t _ { i } ) |$ .
216
+
217
+ Baselines We consider the baselines that add fairness constraints during the training process. Specifically, we compare our method with (I) empirical risk minimization (ERM) that trains the model without considering fairness; (II) adversarial debiasing (Zhang et al., 2018); (III) fair mix-up (Chuang & Mroueh, 2021), a recent data-augmentation and effective approach in the fair representation learning. In fact, the baselines (II) and (III) are DP-based fair approaches, which is designed to demonstrate the general non-compatibility in addressing the sufficiency based fairness.
218
+
219
+ Besides, we include two additional baselines that have the similar objective but different algorithmic realizations. (IV) the original IRM regularization (referred as IRM v1) (Arjovsky et al., 2019), which adds a gradient penalty to encourage the invariance. (V) One-step explicit alignment. In the inner-level optimization, we suppose to conduct the one-step gradient descent for each sub-group. Then in the outer-level optimization, we add a gradient-incoherence constraint to encourage the identical (one-step) optimization path: minλ $\| \bar { \nabla _ { h _ { 0 } } } \mathcal { L } _ { 0 } ( h _ { 0 } , \lambda ) - \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } , \lambda ) \| _ { 2 } ^ { 2 }$ . All the results are reported by averaging five repetitions and additional experimental details are delegated in the Appendix.
220
+
221
+ # 6.2 EMPIRICAL RESULTS
222
+
223
+ # 6.2.1 TOXIC COMMENTS
224
+
225
+ The toxic comments dataset (Jigsaw, 2018) is a binary classification task in NLP to predict whether comment is toxic or not. The original label is actually not binary since the comments is decided by multiple annotators, where the labelling discrepancy generally occurs. To this end, we conduct a simple strategy to decide comment is toxic if at least one annotator marks it. In this dataset, a portion of comments have been labeled with identity attributes, including gender and race. It has also been revealed that the race identity (e.g., black) is correlated with the toxicity label, which can lead to the predictive discrimination. Thus we adopted the race as the protected group by selecting two subgroups of Black and Asian. For the sake of computational simplicity, we first applied the pretrained BERT (Devlin et al., 2018) to extract the word embedding with 748 dimensional vector. Then we adopt representation function $\lambda$ as two fully-connected layers with hidden dimension 200 with Relu activation and classifier $h$ as a linear predictor. We report the test-set sub-group average accuracy and sufficiency gap $( \Delta \mathrm { S u f } _ { C } )$ ) in Tab. 1 and Fig. 4.
226
+
227
+ The results reveal several interesting facts. (1) The Demographic Parity (DP) based fair constraints are generally non-compatible with the sufficiency rule. Specifically, baseline (II,III) even increase $\Delta \mathrm { S u f } _ { C }$ with higher value than ERM. (2) For the baselines that track the sufficiency rule (IV,V), the sufficiency gap $\Delta \mathrm { S u f } _ { C }$ is improved with a similar accuracy, shown in Tab.1. We also change the regularization coefficient in (IV,V) and $\kappa$ in the implicit approach. We observe that the implicit approach demonstrates a consistent better Accuracy-Fair trade-off, shown in Fig. 4.
228
+
229
+ Table 2: CelebA dataset. Accuracy and predictive parity in different approaches.
230
+
231
+ <table><tr><td>Method</td><td>Accuracy (↑)</td><td>△Sufc (↓)</td></tr><tr><td>ERM (I)</td><td>0.780 ± 0.015</td><td>0.210 ± 0.022</td></tr><tr><td>Adv_debias (II)</td><td>0.785 ± 0.022</td><td>0.165 ± 0.028</td></tr><tr><td>Mixup (III) IRM_v1 (IV)</td><td>0.792 ± 0.011</td><td>0.160 ± 0.010</td></tr><tr><td></td><td>0.795 ± 0.012</td><td>0.086 ± 0.015</td></tr><tr><td>One_step (V)</td><td>0.797 ± 0.006</td><td>0.086 ± 0.012</td></tr><tr><td>Implicit</td><td>0.794 ± 0.027</td><td>0.074 ± 0.020</td></tr></table>
232
+
233
+ ![](images/cacb482edbb01819a1917327d805b008b054945dc5ea3d7e53d00b745bce573d.jpg)
234
+ Figure 5: CelebA. Accuracy-Fair Trade-off
235
+
236
+ # 6.2.2 CELEBA DATASET
237
+
238
+ The CelebA dataset (Liu et al., 2015) contains around 200K images of celebrity faces, where each image is associated with 40 human-annotated binary attributes including gender, hair color, young, etc. In this paper, we designate gender as the sensitive attribute, and attractive as the binary classification task. We randomly select around 82K and 18K images as the training and validation set. Then we adopt representation function $\lambda$ as pre-trained ResNet-18 (He et al., 2016) and classifier $h$ as two-fully connected layers. We report the test-set sub-group average accuracy and sufficiency gap $( \Delta \mathrm { S u f } _ { C } )$ in Tab. 2 and Fig. 5.
239
+
240
+ The results in the CelebA show similar behaviors with the Toxic comments. Specifically, the DP based fair approaches (II, III) did not effectively improve $\Delta \mathrm { S u f } _ { C }$ , shown in Tab. 2. In contrast, the sufficiency can be significantly improved in baselines (IV, V) and implicit approach without largely losing the accuracy. Specifically, Fig. 5 visualizes the accuracy-fair trade-off curve, where the later three approaches show quite similar behaviors.
241
+
242
+ # 6.2.3 LAW DATASET
243
+
244
+ The Law Dataset is a regression task to predict a students GPA (real value, ranging from $[ 0 , 4 ] )$ , where the data is utilized from the School Admissions Councils National Longitudinal Bar Passage Study (Wightman, 1998) with 20K examples. In the regression task, we adopt the square loss and race as the protected attribute (white versus non-white). We adopt $\lambda$ as the one fully connected layer with hidden dimension 100 and Relu activation and predictor $h$ as a linear predictor. We report the test-set subgroup average MSE (Mean Square Error) and sufficiency gap $( \Delta \mathrm { S u f } _ { R } )$ in Tab. 1 and Fig. 4.
245
+
246
+ Compared to the classification task, the results show similar behaviors in the regression. Specifically, the DP based fair approaches (II, III) still increase $\Delta \mathsf { S u f } _ { R }$ in the regression. In contrast, the gap is significantly improved in our proposed approach and baseline (IV,V). Specifically, Fig. 7 visualizes the sufficiency-gap of different approaches, where the implicit approach significantly mitigate the sufficiency gap. Besides, Fig. 6 shows the MSE-sufficiency gap curve, which still reveals the implicit approach benefits a better trade-off between the performance and fairness.
247
+
248
+ Table 3: Law dataset. MSE and sufficiency gap in different approaches.
249
+
250
+ <table><tr><td>Method</td><td>MSE(↓)</td><td>△SufR (↓)</td></tr><tr><td>ERM (I)</td><td>0.190 ± 0.005</td><td>0.160 ± 0.007</td></tr><tr><td>Adv_debias (II)</td><td>0.223 ± 0.008</td><td>0.188 ± 0.012</td></tr><tr><td>Mixup (II) IRM_v1 (IV)</td><td>0.216 ± 0.012</td><td>0.172 ± 0.007</td></tr><tr><td>One_step (V)</td><td>0.208 ± 0.006</td><td>0.096 ± 0.006</td></tr><tr><td></td><td>0.204 ± 0.007</td><td>0.125 ± 0.010</td></tr><tr><td>Implicit</td><td>0.198 ± 0.005</td><td>0.091 ± 0.011</td></tr></table>
251
+
252
+ ![](images/10b1762bdbf2bfbbe8d3c4aab6ed01df908a327bfed1964c110f51417b3f70cc.jpg)
253
+ Figure 6: Law. MSE-Fair Trade-off
254
+
255
+ ![](images/02feb1b6be73accaaafed3d45171f57a4b2404ec4d5efdfc32f081afefee5399.jpg)
256
+ Figure 7: Illustration of the sufficiency gap $( \Delta \mathsf { S u f } _ { R } )$ in Law dataset (regression). The ERM and Fair mix-up suffer a high $\Delta \mathsf { S u f } _ { R }$ , while the proposed implicit alignment can significantly mitigate the sufficiency gap.
257
+
258
+ Table 4: NLSY dataset. MSE and sufficiency gap in different approaches.
259
+
260
+ <table><tr><td>Method</td><td>MSE (↓)</td><td>△SufR (↓)</td></tr><tr><td>ERM (I)</td><td>1.939 ± 0.021</td><td>0.246 ± 0.019</td></tr><tr><td>Adv_debias (II)</td><td>1.982 ± 0.016</td><td>0.252 ± 0.020</td></tr><tr><td>Mixup (III)</td><td>1.979 ± 0.025</td><td>0.246 ± 0.023</td></tr><tr><td>IRM_v1 (IV)</td><td>1.927 ± 0.031</td><td>0.077 ± 0.009</td></tr><tr><td>One_step (V)</td><td>1.904 ± 0.027</td><td>0.090 ± 0.019</td></tr><tr><td>Implicit</td><td>1.906 ± 0.019</td><td>0.051 ± 0.005</td></tr></table>
261
+
262
+ ![](images/666991e4ee594e06efb9cb1a8572ca42344282d99214fd5f39e204194004d557.jpg)
263
+ Figure 8: NLSY. MSE-Fair Trade-off
264
+
265
+ # 6.2.4 NLSY DATASET
266
+
267
+ The National Longitudinal Survey of Youth (NLSY, 2021) dataset is a regression task with around 7K dataset, which involves the survey results of the U.S. Bureau of Labor Statistics. It is intended to gather information on the labor market activities and other life events of several groups for predicting the income $y$ of each person. We treat the gender as the sensitive attribute. We also normalize the output $y$ by diving the 10, 000, then the final output $y$ ranges around [0, 8]. The prediction loss is also the square loss. We adopt representation $\lambda$ as the two fully connected layers with hidden dimension 200 and Relu activation and predictor $h$ as a linear predictor. We report the test-set sub-group average MSE (Mean Square Error) and Sufficiency Gap $( \Delta \mathsf { S u f } _ { R } )$ in Tab. 4 and Fig. 8.
268
+
269
+ Tab. 4 provides similar trends with other datasets. Baselines (IV,V) and implicit approach effective control the sufficiency gap, while the DP based approach generally fails to improve the gap. Fig. 8 reveals a slightly better approximation-fair trade off for the implicit approach. Finally, Fig. 11 (in Appendix) visualizes the sufficiency gap of different algorithms. The gap is actually significantly improved while the calibration gap still exists, which is consistent with (Liu et al., 2019). Therefore it can be quite interesting and promising to analyze the triple trade-off between the sufficiency gap, calibration gap and prediction performance in the regression.
270
+
271
+ # 7 CONCLUSION
272
+
273
+ We considered the fair representation learning from a novel perspective through encouraging the invariant optimal predictors on the top of data representation. Then we formulated this problem as a bi-level optimization and proposed an implicit alignment algorithm. We further demonstrated the bilevel objective is to fulfil the sufficiency rule. Besides, we also analyzed the error gap of the implicit algorithm. The empirical results in both classification and regression settings suggest the improved fairness measurement. Finally, we think the future work can include developing computationally efficient explicit algorithms for avoiding the biased gradient computation.
274
+
275
+ # ETHICS STATEMENT
276
+
277
+ This paper proposed a novel fair representation algorithm, which aims to address the potential prediction discrimination towards several subgroups. The proposed approach may also introduce the potential negative impact: we merely address the fairness with respect to the sufficiency rule in the paper, which is not always the preferable criteria in several specific scenarios.
278
+
279
+ # REPRODUCIBILITY STATEMENT
280
+
281
+ We provided a demo source code in the supplementary material for a better understanding the proposed algorithm. Besides, the detailed experimental descriptions and theoretical proofs are also provided in the appendix.
282
+
283
+ # REFERENCES
284
+
285
+ Alekh Agarwal, Miroslav Dud´ık, and Zhiwei Steven Wu. Fair regression: Quantitative definitions and reduction-based algorithms. In International Conference on Machine Learning, pp. 120–129. PMLR, 2019.
286
+
287
+ Martin Arjovsky, Leon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. ´ arXiv preprint arXiv:1907.02893, 2019.
288
+
289
+ Solon Barocas, Moritz Hardt, and Arvind Narayanan. Fairness and Machine Learning. fairmlbook.org, 2019. http://www.fairmlbook.org.
290
+
291
+ Yoshua Bengio. Gradient-based optimization of hyperparameters. Neural computation, 12(8):1889– 1900, 2000.
292
+
293
+ Stephen Boyd, Stephen P Boyd, and Lieven Vandenberghe. Convex optimization. Cambridge university press, 2004.
294
+
295
+ Peter Buhlmann. Invariance, causality and robustness. ¨ Statistical Science, 35(3):404–426, 2020.
296
+
297
+ Kai-Wei Chang, Vinod Prabhakaran, and Vicente Ordonez. Bias and fairness in natural language processing. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLPIJCNLP): Tutorial Abstracts, Hong Kong, China, November 2019. Association for Computational Linguistics. URL https://aclanthology.org/D19-2004.
298
+
299
+ Yining Chen, Elan Rosenfeld, Mark Sellke, Tengyu Ma, and Andrej Risteski. Iterative feature matching: Toward provable domain generalization with logarithmic environments. arXiv preprint arXiv:2106.09913, 2021.
300
+
301
+ Alexandra Chouldechova. Fair prediction with disparate impact: A study of bias in recidivism prediction instruments. Big data, 5(2):153–163, 2017.
302
+
303
+ Ching-Yao Chuang and Youssef Mroueh. Fair mixup: Fairness via interpolation. arXiv preprint arXiv:2103.06503, 2021.
304
+
305
+ Evgenii Chzhen, Christophe Denis, Mohamed Hebiri, Luca Oneto, and Massimiliano Pontil. Fair regression with wasserstein barycenters. arXiv preprint arXiv:2006.07286, 2020.
306
+
307
+ P. Concus, G. Golub, and Gerard Meurant. Block preconditioning for the conjugate gradient method. ´ Siam Journal on Scientific and Statistical Computing, 6, 01 1985. doi: 10.1137/0906018.
308
+
309
+ Elliot Creager, Jorn-Henrik Jacobsen, and Richard Zemel. Environment inference for invariant ¨ learning. In International Conference on Machine Learning, pp. 2189–2200. PMLR, 2021.
310
+
311
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
312
+
313
+ Kawin Ethayarajh. Is your classifier actually biased? measuring fairness under uncertainty with bernstein bounds. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 2914–2919, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.262. URL https://aclanthology.org/2020. acl-main.262.
314
+
315
+ Richard Ribon Fletcher, Audace Nakeshimana, and Olusubomi Olubeko. Addressing fairness, bias, ´ and appropriate use of artificial intelligence and machine learning in global health. Frontiers in Artificial Intelligence, 3:116, 2021. ISSN 2624-8212. doi: 10.3389/frai.2020.561802. URL https://www.frontiersin.org/article/10.3389/frai.2020.561802.
316
+
317
+ Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q Weinberger. On calibration of modern neural networks. In International Conference on Machine Learning, pp. 1321–1330. PMLR, 2017.
318
+
319
+ Umang Gupta, Aaron Ferber, Bistra Dilkina, and Greg Ver Steeg. Controllable guarantees for fair outcomes via contrastive information estimation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 7610–7619, 2021.
320
+
321
+ Moritz Hardt, Eric Price, and Nati Srebro. Equality of opportunity in supervised learning. Advances in neural information processing systems, 29:3315–3323, 2016.
322
+
323
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
324
+
325
+ Ray Jiang, Aldo Pacchiano, Tom Stepleton, Heinrich Jiang, and Silvia Chiappa. Wasserstein fair classification. In Uncertainty in Artificial Intelligence, pp. 862–872. PMLR, 2020.
326
+
327
+ Jigsaw. Toxic comment classification challenge, 2018. URL https://www.kaggle. com/c/jigsaw-toxic-comment-classification-challenge/overview/ description.
328
+
329
+ Thomas Kehrenberg, Myles Bartlett, Oliver Thomas, and Novi Quadrianto. Null-sampling for interpretable and fair representations. In European Conference on Computer Vision, pp. 565–580. Springer, 2020.
330
+
331
+ Byungju Kim, Hyunwoo Kim, Kyungsu Kim, Sungjin Kim, and Junmo Kim. Learning not to learn: Training deep neural networks with biased data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9012–9020, 2019.
332
+
333
+ Junpei Komiyama, Akiko Takeda, Junya Honda, and Hajime Shimao. Nonconvex optimization for regression with fairness constraints. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 2737–2746. PMLR, 10–15 Jul 2018. URL https://proceedings. mlr.press/v80/komiyama18a.html.
334
+
335
+ Volodymyr Kuleshov, Nathan Fenner, and Stefano Ermon. Accurate uncertainties for deep learning using calibrated regression. In International Conference on Machine Learning, pp. 2796–2804. PMLR, 2018.
336
+
337
+ Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436–444, 2015.
338
+
339
+ Lydia T. Liu, Max Simchowitz, and Moritz Hardt. The implicit fairness criterion of unconstrained learning. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4051–4060. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr. press/v97/liu19f.html.
340
+
341
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
342
+
343
+ Francesco Locatello, Gabriele Abbati, Tom Rainforth, Stefan Bauer, Bernhard Scholkopf, ¨ and Olivier Bachem. On the fairness of disentangled representations. arXiv preprint arXiv:1905.13662, 2019.
344
+
345
+ David Madras, Elliot Creager, Toniann Pitassi, and Richard Zemel. Learning adversarially fair and transferable representations. In International Conference on Machine Learning, pp. 3384–3393. PMLR, 2018.
346
+
347
+ Ninareh Mehrabi, Fred Morstatter, Nripsuta Saxena, Kristina Lerman, and Aram Galstyan. A survey on bias and fairness in machine learning. ACM Computing Surveys (CSUR), 54(6):1–35, 2021.
348
+
349
+ NLSY. National longitudinal survey of youth, 2021. URL https://www.bls.gov/nls/.
350
+
351
+ Ziad Obermeyer, Brian Powers, Christine Vogeli, and Sendhil Mullainathan. Dissecting racial bias in an algorithm used to manage the health of populations. Science, 366(6464):447–453, 2019. doi: 10.1126/science.aax2342. URL https://www.science.org/doi/abs/10.1126/ science.aax2342.
352
+
353
+ Fabian Pedregosa. Hyperparameter optimization with approximate gradient. In International conference on machine learning, pp. 737–746. PMLR, 2016.
354
+
355
+ Geoff Pleiss, Manish Raghavan, Felix Wu, Jon Kleinberg, and Kilian Q Weinberger. On fairness and calibration. arXiv preprint arXiv:1709.02012, 2017.
356
+
357
+ Manish Raghavan, Solon Barocas, Jon Kleinberg, and Karen Levy. Mitigating bias in algorithmic hiring: Evaluating claims and practices. In Proceedings of the 2020 conference on fairness, accountability, and transparency, pp. 469–481, 2020.
358
+
359
+ Aravind Rajeswaran, Chelsea Finn, Sham Kakade, and Sergey Levine. Meta-learning with implicit gradients. In Advances in neural information processing systems, 2019.
360
+
361
+ Elan Rosenfeld, Pradeep Ravikumar, and Andrej Risteski. The risks of invariant risk minimization. arXiv preprint arXiv:2010.05761, 2020.
362
+
363
+ Michael W Sjoding, Robert P Dickson, Theodore J Iwashyna, Steven E Gay, and Thomas S Valley. Racial bias in pulse oximetry measurement. New England Journal of Medicine, 383(25):2477– 2478, 2020.
364
+
365
+ Jiaming Song, Pratyusha Kalluri, Aditya Grover, Shengjia Zhao, and Stefano Ermon. Learning controllable fair representations. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 2164–2173. PMLR, 2019.
366
+
367
+ Linda F. Wightman. Lsac national longitudinal bar passage study, 1998.
368
+
369
+ Rich Zemel, Yu Wu, Kevin Swersky, Toni Pitassi, and Cynthia Dwork. Learning fair representations. In International conference on machine learning, pp. 325–333. PMLR, 2013.
370
+
371
+ Brian Hu Zhang, Blake Lemoine, and Margaret Mitchell. Mitigating unwanted biases with adversarial learning. In Proceedings of the 2018 AAAI/ACM Conference on AI, Ethics, and Society, pp. 335–340, 2018.
372
+
373
+ Wenbin Zhang and Eirini Ntoutsi. Faht: an adaptive fairness-aware decision tree classifier. arXiv preprint arXiv:1907.07237, 2019.
374
+
375
+ Han Zhao, Amanda Coston, Tameem Adel, and Geoffrey J Gordon. Conditional learning of fair representations. arXiv preprint arXiv:1910.07162, 2019.
376
+
377
+ # A PROPOSITION 1
378
+
379
+ We consider the regression and classification separately.
380
+
381
+ Regression According to the definition, given a fixed and deterministic representation $\lambda$ , we have
382
+
383
+ $$
384
+ \mathcal { L } _ { 0 } ( h , \lambda ) = \mathbb { E } _ { \mathcal { D } _ { 0 } } ( h ( z ) - y ) ^ { 2 }
385
+ $$
386
+
387
+ It is noted as a typical regression problem with square error. We set the derivative as zero: $\nabla _ { h } \mathcal { L } _ { 0 } ( h , \lambda ) = 0$ , we have $h _ { 0 } ^ { \star } ( z ) \stackrel { - } { = } \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z \stackrel { - } { = } \stackrel { - } { z } ]$ . As for $\mathcal { D } _ { 1 }$ , we apply the same strategy with $h _ { 1 } ^ { \star } ( z ) = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ]$ . Based on the invariant optimal predictor, we have $\begin{array} { r } { \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] \stackrel { - } { = } } \end{array}$ $\mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ]$ with $z = \lambda ( x )$ .
388
+
389
+ Classification According to the definition, we have:
390
+
391
+ $$
392
+ \mathcal { L } _ { 0 } ( h , \lambda ) = \mathbb { E } _ { \mathcal { D } _ { 0 } } \log ( 1 + \exp ( - y h ( z ) ) )
393
+ $$
394
+
395
+ Since the optimal predictor on the logistic loss is the log-conditional density ratio: $h _ { 0 } ^ { \star } ( z ) ~ =$ $\begin{array} { r } { \log \left( \frac { \mathcal { D } _ { 0 } \left( Y = 1 | Z = z \right) } { \mathcal { D } _ { 0 } \left( Y = - 1 | Z = z \right) } \right) } \end{array}$ Observe that in the binary classification with $Y ~ = ~ \{ - 1 , 1 \}$ , we have $\begin{array} { r } { \mathcal { D } _ { 0 } ( Y = 1 | Z = z ) \stackrel { \prime } { = } \frac { 1 } { 2 } ( 1 + \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] ) } \end{array}$ and $\begin{array} { r } { \mathcal { D } _ { 0 } ( Y = - 1 | Z = z ) = \frac { 1 } { 2 } ( 1 - \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] ) } \end{array}$ , then we have:
396
+
397
+ $$
398
+ h _ { 0 } ^ { \star } ( z ) = \log \left( \frac { 1 + \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] } { 1 - \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] } \right)
399
+ $$
400
+
401
+ As for $\mathcal { D } _ { 1 }$ , we adopt the same strategy and we have $\begin{array} { r } { \log \left( \frac { 1 + \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] } { 1 - \mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] } \right) = \log \left( \frac { 1 + \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ] } { 1 - \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ] } \right) } \end{array}$ then we have $\mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ]$ .
402
+
403
+ As for the predictive parity, since we have $\mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | Z = z ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | Z = z ]$ and $h ^ { \star } = h _ { 1 } ^ { \star } = h _ { 2 } ^ { \star }$ then we have $\mathbb { E } _ { \mathcal { D } _ { 0 } } [ Y | h ^ { \star } ( z ) ] = \mathbb { E } _ { \mathcal { D } _ { 1 } } [ Y | h ^ { \star } ( z ) ]$ .
404
+
405
+ # B APPROXIMATION ERROR
406
+
407
+ Theorem 2 (Approximation Error Gap). Suppose that $( l )$ Smooth Predictive Loss. The first-order derivatives and second-order derivatives of $\mathcal { L }$ are Lipschitz continuous; (2) Non-singular Hessian matrix. We assume $\nabla _ { h _ { 0 } , h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } , \lambda ) , \nabla _ { h _ { 1 } , h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } , \lambda )$ , the Hessian matrix of the inner optimization problem, are invertible. (3) Bounded representation and predictor function. We assume the $\lambda$ and $h$ are bounded, i.e., $\| \lambda \| , \| h \|$ are upper bounded by the predefined positive constants. Then the approximation error between the ground truth and algorithmic estimated gradient w.r.t. the representation is be upper bounded by:
408
+
409
+ $$
410
+ \lVert g r a d ( \lambda ) - g \tilde { r a d } ^ { \delta } ( \lambda ) \rVert = \mathcal { O } ( \kappa \epsilon + \epsilon + \delta ) .
411
+ $$
412
+
413
+ Proof. We denote grad $( \lambda )$ as the ground truth gradient w.r.t. $\lambda$ in outer-level loss (given the optimal predictor $h _ { 0 } ^ { \star } , h _ { 1 } ^ { \star } )$ . Then we aim to bound
414
+
415
+ $$
416
+ \lVert \mathrm { g r a d } ( \lambda ) - \mathrm { g } \tilde { \mathrm { r a d } } ^ { \delta } ( \lambda ) \rVert
417
+ $$
418
+
419
+ We first introduce the following terms for facilitating the proof:
420
+
421
+ $$
422
+ \begin{array} { r l } & { 4 _ { 0 } ^ { \epsilon } = \nabla _ { h _ { 0 } } \nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) , A _ { 1 } ^ { \epsilon } = \nabla _ { \lambda } \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) , A _ { 0 } ^ { \star } = \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) , A _ { 1 } ^ { \star } = \nabla _ { \lambda } \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) , } \\ & { 3 _ { 0 } ^ { \epsilon } = \nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) , B _ { 1 } ^ { \epsilon } = \nabla _ { \lambda } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \epsilon } , \lambda ) , B _ { 0 } ^ { \star } = \nabla _ { \lambda } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) , B _ { 1 } ^ { \star } = \nabla _ { \lambda } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) , } \\ & { \mathfrak { p } _ { 0 } ^ { \star } = \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) \right) ^ { - 1 } \left( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) + \kappa ( h _ { 0 } ^ { \star } - h _ { 1 } ^ { \star } ) \right) , } \\ & { \mathfrak { r } _ { 1 } ^ { \star } = \left( \nabla _ { h _ { 1 } } ^ { 2 } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) \right) ^ { - 1 } \left( \nabla _ { h _ { 1 } } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) - \kappa ( h _ { 0 } ^ { \star } - h _ { 1 } ^ { \star } ) \right) . } \end{array}
423
+ $$
424
+
425
+ Then the approximation error gap can be expressed as:
426
+
427
+ $$
428
+ \begin{array} { l } { \displaystyle \| \mathbf { g r a d } ( \lambda ) - \mathbf { g } \tilde { \mathbf { r a d } } ^ { \delta } ( \lambda ) \| = \| \left( B _ { 0 } ^ { \star } - A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } ^ { \star } + B _ { 1 } ^ { \star } - A _ { 1 } ^ { \star } \mathbf { p } _ { 1 } ^ { \star } \right) - \left( B _ { 0 } ^ { \epsilon } - A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } ^ { \delta } + B _ { 1 } ^ { \epsilon } - A _ { 1 } ^ { \epsilon } \mathbf { p } _ { 1 } ^ { \delta } \right) \| } \\ { \displaystyle \leq \sum _ { i = 0 } ^ { 1 } \| B _ { i } ^ { \star } - B _ { i } ^ { \epsilon } \| + \sum _ { i = 0 } ^ { 1 } \| A _ { i } ^ { \star } \mathbf { p } _ { i } ^ { \star } - A _ { i } ^ { \delta } \mathbf { p } _ { i } ^ { \delta } \| } \end{array}
429
+ $$
430
+
431
+ Due to the symmetric of $\mathcal { D } _ { 0 }$ and $\mathcal { D } _ { 1 }$ , we only focus on the term on $i = 0$ , the the upper bound in $i = 1$ can be derived analogously.
432
+
433
+ As for bounding $\| B _ { 0 } ^ { \star } - B _ { 0 } ^ { \epsilon } \|$ , since we assume first order derivative of the loss is Lipschitz functions (with constant $L _ { 1 }$ ), then we have :
434
+
435
+ $$
436
+ \| B _ { 0 } ^ { \star } - B _ { 0 } ^ { \epsilon } \| \leq L _ { 1 } \| h _ { 0 } ^ { \star } - h _ { 0 } ^ { \epsilon } \| \leq \epsilon L _ { 1 }
437
+ $$
438
+
439
+ Then the second term can be upper bounded by three terms:
440
+
441
+ $$
442
+ \bigl \| A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } ^ { \star } - A _ { 0 } ^ { \delta } \mathbf { p } _ { 0 } ^ { \delta } \bigr \| \leq \underbrace { \bigl \| A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } ^ { \star } - A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } \bigr \| } _ { ( 1 ) } + \underbrace { \bigl \| A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } - A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } \bigr \| } _ { ( 2 ) } + \underbrace { \bigl \| A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } - A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } ^ { \delta } \bigr \| } _ { ( 3 ) }
443
+ $$
444
+
445
+ Before estimating the upper bound, we first demonstrate $\| A _ { 0 } ^ { \epsilon } \|$ and $\| A _ { 0 } ^ { \star } \|$ are also bounded.
446
+
447
+ Since we assume $\lambda$ and $h$ are bounded (assuming the bounded constant as $\eta$ and $\phi$ ), the second order derivative are Lipschitz (with constant $L _ { 2 }$ ). Then we consider another fixed point $( \lambda ^ { \prime } , h _ { 0 } ^ { \star } ( \lambda ^ { \prime } ) )$ with bounded second order derivative: $A _ { 0 } = \nabla _ { h _ { 0 } , \lambda } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } ( \lambda ^ { \prime } ) , \lambda ^ { \prime } )$ and $\| A _ { 0 } \| \leq A$ . We have:
448
+
449
+ $$
450
+ \begin{array} { r } { \| A _ { 0 } ^ { \star } - A _ { 0 } \| _ { 2 } \leq L _ { 2 } \| [ h _ { 0 } ^ { \star } ( \lambda ) , \lambda ] - [ h _ { 0 } ^ { \star } ( \lambda ^ { \prime } ) , \lambda ^ { \prime } ] \| _ { 2 } \leq L _ { 2 } \sqrt { \eta ^ { 2 } + \phi ^ { 2 } } } \end{array}
451
+ $$
452
+
453
+ Thus we have be upper boun $\| A _ { 0 } ^ { \star } \| \le A + L _ { 2 } \sqrt { \eta ^ { 2 } + \phi ^ { 2 } } = A _ { \operatorname* { s u p } } ^ { \star }$ . Aant the second derivative at point . $h _ { 0 } ^ { \epsilon }$ , it can $A _ { \mathrm { s u p } } ^ { \epsilon }$
454
+
455
+ # The upper bound of term (1) We have:
456
+
457
+ $$
458
+ \| A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } ^ { \star } - A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } \| \leq \| A _ { 0 } ^ { \star } \| \| \mathbf { p } _ { 0 } ^ { \star } - \mathbf { p } _ { 0 } \|
459
+ $$
460
+
461
+ We have proved $\| A _ { 0 } ^ { \star } \|$ is upper bounded by $A _ { \mathrm { s u p } } ^ { \star }$ . We additionally introduce the following auxiliary terms:
462
+
463
+ $$
464
+ \begin{array} { r l } & { P _ { 0 } ^ { \star } = \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) \right) ^ { - 1 } , P _ { 0 } ^ { \epsilon } = \left( \nabla _ { h _ { 1 } } ^ { 2 } \mathcal { L } _ { 1 } ( h _ { 1 } ^ { \star } , \lambda ) \right) ^ { - 1 } . } \\ & { b _ { 0 } ^ { \star } = \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) + \kappa ( h _ { 0 } ^ { \star } - h _ { 1 } ^ { \star } ) , b _ { 0 } ^ { \epsilon } = \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) + \kappa ( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } ) } \end{array}
465
+ $$
466
+
467
+ Then we have:
468
+
469
+ $$
470
+ \begin{array} { r l } & { \| \mathbf { p } _ { 0 } ^ { \star } - \mathbf { p } _ { 0 } \| = \| P _ { 0 } ^ { \star } b _ { 0 } ^ { \star } - P _ { 0 } ^ { \epsilon } b _ { 0 } ^ { \epsilon } \| } \\ & { \qquad \leq \| P _ { 0 } ^ { \star } b _ { 0 } ^ { \star } - P _ { 0 } ^ { \star } b _ { 0 } ^ { \epsilon } \| + \| P _ { 0 } ^ { \star } b _ { 0 } ^ { \epsilon } - P _ { 0 } ^ { \epsilon } b _ { 0 } ^ { \epsilon } \| } \\ & { \qquad \leq \| P _ { 0 } ^ { \star } \| \| b _ { 0 } ^ { \star } - b _ { 0 } ^ { \epsilon } \| + \| b _ { 0 } ^ { \epsilon } \| \| P _ { 0 } ^ { \star } - P _ { 0 } ^ { \epsilon } \| } \end{array}
471
+ $$
472
+
473
+ As for the $\| P _ { 0 } ^ { \star } \|$ , since we assume the Hessian matrix is invertible thus its norm is upper bounded by some constant (denoted as $A _ { - 1 }$ ). As for $\| b _ { 0 } ^ { \star } - b _ { 0 } ^ { \epsilon } \|$ , we have:
474
+
475
+ $$
476
+ \begin{array} { r l } & { \| b _ { 0 } ^ { \star } - b _ { 0 } ^ { \epsilon } \| \leq \| \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) - \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \| + 2 \kappa \epsilon } \\ & { \qquad \leq \epsilon L _ { 1 } + 2 \kappa \epsilon } \end{array}
477
+ $$
478
+
479
+ Thus we have $\| P _ { 0 } ^ { \star } \| \| b _ { 0 } ^ { \star } - b _ { 0 } ^ { \epsilon } \| \leq A _ { - 1 } ( \epsilon L _ { 1 } + 2 \kappa \epsilon )$ .
480
+
481
+ As for $\| b _ { 0 } ^ { \epsilon } \|$ , we can easily verify that it is indeed bounded by some constant $b$ . For the first term, we can adopt the same strategy in proving bounded $\| A _ { 0 } ^ { \star } \|$ . As for the second term in $b _ { 0 } ^ { \epsilon }$ , it is upper bounded by $2 \kappa \phi$ , due to the bounded predictor.
482
+
483
+ We now demonstrate $\| P _ { 0 } ^ { \star } - P _ { 0 } ^ { \epsilon } \|$ . Denoting $\Delta = ( P _ { 0 } ^ { \star } ) ^ { - 1 } - ( P _ { 0 } ^ { \epsilon } ) ^ { - 1 }$ , then according to the second order Lipschitz assumption, we have: $\lVert \Delta \rVert \leq \epsilon L _ { 2 }$ . Plugging in the result, we have:
484
+
485
+ $$
486
+ \begin{array} { r } { \| P _ { 0 } ^ { \star } - P _ { 0 } ^ { \epsilon } \| = \| ( P _ { 0 } ^ { \star } ) \Delta ( P _ { 0 } ^ { \epsilon } ) \| \le \| P _ { 0 } ^ { \star } \| \| \Delta \| \| P _ { 0 } ^ { \epsilon } \| \le ( A _ { - 1 } ) ^ { 2 } L _ { 2 } \epsilon } \end{array}
487
+ $$
488
+
489
+ We still adopt the assumption that the bounded Hessian-inverse matrix by $A _ { - 1 }$
490
+
491
+ Plugging in all the results, we have:
492
+
493
+ $$
494
+ ( 1 ) \le A _ { 1 } ( \epsilon L _ { 1 } + 2 \kappa \epsilon ) + b ( A _ { 1 } ) ^ { 2 } L _ { 2 } \epsilon : = \mathcal { O } ( \kappa \epsilon + \epsilon )
495
+ $$
496
+
497
+ The upper bound of term (2) We have:
498
+
499
+ $$
500
+ \| A _ { 0 } ^ { \star } \mathbf { p } _ { 0 } - A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } \| \leq \| \mathbf { p } _ { 0 } \| _ { 2 } \| A _ { 0 } ^ { \star } - A _ { 0 } ^ { \epsilon } \|
501
+ $$
502
+
503
+ Since we assume the loss is second-order Lipschitz, thus we have
504
+
505
+ $$
506
+ \begin{array} { r } { \| A _ { 0 } ^ { \star } - A _ { 0 } ^ { \epsilon } \| = \| \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \star } , \lambda ) - \nabla _ { \lambda } \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda ) \| \le L _ { 2 } \| h _ { 0 } ^ { \star } - h _ { 0 } ^ { \epsilon } \| \le \epsilon L _ { 2 } } \end{array}
507
+ $$
508
+
509
+ We can also demonstrate $\left\| \mathbf { p } _ { 0 } \right\|$ is bounded. According to the definition we have:
510
+
511
+ $$
512
+ \begin{array} { r l } & { \| \mathbf { p } _ { 0 } \| \leq \| \left( \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } { \left( h _ { 0 } ^ { \epsilon } , \lambda \right) } \right) ^ { - 1 } \| \| \left( \nabla _ { h _ { 0 } } \mathcal { L } _ { 0 } { \left( h _ { 0 } ^ { \epsilon } , \lambda \right) } + \kappa { \left( h _ { 0 } ^ { \epsilon } - h _ { 1 } ^ { \epsilon } \right) } \right) \| } \\ & { \quad \overset { ( i ) } { \leq } A _ { - 1 } { \left( L _ { 1 } \| h _ { 0 } ^ { \star } - h _ { 0 } ^ { \epsilon } \| _ { 2 } + 2 \kappa \phi \right) } } \\ & { \quad \overset { ( i i ) } { \leq } A _ { - 1 } { \left( \epsilon L _ { 1 } + 2 \kappa \phi \right) } } \end{array}
513
+ $$
514
+
515
+ For (i), we assume: 1) the Hessian matrix is invertible thus its norm is surely upper bounded by some constant (denoted as $A _ { - 1 }$ ), 2) the first-order derivative is Lipschitz (bounded by $L _ { 1 }$ ), 3) the predictor $h$ is bounded. For (ii), we adopt the definition of $h _ { 0 } ^ { \epsilon }$ .
516
+
517
+ Therefore, the upper bound for Term (2) is formulated as:
518
+
519
+ $$
520
+ ( 2 ) \le \epsilon L _ { 2 } A _ { - 1 } ( \epsilon L _ { 1 } + 2 \kappa \phi ) : = \mathcal { O } ( \kappa \epsilon )
521
+ $$
522
+
523
+ The upper bound of term (3) We have:
524
+
525
+ $$
526
+ \| A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } - A _ { 0 } ^ { \epsilon } \mathbf { p } _ { 0 } ^ { \delta } \| \leq \| A _ { 0 } ^ { \epsilon } \| \| \mathbf { p } _ { 0 } - \mathbf { p } _ { 0 } ^ { \delta } \| \leq \delta A _ { \mathrm { s u p } } ^ { \epsilon } = \mathcal { O } ( \delta )
527
+ $$
528
+
529
+ Through the upper bound in (1)-(3), we finally have the error between the estimated and ground-truth gradient:
530
+
531
+ $$
532
+ \lVert \mathbf { g r a d } ( \lambda ) - \mathbf { g } \tilde { \mathbf { r a d } } ^ { \delta } ( \lambda ) \rVert = \mathcal { O } ( \kappa \epsilon + \epsilon + \delta )
533
+ $$
534
+
535
+ # C THE CONVERGENCE BEHAVIOR
536
+
537
+ For the sake of completeness, we provide the convergence analysis of the proposed algorithm.
538
+
539
+ Proposition 2. We execute the implicit alignment algorithm (Algo. 1), obtaining a sequence of $\lambda _ { 1 } , \ldots , \lambda _ { k } , \ldots .$ . Supposing the fair constraint $\kappa$ is fixed. The optimization tolerances are summable: $\textstyle \sum _ { k } \epsilon _ { k } ^ { 2 } \leq + \infty$ and $\textstyle \sum _ { k } \delta _ { k } ^ { 2 ^ { - } } \leq + \infty$ , then $\lambda _ { k }$ is proved to be converged with
540
+
541
+ $$
542
+ \operatorname* { l i m } _ { k \to \infty } \lambda _ { k } = \lambda ^ { \star } .
543
+ $$
544
+
545
+ If the stationary point $\lambda ^ { \star }$ is also within the bounded norm, then we have:
546
+
547
+ $$
548
+ g r a d ( \lambda ^ { \star } ) = 0 .
549
+ $$
550
+
551
+ Proof. We denote the entire outer-level loss w.r.t. $\lambda$ as $\mathcal { L } ( \lambda )$ , by the assumption the $\beta$ -smooth loss $\mathcal { L }$ . Then at iteration $k + 1$ and $k$ , we have:
552
+
553
+ $$
554
+ \begin{array} { l } { \displaystyle \Xi ( \lambda _ { k + 1 } ) \leq \mathcal { L } ( \lambda _ { k } ) - \mathrm { g r a d } ( \lambda _ { k } ) ^ { T } ( \lambda _ { k } - \lambda _ { k + 1 } ) + \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } } \\ { \displaystyle = \mathcal { L } ( \lambda _ { k } ) - \Big ( \mathrm { g r a d } ( \lambda _ { k } ) - \mathrm { g r a d } ^ { \delta } ( \lambda _ { k } ) + \mathrm { g r a d } ^ { \delta } ( \lambda _ { k } ) \Big ) ^ { T } ( \lambda _ { k } - \lambda _ { k + 1 } ) + \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } } \\ { \displaystyle = \mathcal { L } ( \lambda _ { k } ) - \Big ( \mathrm { g r a d } ( \lambda _ { k } ) - \mathrm { g r a d } ^ { \delta } ( \lambda _ { k } ) \Big ) ^ { T } ( \lambda _ { k } - \lambda _ { k + 1 } ) - \mathrm { g r a d } ^ { \delta } ( \lambda _ { k } ) ( \lambda _ { k } - \lambda _ { k + 1 } ) + \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } } \end{array}
555
+ $$
556
+
557
+ Since we assume the representation is within the bounded norm, the projection onto the convex set are non-expansive operators (Boyd et al., 2004). Then for any point $p , q$ , we have $\| \mathrm { p r o j } ( p ) -$ $\operatorname { p r o j } ( q ) \Vert ^ { 2 } \leq ( p - q ) ^ { T } \left( \operatorname { p r o j } ( p ) - \operatorname { p r o j } ( q ) \right)$ . Then we set $\lambda _ { k }$ and $\begin{array} { r } { \lambda _ { k + 1 } = \lambda _ { k } - \frac { 1 } { \beta } \tilde { \mathrm { g r a d } } ^ { \delta } ( \lambda _ { k } ) } \end{array}$ , we have:
558
+
559
+ $$
560
+ \| \lambda _ { k } - \lambda _ { k + 1 } \| ^ { 2 } \leq \frac { 1 } { \beta } ( \tilde { \mathrm { g r a d } } ^ { \delta } ( \lambda _ { k } ) ) ^ { T } ( \lambda _ { k } - \lambda _ { k + 1 } )
561
+ $$
562
+
563
+ Plugging into the results, we have:
564
+
565
+ $$
566
+ \begin{array} { r l r } { { \mathcal { L } ( \lambda _ { k + 1 } ) \le \mathcal { L } ( \lambda _ { k } ) - ( \operatorname { g r a d } ( \lambda _ { k } ) - \operatorname { g r a d } ^ { \delta } ( \lambda _ { k } ) ) ^ { T } ( \lambda _ { k } - \lambda _ { k + 1 } ) - \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } } } \\ & { } & { \ \le \mathcal { L } ( \lambda _ { k } ) + \| \operatorname { g r a d } ( \lambda _ { k } ) - \operatorname { g r a d } ^ { \delta } ( \lambda _ { k } ) \| \| \lambda _ { k } - \lambda _ { k + 1 } \| - \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } } \end{array}
567
+ $$
568
+
569
+ Rearranging the inequality, we have:
570
+
571
+ $$
572
+ \frac { \beta } { 2 } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } - \| \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g r a d } ^ { \delta } ( \lambda _ { k } ) \| \| \lambda _ { k } - \lambda _ { k + 1 } \| + ( \mathcal { L } ( \lambda _ { k + 1 } ) - \mathcal { L } ( \lambda _ { k } ) ) \leq 0
573
+ $$
574
+
575
+ Then we have:
576
+
577
+ $$
578
+ \lambda _ { k + 1 } - \lambda _ { k } \| \leq { \frac { 1 } { \beta } } \left( \| \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g r a d } ^ { \delta } ( \lambda _ { k } ) \| + { \sqrt { \| \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g r a d } ^ { \delta } ( \lambda _ { k } ) \| ^ { 2 } - 2 \beta \left( { \mathcal { L } } ( \lambda _ { k + 1 } ) - { \mathcal { L } } ( \lambda _ { k } ) \right) } } \right)
579
+ $$
580
+
581
+ By denoting $B _ { k } = \Vert \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g } \mathbf { \tilde { r a d } } ^ { \delta } ( \lambda _ { k } ) \Vert$ and $C _ { k } = \mathcal { L } ( \lambda _ { k + 1 } ) - \mathcal { L } ( \lambda _ { k } )$ . Then we have:
582
+
583
+ $$
584
+ \begin{array} { l } { { \displaystyle \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } \le \frac { 1 } { \beta ^ { 2 } } \left( B _ { k } ^ { 2 } + B _ { k } ^ { 2 } - 2 \beta C _ { k } + 2 B _ { k } \sqrt { B _ { k } ^ { 2 } - 2 \beta C _ { k } } \right) } } \\ { ~ \le \frac { 1 } { \beta ^ { 2 } } \left( B _ { k } ^ { 2 } + B _ { k } ^ { 2 } - 2 \beta C _ { k } + B _ { k } ^ { 2 } + B _ { k } ^ { 2 } - 2 \beta C _ { k } \right) } \\ { ~ = \frac { 4 } { \beta ^ { 2 } } [ \| \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g \tilde { r a d } } ^ { \delta } ( \lambda _ { k } ) \| _ { 2 } ^ { 2 } - 2 \beta \left( \mathcal { L } ( \lambda _ { k + 1 } ) - \mathcal { L } ( \lambda _ { k } ) \right) ] } \end{array}
585
+ $$
586
+
587
+ Taking sum over $k$ , we have:
588
+
589
+ $$
590
+ \begin{array} { r l r } { { \sum _ { k = 1 } ^ { + \infty } \| \lambda _ { k + 1 } - \lambda _ { k } \| ^ { 2 } \le \frac { 4 } { \beta ^ { 2 } } \sum _ { k = 1 } ^ { + \infty } \| \mathbf { g r a d } ( \lambda _ { k } ) - \mathbf { g r \tilde { a d } } ^ { \delta } ( \lambda _ { k } ) \| _ { 2 } ^ { 2 } - \frac { 8 } { \beta } ( \operatorname* { l i m } _ { k \to \infty } \mathcal { L } ( \lambda _ { k + 1 } ) - \mathcal { L } ( \lambda _ { 1 } ) ) } } \\ & { } & { \le \frac { 4 } { \beta ^ { 2 } } \sum _ { k } [ ( C + \kappa ) ^ { 2 } \epsilon _ { k } ^ { 2 } + \delta _ { k } ^ { 2 } ] - \frac { 8 } { \beta } ( \operatorname* { l i m } _ { k \to \infty } \mathcal { L } ( \lambda _ { k + 1 } ) - \mathcal { L } ( \lambda _ { 1 } ) ) < + \infty } \end{array}
591
+ $$
592
+
593
+ Since 1) the first term on the right side is finite, because the optimization tolerance is summable; 2) the second term is also finite, because the loss is assumed to be bounded. Then the upper bound is finite. In order to satisfy this condition, on the left side we should have:
594
+
595
+ $$
596
+ \operatorname* { l i m } _ { k \to \infty } \lambda _ { k + 1 } - \lambda _ { k } = 0
597
+ $$
598
+
599
+ By adopting the definition $\lambda _ { k + 1 } = \mathrm { P r o j } ( \lambda _ { k } - \mathrm { g } \tilde { \mathrm { r a d } } ^ { \delta } ( \lambda _ { k } ) )$ and $\begin{array} { r } { \operatorname* { l i m } _ { k \to \infty } \tilde { \mathrm { g r a d } ^ { \delta } } ( \lambda _ { k } ) = \mathrm { g r a d } ( \lambda _ { k } ) } \end{array}$ (Based on theorem 1, the limit of the optimization tolerance is zero), then we have:
600
+
601
+ $$
602
+ \lambda ^ { \star } = \operatorname { p r o j } ( \lambda ^ { \star } - \operatorname { g r a d } ( \lambda ^ { \star } ) )
603
+ $$
604
+
605
+ Where $\begin{array} { r } { \lambda ^ { \star } = \operatorname* { l i m } _ { k \to + \infty } \lambda _ { k + 1 } = \operatorname* { l i m } _ { k \to + \infty } \lambda _ { k } } \end{array}$ . Since the projection is on the bounded norm $L _ { \mathrm { n o r m } }$ and $\lambda ^ { \star }$ is within the bounded norm space, thus if $\lambda ^ { \star } - \operatorname { g r a d } ( \lambda ^ { \star } )$ is within the bounded norm space, we have:
606
+
607
+ $$
608
+ \operatorname { g r a d } ( \lambda ^ { \star } ) = 0
609
+ $$
610
+
611
+ Else if $\lambda ^ { \star } - \mathrm { g r a d } ( \lambda ^ { \star } )$ is outside the bounded norm space, then according to the definition, the projection of $\lambda ^ { \star } - \operatorname { g r a d } ( \lambda ^ { \star } )$ is surely on the boundary of the $L _ { \mathrm { n o r m } }$ space, with $\| \mathrm { p r o j } ( \lambda ^ { \star } - \mathbf { g r a d } ( \lambda ^ { \star } ) ) \bar { \mathbf { \zeta } } \| =$ $L _ { \mathrm { n o r m } }$ . However, we have assumed the $\lambda ^ { \star }$ is within the bounded norm space with $\| \lambda ^ { \star } \| < L _ { \mathrm { n o r m } }$ , which leads to the contradiction. Based on these discussions, we finally have:
612
+
613
+ $$
614
+ \operatorname { g r a d } ( \lambda ^ { \star } ) = 0
615
+ $$
616
+
617
+ # D ADDITIONAL EXPERIMENTAL DETAILS AND RESULTS
618
+
619
+ # D.1 ADDITIONAL DETAILS
620
+
621
+ Toxic Comments We split the training, validation and testing set as $7 0 \%$ , $1 0 \%$ and $2 0 \%$ . We adopt Adam optimizer with learning rate $1 0 ^ { - 3 }$ and eps $1 0 ^ { - 3 }$ . The batch-size is set as 500 for each subgroup and we use sampling with replacement to run the explicit algorithm with maximum epoch 100. The fair coefficient is generally set as $\kappa = 0 . 1 \sim 0 . 0 0 1$ . As for the inner-optimization step, the iteration number is 20 and the iteration in running conjugate gradient approach is 10.
622
+
623
+ CelebA The training/validation/test set are around 82K, 18K and 18K. We also adopt the Adam optimizer with learning rate on $\lambda : 1 0 ^ { - 5 } \sim 1 0 ^ { - 4 }$ and $h : 1 0 ^ { - 3 }$ . The batch-size is set as 64 for each subgroup and we iterate the whole dataset as one epoch. The maximum running epoch is set as 20 and the iteration in running conjugate gradient approach is 10.
624
+
625
+ Law We split the training, validation and testing set as $7 0 \%$ , $1 0 \%$ and $2 0 \%$ . Then we adopt Adam optimizer with learning rate $1 0 ^ { - 3 }$ and eps $1 0 ^ { - 3 }$ . The batch-size is set as 500 for each subgroup and we use sampling with replacement to run the implicit algorithm, with the maximum epoch 100. We adopt the MSE loss in the regression. The fair coefficient is generally set as $\kappa = 0 . { \overset { \underset { \textstyle } { \aa } } { \mathrm { 1 } } } \sim 1 0 ^ { - 4 }$ . As for the inner-optimization, the iteration number is 20 and the iteration in running conjugate gradient is 10. In computing the sufficiency gap in the regression, we sample 33 points to compute the gap.
626
+
627
+ NLSY We split the training, validation and testing set as $7 0 \%$ , $1 0 \%$ and $2 0 \%$ . Then we adopt Adam optimizer with learning rate $1 0 ^ { - 3 }$ and eps $\mathrm { \bar { 1 } 0 ^ { - 3 } }$ . The batch-size is set as 500 for each subgroup and we use sampling with replacement to run the implicit algorithm, with maximum epoch 100. We adopt the MSE loss in the regression. The fair coefficient is generally set as $\kappa \stackrel { \cdot } { = } 0 . 1 \sim 1 0 ^ { - 4 }$ . As for the inner-optimization, the iteration number is 20 and the iteration in running conjugate gradient is 10. In computing the sufficiency gap, we sample 33 points to compute the sufficiency gap.
628
+
629
+ # D.2 ADDITIONAL EMPIRICAL RESULTS
630
+
631
+ ![](images/859e60112ebd2a8d18c0384384bed66411962f5d17cebfadf3ed65e260e8a91a.jpg)
632
+ Figure 9: Computational time between $T$ -step explicit and implicit approach in CelebA. Specifically, solver $= ~ 2$ indicates the the conjugate gradient is executed 2 iterations. The results reveals the benefits of implicit approach: avoiding the back-propagation through the inner-optimization path. In contrast, the time complexity in explicit approach linearly increases with the inner-optimization step, which is consistent with our analysis.
633
+
634
+ Computational complexity To show the efficiency of the implicit approach, we empirically compare the computational complexity of the $T$ -step explicit alignment and implicit approach (for different iterations of conjugate gradient solver.) The experimental results verified the efficiency of the implicit approach, where a significant large inner-optimization step does not considerably increase the computational time.
635
+
636
+ Gradient evolution We also visualize the gradient norm of the representation $\lambda$ in the Toxic dataset, shown in Fig. 10. The results verify the convergence behavior and the gradient norm finally tends to zero.
637
+
638
+ # D.3 DISCUSSION WITH NON-DEEP LEARNING BASELINES
639
+
640
+ In order to show the effectiveness of the proposed approach, we additionally compare the FAHT (Zhang & Ntoutsi, 2019), a decision tree based fair classification approach. We evaluated the empirical performance on Toxic comments dataset.
641
+
642
+ ![](images/3aed371a868af233a012897f3e4d24d57173a65342ecf1b6f2aa2936ac86fdc1.jpg)
643
+ Figure 10: Gradient Norm evolution w.r.t. representation $\lambda$ in Toxic comments dataset. We visualize the norm of $\tilde { \mathrm { g r a d } } ^ { \delta } ( \lambda )$ at each training epoch, which suggests a convergence behavior and the gradient finally tends to zero.
644
+
645
+ Table 5: Comparison with Fairness Aware Decision Tree
646
+
647
+ <table><tr><td>Method</td><td>Accuracy (↑)</td><td>△Sufc (↓)</td></tr><tr><td>FAHT</td><td>0.596</td><td>0.397</td></tr><tr><td>Implicit</td><td>0.760</td><td>0.051</td></tr></table>
648
+
649
+ The implicit approach demonstrates the considerable better results, which may come from two aspects: (1) the Toxic task is a high-dimensional classification problem $( x \in \mathbb { R } ^ { 7 4 8 }$ ), where the deep learning based approach is more effective in handling the high-dim dataset. (2) The FAHT aims to realize the statistical parity (the independence rule), which is not compatible with the sufficiency. According to the analysis of (Barocas et al., 2019), when the sensitive attribute (A) and label (Y) are not independent (This has been justified by computing their Pearson Correlation coefficient), the sufficiency and independence cannot both hold.
650
+
651
+ # D.4 SUFFICIENCY GAP IN REGRESSION
652
+
653
+ We visualize the sufficiency gap of NLSY dataset.
654
+
655
+ # E COMPLEMENTARY TECHNICAL DETAILS
656
+
657
+ We present complementary details that are related to the paper.
658
+
659
+ # E.1 CONJUGATE GRADIENT METHOD
660
+
661
+ We present the Conjugate Gradient (CG) algorithm in Algo. 2 through autograd. In the conventional CG algorithm with objective $\overset { 1 } { 2 } x ^ { T } A X - b X$ , we need to estimate $A X$ and compute its residual and update $X$ . Since in our problem setting, the $A = \nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \epsilon } , \lambda )$ , then computing $A X$ can be realized through Hessian-vector product through autograd, denoted as function $F$ in the paper. i.e., $\nabla _ { h _ { 0 } } ^ { 2 } \mathcal { L } _ { 0 } ( h _ { 0 } ^ { \bar { \epsilon } } , \lambda ) X = F ( x )$ .
662
+
663
+ Below we provided a simple PyTorch code for realizing the Hessian Vector product.
664
+
665
+ 2 def hessain_vector_product(loss,model,vector):
666
+
667
+ # loss: the defined loss
668
+ # model: the model in computing the Hessian
669
+ # vector: the required vector in computing Hessian-vector product
670
+
671
+ ![](images/05caddcc70dc9dfb0af4a78fd35a31920ce4619b44798b4a10b20210b97aced5.jpg)
672
+ Figure 11: Illustration of the sufficiency gap in NLSY dataset. The ERM and mix-up suffer the high predictive sufficiency-gap, while the proposed implicit alignment can significantly mitigate the sufficiency gap. In contrast, the probability calibration is not improved. This results also verifies the inequivalence between the sufficiency gap and calibration gap (Liu et al., 2019).
673
+ Listing 1: Simple demo in computing Hessian vector product
674
+
675
+ # Algorithm 2 Conjugate Gradient Method
676
+
677
+ Ensure: Function $F$ that computes Hessian-vector product through autograd, initial value $X _ { 0 }$ ,
678
+ bias vector $B$ .
679
+ 1: Computing Residual: $r _ { 0 } = B - F ( X _ { 0 } )$
680
+ 2: Set $p _ { 0 } = r _ { 0 }$
681
+ 3: for inner iterations $k$ do
682
+ 4: Computing $\begin{array} { r } { \alpha _ { k } \frac { r _ { k } ^ { T } r _ { k } } { p _ { k } ^ { T } F ( p _ { k } ) } } \end{array}$
683
+ 5: Xk+1 ← Xk + αkpk
684
+ 6: $r _ { k + 1 } \gets r _ { k } - \alpha _ { k } F ( p _ { k } )$
685
+ 7: If $r _ { k + 1 }$ is sufficiency small, then stop.
686
+ 8: $\begin{array} { r } { \beta _ { k } \gets \frac { r _ { k + 1 } ^ { T } r _ { k + 1 } } { r _ { k } ^ { T } r _ { k } } } \end{array}$
687
+ 9: $p _ { k + 1 } r _ { k + 1 } + \beta _ { k } p _ { k }$
688
+ 10: end for
689
+ 11: return $X _ { k + 1 }$
690
+
691
+ 6 partial_grad $=$ torch.autograd.grad(loss, model_parameters(), create_graph ${ \bf \Phi } = { \bf \Phi }$ True) flat_grad $=$ torch.cat([g.contiguous().view(-1) for g in partial_grad ])
692
+ 8 $\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ torch.sum(flat_grad $\star$ vector_to_optimize)
693
+ 9 hvp $=$ torch.autograd.grad(h, model.parameters())
694
+ 10 return hvp
695
+
696
+ # E.2 CALIBRATION GAP IN THE REGRESSION
697
+
698
+ Based on Kuleshov et al. (2018), we first compute the predicted cumulative distribution $( \hat { Y } _ { 0 } )$ of at point $t$ : $D _ { 0 } ( \hat { Y } _ { 0 } \leq t ) = \alpha$ , then we compute the corresponding ground truth cumulative distribution $( Y _ { 0 } )$ at point $t$ . By changing $t$ , we obtain several points on function $\mathcal { D } _ { 0 } ( Y \leq t | \hat { Y } _ { 0 } \leq t ) = \beta$ . Then the regression is probabilistic calibrated when $\alpha \equiv \beta$ . From this perspective, the zero calibration gap can guarantee a zero sufficiency gap. But the inverse is not necessarily true, as our experimental results suggest, a small sufficiency gap can lead to either small or large calibration gap. Thus it can be quite promising to explore their inherent relations and trade-off in the fair regression.
md/dev/s1FjXzJ0jy/s1FjXzJ0jy.md ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Focused Transformer: Contrastive Training for Context Scaling
2
+
3
+ Szymon Tworkowski1,3∗ Konrad Staniszewski1,3∗ Mikołaj Pacek1,3∗ Yuhuai Wu6†
4
+
5
+ Henryk Michalewski3,4 Piotr Miłos´1,2,5
6
+
7
+ 1IDEAS NCBR 2Institute of Mathematics, Polish Academy of Sciences 3University of Warsaw 4Google DeepMind 5deepsense.ai 6xAI
8
+
9
+ # Abstract
10
+
11
+ Large language models have an exceptional capability to incorporate new information in a contextual manner. However, the full potential of such an approach is often restrained due to a limitation in the effective context length. One solution to this issue is to endow an attention layer with access to an additional context, which comprises of (key, value) pairs. Yet, as the number of documents increases, the proportion of relevant keys to irrelevant ones decreases, leading the model to focus more on the irrelevant keys. We identify a significant challenge, dubbed the distraction issue, where keys linked to different semantic values might overlap, making them hard to distinguish. To tackle this problem, we introduce the Focused Transformer (FOT), a technique that employs a training process inspired by contrastive learning. This novel approach enhances the structure of the (key, value) space, enabling an extension of the context length. Our method allows for fine-tuning pre-existing, large-scale models to lengthen their effective context. This is demonstrated by our fine-tuning of $3 B$ and $7 B$ OpenLLaMA checkpoints. The resulting models, which we name LONGLLAMA2, exhibit advancements in tasks requiring a long context. We further illustrate that our LONGLLAMA models adeptly manage a $2 5 6 k$ context length for passkey retrieval.
12
+
13
+ # 1 Introduction
14
+
15
+ Language models have served as a catalyst for substantial advancements in several areas, including natural language processing [Radford et al., 2019, Brown et al., 2020], code generation [Chen et al., 2021, Li et al., 2022], quantitative reasoning [Lewkowycz et al., 2022] and theorem proving [Polu and Sutskever, 2020, Jiang et al., 2022, Mikuła et al., 2023]. One of the central challenges with language models is the effective incorporation of extensive new knowledge. The common practice of fine-tuning the model is not only resource-intensive and complex to manage, but it also does not always clearly indicate how to incorporate new knowledge. For example, fine-tuning on a text such as “Alice in Wonderland” does not equip the model to answer questions about the story itself, but rather it trains the model to predict the next token or complete masked sentences. A promising alternative – integrating the new knowledge within the context – doesn’t require training but is considerably restricted by the model’s effective context length. For this method to work with large knowledge databases (like large code repositories), the model needs to manage a context length extending to millions of tokens.
16
+
17
+ ![](images/c5a6cdcd0426335804cd1903718f42c671b3e41ff13b4124ec33873614ca7705.jpg)
18
+ Figure 1: Accuracy of LONGLLAMA $3 B$ on passkey retrieval compared to the original OpenLLaMA model. Our method extrapolates beyond the training length, achieving $9 4 . 5 \%$ accuracy at a context length of $1 0 0 k$ and $7 3 \%$ at $2 5 6 k$ tokens, while the baseline is unable to handle context longer than its training length $( 2 k )$ .
19
+
20
+ In this research, we highlight one of the primary obstacles in augmenting the context length: as the number of documents increases, the ratio of pertinent to irrelevant tokens diminishes. The standard training procedure frequently results in overlaps between keys connected with irrelevant values and those related to relevant ones, exacerbating the model’s task of differentiating between them. We term this challenge the distraction issue.
21
+
22
+ We propose the Focused Transformer (FOT), an innovative technique developed explicitly to address this issue. The Focused Transformer permits a subset of attention layers to access an additional context of (key, value) pairs through the k-nearest neighbors (kNN) algorithm, akin to the method used in [Wu et al., 2022]. This mechanism effectively extends the total context length. The distinctive aspect of the Focused Transformer is its training procedure, drawing from contrastive learning. This method addresses the distraction issue and facilitates larger context capacities. Specifically, during the training phase, we deliberately expose the chosen subset of attention layers to both relevant and irrelevant keys (like negative samples from unrelated documents). This strategy incentives the model to differentiate keys connected with semantically diverse values, thereby enhancing their structure.
23
+
24
+ We introduce and make available LONGLLAMAs $( \nwarrow 1 )$ , fine-tuned OpenLLaMA models with FOT, demonstrating that our method does not require long context during training and can be applied to existing models. Notably, LONGLLAMAs show significant improvements on tasks necessitating long-context modeling. In particular, they can manage a $2 5 6 k$ context length on the passkey retrieval task [Mohtashami and Jaggi, 2023].
25
+
26
+ Our research contributions are the following:
27
+
28
+ 1. We pinpoint the distraction issue as a significant challenge and a primary obstacle to scaling up the context length in Transformer models, particularly in multi-document scenarios.
29
+
30
+ 2. We develop the Focused Transformer (FOT), designed to alleviate the distraction issue. FOT includes a unique training objective that improves the (key, value) structure, enabling the use of extensive additional context and k-nearest neighbors lookup to scale the context length.
31
+
32
+ 3. Our method is simple to implement, and it provides the benefit of extending model context without modifying the architecture, facilitated by cost-effective fine-tuning. We demonstrate this on the $3 B$ and $7 B$ OpenLLaMA checkpoints. The resulting models, named LONGLLAMAs, display enhancements on tasks that benefit from increasing the number of few-shot demonstrations in the extended context, such as TREC [Li and Roth, 2002, Hovy et al., 2001] and WebQS [Berant et al.,
33
+
34
+ 2013]. We also prove that for passkey retrieval Mohtashami and Jaggi [2023], our LONGLLAMA models successfully handle a $2 5 6 k$ context length.
35
+
36
+ 4. We further scrutinize FOT’s capabilities across various datasets and model sizes. We show that a FOT trained with a total context of 512 tokens can extrapolate to 16 million tokens in a benchmark dictionary lookup task. We also assess FOT on long-context language modeling tasks such as books (PG-19), mathematics (arXiv), code (GitHub), and formal proofs (Isabelle), where it exhibits improvements in perplexity over baselines.
37
+
38
+ # 2 Related work
39
+
40
+ Long-context transformer architectures A multitude of approaches have been developed to increase the context length of transformers, mostly focusing on alleviating the quadratic complexity of the attention computation. For instance, Transformer-XL [Dai et al., 2019] caches the previous context and enables the linear extension of context with the number of layers. Longformer [Beltagy et al., 2020] employs an attention mechanism that allows tokens to attend to distant tokens sparsely, reducing the computational complexity. BigBird [Zaheer et al., 2020], LongT5 [Guo et al., 2021], and [Dao et al., 2022] also use sparse attention to handle long sequences. Different efficiency considerations have been studied in [Kaddour et al., 2023], showing that they lead to limited gains. Hierarchical transformers [Nawrot et al., 2021, 2023] downsample activations in intermediate layers to reduce computation and enable longer contexts. COLT5 [Ainslie et al., 2023] proposes conditional computation to save memory and enable larger contexts. Memorizing Transformer [Wu et al., 2022] uses kNN lookup to pick up the most relevant tokens, which might also be seen as a way to reduce the computational complexity of attention. Our work adheres to this approach and aims to train a key space that handles longer attention context length (e.g., by mitigating the distraction issue) and, thus, has better long-context capabilities.
41
+
42
+ Fine-tuning LLMs for longer retrieval Prior works such as RETRO [Borgeaud et al., 2022] (RETROfitting) and Memorizing Transformer [Wu et al., 2022] have demonstrated a promising path for fine-tuning existing LMs to add new capabilities without the need to retrain the entire model. In contrast to those approaches our method is not framed as a retrieval but as a way of extending the context of the model. In contrast to RETRO, we propose a single-stage method for context extension instead of a two-stage retrieve-then-embed approach. We provide a more detailed comparison with the Memorizing Transformer in Appendix C.3. More recently, a number of works have explored fine-tuning LLaMA to extend its context length. Landmark attention [Mohtashami and Jaggi, 2023] proposes a compression scheme of LLM’s context into landmarks, increasing the context length of LLaMA-7B to $3 2 K$ . Position Interpolation (PI, [Chen et al., 2023] and [kaiokendev, 2023]) introduces a modification to the rotary positional encoding scheme that enables fine-tuning for $3 2 K$ context. In contrast to this work, our method does not rely on positional encodings, following the findings from [Haviv et al., 2022]. Removing positional encoding in additional context allows us to extrapolate to $2 5 6 k$ tokens, although the model was only trained on sequences up to $8 K$ , yielding theoretically unbounded context length.
43
+
44
+ Zero-shot methods KNN-LM [Khandelwal et al., 2019] shows that one can improve the performance of a LLM by combining two probability distributions. One created by a pre-trained model, and one based on the similarity between the embedding of the currently processed token and the embeddings of tokens retrieved from a large database. Meanwhile, we extend the model context in a subset of attention layers, potentially allowing for reasoning within this extended context. Parallel Context Windows for Large Language Models [Ratner et al., 2023] introduces a method for extending the context of language models without training. They achieve this by embedding several context windows independently in parallel and allowing only a subset of tokens to attend to all windows. On the other hand, we fine-tune existing models and allow all tokens to attend to all previous tokens but only in a subset of layers. Additionally, our method allows us to improve the structure of the key-value space of the existing models.
45
+
46
+ Contrastive learning Contrastive learning aims to learn good representations by comparing positive and negative examples. CLIP [Radford et al., 2021] and SimCLR [Chen et al., 2020] are two popular contrastive learning methods that have achieved state-of-the-art performance in the image domain. During contrastive pre-training, negative examples are kept in the same batch to learn to distinguish
47
+
48
+ # Inference
49
+
50
+ ![](images/3596771ae9a23085118d66c2dd261ced18d644bda834afbef45187c1ffa02614.jpg)
51
+
52
+ ![](images/205d6f1c634fed4f46b494212ee8a0fa81c386eff82444e10c3dcdad59ed709e.jpg)
53
+ Figure 2: The Focused Transformer overview. During inference, a memory attention layer (green) uses additional context of $( k e y , v a l u e )$ pairs via kNN lookup, which effectively extends its context length. This layer is trained using crossbatch. Namely, the tokens from the current context $C _ { c u r r }$ attend in a differentiable way $( \mathrm { A t t } + \boldsymbol { \nabla } )$ to the previous context $C _ { p r e v }$ of the same document and, importantly, $d - 1$ contexts of other documents. The latter serve as ’negative’ examples intended to better shape the $( k e y , v a l u e )$ space.
54
+
55
+ them from positive examples. Scaling the batch size in contrastive learning has been demonstrated to enhance the quality of representations, as shown in [Gao et al., 2021b]. It has been suggested [Gao et al., 2019] that the embedding space in language modeling suffers from degeneracy, where embeddings are tightly packed in a narrow cone, making it difficult to distinguish between them. TRIME [Zhong et al., 2022] proposes a training approach designed for training LMs with memory augmentation, which uses negatives to improve the quality of representations. The main difference between this and our approach is that we incorporate negatives into the chosen subset of attention layers instead of interpolating in the output layer and use the standard language modeling loss. TRIME [Zhong et al., 2022] also focuses on retrieval from large databases, whereas we focus on extending the context of the model. ContraCLM [Jain et al., 2023] applies contrastive losses at both the token and sequence levels during training to promote more uniformly distributed, isotropic representations. It is shown to enhance the discrimination of representations on textual semantic similarity benchmarks. While ContraCLM focuses on improving the general expressiveness of representations, our work introduces contrastive-inspired techniques designed specifically for training the attention mechanism to handle longer context lengths. Nonetheless, exploring other contrastive learning objectives could be beneficial for further improving the key structure in future work.
56
+
57
+ # 3 FOT: Focused Transformer
58
+
59
+ Our method, the Focused Transformer (FOT), is a simple plug-and-play extension of transformer models and can be used both to train new models or fine-tune existing, possibly large, models with longer context. To this end, FOT uses memory attention layers and the crossbatch training procedure. Memory attention layers enable the model to retrieve information from the additional context at inference time, effectively extending the context. The crossbatch training procedure biases the model to learn $( k e y , v a l u e )$ representations, which are easy to use by a memory attention layer. See Figure 2 for an overview of the FOT architecture and Appendix L for pseudocode.
60
+
61
+ # 3.1 Memory attention layers
62
+
63
+ Memory attention layers $\mathcal { L }$ are endowed with access to an additional context during inference. Namely, each query in $\ell \in { \mathcal { L } }$ attends to preceding keys from the local context and the top $k$ most matching keys (i.e. having the largest inner product with the query) from memory. The memory keys are ranked by the inner product with the query and retrieved using the kNN search algorithm. We use the exact kNN search implemented in FAISS [Johnson et al., 2017]. The memory is populated incrementally with $( k e y , v a l u e )$ pairs processed by $\ell$ beforehand. Our memory attention layer design is closely related to [Wu et al., 2022], we follow most of its design choices, except for the gating, which we replace with a simpler mechanism, which turns out to be more effective in our applications. See details in Section C.3 and Appendix B.2. We remove positional encodings in memory layers in all our models except LONGLLAMAs. This allows LONGLLAMA checkpoints to be a drop-in replacement for LLaMA checkpoints. We treat the kNN search algorithm as an approximation of full dense attention, which opens the doors for future speed-ups.
64
+
65
+ # 3.2 Crossbatch training procedure
66
+
67
+ Our training procedure is a novel way of training (or fine-tuning) transformer-based architectures in order to improve the structure of the $( k e y , v a l u e )$ space. The main motivation is to shape this space so that a memory attention layer $\ell \in \mathcal L$ can easily focus on relevant information. The key idea, inspired by contrastive learning, is to expose $\ell$ to $( k e y , v a l u e )$ pairs from the current and previous local context of the given document (positives) and $d - 1$ contexts from unrelated documents (negatives). Importantly, this is done in a differentiable way.
68
+
69
+ To achieve this, we use a data pipeline in which each element of the batch corresponds to a different document. We embed the previous $( C _ { \mathrm { p r e v } } )$ and the current $( C _ { \mathrm { c u r r } } )$ local context for each of the processed documents. The overview of our procedure can be found in Figure 2. Specifically for each document $\delta$ in $C _ { \mathrm { c u r r } }$ we create a set $\{ p _ { i } ^ { \delta } \} _ { i = \{ 1 , \dots , d \} }$ consisting of the $( k e y , v a l u e )$ pairs from the previous local context of $\delta$ (positives), along with pairs from $d - 1$ other contexts coming from $C _ { \mathrm { p r e v } }$ (negatives). We also experiment with varying the number of previous contexts and negatives for different batch elements.
70
+
71
+ The operation is fully differentiable, and thus, we improve all the $( k e y , v a l u e )$ pairs in $p ^ { \delta }$ . Two, the procedure is easy to implement; it does not require any additional loss (i.e., uses the standard transformer training objective) and is done on the level of the data loading pipeline and a minor self-attention change. The only new hyperparameter is $d$ , which prescribes the ratio of positive to negative samples. Typically, we find it beneficial to start with small $d \leq 8$ (otherwise, the model tends to ignore the previous local context) and later switch to bigger values, say $d \geq 6 4$ . Appendix B.3 provides more details about the method. Listing 1 outlines an implementation of the crossbatch.
72
+
73
+ # 3.3 The distraction issue
74
+
75
+ In this section, we conceptualize what we call the distraction issue and hypothesize it is one of the key problems in dealing with long multi-document contexts (like large code repositories). Namely, during the standard training, the model is not incentivized to distinguish the keys from different documents. We measure that the attention mass is evenly spread on the related and unrelated documents; see Figure 3. More precisely, for a document $\delta$ let $w _ { i j }$ be the softmax weights related to $p _ { i j } ^ { \delta }$ constructed as described in Section 3.2. We define the positive attention mass as $\begin{array} { r } { r _ { d } \ : = \ \sum _ { j } w _ { 1 j } / \sum _ { i = 1 } ^ { d } \sum _ { j } w _ { i j } } \end{array}$ . We observe that $r _ { d } \approx 1 / d$ , which can be interpreted as the fact that the attention is equally distracted by the positive (coming from the current document at $i = 1$ ) and negative keys. This is an undesirable prop
76
+
77
+ ![](images/fcb71d55846178ae021be4e3a13b2712351a71f0959cc27a49354743e625944c.jpg)
78
+ Figure 3: Distraction issue. We compare FOT trained with different values of parameter $d$ to the standard Transformer baseline. During the evaluation, both models see the previous local context and some contexts from other documents in the chosen layer (as in crossbatch training procedure). For a document $\delta$ we measure the distribution of attention mass on $p ^ { \delta }$ . Scale $_ x$ : the number of contexts from documents that the model can see. Scale $_ y$ : avg attention mass to the previous local context of the current document.
79
+
80
+ erty since when scaling the memory, the attention becomes increasingly distracted. We show that the crossbatch mostly alleviates the distraction issue, resulting in a focused attention. More information can be found in Appendix B.4. In Section 5.3, we also show that the distraction issue has a harmful effect on metrics like perplexity.
81
+
82
+ # 4 LONGLLAMA : extending LLaMA’s context length with FOT
83
+
84
+ One of the promises of our work is that FOT can be used to fine-tune already existing large models to extend their context length. In this section, we show that this is indeed the case. We use OpenLLaMA-3B and OpenLLaMA-7B models trained for $1 T$ tokens as starting points and fine-tune them with FOT. We show that the resulting models, which we call LONGLLAMAs, are capable of extrapolating beyond their training context length (even up to $2 5 6 K )$ and retain the performance on short-context tasks. We release the inference code on GitHub: https://github.com/CStanKonrad/long_llama and the LONGLLAMA-3B checkpoint on Hugging Face: https://huggingface.co/syzymon/long_llama_3b. We note that our checkpoint is backward compatible, i.e. can be used with any existing LLaMA inference code (both in Hugging Face and other implementations), albeit without long-context capabilities.
85
+
86
+ # 4.1 Experimental setup
87
+
88
+ The architecture of the models is the same as OpenLLaMAs, see Geng and Liu [2023] and Appendix A.1. We use $\mathcal { L } = \{ 6 , 1 2 , 1 8 \}$ (resp. $\mathcal { L } = \{ 8 , 1 6 , 2 4 \} )$ as the memory layers for $3 B$ (resp. $7 B$ ) LONGLLAMA model. We fine-tune the models on $1 0 B$ (resp. $3 B$ ) tokens using FOT, $8 k$ context length and our dataset mixture based on RedPajama [TogetherComputer, 2023], see Appendix A.3.
89
+
90
+ There are three minor differences from the standard FOT procedure. First, we retain the positional encodings in the local context of the memory layers (this is not necessary for FOT, but makes our checkpoints fully compatible with any existing LLaMA inference codebase). To be more precise, queries and keys from the local context (up to $2 K$ tokens) receive the standard LLaMA rotary positional encoding, whereas memory keys are encoded as if they had position 0 in the local context window. Second, we use dense attention instead of the kNN retrieval, as we found only marginal performance differences, and it is simpler to implement. Third, we modify the crossbatch training procedure to have more fine-grained control over the number of additional contexts and the ratio of positive to negative samples. All these differences are detailed in Appendix A.2.
91
+
92
+ # 4.2 Context length extrapolation on the passkey retrieval task
93
+
94
+ We first measure the effective context length of LONGLLAMA, namely the distance for which tokens can effectively attend each other. We use passkey retrieval introduced in [Mohtashami and Jaggi, 2023], a synthetic task designed to measure this property. In this task, the model has to retrieve a passkey placed randomly in a long prompt. Results are shown in Figure 1 - importantly, our $3 B$ model is capable of solving this task much beyond its training context length $8 K$ , achieving $9 4 . 5 \%$ accuracy for prompts of length $1 0 0 k$ and $7 3 \%$ for $2 5 6 k$ .
95
+
96
+ # 4.3 Question answering over research papers
97
+
98
+ In Table 6 we present the performance on the validation set of Qasper [Dasigi et al., 2021] from SCROLLS [Shaham et al., 2022] and compare our results to LongChat 7B [Ma and Zhang, 2023] and two baseline short-context models. We note that our model shows gains from increased context length.
99
+
100
+ # 4.4 Improving few-shot learning accuracy with longer context
101
+
102
+ We measure long-context capabilities of these models on two downstream tasks, TREC question classification [Li and Roth, 2002, Hovy et al., 2001] and WebQS question answering [Berant et al., 2013]. We follow the experimental setup of [Hao et al., 2022]. Namely, we few-shot prompt the models with as many demonstration examples as possible up to the given context length. We do not use structured prompting like in [Hao et al., 2022] - instead, we directly provide all demonstrations in context.
103
+
104
+ We observe significant accuracy gains from longer contexts on TREC and some improvements on WebQS (see Table 1). The TREC dataset consists of 50 classes. A model is tasked to predict the class label given in-context examples. Only 100 examples fit the standard context length $( 2 K )$ ; it is not unusual that no class example is present for a given question, making the task impossible. Increasing the context length and the number of examples mitigates this risk. Moreover, having more demonstrations of the given class is also likely to be beneficial.
105
+
106
+ Table 1: Few-shot in-context learning performance of LONGLLAMA; accuracy on TREC and WebQS. We see significant gains from the additional context on the TREC dataset. To calculate the results, we average over 20 trials for sampling in-context demonstrations from the train set; the resulting confidence intervals for TREC and WebQS are smaller than $1 \%$ and $0 . 1 \%$ , respectively.
107
+
108
+ <table><tr><td rowspan="2">Dataset Context</td><td colspan="2">TREC</td><td colspan="2">WebQS</td></tr><tr><td>LONGLLAMA 3B</td><td>LONGLLAMA 7B</td><td>LONGLLAMA 3B</td><td>LONGLLAMA 7B</td></tr><tr><td>2K</td><td>67.0</td><td>63.2</td><td>21.2</td><td>25.5</td></tr><tr><td>4K</td><td>71.6</td><td>72.7</td><td>21.4</td><td>26.4</td></tr><tr><td>6K</td><td>72.9</td><td>74.9</td><td>22.2</td><td>27.2</td></tr><tr><td>8K</td><td>73.3</td><td>75.9</td><td>22.4</td><td>27.7</td></tr></table>
109
+
110
+ Table 2: Few-shot in-context learning performance comparison between standard fine-tuning on $4 K$ context (baseline) and FoT fine-tuning on the same context length for $1 B$ tokens. On TREC, FOT is able to utilize additional examples beyond its training context length to achieve higher accuracy at $8 K$ context length, which is not possible for the baseline since its context is bounded to $4 K$ .
111
+
112
+ <table><tr><td rowspan="2">Dataset Context</td><td colspan="2">TREC</td><td colspan="2">WebQS</td></tr><tr><td>baseline</td><td>FoT (ours)</td><td>baseline</td><td>FoT (ours)</td></tr><tr><td>2K</td><td>52.8</td><td>55.6</td><td>20.7</td><td>20.8</td></tr><tr><td>4K</td><td>57.2</td><td>60.9</td><td>18.7</td><td>21.0</td></tr><tr><td>6K</td><td>1</td><td>61.7</td><td>1</td><td>21.2</td></tr><tr><td>8K</td><td>1</td><td>62.5</td><td>1</td><td>20.7</td></tr></table>
113
+
114
+ # 4.5 Comparison to standard long-context fine-tuning
115
+
116
+ In this section, we compare FOT to standard long-context fine-tuning, showing that it already achieves better performance for the context length used for fine-tuning and, importantly, that it can extrapolate beyond this context length, which is not the case for the baseline.
117
+
118
+ For comparisons, we fine-tune two models, one trained with FOT and another one (baseline) with standard fine-tuning (done similarly to [MosaicML, 2023, Nijkamp et al., 2023]). In both cases, we use $3 B$ models fine-tuned on $1 B$ tokens using the $4 K$ context length. We evaluate both models on a number of few-shot downstream tasks in the setting described in Section 4.4.
119
+
120
+ In most cases, see Table 2, we observe accuracy improvements when more few-shot demonstrations are provided in the extended context (from $2 K$ used by OpenLLaMA to $4 K$ used in our fine-tuning). On TREC, the gains from additional context are significant for both models, while on WebQS, the standard fine-tuning baseline does not provide any improvement from extended context. Notably, the model fine-tuned with FOT enjoys further accuracy gains when evaluated with context lengths beyond its training length $6 K$ and $8 K$ ). This shows extrapolation capabilities of FOT, which are not present in the baseline (see e.g. Figure 1).
121
+
122
+ # 4.6 Performance on short-context tasks
123
+
124
+ Fine-tuning for longer contexts could hurt performance on the original context length $( 2 K )$ , as the training data distribution changes. We show that this is not the case for the LONGLLAMA models by evaluating them using the LM Evaluation Harness library [Gao et al., 2021a]. On most tasks, the performance is kept intact; see Appendix A.4 for details. This also confirms that LONGLLAMAs could be used as a drop-in replacement of LLaMA models as they are compatible with the original LLaMA inference code.
125
+
126
+ # 5 Analysis of FOT
127
+
128
+ In this section, we perform extensive experiments on smaller models to analyze and further validate our approach. In particular, we answer the following questions: (1) How does FOT perform when scaling the context length at inference time? (2) Can FOT be used to extend the context length of
129
+
130
+ an existing, pre-trained model? (3) How effectively can it handle distractions, and how does this capability translate to enhanced performance in long-context language modeling tasks? Moreover, we provide ablation studies of our method and additional analysis.
131
+
132
+ # 5.1 Experimental setup
133
+
134
+ Architecture For experiments described in this section we use decoder-only Transformer [Vaswani et al., 2017] models with 12 layers and $1 8 4 M$ parameters (unless stated otherwise). Following Wu et al. [2022]; we pick $\ell = 8$ as the memory attention layer. We tune $k = 1 2 8$ , the number of top keys retrieved by kNN. In most experiments, we start training with a small crossbatch dimension $d \leq 8$ and switch to $d \geq 6 4$ after some training. For more details about the architecture and hyperparameters, see Appendix B and Appendix E.
135
+
136
+ Evaluation We distinguish two evaluation settings: single-document (abbreviated to single-doc) and multi-document (abbreviated to multi-doc). The single-doc setting is typically used for evaluating models that process long contexts. Here, we clear the memory for each new document, ensuring that only the current document is available in the context. The multi-doc setting retains memory across multiple documents without resets. This scenario tests whether the model can ignore irrelevant information and focus on the relevant data, which can be useful in setups like repository-level code generation.
137
+
138
+ Datasets We evaluate on the following long-context language modeling datasets: PG-19 (English books), arXiv (mathematical papers), GitHub (code), and Isabelle (formal proofs). PG-19 [Rae et al., 2019] is a large dataset of English-language books published prior to 1919, sourced from the Project Gutenberg archive. This dataset is a well-established benchmark for evaluating long-context language models [Sun et al., 2021]. The arXiv dataset contains LATEX source of papers labeled as "Mathematics" that were obtained by downloading articles through the arXiv Bulk Data Access. The token count per paper in this dataset is comparable to that of a book in PG19. For details on the remaining datasets, refer to Appendix H.
139
+
140
+ # 5.2 FOT fine-tuning and context length extrapolation
141
+
142
+ FOT is a minimal modification to the standard transformer architecture; therefore, it is possible to fine-tune existing models to endow them with a longer context length via the memory attention layer, as we already demonstrated in Section 4. In this section, we deepen this analysis (on a smaller model) by studying perplexity improvements on various datasets.
143
+
144
+ As a base model, we use a standard transformer model pre-trained for $1 0 0 k$ steps with context of $1 K$ tokens using the standard objective and fine-tune with the FOT objective (i.e. crossbatch). The data used for both fine-tuning and pre-training is the C4 dataset Raffel et al. [2019a] (we omit documents shorter than $2 K$ tokens). The fine-tuning phase takes $1 0 k$ steps. We use the crossbatch dimension $d = 1 2 8$ and local context of $1 K$ tokens (context is $2 K$ during training). We evaluate models in a zero-shot way on 4 language modeling datasets, which require long context: arXiv, PG-19, GitHub and Isabelle, see Section 5.1 and Appendix E for details.
145
+
146
+ In Table 3, we observe that FOT enjoys steady perplexity gains up to $6 4 K$ tokens, although it was fine-tuned only with the $2 K$ total differentiable context length. We compare the model perplexity to the following baselines: Memorizing Transformer (MT) [Wu et al., 2022] fine-tuned with the local context of $1 K$ and memory size of $1 6 K$ , and Transformer-XL [Dai et al., 2019] fine-tuned with both local context and window length of $1 K$ . To ensure a fair comparison, all three models are fine-tuned from the same base checkpoint. When evaluated with a context of $2 K$ , our method achieves results on par with the Transformer-XL baseline, which has access to the previous context in all layers, unlike MT and FOT. Compared to the MT baseline, we achieve better scaling when evaluated with $6 4 K$ context length and significantly better perplexity values. Unlike MT, our method does not require training on long sequences, which is reflected by the lower perplexities of FOT when evaluated in the zero-shot setting. For more details, see Appendix G.
147
+
148
+ We also confirm the context extrapolation abilities using a synthetic dictionary lookup task. In this task, the model is first provided with $k _ { i } : v _ { i }$ mappings and then asked what value is associated with a particular key. We train 37M parameter models using documents of length 512. Figure 10 shows that
149
+
150
+ Table 3: Perplexity for different context lengths after fine-tuning a standard transformer model. The model is fine-tuned using the FOT objective (i.e., crossbatch) on C4 and evaluated zero-shot varying the context size. Transformer-XL [Dai et al., 2019] and Memorizing Transformer [Wu et al., 2022] fine-tuned in the same setting are used as baselines.
151
+
152
+ <table><tr><td>Method</td><td>Context Length</td><td>GitHub</td><td>Isabelle</td><td>arXiv</td><td>PG-19</td></tr><tr><td rowspan="4">FoT</td><td>2K</td><td>6.72</td><td>5.63</td><td>8.17</td><td>23.74</td></tr><tr><td>4K</td><td>5.88</td><td>4.93</td><td>7.44</td><td>23.25</td></tr><tr><td>16K</td><td>5.43</td><td>4.51</td><td>6.94</td><td>22.85</td></tr><tr><td>64K</td><td>5.32</td><td>4.44</td><td>6.81</td><td>22.65</td></tr><tr><td>Transformer-XL</td><td>2K</td><td>6.85</td><td>5.76</td><td>8.21</td><td>23.57</td></tr><tr><td rowspan="4">Memorizing Transformer</td><td>2K</td><td>8.10</td><td>7.34</td><td>9.39</td><td>24.03</td></tr><tr><td>4K</td><td>7.55</td><td>6.93</td><td>8.95</td><td>23.62</td></tr><tr><td>16K</td><td>7.27</td><td>6.66</td><td>8.66</td><td>23.32</td></tr><tr><td>64K</td><td>7.26</td><td>6.64</td><td>8.60</td><td>23.24</td></tr></table>
153
+
154
+ FOT, after 5k steps of training, can effectively utilize memory consisting of 16M tokens achieving accuracy above $9 \hat { 2 } \%$ . Details can be found in Appendix F.
155
+
156
+ # 5.3 Handling distractions in language modeling tasks
157
+
158
+ In this section, we measure how handling distractions in the multi-document setting helps in language modeling. We pick the PG-19 dataset [Rae et al., 2019] and measure the perplexity of the next token prediction (language modeling task) when varying the size of multi-doc memory (in this case consisting of books). Intuitively, the memory tokens corresponding to the current book might be beneficial (which is also confirmed in [Wu et al., 2022]), while the ones from the other books are unlikely to be useful and thus are distractions.
159
+
160
+ We observe, see Figure 8, that higher values of the crossbatch dimension $d$ lead to better perplexity. This aligns with the observations in Section 3.3, indicating that by mitigating the distraction issue, we experience benefits in language modeling.
161
+
162
+ Moreover, all versions of FOT are able to utilize memory and achieve much better perplexity than the standard Transformer (no memory). Unsurprisingly, perplexity increases with memory size, but we stress that this happens gracefully. In the standard variant of FOT (bold line), the perplexity increases only by 0.18 when scaling to $> 5 0 0 k$ tokens. Importantly, the perplexity of FOT is close to this of Memorizing Transformer with the single-doc memory, which we treat as a soft lower bound since it is not exposed to distractions from unrelated books.
163
+
164
+ # 5.4 Context length extrapolation in single-doc
165
+
166
+ The original motivation behind FOT is to improve the multi-doc setting performance by handling distractions. Interestingly, our method also helps to extrapolate to longer contexts, even when evaluated in the single-doc setting.
167
+
168
+ To study this, we perform FoT fine-tuning (as in Section 5.2) and evaluate the perplexity of the resulting model on the PG-19 dataset with different context lengths in the zero-shot fashion. To deepen the analysis, we introduce an additional parameter $w$ (the number of previous contexts used in cross batch training procedure). We provide results for $w = 1$ (the standard setting for FOT, that corresponds to the total differentiable context being $2 \cdot 1 0 2 4 )$ ) and $w = 2$ (corresponding to the total differentiable context $3 \cdot 1 0 2 4 ^ { \cdot }$ ).
169
+
170
+ We observe, see Figure 9, improvements when context grows, even far beyond the training context length, which reaffirms the hypothesis that FOT helps with extrapolation to longer contexts. Moreover, $d = 2$ is significantly better than $d = 1$ . When comparing $d = 1$ and $w = 2$ to $d = 2$ and $w = 1$ , we observe that the former is slightly better. This is natural, as the former has longer training context.
171
+
172
+ # 5.5 Ablations and design choices
173
+
174
+ In Appendix C we present ablations on our design choices. In particular, we note the importance of differentiability and the inclusion of negatives. We also discuss the relation to Memorizing Transformer. We note that due to the limited resources we have followed the Memorizing Transformer in the choice of memory layers.
175
+
176
+ # 6 Limitations and future work
177
+
178
+ Our research opens a few avenues for future work. We list them as well as challenges and limitations.
179
+
180
+ Scaling up context This is by far the most important future research direction. The challenges start from purely engineering, storing more than 16M $( k e y , v a l u e )$ pairs will require a distributed multi-node system. In our experiments, we use the exact kNN search, which is not scalable to large memory. Using approximate kNN search will require a lot of engineering effort, as well as careful evaluation of the impact of the approximation on the model performance.
181
+
182
+ Scaling up crossbatch We observed that increasing $d$ is beneficial. In our experiments, we used $d = 6 4$ or $d = 1 2 8$ , which is the maximum value that fits into the memory of a single TPUv3/TPUv2 machine, see also Appendix I. In future work, we want to further increase $d$ as well as test on devices with bigger memory or utilize multi-node training. We also note that crossbatch increases the training cost, but only in a subset of layers.
183
+
184
+ Exploring contrastive learning The FOT training is inspired by rather basic contrastive learning (CL) techniques. We show that this improves the key structure so that the distraction issue is mitigated. We expect that other CL methods could be beneficial, for example, hard negative mining to utilize a larger memory during training (see [Lindgren et al., 2021]). We leave this for future work.
185
+
186
+ Combining with other methods Developing long-context methods is an active research field, see Section 2. We believe that some of these methods could be combined with FOT, resulting in mutually beneficial interactions.
187
+
188
+ Listing 1: Possible implementation of cross-batch. To simplify the code we assume that each document occupies two consecutive elements of the batch. A more detailed version is in Appendix L.
189
+
190
+ # keys from other contexts will be encoded as if they
191
+ # were at the beginning of the local context
192
+ pkey_fst $=$ pos_encode_as_first ( $\mathtt { x k } = \mathtt { k } \in \mathtt { y }$ )
193
+ # local context keys encoded in the standard way
194
+ pquery , pkey $=$ pos_encode ( $\mathbf { x } \mathbf { q } =$ query , $\mathbf { x k } = \mathbf { k } \in \mathbf { y }$ )
195
+ # for each element of the batch we calculate indices of
196
+ # the batch that will be used in cross - batch
197
+ cross_batch_rel_ids $=$ jnp. arange (0 , -num_attentions , -1) . reshape (1 , -1)
198
+ batch_ids $=$ jnp . arange (0 , batch_size ). reshape ( -1 , 1)
199
+ cross_batch_selector $=$ cross_batch_rel_ids $^ +$ batch_ids
200
+ # here we want other contexts
201
+ cross_batch_keys $=$ pkey_fst [ cross_batch_selector [: , 1:]]
202
+ # here we concatenate local context with other contexts
203
+ attention_keys $=$ jnp . concatenate ([ pkey [: , None ] , cross_batch_keys ] , axis $= 1$ )
204
+ cb_attn_weights $=$ jnp . einsum ("bqhd ,bckhd - > bhqck ", pquery , attention_keys , precision $=$ precision )
205
+
206
+ # Acknowledgments and Disclosure of Funding
207
+
208
+ We gratefully acknowledge the TPU Research Cloud program, which was instrumental to our research by providing significant computational resources. Parts of the project were realized using the resources of Poznanskie Centrum Superkomputerowo - Sieciowe. We would also like to thank ´ Markus Rabe for reviewing the initial manuscript and Christian Szegedy, Charles Staats, and DeLesley Hutchins for helpful discussions. We are also grateful to Xinyang Geng and Hao Liu for releasing OpenLLaMA checkpoints and the EasyLM library [Geng, 2023], allowing for training these models, which significantly accelerated our research. Piotr Milos was supported by the Polish National Science Centre grant 2019/35/O/ST6/03464. Henryk Michalewski was supported by the Polish National Science Center grant UMO-2018/29/B/ST6/02959.
209
+
210
+ # References
211
+
212
+ Joshua Ainslie, Tao Lei, Michiel de Jong, Santiago Ontañón, Siddhartha Brahma, Yury Zemlyanskiy, David C. Uthus, Mandy Guo, James Lee-Thorp, Yi Tay, Yun-Hsuan Sung, and Sumit Sanghai. Colt5: Faster long-range transformers with conditional computation. CoRR, abs/2303.09752, 2023. doi: 10.48550/arXiv.2303.09752. URL https://doi.org/10.48550/arXiv.2303.09752.
213
+ Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
214
+ Jonathan Berant, Andrew Chou, Roy Frostig, and Percy Liang. Semantic parsing on Freebase from question-answer pairs. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pages 1533–1544, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/D13-1160.
215
+ Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, Diego de Las Casas, Aurelia Guy, Jacob Menick, Roman Ring, Tom Hennigan, Saffron Huang, Loren Maggiore, Chris Jones, Albin Cassirer, Andy Brock, Michela Paganini, Geoffrey Irving, Oriol Vinyals, Simon Osindero, Karen Simonyan, Jack W. Rae, Erich Elsen, and Laurent Sifre. Improving language models by retrieving from trillions of tokens. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato, editors, International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pages 2206–2240. PMLR, 2022. URL https://proceedings.mlr.press/v162/borgeaud22a.html.
216
+ Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. CoRR, abs/2005.14165, 2020. URL https://arxiv.org/abs/2005.14165.
217
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harrison Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Nikolas Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evaluating large language models trained on code. CoRR, abs/2107.03374, 2021. URL https://arxiv. org/abs/2107.03374.
218
+
219
+ Shouyuan Chen, Sherman Wong, Liangjian Chen, and Yuandong Tian. Extending context window of large language models via positional interpolation, 2023.
220
+
221
+ Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597–1607. PMLR, 2020.
222
+
223
+ Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. arXiv preprint arXiv:1901.02860, 2019.
224
+
225
+ Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. Flashattention: Fast and memory-efficient exact attention with io-awareness. In NeurIPS, 2022. URL http://papers.nips.cc/paper_files/paper/2022/hash/ 67d57c32e20fd0a7a302cb81d36e40d5-Abstract-Conference.html.
226
+
227
+ Pradeep Dasigi, Kyle Lo, Iz Beltagy, Arman Cohan, Noah A. Smith, and Matt Gardner. A dataset of information-seeking questions and answers anchored in research papers, 2021.
228
+
229
+ Stefan Elfwing, Eiji Uchibe, and Kenji Doya. Sigmoid-weighted linear units for neural network function approximation in reinforcement learning, 2017.
230
+
231
+ Jun Gao, Di He, Xu Tan, Tao Qin, Liwei Wang, and Tie-Yan Liu. Representation degeneration problem in training natural language generation models. arXiv preprint arXiv:1907.12009, 2019.
232
+
233
+ Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, Jason Phang, Laria Reynolds, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. A framework for few-shot language model evaluation, September 2021a. URL https://doi.org/10.5281/zenodo.5371628.
234
+
235
+ Luyu Gao, Yunyi Zhang, Jiawei Han, and Jamie Callan. Scaling deep contrastive learning batch size under memory limited setup. arXiv preprint arXiv:2101.06983, 2021b.
236
+
237
+ Xinyang Geng. Easylm: A simple and scalable training framework for large language models, 2023. URL https://github.com/young-geng/EasyLM.
238
+
239
+ Xinyang Geng and Hao Liu. Openllama: An open reproduction of llama, May 2023. URL https: //github.com/openlm-research/open_llama.
240
+
241
+ Mandy Guo, Joshua Ainslie, David Uthus, Santiago Ontanon, Jianmo Ni, Yun-Hsuan Sung, and Yinfei Yang. Longt5: Efficient text-to-text transformer for long sequences. arXiv preprint arXiv:2112.07916, 2021.
242
+
243
+ Yaru Hao, Yutao Sun, Li Dong, Zhixiong Han, Yuxian Gu, and Furu Wei. Structured prompting: Scaling in-context learning to 1, 000 examples. CoRR, abs/2212.06713, 2022. doi: 10.48550/ arXiv.2212.06713. URL https://doi.org/10.48550/arXiv.2212.06713.
244
+
245
+ Adi Haviv, Ori Ram, Ofir Press, Peter Izsak, and Omer Levy. Transformer language models without positional encodings still learn positional information, 2022.
246
+
247
+ Alex Henry, Prudhvi Raj Dachapally, Shubham Shantaram Pawar, and Yuxuan Chen. Query-key normalization for transformers. In Trevor Cohn, Yulan He, and Yang Liu, editors, Findings of the Association for Computational Linguistics: EMNLP 2020, Online Event, 16-20 November 2020, volume EMNLP 2020 of Findings of ACL, pages 4246–4253. Association for Computational Linguistics, 2020. doi: 10.18653/v1/2020.findings-emnlp.379. URL https://doi.org/10. 18653/v1/2020.findings-emnlp.379.
248
+
249
+ Eduard Hovy, Laurie Gerber, Ulf Hermjakob, Chin-Yew Lin, and Deepak Ravichandran. Toward semantics-based answer pinpointing. In Proceedings of the First International Conference on Human Language Technology Research, 2001. URL https://www.aclweb.org/anthology/ H01-1069.
250
+
251
+ Nihal Jain, Dejiao Zhang, Wasi Uddin Ahmad, Zijian Wang, Feng Nan, Xiaopeng Li, Ming Tan, Ramesh Nallapati, Baishakhi Ray, Parminder Bhatia, Xiaofei Ma, and Bing Xiang. Contraclm: Contrastive learning for causal language model, 2023.
252
+
253
+ Albert Qiaochu Jiang, Wenda Li, Szymon Tworkowski, Konrad Czechowski, Tomasz Odrzygó´zd´z, Piotr Miłos, Yuhuai Wu, and Mateja Jamnik. Thor: Wielding hammers to integrate language ´ models and automated theorem provers. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id $\equiv$ fUeOyt-2EOp.
254
+
255
+ Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with gpus, 2017.
256
+
257
+ Jean Kaddour, Oscar Key, Piotr Nawrot, Pasquale Minervini, and Matt J. Kusner. No train no gain: Revisiting efficient training algorithms for transformer-based language models, 2023.
258
+
259
+ kaiokendev. Things im learning while training superhot. ´ https://kaiokendev.github.io/til# extending-context-to-8k, 2023.
260
+
261
+ Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. arXiv preprint arXiv:1911.00172, 2019.
262
+
263
+ Denis Kocetkov, Raymond Li, Loubna Ben Allal, Jia Li, Chenghao Mou, Carlos Muñoz Ferrandis, Yacine Jernite, Margaret Mitchell, Sean Hughes, Thomas Wolf, Dzmitry Bahdanau, Leandro von Werra, and Harm de Vries. The stack: 3 tb of permissively licensed source code. Preprint, 2022.
264
+
265
+ Taku Kudo and John Richardson. SentencePiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 66–71, Brussels, Belgium, November 2018. Association for Computational Linguistics. doi: 10.18653/v1/ D18-2012. URL https://aclanthology.org/D18-2012.
266
+
267
+ Aitor Lewkowycz, Anders Johan Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. Solving quantitative reasoning problems with language models. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview. net/forum?id $\cdot ^ { = }$ IFXTZERXdM7.
268
+
269
+ Xin Li and Dan Roth. Learning question classifiers. In COLING 2002: The 19th International Conference on Computational Linguistics, 2002. URL https://www.aclweb.org/anthology/ C02-1150.
270
+
271
+ Yujia Li, David H. Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. Competition-level code generation with alphacode. CoRR, abs/2203.07814, 2022. doi: 10.48550/arXiv.2203.07814.
272
+
273
+ Erik Lindgren, Sashank Reddi, Ruiqi Guo, and Sanjiv Kumar. Efficient training of retrieval models using negative cache. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, volume 34, pages 4134–4146. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper_ files/paper/2021/file/2175f8c5cd9604f6b1e576b252d4c86e-Paper.pdf.
274
+
275
+ Dacheng Li Rulin Shao Anze Xie Ying Sheng Lianmin Zheng Joseph E. Gonzalez Ion Stoica Xuezhe Ma and Hao Zhang. How long can open-source llms truly promise on context length?, June 2023. URL https://lmsys.org/blog/2023-06-29-longchat.
276
+
277
+ Maciej Mikuła, Szymon Antoniak, Szymon Tworkowski, Albert Qiaochu Jiang, Jin Peng Zhou, Christian Szegedy, Łukasz Kucinski, Piotr Miło ´ s, and Yuhuai Wu. Magnushammer: A transformer- ´ based approach to premise selection, 2023.
278
+
279
+ Amirkeivan Mohtashami and Martin Jaggi. Landmark attention: Random-access infinite context length for transformers. CoRR, abs/2305.16300, 2023. doi: 10.48550/arXiv.2305.16300. URL https://doi.org/10.48550/arXiv.2305.16300.
280
+
281
+ MosaicML. Introducing mpt-30b: Raising the bar for open-source foundation models, 2023. URL www.mosaicml.com/blog/mpt-30b. Accessed: 2023-06-22.
282
+
283
+ Piotr Nawrot, Szymon Tworkowski, Michal Tyrolski, Lukasz Kaiser, Yuhuai Wu, Christian Szegedy, and Henryk Michalewski. Hierarchical transformers are more efficient language models. CoRR, abs/2110.13711, 2021. URL https://arxiv.org/abs/2110.13711.
284
+
285
+ Piotr Nawrot, Jan Chorowski, Adrian Łancucki, and Edoardo M. Ponti. Efficient transformers with ´ dynamic token pooling, 2023.
286
+
287
+ Erik Nijkamp, Hiroaki Hayashi, Tian Xie, Congying Xia, Bo Pang, Rui Meng, Wojciech Kryscinski, Lifu Tu, Meghana, Chen Xing, Jesse Vig, Lidiya Murakhovs’ka, Chien-Sheng Wu, Silvio Savarese, Yingbo Zhou, Shafiq Rayhan Joty, and Caiming Xiong. Long sequence modeling with xgen: A 7b llm trained on 8k input sequence length. Salesforce AI Research Blog, 2023. URL https: //blog.salesforceairesearch.com/xgen-7b/.
288
+
289
+ Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. CoRR, abs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393.
290
+
291
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
292
+
293
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021.
294
+
295
+ Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint, 2019. URL https://arxiv.org/abs/1911.05507.
296
+
297
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv e-prints, 2019a.
298
+
299
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. CoRR, October 2019b.
300
+
301
+ Nir Ratner, Yoav Levine, Yonatan Belinkov, Ori Ram, Inbal Magar, Omri Abend, Ehud Karpas, Amnon Shashua, Kevin Leyton-Brown, and Yoav Shoham. Parallel context windows for large language models, 2023.
302
+
303
+ Uri Shaham, Elad Segal, Maor Ivgi, Avia Efrat, Ori Yoran, Adi Haviv, Ankit Gupta, Wenhan Xiong, Mor Geva, Jonathan Berant, and Omer Levy. Scrolls: Standardized comparison over long language sequences, 2022.
304
+
305
+ Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. CoRR, abs/2104.09864, 2021. URL https://arxiv.org/abs/ 2104.09864.
306
+
307
+ Simeng Sun, Kalpesh Krishna, Andrew Mattarella-Micke, and Mohit Iyyer. Do long-range language models actually use long-range context?, 2021.
308
+
309
+ TogetherComputer. Redpajama: An open source recipe to reproduce llama training dataset, 2023. URL https://github.com/togethercomputer/RedPajama-Data.
310
+
311
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
312
+
313
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. CoRR, abs/1706.03762, 2017. URL http://arxiv.org/abs/1706.03762.
314
+
315
+ Yuhuai Wu, Markus Norman Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id= TrjbxzRcnf-.
316
+
317
+ Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. Advances in neural information processing systems, 33:17283–17297, 2020.
318
+
319
+ Biao Zhang and Rico Sennrich. Root mean square layer normalization, 2019.
320
+
321
+ Zexuan Zhong, Tao Lei, and Danqi Chen. Training language models with memory augmentation. In Yoav Goldberg, Zornitsa Kozareva, and Yue Zhang, editors, Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, EMNLP 2022, Abu Dhabi, United Arab Emirates, December 7-11, 2022, pages 5657–5673. Association for Computational Linguistics, 2022. URL https://aclanthology.org/2022.emnlp-main.382.
322
+
323
+ # Broader Impact
324
+
325
+ Recent rapid developments in language models have brought a lot of new capabilities. At the same, these raised concerns about the social impact and very animated discussions in the community. Our work develops a generic technique, which in principle, could be applied to virtually any language model and thus, by extending their capabilities, exacerbate threats. We note, however, that FOT does not create any new threats. Thus, we refer to the existing body of knowledge on the broader impact of language models, see e.g. Borgeaud et al. [2022].
326
+
327
+ # A LONGLLAMA
328
+
329
+ # A.1 Architecture
330
+
331
+ OpenLLaMA [Geng and Liu, 2023] is an open-source reproduction of LLaMA [Touvron et al., 2023]. It uses a decoder-only architecture with rotary positional embeddings, and a few changes including pre-normalization with RMSNorm [Zhang and Sennrich, 2019], and SiLU activation [Elfwing et al., 2017]. A SentencePiece [Kudo and Richardson, 2018] tokenizer with $3 2 \mathrm { k }$ vocabulary size is used.
332
+
333
+ # A.2 Extending context length with FOT
334
+
335
+ Positional encodings To achieve backward compatibility with the original LLaMA, we retain positional encodings in the local context. The tokens outside the local context are assigned the same position as the first token in the local context.
336
+
337
+ Dense attention to longer context To make the implementation simpler and less dependent on external software, we resign from using kNN lookup and perform attention over the whole memory. We have found only marginal performance differences between those two approaches to memory attention.
338
+
339
+ Crossbatch details For the 3B LONGLLAMA model, we set $\mathcal { L } = \{ 6 , 1 2 , 1 8 \}$ as the memory layers. We vary the number of additional contexts $d \in \{ 0 , 2 , 3 \}$ across elements of the batch by dividing batch entries into four segments of equal size. Elements from the first segment only see local context $\langle d = 0$ ). Elements from the second segment see two additional contexts ( $\ Q = 2$ ), one from the same document (positive) and one from a different one (negative). Elements from the third segment see three additional contexts, two positives, and one negative. The last segment consists of elements exposed to three additional contexts coming from the same document. We abbreviate this setup as $\begin{array} { r } { \frac { 1 } { 4 } ( \dot { 0 } , 0 ) , \frac { 1 } { 4 } ( 1 , 1 ) , \frac { 1 } { 4 } ( 2 , 1 ) , \frac { 1 } { 4 } ( 3 , 0 ) } \end{array}$ .
340
+
341
+ For the 7B LONGLLAMA model, we set $\mathcal { L } = \{ 8 , 1 6 , 2 4 \}$ as the memory layers. Here we divide batch entries into four segments and use the following setup: $\begin{array} { r } { \frac { 1 } { 4 } ( 0 , 0 ) , \frac { 1 } { 4 } ( 1 , \mathbf { \bar { 2 } } ) , \frac { \mathbf { \bar { 1 } } } { 4 } ( 2 , 5 ) , \frac { 1 } { 4 } ( 3 , 4 ) . } \end{array}$ .
342
+
343
+ Hyperparameters We follow the choices of OpenLLaMA with respect to most of the hyperparameters, including using the same optimizer. During fine-tuning, we use a batch size of $2 5 6 K$ tokens and constant learning rate of $2 \mathrm { e } { - } 5$ , which is lower than the learning rate at the end of OpenLLaMA training (3e−5 after 1T tokens), and weight decay of 0.01.
344
+
345
+ # A.3 LLaMA fine-tuning dataset
346
+
347
+ We use a mixture based on RedPajama [TogetherComputer, 2023] and The Stack [Kocetkov et al., 2022] with the following proportions of each subset:
348
+
349
+ All subsets apart from python are taken directly from RedPajama. For the python subset, we gather Python source code from The Stack and, to obtain long documents for training, concatenate files that are in the same subdirectory in random order, using a similar procedure as for the GitHub dataset in Section H. Additionally, we filter out short documents for some subsets of the original RedPajama, namely shorter than the Min. doc. length column indicates.
350
+
351
+ In case one document is too short to span across several contexts for crossbatch, then we concatenate it with the next document from the dataset.
352
+
353
+ Table 4: Proportions of RedPajama subsets for the LONGLLAMA fine-tuning mixture. For python subset, data from The Stack is used (see text for details). We only train on documents with length being at least Min. doc. length, if specified (otherwise we train on all documents from that subset). The horizontal line separates long-context and short-context subsets.
354
+
355
+ <table><tr><td>Subset</td><td>Sampling proportion (%)</td><td>Min. doc.length</td></tr><tr><td>arxiv</td><td>25</td><td>=</td></tr><tr><td>python</td><td>25</td><td>4096</td></tr><tr><td>book</td><td>10</td><td>=</td></tr><tr><td>common_crawl</td><td>29</td><td>=</td></tr><tr><td>c4</td><td>5</td><td>1024</td></tr><tr><td>github</td><td>2</td><td>2048</td></tr><tr><td>stackexchange</td><td>2</td><td>1024</td></tr><tr><td>wikipedia</td><td>2</td><td>1024</td></tr></table>
356
+
357
+ # A.4 Language Model Evaluation Harness
358
+
359
+ To ensure that the performance of LONGLLAMAs has not degraded in short context scenarios, we evaluate our models on the Language Model Evaluation Harness benchmark [Gao et al., 2021a]. Table 5 compares our results with OpenLLaMA [Geng and Liu, 2023]. Similarly to the authors of OpenLLaMA, we omit CB and WSC tasks.
360
+
361
+ Table 5: Model comparison across different tasks/metrics on Language Model Evaluation Harness. The LONGLLAMA models were evaluated without context extension (i.e. as standard OpenLLaMA models). Results indicate that LONGLLAMAs maintain good performance in short context scenarios.
362
+
363
+ <table><tr><td>Task/Metric</td><td>OpenLLaMA 3B</td><td>LongLLaMA 3B</td><td>OpenLLaMA 7B</td><td>LongLLaMA 7B</td></tr><tr><td>anli_rl/acc</td><td>0.33</td><td>0.32</td><td>0.33</td><td>0.35</td></tr><tr><td>anli_r2/acc</td><td>0.32</td><td>0.33</td><td>0.36</td><td>0.37</td></tr><tr><td>anli_r3/acc</td><td>0.35</td><td>0.35</td><td>0.38</td><td>0.36</td></tr><tr><td>arc_challenge/acc</td><td>0.34</td><td>0.34</td><td>0.37</td><td>0.37</td></tr><tr><td>arc_challenge/acc_norm</td><td>0.37</td><td>0.37</td><td>0.38</td><td>0.38</td></tr><tr><td>arc_easy/acc</td><td>0.69</td><td>0.68</td><td>0.72</td><td>0.70</td></tr><tr><td>arc_easy/acc_norm</td><td>0.65</td><td>0.63</td><td>0.68</td><td>0.66</td></tr><tr><td>boolq/acc</td><td>0.68</td><td>0.68</td><td>0.71</td><td>0.71</td></tr><tr><td>hellaswag/acc</td><td>0.49</td><td>0.48</td><td>0.53</td><td>0.52</td></tr><tr><td>hellaswag/acc_norm</td><td>0.67</td><td>0.65</td><td>0.72</td><td>0.71</td></tr><tr><td>openbookqa/acc</td><td>0.27</td><td>0.28</td><td>0.30</td><td>0.30</td></tr><tr><td>openbookqa/acc_norm</td><td>0.40</td><td>0.38</td><td>0.40</td><td>0.41</td></tr><tr><td>piqa/acc</td><td>0.75</td><td>0.73</td><td>0.76</td><td>0.75</td></tr><tr><td>piqa/acc_norm</td><td>0.76</td><td>0.75</td><td>0.77</td><td>0.76</td></tr><tr><td>record/em</td><td>0.88</td><td>0.87</td><td>0.89</td><td>0.89</td></tr><tr><td>record/f1</td><td>0.89</td><td>0.87</td><td>0.90</td><td>0.90</td></tr><tr><td>rte/acc</td><td>0.58</td><td>0.60</td><td>0.60</td><td>0.59</td></tr><tr><td>truthfulqa_mc/mc1</td><td>0.22</td><td>0.24</td><td>0.23</td><td>0.24</td></tr><tr><td>truthfulqa_mc/mc2</td><td>0.35</td><td>0.38</td><td>0.35</td><td>0.35</td></tr><tr><td>wic/acc</td><td>0.48</td><td>0.50</td><td>0.51</td><td>0.50</td></tr><tr><td>winogrande/acc</td><td>0.62</td><td>0.60</td><td>0.67</td><td>0.67</td></tr><tr><td>Average score</td><td>0.53</td><td>0.53</td><td>0.55</td><td>0.55</td></tr></table>
364
+
365
+ # A.5 Question answering over research papers
366
+
367
+ We evaluate the context utilization of our model on the validation set of Qasper [Dasigi et al., 2021] from SCROLLS [Shaham et al., 2022]. Details are in the Table 6.
368
+
369
+ Table 6: Zero-shot performance with different context lengths on the validation subset of Qasper [Dasigi et al., 2021]. We use the implementation from Language Model Evaluation Harness [Gao et al., 2021a]. In the Harness implementation, yes/no questions are evaluated separately from open questions. Observe that LONGLLAMA 3B benefits from the extended context.
370
+
371
+ <table><tr><td>Context length</td><td>|OpenLLaMA 3B</td><td>LONGLLAMA3B</td><td>LLaMA 7B</td><td>LongChat 7B</td></tr><tr><td>2K</td><td>18.7</td><td>18.7</td><td>18.7</td><td>19.4</td></tr><tr><td>4K</td><td>-</td><td>20.7</td><td>-</td><td>21.2</td></tr><tr><td>6K</td><td>1</td><td>23.2</td><td>1</td><td>25.0</td></tr><tr><td>8K</td><td>1</td><td>26.6</td><td>1</td><td>28.8</td></tr></table>
372
+
373
+ # B Architecture
374
+
375
+ This section describes the architecture and crossbatch details for non-LLaMA-based models presented in this paper. The main differences are that for LLaMA-based models (LONGLLAMA) we maintain the positional encodings (with a slight modification detailed in A.2), do not introduce the attention temperature parameter, and replace kNN with full dense attention.
376
+
377
+ # B.1 Transformer models
378
+
379
+ For non-LLaMA-based models we use the transformer architecture introduced in [Vaswani et al., 2017] with a few standard changes. First, we use only the decoder without the encoder part. Secondly, we perform layer normalization before the input of both the attention and feed-forward modules. Additionally, we use Rotary Position Embedding [Su et al., 2021], normalize keys and queries [Henry et al., 2020], and introduce a learnable temperature parameter for each attention head.
380
+
381
+ The hyperparameters for each model size can be found in Appendix E. For training the models on PG-19, we use the standard T5 tokenizer with $\mathrm { 3 2 k }$ vocabulary [Raffel et al., 2019b]. The larger models in Section 5.2 are trained with a custom SentencePiece tokenizer [Kudo and Richardson, 2018] with $6 4 \mathrm { k }$ vocabulary size.
382
+
383
+ # B.2 Memory attention layer
384
+
385
+ Memory attention layer $\ell$ is one of the transformer layers, which has access to the additional context $M$ . The memory stores $( k e y , v a l u e )$ pairs. For each query $q$ in $\ell$ , we retrieve the $k$ most matching entries from $M$ and use them to compute the attention value. More precisely, we use the kNN algorithm to pick $M _ { t o p } : = \{ ( k e y _ { 1 } , v a l { \bar { u } } e _ { 1 } ) , \dots , ( k e y _ { k } , v a l u e _ { k } ) \} \subset M$ such that $\{ \langle q , k e y _ { i } \rangle \} _ { i = 1 , \ldots , k }$ are the top $k$ inner products in $M$ . These are merged with the part of the local context before $q$ denoted as $C _ { < q }$ and used to compute the attention value using the standard Transformer formula:
386
+
387
+ $$
388
+ v : = \sum _ { ( k e y , v ) \in M _ { t o p } \cup C < q } s ( k e y ) \cdot v ,
389
+ $$
390
+
391
+ where $s ( k e y )$ is the softmax score for key. This softmax is calculated as follows:
392
+
393
+ $$
394
+ s o f t m a x \left( \left[ \frac { \langle q , k e y \rangle } { \tau } \right] _ { k e y \in M _ { t o p } \cup C _ { < q } } \right) ,
395
+ $$
396
+
397
+ where $\tau$ is a temperature parameter. In this approach, we do not distinguish between the local context and the memory.
398
+
399
+ Another way of integrating $M _ { t o p }$ is via gating. In this approach, we separately compute the attention value $v _ { M }$ for $M _ { t o p }$ and for the local context $v _ { C }$ (using the standard Transformer formula). Then we use a gating mechanism to combine them:
400
+
401
+ $$
402
+ v : = v _ { M } \cdot g + v _ { C } \cdot ( 1 - g ) , \quad g = \sigma ( b _ { g } ) ,
403
+ $$
404
+
405
+ where $\sigma$ is the sigmoid function and $b _ { g }$ is a trainable bias. The gating approach was proposed in [Wu et al., 2022], see formula [Wu et al., 2022, (2)].
406
+
407
+ We found our approach, i.e. using (1), to be equally effective, see Figure 4. At the same time, (1) is simpler and does not require additional parameters. Thus, we use it in our experiments.
408
+
409
+ For kNN lookup, we use the exact kNN search implemented in FAISS [Johnson et al., 2017]. The memory attention layer does not use positional encodings. The memory is populated incrementally with $( k e y , v a l u e )$ pairs processed by $\ell$ beforehand. In the single-doc setting, the memory is erased after each document.
410
+
411
+ We do not use the $\tau$ parameter for LONGLLAMAs as their architecture does not normalize keys and queries. For LONGLLAMAs, we also replace the kNN search with dense attention and retain positional encodings (see Appendix A.2).
412
+
413
+ # B.3 Crossbatch training procedure
414
+
415
+ In FOT we choose a subset $\mathcal { L }$ of the attention layers for later augmentation with the memory of $( k e y , v a l u e )$ pairs. Let $\ell$ an attention layer from $\mathcal { L }$ . During the training we expose this layer to a mixture of $( k e y , v a l u e )$ pairs from the current local context, $C _ { \mathrm { c u r r } }$ , and the previous local context and $d - 1$ contexts from other documents, $C _ { \mathrm { p r e v } }$ ; see also Figure 2 for an illustration. We achieve this by modifying the input pipeline so that each batch index corresponds to a different document (the batch index occupied by each document is fixed from the moment we load the document till we finish processing it).
416
+
417
+ More specifically, we embed the previous and the current local context for each document in the batch. Then we use $C _ { \mathrm { p r e v } }$ as a source of the previous local context for a given document and $d - 1$ contexts from other documents. For each element of the batch, the choices of those $d$ additional contexts are fixed. We disable positional encoding in $\ell$ , as we envision it to handle global information.
418
+
419
+ To be more precise, for each document $\delta$ within the batch and query $q$ from the layer $\ell$ we create the set $p ^ { \delta }$ consisting of $( k e y , v a l u e )$ pairs from the previous local context of document $\delta$ along with pairs from $d - 1$ contexts gathered from $C _ { \mathrm { p r e v } }$ . The attention value for $q$ is given by
420
+
421
+ $$
422
+ v : = \sum _ { ( k e y , v ) \in p ^ { \delta } \cup C _ { \mathrm { c u r r } } ^ { \delta , < q } } s ( k e y ) \cdot v ,
423
+ $$
424
+
425
+ where $C _ { \mathrm { c u r r } } ^ { \delta , < q }$ consists of $( k e y , v a l u e )$ pairs that preceded $q$ in its local context and $s ( k e y )$ is the softmax score for $k e y$ . We use softmax with learnable temperature $\tau$ :
426
+
427
+ $$
428
+ s o f t m a x \left( \left[ \frac { \langle q , k e y \rangle } { \tau } \right] _ { k e y \in p ^ { \delta } \cup C _ { \mathrm { c u r r } } ^ { \delta , < q } } \right) .
429
+ $$
430
+
431
+ Note that the only difference between (1) and (2) is the source of the additional $( k e y , v a l u e )$ pairs: $p ^ { \delta }$ .
432
+ This, in particular, implies that all the operations with respect to the previous context are differentiable.
433
+
434
+ The number of different documents is equal to $b _ { S }$ (the batch size, i.e. each document has a separate index in the batch). Assume that document $\delta$ has index $i$ . We include into $p ^ { \delta }$ all tokens from $C _ { p r e v }$ with the batch indices in $\{ i , ( i + 1 )$ mod $b _ { s } , \dotsc , ( i + d - 1 )$ mod $b _ { s } \}$ .
435
+
436
+ ![](images/09f6739162099781ee3ce46aa3ce84d642986e46d798bc1941b3ba094ef5ceb4.jpg)
437
+ Figure 4: Perplexity (on the test set) during training on PG-19. We train two Memorizing Transformer models [Wu et al., 2022], one with original gating and one without (i.e. memory attention shared with local attention as described in (1)). We use the single-doc setting with 16k memory.
438
+
439
+ # B.4 Qualitative analysis
440
+
441
+ Table 7 provides a brief qualitative analysis of FOT. It shows that the model can handle distractions and retrieve the parts of the character name from the multi-document memory in the PG-19 task dataset and appropriate definitions from the large dictionary (dictionary lookup task).
442
+
443
+ # B.5 Memorizing Transformer
444
+
445
+ The Focused Transformer shares many similarities with the Memorizing Transformer [Wu et al., 2022]. In this section, we summarize the differences between those two models.
446
+
447
+ Training The key difference between these two methods lies in the training procedure. Our method uses crossbatch, see Section B.3, which, in a nutshell, is the standard transformer training objective, but we additionally attend to tokens from the previous context window, both from the same and different documents, see Appendix B.3 for details. The Memorizing Transformer trains on tokens retrieved from the same document (it was envisioned for single-doc).
448
+
449
+ This has a few important consequences:
450
+
451
+ • FOT does not use memory during training, while MT does. This may result in faster training; moreover, FOT always uses the most up-to-date values, while MT uses the values from memory, which may be outdated.
452
+ • FOT is differentiable through all (key, value) pairs, while MT does not differentiate through the retrieved tokens. We argue that this is key for joint training of well-structured key, value, and query embeddings and, consequently, good model performance.
453
+ • FOT does not require long documents in the training set, while MT does in order to capture long dependencies in memory. This is practically important, as many popular datasets consist of short documents.
454
+
455
+ We speculate that there may be benefits in blending these two approaches. One can, for example, argue that MT is better at providing ’hard’ negatives for the model. We provide a proof-of-concept experiment in Appendix C.3, and leave this for future work.
456
+
457
+ Inference Both models use a very similar memory attention layer. The difference is how the retrieved $( k e y , v a l u e )$ pairs are integrated. FOT treats the retrieved information in the same way as the local context. MT uses a gating mechanism. Details are provided in Section B.2.
458
+
459
+ Table 7: Example of elements retrieved by kNN search along with their scores on PG-19 and dictionary lookup task. The first column shows the token associated with a particular query (bolded) along with fragments of its context. The second column shows tokens associated with the keys retrieved by kNN for this query. The kNN score shows what fraction of the attention mass dedicated to retrieved keys corresponds to a particular key. The Focus score is calculated by taking the key along with 32 preceding and 32 following keys, calculating attention weights for them, and checking what fraction of attention the retrieved key gets. In the PG-19 setting the model was equipped with the memory of size 4096 spanning across parts of 8 documents. In the dictionary lookup setting the model was provided with memory of size $1 6 M$ .
460
+
461
+ <table><tr><td colspan="2">Text</td><td>kNN Results</td><td>kNN Focus Score Score</td><td></td></tr><tr><td colspan="2">PG-19</td><td colspan="3"></td></tr><tr><td rowspan="4">S HE BA takes the gold-rimmed pince-nez which hangs upon THE DEAN&#x27;S waistcoat and places it before his eyes</td><td>Then if we&#x27;re here with the closed carriage at ten-![They go together into the library. DARBEY.[To SHE BA.]</td><td></td><td>0.690.99</td><td></td></tr><tr><td>Oh![He sinks on to the settee with a vacant stare,his arms hanging helplessly. DAR- BEY. [To SHE BA is a burden to him!</td><td>.] There-now his career</td><td>0.230.92</td><td></td></tr><tr><td>Papa! SHE BA. Papsey![THE DEAN rouses himself, discovers his children and removes his hat.</td><td></td><td>0.025 0.92</td><td></td></tr><tr><td>Then if we&#x27;re here with the closed carriage at ten-![They go together into the library. DARBE Y [To SHEBA.] Oh! [He sinks on to the settee with a</td><td>0.71</td><td></td><td>0.99</td></tr><tr><td>THE DEAN gives DAR BE Ya severe look,and with an important cough walks into the Library. The men and the girls speak in undertones.</td><td>vacant stare,his arms hanging helplessly. DARBE Y career is a burden to him! Oh,Salome!Papa!Papa! TARVER.The</td><td>[To SHEBA.] There-now his The Dean!</td><td>0.190.99 0.080.99</td><td></td></tr><tr><td colspan="7">Dean?DARBE Y Dictionary Lookup Task</td></tr><tr><td colspan="2">&lt;q&gt; 14 42 23 38 &lt;v&gt; 40 41 05 56 &lt;q&gt; 30 55 07 23 &lt;v&gt; 36 17 26 63 &lt;q&gt; 10 41 26 39 &lt;v&gt; 48 38 11 24</td><td colspan="2">&lt;k&gt; 14 42 23 38 &lt;v&gt; 40 41 05 56 &lt;k&gt; 30 55 07 23 &lt;v&gt; 36 17 26 63 &lt;k&gt; 10 41 26 39 &lt;v&gt; 48 38 11 24</td><td>0.96 0.88 0.87</td><td>0.99 1.0 0.99</td></tr></table>
462
+
463
+ # C Ablations
464
+
465
+ In this section, we focus on two key properties of crossbatch training procedure: differentiability and the inclusion of negatives. We also discuss the relation to Memorizing Transformer in terms of the training protocol and memory integration. We refer to Appendix B.5 for a detailed technical description of differences between FOT and Memorizing Transformer.
466
+
467
+ # C.1 Impact of differentiable keys and values
468
+
469
+ We compare FOT to Memorizing Transformer, which uses a non-differentiable memory of keys and values during training. In the multi-doc experiment presented in Figure 5, both MT and FOT are trained with local context of 512. We observe that FOT is significantly better when the context is expanded during inference, which confirms that differentiable keys and values are beneficial.
470
+
471
+ Table 8: Perplexity on PG-19 in the single-doc setting for various local context lengths during training. In these experiments, we used the same context length both during training and evaluation.
472
+
473
+ <table><tr><td>Context Length</td><td>FoT d=1</td><td>MT</td></tr><tr><td>512</td><td>14.18</td><td>14.68</td></tr><tr><td>1024</td><td>14.17</td><td>14.46</td></tr><tr><td>2048</td><td>14.11</td><td>14.43</td></tr></table>
474
+
475
+ ![](images/5037c9be4e21847093776e38a3b4ee843bfadca35c4fbfb02692a8ff48763239.jpg)
476
+ Figure 5: Perplexity on PG-19 in the multi-doc setting. Both FOT and Multi-doc MT were trained with local context of size 512. During training, Multi-doc MT utilized memory of size 4096 shared across 8 documents. Differentiability of keys and values results in better perplexity.
477
+
478
+ ![](images/6833b967840706b019ade3f71c46eb8406d8e846ebe671f8c42a7bb3ef5fbb91.jpg)
479
+ Figure 6: Importance of negatives in the multidocument setting. We compare FOT trained with $d = 1$ to the one that started with $d = 2$ and later switched to $d = 6 4$ . For additional comparison, we show the performance of MT trained with the memory of size $1 6 K$ .
480
+
481
+ We also check whether differentiable keys and values can improve the performance in the single-doc setting. For this, we compare FoT with $d = 1$ to MT with memory consisting of the previous local context. Table 8 confirms that differentiable keys and values can also help in this scenario.
482
+
483
+ # C.2 Importance of negatives
484
+
485
+ We reaffirm the importance of negatives in a multi-document setting. In previous experiments in Figure 3, we already observed that increasing the number of negatives (i.e., increasing $d$ ) results in more attention mass being dedicated to relevant tokens. In Figure 6, we additionally show that the lack of negatives in training $( d = 1 )$ ) results in a significant deterioration in model perplexity when the context length grows. This confirms that both using negatives and differentiability are important for FOT to work well.
486
+
487
+ # C.3 Relation to Memorizing Transformer
488
+
489
+ Memorizing Transformer Wu et al. [2022] is closely related to our method. The two key differences are 1) the training protocol and 2) how the memory is integrated into the model. In this section, we provide additional insights into these differences.
490
+
491
+ Training protocol In the previous sections, we have discussed the benefits of the crossbatch training, namely using the contrastive-inspired objective and backpropagating through the previous context. A potential advantage of the MT approach is that it is exposed to the whole memory during training (instead of just the previous context). We performed a proof-of-concept experiment combining the two approaches to explore this further. Namely, we trained the model for $4 9 9 \mathrm { k }$ steps using crossbatch and fine-tuned it with the MT objective for 1k steps. Interestingly, we observed a significant improvement compared to the MT training with the same step budget, see Figure 7. We believe there is further room to explore various training protocols combining the best of both worlds.
492
+
493
+ Memory integration FOT uses a simple memory integration approach where the (key, value) pairs retrieved by kNN lookup are treated the same way as the local context. In contrast, MT uses a gating mechanism, a weighted average of the memory, and local values; see details in Appendix B.2. We evaluated both approaches and found no difference in performance between these two memory integration methods. However, we decided to use our approach because it does not require any architectural changes (and thus makes fine-tuning existing models easy). For these reasons, we recommend using it. We speculate that the reason why the gating is not needed in FOT is another benefit of the fact that the crossbatch training backpropagates through the $( k e y , v a l u e )$ pairs from the previous context $C _ { p r e v }$ in contrast to MT that cannot backpropagate there and needs to rely on local context when computing gradients for keys and values. Another reason might be the fact that $C _ { p r e v }$ is embedded for each batch, and thus staleness (see [Wu et al., 2022, Section 3.2]) is avoided.
494
+
495
+ ![](images/f69be982ec0ad5cd7420547d35eec47a3f1e0c712d65c095dc33bfbfbc6be042.jpg)
496
+ Figure 7: Single-doc eval of FOT finetuned for 1k steps on non differentiable memory. It achieves lower perplexity than MT, which has access to this memory for the whole training $( 5 0 0 \mathrm { k }$ steps).
497
+
498
+ # D Additional figures
499
+
500
+ ![](images/05eab77dd5d8da05a45947173c993d677ed18a22ea87b8c85ff30914cc4672d2.jpg)
501
+ Figure 8: Perplexity in the multi-doc setting. FOT was trained with local context of size 512 and different $d$ . FOT $2 \mathrm { - } 2 6 4$ started with $d = 2$ and then switched to $d = 6 4$ . Single-doc MT was trained with a memory size of $1 6 K$ . As we increase the memory size, the number of distractions (irrelevant keys) increases, making the task harder. Single-doc MT evaluated in the single-doc setting is a soft lower bound since it lacks distractions.
502
+
503
+ ![](images/45ba00ab844ca711a9db7335f4f54c76264b3e78340b619a62d4a14b688385b7.jpg)
504
+ Figure 9: Zero-shot performance on PG19 of FOT pretrained on C4. Model fine-tuned with the crossbatch dimension $d = 2$ outperforms the one with $d = 1$ . Using the double $w = 2$ ) training context of 2048 is beneficial.
505
+
506
+ # E Hyperparameters
507
+
508
+ Table 9 shows hyperparameters used in our experiments. We used context length 512 unless stated otherwise. In Appendix F, Section 5.3, Section 5.5, we use the total batch size of $3 2 K$ tokens. In Section 5.2 and Section 5.4, the total batch size is $1 2 8 K$ tokens.
509
+
510
+ Table 9: Hyperparameters for different model sizes. The batch size is given in number of tokens. For the $3 7 M$ model local context length was 256 for FOT and 512 for the baseline.
511
+
512
+ <table><tr><td colspan="3">Hyperparameter</td></tr><tr><td></td><td colspan="2">Value Common</td></tr><tr><td>#Layers</td><td colspan="2">12</td></tr><tr><td>Index of memory attention layer (l)</td><td colspan="2">8</td></tr><tr><td>Optimizer</td><td colspan="2">AdaFactor</td></tr><tr><td>Learning rate schedule</td><td colspan="2">Inverse Square Root</td></tr><tr><td>Warmup steps</td><td colspan="2">1000</td></tr><tr><td>β1</td><td colspan="2">0.9</td></tr><tr><td>#Params</td><td>Model-specific 37M</td><td>184M</td></tr><tr><td>Max learning rate</td><td>0.02</td><td>0.01</td></tr><tr><td>Min learning rate</td><td>0.01</td><td>0.0005</td></tr><tr><td>Embedding dim</td><td>512</td><td>1024</td></tr><tr><td>Head dim</td><td>64</td><td>128</td></tr><tr><td>#Heads</td><td>8</td><td>8</td></tr><tr><td>FeedForward dim</td><td>2048</td><td>4096</td></tr><tr><td>Local context length</td><td>256/512</td><td>512</td></tr><tr><td>Batch size</td><td>32K/64K</td><td>32K</td></tr><tr><td>#Number of training steps</td><td>5k</td><td>500k</td></tr></table>
513
+
514
+ For the experiments described in Section 5.3 and Section 5.5 we performed the following hyperparameter sweeps:
515
+
516
+ • Learning rate: $\{ 1 \mathrm { e - 2 , 5 \mathrm { e - 3 , 3 \mathrm { e - 3 , 1 \mathrm { e - 3 } } } } \}$ , chosen: 1e−2, • Batch size: $\{ 8 K , 1 6 K , 3 2 K \}$ , chosen: $3 2 K$ .
517
+
518
+ For the dictionary lookup task (Appendix F) we checked the following hyperparameters:
519
+
520
+ • Learning rate: $\{ 4 \mathrm { e } { - } 2 , 2 \mathrm { e } { - } 2 , 1 \mathrm { e } { - } 2 , 5 \mathrm { e } { - } 3 , 3 \mathrm { e } { - } 3 \}$ , chosen: $2 \mathrm { e } { - 2 }$ ,
521
+ • Number of dictionary tokens in training step: $\{ 1 6 K , 3 2 K \}$ , chosen: $3 2 K$ . Note that during the training number of document tokens dedicated to the dictionary is the same as the number of tokens dedicated to questions.
522
+
523
+ For most of the other hyperparameter choices, we followed [Wu et al., 2022], to provide a fair comparison.
524
+
525
+ # E.1 Schedule of $d$
526
+
527
+ In Sections 5.3, 5.4 and 5.5 for models with $d \in \{ 1 , 2 , 4 , 8 \}$ we used constant schedule, and for models with $d = 6 4$ we trained with $d = 2$ for $4 5 0 k$ steps and switched to $d = 6 4$ for the final $5 0 k$
528
+
529
+ steps. In Appendix $\mathrm { F }$ we trained with $d = 1$ until the model reached $9 8 \%$ accuracy and then we switched to $d = 1 2 8$ . For the $1 8 4 M$ model in Section 5.2, we randomly sampled $d$ from $\{ 2 , 1 2 8 \}$ in each training step.
530
+
531
+ # F Dictionary lookup task
532
+
533
+ ![](images/4b3b734e13f8f91a4b69f7f923929c7aa1db3a0eb97a69cbfeb0cbbaf6055715.jpg)
534
+ Figure 10: Accuracy vs number of dictionary tokens in a dictionary look-up task. The task format is as follows: $< \mathtt { k } > k _ { 1 } < \mathtt { v } > v _ { 1 } < \mathtt { k } > k _ { 2 } < \mathtt { v } > v _ { 2 } \ldots < \mathtt { k } > k _ { n } < \mathtt { v } > v _ { n } < \mathtt { q } > k _ { i } < \mathtt { v } > v _ { i } \ldots ,$ where a dictionary is provided, followed by queries on randomly selected keys. Accuracy is determined by measuring the predicted values $v _ { i }$ after $< _ { \mathsf { q } } >$ tokens. Models were trained on examples containing 512 tokens and evaluated with an extended context length. FOT demonstrates high accuracy even when the memory size is large. The baseline transformer fails already for $1 6 K$ tokens. Error bars represent the minimum and maximum on 10 seeds.
535
+
536
+ We propose a dictionary lookup task to test whether the model trained using our crossbatch method can utilize a large memory database. Documents in this task are split into two parts. The first part defines keys and their associated values using the records of the format:
537
+
538
+ $$
539
+ < \mathrm { k } > , k _ { 1 } , k _ { 2 } , k _ { 3 } , k _ { 4 } , < \mathrm { v } > , v _ { 1 } , v _ { 2 } , v _ { 3 } , v _ { 4 } ,
540
+ $$
541
+
542
+ where $- \mathtt { k } >$ is a special token that denotes the beginning of the defining sequence,
543
+
544
+ The second part consists of queries about the values associated with the previously defined keys. The queries are in the following format:
545
+
546
+ $$
547
+ < \mathrm { q } > , k _ { 1 } , k _ { 2 } , k _ { 3 } , k _ { 4 } , < \mathrm { v } > , v _ { 1 } , v _ { 2 } , v _ { 3 } , v _ { 4 } ,
548
+ $$
549
+
550
+ where $< \mathsf { q } >$ is a special token that denotes the beginning of the query. We mask the loss so that for such a question, only $v _ { 1 } , v _ { 2 } , v _ { 3 } , v _ { 4 }$ are included. We use a vocabulary of 64 tokens, keys and values are described using 4 tokens.
551
+
552
+ During training, we use documents comprising 512 tokens. The first half of each document consists of definitions, whereas the second one consists of questions. For FOT, we use a local context of 256, thus the model needs to use the memory attention layer to answer the questions correctly. We start with $d = 1$ and increase to $d = 1 2 8$ as soon as the model is able to reach $9 8 \%$ training accuracy. During the inference, we use $k = 3 2$ (the number of keys retrieved by kNN). As a baseline, we use a standard transformer model trained with the context length of 512. In evaluation, we test different local context lengths, which quickly leads to very poor results.
553
+
554
+ In evaluation, we use longer documents but make only the last 256 tokens correspond to questions. That is, as the context gets bigger (the token axis on Figure 10), the number of definitions increases, but the number of queries remains the same.
555
+
556
+ # G FOT fine-tuning
557
+
558
+ For comparison in Table 3, our model is pre-trained for $1 0 0 k$ steps with a total batch size of 128 ( $1 2 8 K$ tokens per step, with 1024 local context). Then we fine-tune both FOT and baselines for additional $1 0 k$ steps with the same batch size. When fine-tuning FOT, we randomly sample $d$ from $\{ 2 , 1 2 8 \}$ in each training step to prevent the model from overfitting to a large additional context length during training.
559
+
560
+ # H Datasets
561
+
562
+ Section 5.1 outlines essential details concerning the PG-19 and arXiv datasets employed in this study. Now, we will present details about the remaining datasets:
563
+
564
+ GitHub We obtained a large corpus of permissively licensed Github repositories using BigQuery. By filtering for specific file extensions (C, $\mathrm { C } { + + }$ , Java, Python, Go, and TypeScript), we captured individual source code files that are often short but have numerous dependencies and cross-references within the repository. To preserve the structure while shuffling the files and subdirectories in a random order, we concatenated all the files within each repository, treating subdirectories as a unit, similarly to Wu et al. [2022].
565
+
566
+ Isabelle The Isabelle corpus comprises formal mathematical proofs in the form of theories written in a formal language. We combined theories from The Archive of Formal Proofs (from October 2021) 3 and the Isabelle standard library to create a corpus of theories licensed as open source. Each theory focuses on topics like foundational logic, advanced analysis, algebra, or cryptography and consists of multiple files containing proofs. Similar to the GitHub corpus, the files within each theory are concatenated into a single document. However, unlike the Github corpus, we arrange the files based on their import dependencies, ensuring that later files can utilize sub-theorems proven in earlier files.
567
+
568
+ # I Hardware and technical details
569
+
570
+ We used TPU virtual machines from the Google Cloud Platform (GCP). Each TPU virtual machine has 8 TPUv2 / TPUv3 cores totaling 64GB / 128GB of device memory, 96 CPU cores, and over 300GB of RAM. In larger-scale experiments (Section 5.2) we used machines with 32 TPUv3 cores. For training the LONGLLAMA checkpoints, a TPUv3-128 pod provided by the TPU Research Cloud was used, which we gratefully acknowledge.
571
+
572
+ # J Randomness
573
+
574
+ To evaluate the significance of our results, we conducted multiple runs for selected experiments in our study. In Figure 10, we calculate error bars, showing the minimum and maximum value over 10 runs of the same experiment. For the arXiv baseline experiment in Appendix K, we performed three runs with different random seeds and calculated their standard deviation, which is equal to 0.002 perplexity. However, due to resource constraints, we were unable to conduct multiple runs for all experiments. Our preliminary findings indicate that the observed variance was minimal compared to the impact observed from other factors under investigation.
575
+
576
+ For the calculation of test perplexities, we used $1 M$ tokens.
577
+
578
+ # K Additional experimental results
579
+
580
+ This section presents additional empirical results, providing a detailed comparison of FOT with the Memorizing Transformer [Wu et al., 2022] baseline. Both models are trained for the same number of $5 0 0 k$ steps with local context of $2 K$ and evaluated on the arXiv dataset in the single-document setup, following [Wu et al., 2022]. In particular, we study how models trained with a given context length perform when evaluated with different context lengths. These experiments differ from those in Section 5.2, as the models were both trained and evaluated on the same dataset (arXiv), unlike the C4 training and zero-shot evaluation done in Section 5.2.
581
+
582
+ The MT baseline in Table 10 with a memory length of $2 K$ struggles to utilize additional context beyond $3 2 K$ tokens effectively. The model trained with $8 K$ memory performs significantly better when evaluated with longer contexts, showing further perplexity gains at $6 4 K$ tokens. We observe diminishing returns when scaling up the training memory length to $1 6 K$ tokens and beyond.
583
+
584
+ Using the same setup, we study the performance of FOT while varying $d$ and $w$ configurations, similarly to Section 5.4, see Table 11. Parameter values $w = 1$ and $w = 2$ correspond to additional context lengths of $2 K$ and $4 K$ , respectively. In an apples-to-apples comparison to MT with $2 K$ additional context length, FOT outperforms the MT baseline, which shows the importance of trainable keys and values (see also Section C.1). Moreover, we confirm the findings from Section 5.4 that $d = 2$ works significantly better than $d = 1$ in all settings. Our best configuration achieves 2.148 perplexity with $4 K$ additional context during training, compared to 2.164 of MT with $1 6 K$ additional context.
585
+
586
+ Table 10: Memorizing Transformer: arXiv perplexity values for different training memory lengths and evaluation context sizes
587
+
588
+ <table><tr><td rowspan="2">Eval Context</td><td colspan="4"> Training Memory Length</td></tr><tr><td>2k</td><td>8k</td><td>16k</td><td>32k</td></tr><tr><td>4K</td><td>2.309</td><td>2.334</td><td>2.348</td><td>2.365</td></tr><tr><td>8K</td><td>2.242</td><td>2.244</td><td>2.252</td><td>2.265</td></tr><tr><td>16K</td><td>2.215</td><td>2.206</td><td>2.206</td><td>2.215</td></tr><tr><td>32K</td><td>2.199</td><td>2.178</td><td>2.177</td><td>2.181</td></tr><tr><td>64K</td><td>2.195</td><td>2.169</td><td>2.166</td><td>2.168</td></tr><tr><td>128K</td><td>2.195</td><td>2.168</td><td>2.164</td><td>2.166</td></tr></table>
589
+
590
+ Table 11: FoT: arXiv perplexity values for different parameter combinations and evaluation context sizes
591
+
592
+ <table><tr><td rowspan="2">Evaluation Context</td><td colspan="4">Parameter Combinations (w, d), Training Memory Length</td></tr><tr><td>(1, 1), 2048</td><td>(1,2),2048</td><td>(2, 1), 4096</td><td>(2,2), 4096</td></tr><tr><td>4K</td><td>2.292</td><td>2.299</td><td>2.305</td><td>2.309</td></tr><tr><td>8K</td><td>2.229</td><td>2.224</td><td>2.214</td><td>2.217</td></tr><tr><td>16K</td><td>2.206</td><td>2.194</td><td>2.178</td><td>2.178</td></tr><tr><td>32K</td><td>2.192</td><td>2.176</td><td>2.159</td><td>2.156</td></tr><tr><td>64K</td><td>2.187</td><td>2.171</td><td>2.152</td><td>2.149</td></tr><tr><td>128K</td><td>2.187</td><td>2.171</td><td>2.152</td><td>2.148</td></tr></table>
593
+
594
+ # L Code
595
+
596
+ In Listing 2, we show the FOTs attention code (i.e., the code for the memory attention layers and crossbatch training), see Section 3, Appendix B.2, Appendix B.3. We note that the changes to the code are small; they are localized to the memory layer (the other layers follow the standard transformer protocol) and do not require any new trainable parameters.
597
+
598
+ Listing 2: Memory attention: Let $\ell$ be a memory attention layer. During the training, we make $\ell$ attend to the $( k e y , v a l u e )$ pairs from the local context, previous local context, and $d - 1$ contexts coming from other documents. During the inference, queries from $\ell$ attend to the local context and $k$ nearest neighbors retrieved from memory. For simplicity, we provide the code for one head and assume that the crossbatch dimension $d$ is equal to the batch size.
599
+
600
+ def mem_attn_layer (Ql , Kl , Vl , Cl , $\mathtt { K m }$ , $\mathtt { V m }$ , $\mathtt { K p }$ , $\mathtt { V p }$ , attn_scf , mode ): """ Attention mechanism for crossbatch and memory attention Args : Ql , Kl , Vl: tensors of shape [batch , ctx_len , dim] with queries , keys and values from the local context Km , Vm: tensors of shape [batch , ctx_len , k, dim] with k most matching memory keys for each query from Ql along with associated values Kp , Vp: tensors of shape [batch , ctx_len , dim] with keys and values from the previous context attn_scf : a scale factor used before softmax mode : either training or inference Returns : y: a vector with shape [batch , ctx_len , dim] """ # attention to the local context local_attention $=$ jnp. einsum ("bqd ,bkd ->bqk ", Ql , Kl) local_attention $\ast =$ attn_scf local_attention $=$ apply_causal_mask ( local_attention )
601
+
602
+ if mode $= =$ " train ":
603
+
604
+ # In train mode , we additionally use previous context # and batch -1 contexts from other documents . prev_attention $=$ jnp. einsum ("bqd ,ckd ->bqck ", Ql , Kp) shape $=$ prev_attention . shape additional_attention $=$ prev_attention . reshape ( shape [: -2] + ( -1 ,))
605
+ elif mode $= =$ " inference ": # In the inference mode , we additionally use nearest neighbors # retrieved from memory . We retrieve k (key , value ) # pairs for each query . memory_attention $=$ jnp. einsum ("bqd , bqnd -> bqn", Ql , Km) additional_attention $=$ memory_attention
606
+ else : raise Exception (" Only train and inference modes are supported ")
607
+
608
+ additional_attention $\ast =$ attn_scf
609
+
610
+ # We merge the raw attention scores and calculate the softmax
611
+ combined_attention $=$ jnp . concatenate ([ local_attention , additional_attention ] , axis = -1)
612
+ combined_weights $=$ jax.nn. softmax ( combined_attention , axis $= - 1$ )
613
+ ctx_len $\qquad = \quad { \mathsf { Q 1 } }$ . shape [1]
614
+ local_weights $=$ combined_weights [... , : ctx_len ]
615
+ additional_weights $=$ combined_weights [... , ctx_len :]
616
+
617
+ y = jnp . einsum ("bqk , bkd ${ } - > { }$ bqd", local_weights , Vl)
618
+
619
+ if mode $= =$ " train ": prev_weights $=$ additional_weights shape $=$ prev_weights . shape prev_weights $=$ prev_weights . reshape ( shape [: -1] + ( -1 , ctx_len )) y $+ =$ jnp. einsum ("bqck ,ckd -> bqd", prev_weights , Vp)
620
+ else : memory_weights $=$ additional_weights y $+ =$ jnp. einsum ("bqn , bqnd -> bqd", memory_weights , Vm)
621
+ return y
md/dev/uLYc4L3C81A/uLYc4L3C81A.md ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Confident Adaptive Language Modeling
2
+
3
+ Tal Schuster1,⇤ Adam Fisch2,⇤ Jai Gupta1
4
+
5
+ Mostafa Dehghani1 Dara Bahri1 Vinh Q. Tran1 Yi Tay1 Donald Metzler1
6
+
7
+ 1Google Research 2CSAIL, MIT
8
+
9
+ # Abstract
10
+
11
+ Recent advances in Transformer-based large language models (LLMs) have led to significant performance improvements across many tasks. These gains come with a drastic increase in the models’ size, potentially leading to slow and costly use at inference time. In practice, however, the series of generations made by LLMs is composed of varying levels of difficulty. While certain predictions truly benefit from the models’ full capacity, other continuations are more trivial and can be solved with reduced compute. In this work, we introduce Confident Adaptive Language Modeling (CALM), a framework for dynamically allocating different amounts of compute per input and generation timestep. Early exit decoding involves several challenges that we address here, such as: (1) what confidence measure to use; (2) connecting sequence-level constraints to local per-token exit decisions; and (3) attending back to missing hidden representations due to early exits in previous tokens. Through theoretical analysis and empirical experiments on three diverse text generation tasks, we demonstrate the efficacy of our framework in reducing compute—speedup of up to $\times 3 .$ —while provably maintaining high performance.
12
+
13
+ # 1 Introduction
14
+
15
+ Recent advances in Large Language Models (LLMs) have led to breakthroughs in language understanding and language generation across almost every widely-used Natural Language Processing (NLP) task considered in the field today [5; 15; 17; 20; 51; 52; 53; 75; 89; 73]. Autoregressive language modeling provides a flexible framework for solving complex tasks with a unified natural language input and output format, while also relaxing the need for large-scale task-specific data collection and training [67; 15; 17; 58; 80]. The large size of LLMs, however, results in massive computational load that might be limiting for certain real-world applications (e.g., machine translation) [9; 30; 42; 49; 59; 63; 71]. This is especially pronounced in the autoregressive decoding process where the full stack of Transformer layers is repeatedly computed for each output token [37; 40; 86].
16
+
17
+ While large models do better in general, the same amount of computation may not be required for every input to achieve similar performance (e.g., depending on if the input is easy or hard) [66]. Early exiting is a promising approach to decreasing the computational cost of multilayered architectures such as those used in Transformer-based LLMs, where the number of layers used by the model is dynamically decided on an input-by-input basis [18; 23; 57; 60; 70]. In this setting, an LLM can choose to generate a new token based off the representation at an intermediate layer instead of using the full model, and save computation as a result. A natural question that arises, however, is when is it a good decision to exit early, as opposed to wait? Naively choosing when to exit can be suboptimal in terms of saving computation time, and also result in unpredictable degradations to model performance, especially when predictions depend on each other, as in autoregressive language generation.
18
+
19
+ ![](images/6403c6cf0f82b2a39928dda68d9bb61b123b168bef6e6e383a2672124b140f74.jpg)
20
+ Figure 1: Illustration of CALM generation (see Figure 4 for the full example) with local per-token early exiting decisions that provably satisfy global user-defined constraints on the full sequence.
21
+
22
+ In this work, we analyze the early exiting paradigm for LLMs, and present a principled method for increasing model efficiency while remaining confident in the quality of the resulting predictions. Specifically, we develop a method for calibrating local, per-token, exit decisions such that global, sequence-level constraints—as determined by lexical or semantic sequence-level metrics like ROUGE or BLEURT score—are provably maintained with arbitrarily high probability (e.g., $9 5 \%$ ). This process, which we call Confident Adaptive Language Modeling (CALM), is illustrated in Figure 1.
23
+
24
+ Our approach leverages recent techniques in distribution-free risk control in order to create confident generations with strong statistical guarantees [2; 3; 10]. Concretely, suppose we have been given a calibration set $S _ { \mathrm { c a l } } : = \{ P _ { i } \} _ { i = 1 } ^ { n } \in \mathcal { P } ^ { n }$ of independent and identically distributed (i.i.d.) prompts to our LLM (e.g., paragraphs to be summarized, sentences to be translated, or questions to be answered via language modeling). Let $P _ { \mathrm { t e s t } }$ be a new i.i.d. test prompt to our LLM, where $Y _ { \mathrm { e a r l y } } : =$ $\mathbf { L L M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } )$ and $Y _ { \mathrm { f u l l } } : = \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } )$ are the adaptive and standard outputs of our LLM, respectively. In order to be satisfied with $Y _ { \mathrm { e a r l y } }$ , we might require it to be textually consistent with $Y _ { \mathrm { f u l l } }$ . Given any bounded text dissimilarity function $\mathcal { D }$ , we aim to calibrate the early-exiting LLM such that its predictions agree to a tolerance $\delta$ with the full model in expectation with high probability,
25
+
26
+ $$
27
+ \begin{array} { r } { \mathbb { P } \Big ( \mathbb { E } \big [ \mathcal { D } ( Y _ { \mathrm { e a r l y } } , Y _ { \mathrm { f u l l } } ) \big ] \leq \delta \mid \mathcal { S } _ { \mathrm { c a l } } \Big ) \geq 1 - \epsilon , } \end{array}
28
+ $$
29
+
30
+ where the randomness is over draws of $ { S _ { \mathrm { c a l } } }$ , and $\epsilon \in ( 0 , 1 )$ . Eq. (1) has the significant advantage of being achievable using only unlabeled calibration data $ { S _ { \mathrm { c a l } } }$ (a quality that is critical for fewshot tasks, for example). Enforcing textual consistency with the original $Y _ { \mathrm { f u l l } }$ , however, may be unnecessarily strict for certain tasks, especially where multiple generations may be acceptable. As an alternative, given a calibration set of prompts paired with a set of (potentially multiple) target references, $\bar { S _ { \mathrm { c a l } } } : = \{ ( P _ { i } , Z _ { i } ) \} _ { i = 1 } ^ { n } \in ( \mathcal { P } \times 2 ^ { \mathcal { V } } ) ^ { \bar { n } }$ , and any bounded risk function $\mathcal { R }$ , we also consider an objective that enforces risk consistency by limiting the relative increase in risk of the predictions $Y _ { \mathrm { e a r l y } }$ compared to $Y _ { \mathrm { f u l l } }$ , with respect to the set of test-time references $Z _ { \mathrm { t e s t } }$ , i.e.,
31
+
32
+ $$
33
+ \mathbb { P } \Big ( \mathbb { E } \big [ \mathcal { R } ( Y _ { \mathrm { e a r l y } } , Z _ { \mathrm { t e s t } } ) - \mathcal { R } ( Y _ { \mathrm { f u l l } } , Z _ { \mathrm { t e s t } } ) \big ] \leq \delta \big | \ S _ { \mathrm { c a l } } \Big ) \geq 1 - \epsilon .
34
+ $$
35
+
36
+ Within the constraints of either Eq. (1) or Eq. (2), the goal of our work is to find the most computationally efficient $Y _ { \mathrm { e a r l y } }$ , i.e., generations that exit as early as possible while still maintaining our desired performance guarantees. In order to achieve this, it is necessary to develop a reliable signal for how likely local, per-token early-exit decisions are to disrupt the global properties of the complete sequence. Here, we first analyze how errors are propagated in Transformer-based LLMs, and then present an effective and efficient scoring mechanism for assigning “consistent early-exit” confidence scores after each layer used during the generation of a new token. The decision to exit or not is based on these scores, and is carefully calibrated using $ { S _ { \mathrm { c a l } } }$ such that our performance bounds are provably satisfied.
37
+
38
+ Finally, we empirically validate our method on multiple, diverse NLP generation tasks, including text summarization, machine translation, and question answering. Our experiments demonstrate the potential of CALM in reducing the average complexity of the model and accelerating inference by about $\times 3$ while reliably controlling for high performance.
39
+
40
+ Contributions. In summary, our main contributions are as follows:
41
+
42
+ • A framework (CALM) for reliably accelerating Transformer-based LLM generations. • A systematic analysis of the token-wise early exit mechanism that motivates a simple-but-effective class of confidence measures and threshold functions that are used as part of the CALM framework. • An empirical demonstration of CALM’s efficiency gains on three diverse generation datasets.
43
+
44
+ # 2 Related Work
45
+
46
+ Improving inference-time efficiency of LLMs has been an ongoing effort of the research community over the past several years [49; 72; 85], leveraging techniques such as knowledge distillation [6; 32; 36; 69; 69; 78; 56], floating point quantization [71; 65], layer pruning [24], vector dropping [38], and others [41]. Another line of work involves conditional computation to train larger models that only use a sparser subset of the full network during inference, for example by routing over mixture-ofexperts [9; 22; 39; 91], recurring modules [18; 29; 35], or accessing external memory [82]. These models, however, still use the same amount of compute for all input examples.
47
+
48
+ Here, we focus on adaptive compute, a specific kind of conditional compute that aims to dynamically allocate different computational power per example, with the goal of reducing the overall complexity while maintaining high performance. This approach, often referred to as early-exiting [16; 25; 47; 74; 79; 87], is complementary to many of the solutions above and can potentially be combined with them. Multiple early-exit techniques for encoder-only Transformers (e.g., BERT [20]) have been recently proposed [8; 34; 43; 44; 45; 60; 68; 83; 90; 92]. Most of these methods rely on intrinsic confidence measures (e.g., based on the softmax distribution), while others try to predict the routing in advance [46; 70], or train a small early-exit classifier [57; 84], as we also examine here. These measures can be calibrated to reliably guarantee consistency of the early prediction with the full model [57]. However, the techniques used for encoder-only classifiers are unsuitable for global consistency constraints with a sequence of dependent predictions, which are inherent in the decoding process of autoregressive language models, which we address here.
49
+
50
+ Our work is also motivated by recent findings on the existence of saturation events in LMs, where the top-ranked prediction is unchanged after some layer and is propagated upward. Geva et al. [28] examined interactions of the hidden-state with feed-forward layers to predict these events. However, they only consider local single predictions and do not address the challenges involved with sequence generation. Our early-exit LM architecture most closely relates to Elbayad et al. [23], who found a tokenlevel early-exit classifier to provide the best efficiency-performance tradeoffs on machine translation. Here, we introduce a theoretically-grounded calibration method for provably controlling the quality of the full sequence. By doing so, we provide reliable efficiency gains—deriving local early exiting decisions from the global desirable constraints. Moreover, we introduce several model improvements and empirical analyses, including (1) analyzing the primary sources of performance degradation, leading us to propose a decaying threshold function for better tradeoff control without inflating the search space; (2) improving the early-exit classifier training; and (3) experimenting with two new tasks.
51
+
52
+ Our calibration procedure for connecting global constraints to local decisions, relates to recent research around distribution-free uncertainty quantification [1; 62; 77]. Several methods were developed in recent studies to expand and adjust the theoretical framework for obtaining practical efficiency gains on target applications [4; 7; 21; 26; 27; 48; 88]. Here, we frame our consistency requirements around the Learn then Test (LTT) framework [3], and leverage the approximately monotonic behavior of our confidence measures and the nested structure of our problem, that by definition guarantees consistency with large enough threshold, to form tight and effective bounds.
53
+
54
+ # 3 Early Exiting for Adaptive Language Modeling
55
+
56
+ In the following, we describe and analyze the early-exiting Transformer LM. We begin with a brief recap of the Transformer architecture (§3.1) and early exiting (§3.2) for convenience, following previous work [23; 70; 76]. We then investigate the effects of early exiting on model performance, and identify primary sources of performance degradation and how to alleviate them (§3.3)—which guide our architecture and training design (§3.4) and proposed per-token confidence measures (§3.5).
57
+
58
+ # 3.1 The Transformer architecture
59
+
60
+ We use the Transformer sequence-to-sequence model, based on the T5x implementation [55]. Here, we only review simplified details of the Transformer architecture relevant to early-exiting, and refer the reader to Vaswani et al. [76] for full details. At a high level, both encoder and decoder networks contain $L$ stacked layers, where each layer is composed of a multi-head self-attention sub-layer, followed by a feedforward sub-layer, each with residual connections and layer normalization. The decoder network has an additional multi-head attention sub-layer that attends to the encoder states.
61
+
62
+ Consider a prompt $\boldsymbol { x } = ( x _ { 1 } , \dots , x _ { p } )$ , processed by the encoder to yield encoder states $( e _ { 1 } , \ldots , e _ { p } )$ , and the current, partially generated response $( y _ { 1 } , \dots , y _ { t } )$ . When generating the next token $y _ { t + 1 }$ , the decoder computes a decoder state $d _ { t } ^ { i }$ for layer $i$ out of $L$ as:
63
+
64
+ $$
65
+ \begin{array} { r } { h _ { t } ^ { i } : = \mathrm { A t t e n t i o n } ( d _ { t } ^ { i - 1 } , d _ { 1 : t - 1 } ^ { i - 1 } ) ; \quad a _ { t } ^ { i } : = \mathrm { A t t e n t i o n } ( h _ { t } ^ { i } , e _ { 1 : p } ) ; \quad d _ { t } ^ { i } : = \mathrm { F e e d F o r w a r d } ( a _ { t } ^ { i } ) . } \end{array}
66
+ $$
67
+
68
+ Internal to each of the attention mechanisms, written as $\mathrm { A t t e n t i o n } ( x , z _ { 1 : m } )$ for some input $x$ and sequence of $m$ states $z _ { 1 : m }$ , $x$ is first projected to a query vector $q : = \mathbf { W } _ { Q } x \in \mathbb { R } ^ { \dim _ { k } }$ , while $z$ is projected to a matrix of key-value vectors, $\mathbf { K } : = \mathbf { W } _ { K } z _ { 1 : m } \in \mathbb { R } ^ { m \times \mathrm { d i m } _ { k } }$ and $\mathbf { V } : = \mathbf { W } _ { V } z _ { 1 : m } \in$ $\mathbf { \mathbb { R } } ^ { m \times \dim _ { v } }$ . The output $o$ is then computed as o := softmax $\left( q \mathbf { K } ^ { \top } / \sqrt { \mathrm { d i m } _ { k } } \right) \mathbf { V }$ .
69
+
70
+ Multi-head and normalization components are omitted for brevity. Each layer uses different projections $\mathbf { W } _ { Q } ^ { i } , \mathbf { W } _ { K } ^ { i }$ , and $\mathbf { W } _ { V } ^ { i }$ (which are also unique for computing $h _ { t } ^ { i }$ versus $\dot { a } _ { t } ^ { i \cdot }$ ).
71
+
72
+ Finally, after layer $L$ , a distribution over vocabulary tokens $y _ { t + 1 } \in \mathcal { D }$ is computed via a softmaxnormalized linear classifier $\mathbf { W } _ { L }$ , where $p ( y _ { t + 1 } \mid d _ { t } ^ { L } ) = \mathrm { s o f t m a x } ( \mathbf { W } _ { L } d _ { t } ^ { L } )$ .
73
+
74
+ # 3.2 Decoding with early exiting
75
+
76
+ Instead of always making a prediction based on the representation at the final layer, $d _ { t } ^ { L }$ , the key idea in early-exiting is to choose $y _ { t + 1 }$ more quickly, if confident, by computing $p ( y _ { t + 1 } \mid d _ { t } ^ { i } ) =$ softmax $( \dot { W _ { i } } \dot { d _ { t } ^ { i } } )$ for some intermediate layer $i < L$ . Concretely, let $\bar { c } _ { t } ^ { i } \in [ \bar { 0 } , 1 ]$ denote some local confidence score for layer $i$ while processing token $t$ , where higher values indicate a higher propensity to exit early (we will propose effective instantiations of $c _ { t } ^ { i }$ in $\ S 3 . 5 )$ . Let $\lambda _ { t } ^ { i } \in [ 0 , 1 ]$ denote some local early-exiting threshold, where the model exits early if $c _ { t } ^ { i } \geq \lambda _ { t } ^ { i }$ , or otherwise proceeds to compute the next representation, $d _ { t } ^ { i + 1 }$ . The (greedily chosen) prediction $y _ { t + 1 }$ can then be written as:
77
+
78
+ $$
79
+ y _ { t + 1 } : = \left\{ \begin{array} { l l } { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { 1 } ) \quad } & { \mathrm { i f } c _ { t } ^ { 1 } \geq \lambda _ { t } ^ { 1 } , } \\ { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { 2 } ) \quad } & { \mathrm { i f } c _ { t } ^ { 2 } \geq \lambda _ { t } ^ { 2 } , } \\ { \quad } & { \ \vdots } \\ { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { L } ) \quad } & { \mathrm { o t h e r w i s e } . } \end{array} \right.
80
+ $$
81
+
82
+ Note that due to the self-attention mechanism of the Transformer, computing the input hidden state $h _ { t } ^ { i }$ for layer $i$ depends on $d _ { 1 : t - 1 } ^ { i - 1 }$ , i.e., the output hidden states of the previous layer for all the tokens that have been generated so far.2 Therefore, if the model has early exited at some layer $j < i - 1$ for a token $s < t$ , then $d _ { s } ^ { i - 1 }$ is not available. As an approximation, we set $d _ { s } ^ { k } = d _ { s } ^ { j }$ for all layers $k > j$ following Elbayad et al. [23], with the understanding that this will introduce some error. In the next section, in addition to other factors, we will analyze the impact of this copied state on performance.
83
+
84
+ # 3.3 The effects of early exiting on error propagation
85
+
86
+ We perform several controlled experiments to investigate the behavior and the potential of earlyexiting during decoding. We use an 8-layer T5 encoder-decoder and the CNN/DM dataset for these experiments. See $\ S 5$ for more details on this model and data.
87
+
88
+ # 3.3.1 State propagation
89
+
90
+ First, we control for the correctness of the predicted tokens to examine the effect of state copying (§3.2), and also measure an approximate upper bound for compute reduction. We use an oracle confidence measure that exits at the earliest layer that agrees with the top prediction (i.e., replacing the conditions in Eq. 4 with arg max $p ( y _ { t + 1 } \mid \bar { d } _ { t } ^ { i } ) = \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid { \dot { d } } _ { t } ^ { \hat { L } } ) )$ . Hence, the only factor that can cause divergence in the generation is the state copying mechanism for skipped layers. The results of this experiment are highly encouraging. This oracle achieves an ROUGE-L score of 38.24, compared to 38.32 with the full model, while only using an average of 1.53 layers per token. We also try an oracle that always uses $d _ { 1 : t - 1 } ^ { 1 }$ and it reaches 38.31 ROUGE-L. These results indicate that (1) the model is robust to state copying from lower layers, and (2) there is remarkable potential for saving compute—by up to $\times 5 . 2$ —while preserving performance, given a good confidence measure.
91
+
92
+ We also experiment with copying the projected states $\mathbf { K } ^ { j } , \mathbf { V } ^ { j }$ to skipped layers $k > j$ . This version of the oracle results in a significant drop in performance to 23.02 ROUGE-L. Overall, we conjecture that the self-attention at layer $i$ for token $t$ can safely use hidden-states $d _ { s } ^ { j }$ for $j < i - 1$ as key-values of tokens $s < t$ , as long as the projections $\mathbf { W } _ { K / V } ^ { i }$ of layer $i$ are used. Notably, this projection can now be computed concurrently for all skipped layers as they all use the same $d$ from the exited layer.
93
+
94
+ ![](images/c9293fe540f82f85222a9ced360ae50fb5c8012dd05f8b51c72a691482b5286a.jpg)
95
+ Figure 2: Earlier noise in the decoding process has greater effect on the overall output (a), though in practice the affect of early exits is minor due to high performance of early layers. A decaying confidence threshold (b) allows finer control over the performance-efficiency tradeoff (c).
96
+
97
+ # 3.3.2 Sensitivity to local errors
98
+
99
+ Next, we examine the impact of local token modifications—which might occur due to early exits—on the whole generated sequence. We experiment with two kinds of perturbations: sampling-based, where we select the 10th-ranked token according to layer $L$ ; and layer-based, where we select the the first layer’s prediction at timestep $t$ . All other tokens are predicted greedily by layer $L$ . As shown in Figure 2a, earlier perturbations result in lower sequence-level scores as there are more tokens that might suffer from the divergence. The degradation, though, is much smaller with layer- compared to sampling-based perturbations since, in practice, the early exit predictions are mostly accurate.
100
+
101
+ Decaying threshold. Following the above observation, we introduce a decaying early-exiting threshold that is more permissive towards exiting as the decoding process continues. Motivated by the logarithmic behavior in Figure 2a, we use an exponential function with a user-defined temperature $\tau$ :
102
+
103
+ $$
104
+ \lambda ^ { \prime } ( \lambda , t ) : = \mathrm { c l i p } _ { [ 0 , 1 ] } \left( \frac { 9 } { 1 0 } \lambda + \frac { 1 } { 1 0 } e ^ { - \tau \cdot t / N } \right) ,
105
+ $$
106
+
107
+ where $N$ is the maximum output length. Figure 2b illustrates this function. Essentially, this function presents an effective compromise between simply using the same threshold for all tokens, and searching over a huge space of per-position different thresholds. Practically, it supports finer and better control over the performance-efficiency tradeoff compared to a single threshold. Figure $2 \mathrm { c }$ presents the outcomes of a search over $\lambda$ with steps of 0.01 and softmax-based confidence $( \ S 3 . 5 )$ . With the single threshold variant $( \tau = 0$ ), attempting to improve the efficiency will lead to a drastic drop of more than 10 points in the textual similarity against the full model’s prediction. In contrast, the decaying thresholds reveal several intermediate points with desirable tradeoffs to consider.
108
+
109
+ # 3.4 Training early exit classifiers for local consistency
110
+
111
+ While our goal is to preserve the quality of the complete output sequence, we note that this doesn’t necessarily demand local token-level consistency. Consider the target sequence “the concert was wonderful and long.” An output that switches the order of adjectives to “the concert was long and wonderful” would be called consistent by most semantic measures (and obtain 100 token- $F _ { 1 }$ score). Yet, the sentences diverge at the first adjective long which is semantically different from wonderful.
112
+
113
+ Training for global consistency, however, could be challenging [81] as it depends on possibly noisy signals that might affect the learning, and also breaks the efficient teacher-forcing training strategy of LMs that relies on local-decisions. On the other hand, perfect local consistency implies global consistency. Therefore, we opt to train for local consistency, which requires minimal changes to the training procedure, and relax the local requirement to a global one during inference.
114
+
115
+ Specifically, similar to Elbayad et al. [23], we average losses for each layer to obtain the objective
116
+
117
+ $$
118
+ \mathcal { L } = \sum _ { i = 1 } ^ { L } \omega _ { i } \mathcal { L } _ { i } , \quad \mathrm { w h e r e } \quad \sum _ { i = 1 } ^ { L } \omega _ { i } = 1 .
119
+ $$
120
+
121
+ $\mathcal { L }$ is the negative log-likelihood loss. We set $\begin{array} { r } { \omega _ { i } = i / \sum _ { j = 1 } ^ { L } j } \end{array}$ to favor higher layers, and find this objective to mostly preserve the full model’s performance compared to regular training. We note that there is some misalignment between this training and inference behavior due to the hidden states of skipped layers. However, as discussed in $\ S 3 . 3 . 1$ , the performance is not affected if the hidden-state is copied.
122
+
123
+ # 3.5 Local confidence measures
124
+
125
+ We experiment with three confidence measures for Eq. (4) that differ in their parameter and compute operation efficiencies. Our experiments (§6) will also show that they differ in their predictive power.
126
+
127
+ Softmax response. We take the difference between the top two values of Softmax $( \mathbf { W _ { i } } d _ { t } ^ { i } )$ . With a large output vocabulary, this results in many floating point operations (FLOPs)—though, the next layer $i + 1$ can start its computation in parallel, avoiding additional runtime.
128
+
129
+ Hidden-state saturation. As a simple parameter-free and fast to compute alternative, we take the cosine similarity $\mathrm { s i m } ( d _ { t } ^ { i } , d _ { t } ^ { i - 1 } )$ for $i > 1$ . By definition, the first possible exit is at the second layer (unless $\lambda = 0$ ). This measure tries to identify early saturation events of the hidden-state [28].
130
+
131
+ Early exit classifier. We train a dedicated linear classifier $\mathcal { M }$ to predict the likelihood of exiting with local consistency given the current hidden-state: $c _ { t } ^ { i } = \mathcal { M } ( \bar { d } _ { t } ^ { i } )$ . This measure is very fast to compute at inference, and adds only $| d | + 1$ new parameters. To avoid any impact on the core model’s performance, we train it as a second step where we freeze all parameters other than $\mathcal { M }$ . We simply use a per-layer independent cross-entropy loss against a consistency oracle $\mathbb { 1 } [ \operatorname { a r g m a x } ( p ( y _ { t + 1 } | d _ { t } ^ { i } ) \bar { = }$ ar $\mathrm { g } \operatorname* { m a x } ( p ( y _ { t + 1 } | d _ { t } ^ { L } ) ]$ , and average across the $L - 1$ layers. We also experimented with the geometriclike training of Elbayad et al. [23], but find it to be less effective here (see App. D). The two objectives are closely related, but the geometric one ignores any signal from the states post the first oracle exit.
132
+
133
+ # 4 Calibrating Local Early Exits from Global Constraints
134
+
135
+ We now describe our calibration procedure for finding a shared exit threshold $\lambda \in [ 0 , 1 ]$ that can be used directly in Eq. (4), or via Eq. (5), such that we provably satisfy our desired global constraints over the fully generated sequences. At a high level, our approach uses the following basic recipe:
136
+
137
+ 1. We specify a grid of possible values of $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ that may result in acceptable generations;
138
+ 2. We choose the lowest valid $\lambda \in \Lambda$ that we can identify with rigorous statistical testing tools.
139
+
140
+ Let $P _ { \mathrm { t e s t } }$ be an i.i.d. prompt given to the LLM at test time, and let $Y _ { \mathrm { f u l l } } : = \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } ) \in \mathcal { V }$ and $Y _ { \mathrm { e a r l y } } : = \mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } , \lambda ) \in \mathcal { Y }$ denote the full and adaptive responses, respectively. Optionally, let $\dot { Z } _ { \mathrm { t e s t } }$ be a set of gold references for our task, if assumed. Our goal, as introduced in $\ S 1$ , is to find a valid $\lambda$ using $ { S _ { \mathrm { c a l } } }$ such that we satisfy either of two types of global “consistency” constraints:
141
+
142
+ Definition 1 (Textual consistency). An adaptive LLM is textually consistent if given any bounded text dissimilarity function, $\mathcal { D } \colon \mathcal { V } \times \mathcal { V } \to \mathbb { R }$ , and tolerance $\delta \in \mathbb { R }$ , $\mathbb { E } \big [ { \cal D } ( Y _ { \mathrm { e a r l y } } , \tilde { Y _ { \mathrm { f u l l } } } ) \big ] \leq \dot { \delta }$ .
143
+
144
+ Definition 2 (Risk consistency). An adaptive LLM is risk consistent if given any bounded risk function, $\mathcal { R } : \mathcal { V } \times 2 ^ { \mathcal { V } } \to \mathbb { R } ,$ , and tolerance $\delta \in \mathbb { R } ,$ $\mathbb { E } [ \mathcal { R } ( Y _ { \mathrm { e a r l y } } , Z _ { \mathrm { t e s t } } ) ] \le \mathbb { E } [ \mathcal { R } ( Y _ { \mathrm { f u l l } } , Z _ { \mathrm { t e s t } } ) ] + \delta$ .
145
+
146
+ Without loss of generality, we will assume that $\mathcal { D }$ and $\mathcal { R }$ are always normalized to the unit interval $[ 0 , 1 ]$ , and therefore will only be considering tolerances $\delta \in ( 0 , 1 )$ . At a glance, to find a $\lambda$ that produces a consistent $\mathbf { L L M } _ { \mathrm { e a r l y } }$ , we cast our problem as a multiple hypothesis testing problem over a large array of $k$ candidate classifier exit thresholds, $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ , and apply the Learn then Test (LTT) framework of Angelopoulos et al. [3] to identify a subset of statistically valid, constraint-satisfying thresholds $\Lambda _ { \mathrm { v a l i d } } \subset \Lambda$ . Our final $\lambda$ is then chosen as $\lambda : = \operatorname* { m i n } ( \Lambda _ { \mathrm { v a l i d } } \cup \dot { \{ 1 \} } )$ .
147
+
148
+ # 4.1 The Learn then Test calibration framework
149
+
150
+ Choosing a value of $\lambda$ that rigorously satisfies our consistency objectives is challenging, as the performance impact of increasing or decreasing $\lambda$ is not necessarily monotonic. Naively setting $\lambda$ , for example, based simply on average calibration set performance, can lead to statistically invalid results in our finite-sample, distribution-free setting. The LTT framework proposed by Angelopoulos et al. [3] solves this problem by reframing hyper-parameter selection as a multiple testing problem.
151
+
152
+ Let $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ be a finite grid of hyper-parameter values that may, or may not, obtain valid consistency. For example, when searching for a value of $\lambda \in [ 0 , 1 ]$ , we might consider the evenly spaced set $\begin{array} { r } { \dot { \Lambda } = \{ \frac { i } { k + 1 } : \stackrel { \cdot } { i } = 1 , \dots , k \} } \end{array}$ . LTT then identifies a subset of values, $\Lambda _ { \mathrm { v a l i d } } \subset \Lambda$ , where
153
+
154
+ $$
155
+ \mathbb { P } \Big ( \exists \lambda \in \Lambda _ { \mathrm { v a l i d } } \colon \mathbf { L L M _ { \mathrm { e a r l y } } } ( P _ { \mathrm { t e s t } } , \lambda ) \mathrm { ~ a n d ~ } \mathbf { L L M _ { \mathrm { f u l l } } } ( P _ { \mathrm { t e s t } } ) \mathrm { ~ a r e ~ } \mathbf { n o t } \mathrm { ~ c o n s i s t e n t } \Big ) \le \epsilon .
156
+ $$
157
+
158
+ Here, we are using consistency to refer to either textual consistency or risk consistency. Eq. (7) can be satisfied by applying standard multiple hypothesis testing techniques as long as super-uniform p-values, $p _ { j }$ , are supplied for each value $\lambda _ { j } \in \Lambda$ that support the null hypothesis
159
+
160
+ $$
161
+ H _ { j } \colon \mathbf { L } \mathbf { L } \mathbf { M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } , \lambda _ { j } ) \ \mathrm { a n d } \ \mathbf { L } \mathbf { L } \mathbf { M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } ) \ \mathrm { a r e } \ \mathbf { n o t } \ \mathrm { c o n s i s t e n t } .
162
+ $$
163
+
164
+ $\lambda _ { j }$ is placed in $\Lambda _ { \mathrm { v a l i d } }$ if $H _ { j }$ is rejected, and discarded otherwise. This yields a consistent $\mathbf { L L M } _ { \mathrm { e a r l y } }$ . Proposition 1 (LTT for CALM). Suppose $p _ { j }$ is super-uniform for all $j$ under $H _ { j }$ for some specified tolerance $\delta \in ( 0 , 1 )$ . Let $\mathcal { A }$ be any family-wise error rate (FWER) controlling procedure at a level $\epsilon \in ( 0 , 1 )$ , where $\mathcal { A } ( p _ { 1 } , \ldots , p _ { k } )$ selects $H _ { j }$ to reject. Choosing $\lambda : = \operatorname* { m i n } ( \Lambda _ { \mathrm { v a l i d } } \cup \{ 1 \} )$ then yields a consistent $L L M _ { \mathrm { e a r l y } }$ with probability at least $1 - \epsilon$ .
165
+
166
+ Note that a FWER-controlling procedure at a level $\epsilon$ is an algorithm that decides to accept or reject hypotheses $\{ H _ { i } \} _ { i = 1 } ^ { k }$ , while ensuring that the probability of falsely rejecting any $H _ { j }$ is less than $\epsilon$ . The proof of Proposition 1, given in Appendix A.1, follows directly from Theorem 1 of Angelopoulos et al. [3], and the fact that $\mathbf { L L M _ { \mathrm { e a r l y } } } ( P _ { \mathrm { t e s t } } ^ { - } , 1 ) = \mathbf { L L M _ { \mathrm { f u l l } } } ( P _ { \mathrm { t e s t } } )$ by construction per Eq. (4), so that we can always use $\lambda = 1$ as a valid fallback if we fail to identify non-empty $\Lambda _ { \mathrm { v a l i d } }$ . In the next sections, we describe how we calculate valid $\mathsf { p }$ -values using $ { S _ { \mathrm { c a l } } }$ , and our choice of FWER-controlling procedure.
167
+
168
+ # 4.2 Defining p-values for consistent early-exiting
169
+
170
+ LTT relies on valid $\mathfrak { p }$ -values $p _ { j }$ , where $p _ { j }$ is a random variable satisfying $\mathbb { P } ( p _ { j } \leq u ) \leq u$ under $H _ { j }$ for all $u \in [ 0 , 1 ]$ . For our purposes, we can obtain valid $\mathsf { p }$ -values from the empirical consistency of $\mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda )$ measured over the random calibration sample, $ { S _ { \mathrm { c a l } } }$ . Since we have assumed w.l.o.g. that either of our bounded consistency functions $\mathcal { D }$ and $\mathcal { R }$ from Defs. 1 and 2 have been normalized to lie in $[ 0 , 1 ]$ , we can, for example, obtain a valid $\mathfrak { p }$ -value by simply inverting Hoeffding’s inequality:3
171
+
172
+ $$
173
+ p _ { j } ^ { \mathrm { H o e f f d i n g } } : = e ^ { - 2 n ( \operatorname* { m a x } ( 0 , \delta - \widehat { E } ( \lambda _ { j } ) ) ) ^ { 2 } } ,
174
+ $$
175
+
176
+ where $\begin{array} { r } { \widehat { E } ( \lambda _ { j } ) : = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } L _ { i } ( \lambda _ { j } ) } \end{array}$ is the empirical average of random variable $L _ { i } ( \lambda _ { j } ) \in [ 0 , 1 ]$ , with
177
+
178
+ $$
179
+ \mathsf { \Pi } _ { \mathsf { L } _ { i } } ( \lambda _ { j } ) : = \mathcal { D } ( \mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda _ { j } ) , \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { i } ) ) \quad \mathrm { o r }
180
+ $$
181
+
182
+ $$
183
+ L _ { i } ( \lambda _ { j } ) : = \operatorname* { m a x } \left( 0 , \mathcal { R } ( \operatorname { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda _ { j } ) , Z _ { i } ) - \mathcal { R } ( \operatorname { L L M } _ { \mathrm { f u l l } } ( P _ { i } ) , Z _ { i } ) \right) ,
184
+ $$
185
+
186
+ for textual consistency versus risk consistency, respectively. Note that, as a technicality of enforcing the r.v. $L _ { i } ( \lambda _ { j } )$ to be within $[ 0 , 1 ]$ , Eq. (11) computes a conservative estimate of the difference in the empirical risk that doesn’t reward instances in which the risk of the early-exit model is lower.
187
+
188
+ # 4.3 Efficient fixed sequence testing
189
+
190
+ The more values of $\lambda$ we test, the higher the chance that we might accidentally choose a $\lambda$ that does not in fact result in consistent generations, despite whatever misleading performance we might have measured by chance on $ { S _ { \mathrm { c a l } } }$ . As part of LTT, we must select a multiple testing procedure that corrects for this (i.e., that controls the FWER at level $\epsilon$ ). Though the precise dependence between the early-exit LLM’s performance and $\lambda$ is unknown, in practice we find that it tends to be fairly smooth and roughly monotonic. That is, nearby thresholds $\bar { \lambda } \approx \lambda ^ { \prime }$ tend to perform similarly, whereas $\lambda > \lambda ^ { \prime }$ tends to result in relatively more consistent performance. Taking advantage of this structure, we choose to employ fixed sequence testing (FST) as our FWER-controlling procedure [3; 11].
191
+
192
+ Here we define a sequence of descending thresholds $\lambda _ { 1 } > \lambda _ { 2 } > . . . \lambda _ { k }$ with a relatively coarse step size (e.g., increments of 0.05). For each $\lambda _ { j }$ in order, we compute $p _ { j }$ , and reject $H _ { j }$ if $p _ { j } \leq \epsilon$ . The first time we fail to reject $H _ { j }$ , we immediately terminate our search, and return $\lambda _ { j - 1 }$ to use as our calibrated threshold (or 1, if we fail to reject $H _ { 1 }$ ). An Algorithm of the full procedure is provided in Appendix E.
193
+
194
+ ![](images/0c105aa367418bb431e00db485785f8d1b130393e688a242b52e2fc317d8243b.jpg)
195
+ Figure 3: Validation empirical performance-efficiency tradeoffs for different confidence measures, compared to static baselines and a local oracle measure with state propagation for skipped layers.
196
+
197
+ # 5 Experimental Setting
198
+
199
+ We empirically evaluate our methods on three popular text generation tasks that vary in their target generation length and extractive degrees against the input. CNN/DM [31] is a collection of news articles to be summarized in few sentences. WMT15 EN-FR [13] contains English sentences (one per example) to be machine translated to French. Open-book SQUAD 1.1 [54] is a QA dataset with Wikipedia paragraphs paired with questions, where the target answer is a text span from the input. Length statistics of the validation sets are summarized in Table 1.
200
+
201
+ Table 1: Average number of tokens in reference targets of evaluation datasets (5/95th percentiles in parenthesis).
202
+
203
+ <table><tr><td>Dataset</td><td>Output length</td></tr><tr><td>CNN/DM</td><td>82 (42 - 141)</td></tr><tr><td>WMTEN-FR</td><td>39 (10 -82)</td></tr><tr><td>SQUAD</td><td>5 (1-13)</td></tr></table>
204
+
205
+ Model. We implement CALM on top of the T5 encoder-decoder model that showed good performance on the tasks above [53], using the T5X framework [55]. We use the 8 layers T5 1.1 model that doesn’t share input and output embeddings. We share all output embeddings for the softmax predictions, and the early-exit classifier across all decoder layers. Based on validation results, we set the temperature of our decaying threshold to $\tau = 4$ for the softmax and classifier measures of CNN/DM and WMT. In other settings, we use $\tau = 0$ . See App. C for more details, and App. B.3 for a 12 layers T5 model.
206
+
207
+ Evaluation metrics. We use the standard metrics for each task: ROUGE-L for CNN/DM, BLEU [50] for WMT, and Token-F1 [54] for SQUAD. We rely on the same metrics for computing the risk and textual distance, other than BLEU which is a corpus-level metric that doesn’t directly enable expectation control. Instead, we use the BLEURT learned metric [61]. For a given metric $m ( y _ { \mathrm { e a r l y } } , y _ { \mathrm { f u l l ~ o r } } z _ { \mathrm { t e s t } } ) \in [ 0 , 1 ]$ , we use $1 - m$ for distance or risk computation, respectively.
208
+
209
+ Our main efficiency metric is the average number of decoder layers used per output token, as it directly measures complexity reduction without conflating with implementation or infrastructure specific details [19]. For reference, we also report the average decoder FLOPs reduction per token [23]. Also, we compute an estimated speedup of the whole encoder-decoder model for generating the full sequence, based on TPUv3 benchmarking with 200 examples in Colab (see App. C for details).
210
+
211
+ Calibration experiments. For each task, we use the validation and test sets to evaluate our calibration method (§4) (for SQUAD we only use the validation set as the test answers are hidden). We run 50 random trials per target tolerance $\delta$ and consistency objective (textual or risk), where we partition the data to $80 \%$ calibration $( S _ { \mathrm { c a l } } )$ and $20 \%$ test $( P _ { \mathrm { t e s t } } )$ . We set $\epsilon = 0 . 0 5$ for all experiments.
212
+
213
+ Baselines. We emphasize that the CALM framework is general for any autoregressive multi-layered LM with any confidence measure, allowing controlled consistency by Eq. (1) or Eq. (2). To empirically evaluate the efficiency gains enabled by our proposed confidence measures, we compare with static baselines that use the same number of layers for all tokens. We also compare our early-exit classifier training with the geometric method of [23] in Appendix D. Also, we compute an oracle local measure (§3.3.1) as an upper-bound estimate of the performance-efficiency tradeoff.
214
+
215
+ # 6 Experimental Results
216
+
217
+ We first report the empirical performance-efficiency tradeoff achieved with each confidence measure.
218
+ For each task and measure, we evaluate the full range of $\lambda$ on the validation set, with steps of 0.05.
219
+
220
+ Table 2: Test efficiency gains per choice of $\delta$ , consistency objective, and confidence measure. $\epsilon$ is set to 0.05. For plots of the full range of $\delta$ with standard deviation, see Appendix B.
221
+
222
+ <table><tr><td rowspan="2">8</td><td rowspan="2">Measure</td><td rowspan="2"></td><td colspan="3">CNN/DM</td><td colspan="3">WMT</td><td colspan="3">SQUAD</td></tr><tr><td>layers</td><td>FLOPs r.</td><td>speedup</td><td>layers</td><td>FLOPs r.</td><td>speedup</td><td>layers</td><td>FLOPs r.</td><td>speedup</td></tr><tr><td rowspan="6">sisuos[enxəL 5</td><td rowspan="6">1</td><td>softmax state</td><td>5.73 8.00</td><td>×0.44 ×1.00</td><td>×1.41 ×1.00</td><td>3.35</td><td>×0.66</td><td>×2.01</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td></td><td></td><td></td><td></td><td>7.68</td><td>×1.01</td><td>×1.00</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>7.16</td><td>×1.03</td><td>×1.42</td><td>5.50</td><td>×1.06</td><td>×2.05</td><td>2.59</td><td>×2.37</td><td>×1.10</td></tr><tr><td>softmax</td><td>2.62</td><td>×0.49</td><td>×2.57</td><td>1.76</td><td>×0.91</td><td>×2.83</td><td>1.03</td><td>×5.68</td><td>×1.88</td></tr><tr><td>state</td><td>7.97</td><td>×1.00</td><td>×1.01</td><td>2.84</td><td>×1.93</td><td>×1.55</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>4.51</td><td>×1.15</td><td>×2.04</td><td>2.97</td><td>×1.22</td><td>×2.00</td><td>1.37</td><td>×5.09</td><td>×1.11</td></tr><tr><td rowspan="6">Prrsrorssrr 00</td><td rowspan="6">0</td><td>softmax</td><td>3.75</td><td>×0.47</td><td>×1.96</td><td>3.19</td><td>×0.67</td><td>×2.10</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td>state</td><td>7.97</td><td>×1.00</td><td>×1.01</td><td>7.68</td><td>×1.01</td><td>×1.00</td><td>3.13</td><td>×2.11</td><td>×1.68</td></tr><tr><td>classifier</td><td>6.49</td><td>×1.06</td><td>×1.71</td><td>5.05</td><td>×1.08</td><td>×1.97</td><td>3.36</td><td>×1.55</td><td>×1.11</td></tr><tr><td>softmax</td><td>1.73</td><td>×0.50</td><td>×3.53</td><td>1.96</td><td>×0.85</td><td>×2.73</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td>state</td><td>5.22</td><td>×1.11</td><td>×1.64</td><td>2.72</td><td>×2.01</td><td>×1.58</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>2.30</td><td>×1.25</td><td>×2.09</td><td>3.08</td><td>×1.21</td><td>×1.98</td><td>2.59</td><td>×2.37</td><td>×1.10</td></tr></table>
223
+
224
+ The results, presented in Figure 3, show the power of the softmax response measure, allowing only minor performance loss while reducing more than half of the layers in all three tasks. The early-exit classifier, that is more FLOP-efficient, is also effective, mostly when targeting high performance (right hand side of plots). The simple and parameter-free state saturation measure is competitive, but often falls bellow the static baseline, despite enabling per-token exit decisions.
225
+
226
+ The dynamic oracle obtains compelling efficiency gains, using only 1.5, 1.3, and 1.2 layers on average for summarization, WMT, and QA, respectively, without losing any performance. This illustrates the full potential of CALM and leaves further room for improvements with better confidence measures. It also shows the effectiveness of inference-time state propagation for skipped layers (§3.3.1).
227
+
228
+ # 6.1 Calibrated performance with guaranteed textual or risk consistency
229
+
230
+ Next, we examine the outcomes of the calibration process. Since the obtained risk is guaranteed to be valid (i.e., $\leq \delta$ at least $9 5 \%$ of the time), we focus here on efficiency gains per chosen $\delta$ . We refer the reader to Appendix B for empirical validation and for additional results and qualitative examples.
231
+
232
+ Table 2 presents the efficiency gains per choice of $\delta$ for each consistency objective and confidence measure. We examine larger $\delta$ values for textual consistency as this is generally a stricter requirement since the full model’s error is not considered.
233
+
234
+ Across all, the softmax confidence measure leads to the greatest decrease in number of decoder layers required. Accordingly, softmax mostly enables the highest speedup gains of up to about three times faster than running through all the model’s layers. The very lightweight early-exit classifier sometimes provides better gains than softmax, even if more decoding layers are used. Since the speedup is computed over the full generated output, we see more gains on the longer outputs of summarization and translation where the decoding takes most of the time, compared to the short QA outputs where the whole decoding time is not much longer than the encoding time.
235
+
236
+ These encouraging efficiency gains are enabled even with the rigorous performance guarantees that are sometimes conservative (e.g., Eq. (11)). We note that relaxing these constraints, or tightening the confidence intervals (e.g., with larger calibration sets), can further improve the empirical gains.
237
+
238
+ The softmax operation over the full output vocabulary is FLOPs heavy (though, this compute can potentially be paralleled), sometime leading to increased total FLOPs, even with fewer used layers. The state-based and early-exit classifier measures require minimal FLOPs and provide a good alternative with compelling efficiency gains, if total (parallelizable, or not) FLOPs is of concern.
239
+
240
+ # 6.2 Example output: effectively distributing the model’s capacity across timesteps
241
+
242
+ Figure 4 presents two CALM summary generations for an article from the CNN/DM dataset, compared to the output of the full model (See Figure B.5 in the Appendix for examples from the other tasks) . Y (2) y uses a lower confidence threshold for early exiting compared to Y (1)early . The colors, depicting the number of decoder layers used per output token, illustrate how CALM obtains the
243
+
244
+ <table><tr><td>test</td><td colspan="5">SouthAfrica-bGntotiatig84tiilackCapscdfrstCufiiElit&#x27;sutiatei Eliot,6,adotpadinteaialcketfor14montsenedinisindicaiofrteacigrandplaedunderdon McCullum.New Zealand play the winner of the semi-final between Australia or India.</td></tr><tr><td>Yfull:</td><td colspan="5">GrantElititZaadrougoteordCupfal.6yedaiSouthAutaturaldKltwil surely never playanotherinningslike his 84.New Zealandwilltake oneither Australiaor India in the finalon Sunday.</td></tr><tr><td>Y): early</td><td colspan="5">_Grant_Eliott_hit_a_six_to_put_New_Zealand_through__to__the_World_Cup_final_._Elliott tt_was__born_in_South__Africa_but_ a_naturalised_Kiwi_ The_36-year-old_will_surely_never__play_another_innings_like_his_unbeaten_84_ New_Zealand_will_now__take_on_either_Australia_or__India_in_the_final_on_Sunday_.&lt;EOS&gt;</td></tr><tr><td>Y(2) early ‘</td><td colspan="5">Grant_Ellott_hit_84_in_the_Black_Caps_chase__New_Zealand_reached_the_World_Cup_final._lliott tt_was__born__in_So uthAfrica_butanaturalised_KiwiEliowillsurelynevepayanotheinninglikehisunbeate84&gt;</td></tr><tr><td rowspan="2">y(1) Yearly</td><td colspan="5">D(Yearly,Yfull)</td><td rowspan="2"></td></tr><tr><td colspan="2">0.02</td><td>Rearty-Rfull</td><td>Average layers</td><td>Speedup</td></tr><tr><td colspan="2">Y(2) early</td><td>0.01 -0.3</td><td>2.1 1.9</td><td>X 2.9 X3.6</td><td>Exit layer-colormapping:12345678 D and R are computed with ROUGE-L</td><td></td></tr></table>
245
+
246
+ Figure 4: CALM accelerates the generation by early exiting when possible, and selectively using the full decoder’s capacity only forsoftmax-based confidence measure. $Y _ { \mathrm { e a r l y } } ^ { ( 1 ) }$ Y (2) kenand onstrated here on a CNN/DM example withuse different confidence thresholds for early exiting. Bellow the text, we report the measured textual and risk consistency of each of the two outputs, along with efficiency gains. The colors represent the number of decoding layers used for each token—light green shades indicate less than half of the total layers.
247
+
248
+ efficiency gains. Only a few selected tokens use the full capacity of the model (colored in red), while for most tokens the model exits after one or few decoding layers (colored in green).
249
+
250
+ The example in Figure 4 also demonstrates one difference between the two types of consistency constraints, given a reference output $Z _ { \mathrm { t e s t } }$ . Textual consistency $D ( Y _ { \mathrm { e a r l y } } , Y _ { \mathrm { f u l l } } )$ generally (though, not always) degrades (i.e., increases) when decreasing the confidence threshold as the outputs tend to more significantly diverge from $Y _ { \mathrm { f u l l } }$ . The trend of risk consistency, however, depends also on the reference output $Z _ { \mathrm { t e s t } }$ . If $Y _ { \mathrm { f u l l } } \approx Z _ { \mathrm { t e s t } }$ then the two constraints are nearly the same. In this example, they are sufficiently different that Y (2)early obtained better (lower) risk even though the textual distance from $Y _ { \mathrm { f u l l } }$ is higher. On the one hand, given the availability of reference outputs for calibration, this suggests that for an imperfect model, risk consistency could lead to more aggressive early-exiting while maintaining the quality of generations. On the other hand, since the Relu in Eq. (11) doesn’t reward negative risk differences, the benefits might not fully materialize. Overall, the two constraints provide different alternatives for the user to choose from depending on the availability of reference outputs, the performance of the full model, and the exact desired performance guarantees.
251
+
252
+ # 7 Conclusion
253
+
254
+ We present confident adaptive language modeling (CALM) for dynamically allocating different amounts of compute per generated token, following explicitly defined tolerance levels on the full generation output. This paper covers both modeling solutions and analyses towards this goal, as well as a theoretically-grounded framework for provably controlling the quality of the full output to meet the user-specified tolerance levels. We investigate the effects of local early exiting during decoding on the final output, leading us to propose a decaying function over the initial threshold that enables finer control over the performance-efficiency tradeoffs without inflating the search space. We also study different solutions for addressing missing computations of early-exited tokens that are dependent upon for future tokens. Overall, our complete adaptive compute framework for LMs requires minimal modifications to the underlying model and enables efficiency gains while satisfying rigorous quality guarantees for the output. Also, our oracle experiments and runtime analysis demonstrates the full potential of this framework and leave room for future research to further improve the efficiency in a controllable way.
255
+
256
+ # Acknowledgements
257
+
258
+ We thank Ionel Gog for significantly improving the implementation after submission. We also thank Anselm Levskaya, Hyung Won Chung, Seungyeon Kim, Tao Wang, Paul Barham, and Michael Isard for great discussions and code suggestions. We thank Orhan Firat, Carlos Riquelme, Aditya Menon, Zhifeng Chen, Sanjiv Kumar, and Jeff Dean for helpful discussions and feedback on the project.
259
+
260
+ # References
261
+
262
+ [1] Anastasios N. Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification. 2021. doi: 10.48550/ARXIV.2107.07511. URL https://arxiv.org/abs/2107.07511. [2] Anastasios Nikolas Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification, 2021. URL https://arxiv. org/abs/2107.07511.
263
+ [3] Anastasios Nikolas Angelopoulos, Stephen Bates, Emmanuel J. Candès, Michael I. Jordan, and Lihua Lei. Learn then test: Calibrating predictive algorithms to achieve risk control. ArXiv preprint: 2110.01052, 2021.
264
+ [4] Anastasios Nikolas Angelopoulos, Amit Kohli, Stephen Bates, Michael I. Jordan, Jitendra Malik, Thayer Alshaabi, Srigokul Upadhyayula, and Yaniv Romano. Image-to-image regression with distribution-free uncertainty quantification and applications in imaging. ArXiv, abs/2202.05265, 2022.
265
+ [5] Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Gupta, Kai Hui, Sebastian Ruder, and Donald Metzler. Ext5: Towards extreme multi-task scaling for transfer learning. In International Conference on Learning Representations, 2022. URL https://openreview. net/forum?id $\equiv$ Vzh1BFUCiIX.
266
+ [6] Haoli Bai, Wei Zhang, Lu Hou, Lifeng Shang, Jing Jin, Xin Jiang, Qun Liu, Michael Lyu, and Irwin King. Binarybert: Pushing the limit of bert quantization. arXiv preprint arXiv:2012.15701, 2020.
267
+ [7] Yu Bai, Song Mei, Haiquan Wang, Yingbo Zhou, and Caiming Xiong. Efficient and differentiable conformal prediction with general function classes. ArXiv, abs/2202.11091, 2022. [8] Aaron Baier-Reinio and Hans De Sterck. N-ode transformer: A depth-adaptive variant of the transformer using neural ordinary differential equations. ArXiv, abs/2010.11358, 2020. [9] Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. Controlling computation versus quality for neural sequence models. 2020. doi: 10.48550/ARXIV.2002.07106. URL https://arxiv. org/abs/2002.07106.
268
+ [10] Stephen Bates, Anastasios Nikolas Angelopoulos, Lihua Lei, Jitendra Malik, and Michael I. Jordan. Distribution free, risk controlling prediction sets. ArXiv preprint: 2101.02703, 2020.
269
+ [11] Peter Bauer. Multiple testing in clinical trials. Statistics in medicine, 10 6:871–89; discussion 889–90, 1991.
270
+ [12] Vidmantas Bentkus. On hoeffding’s inequalities. Annals of Probability, 32:1650–1673, 2004.
271
+ [13] Ondˇrej Bojar, Rajen Chatterjee, Christian Federmann, Barry Haddow, Matthias Huck, Chris Hokamp, Philipp Koehn, Varvara Logacheva, Christof Monz, Matteo Negri, Matt Post, Carolina Scarton, Lucia Specia, and Marco Turchi. Findings of the 2015 workshop on statistical machine translation. In Proceedings of the Tenth Workshop on Statistical Machine Translation, pages 1–46, Lisbon, Portugal, September 2015. Association for Computational Linguistics. doi: 10.18653/v1/W15-3001. URL https://aclanthology.org/W15-3001.
272
+ [14] James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
273
+ [15] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh,
274
+
275
+ Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/ file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
276
+
277
+ [16] Berkant Barla Cambazoglu, Hugo Zaragoza, Olivier Chapelle, Jiang Chen, Ciya Liao, Zhaohui Zheng, and Jon Degenhardt. Early exit optimizations for additive machine learned ranking systems. In WSDM ’10, 2010.
278
+
279
+ [17] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways. 2022.
280
+
281
+ [18] Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Lukasz Kaiser. Universal transformers. In International Conference on Learning Representations (ICLR), 2019.
282
+
283
+ [19] Mostafa Dehghani, Yi Tay, Anurag Arnab, Lucas Beyer, and Ashish Vaswani. The efficiency misnomer. In International Conference on Learning Representations, 2022. URL https: //openreview.net/forum?id $=$ iulEMLYh1uR.
284
+
285
+ [20] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://aclanthology.org/N19-1423.
286
+
287
+ [21] Neil Dey, Jing Ding, Jack G. Ferrell, Carolina Kapper, Maxwell Lovig, Emiliano Planchon, and Jonathan P Williams. Conformal prediction for text infilling and part-of-speech prediction. ArXiv, abs/2111.02592, 2021.
288
+
289
+ [22] Nan Du, Yanping Huang, Andrew M. Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, Maxim Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, Barret Zoph, Liam Fedus, Maarten Bosma, Zongwei Zhou, Tao Wang, Yu Emma Wang, Kellie Webster, Marie Pellat, Kevin Robinson, Kathy Meier-Hellstern, Toju Duke, Lucas Dixon, Kun Zhang, Quoc V Le, Yonghui Wu, Zhifeng Chen, and Claire Cui. Glam: Efficient scaling of language models with mixtureof-experts. 2021.
290
+
291
+ [23] Maha Elbayad, Jiatao Gu, Edouard Grave, and Michael Auli. Depth-adaptive transformer. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $\equiv$ SJg7KhVKPH.
292
+
293
+ [24] Angela Fan, Edouard Grave, and Armand Joulin. Reducing transformer depth on demand with structured dropout. arXiv preprint arXiv:1909.11556, 2019.
294
+
295
+ [25] Michael Figurnov, Artem Sobolev, and Dmitry P. Vetrov. Probabilistic adaptive computation time. ArXiv, abs/1712.00386, 2017.
296
+
297
+ [26] Adam Fisch, Tal Schuster, Tommi Jaakkola, and Regina Barzilay. Efficient conformal prediction via cascaded inference with expanded admission. In International Conference on Learning Representations (ICLR), 2021.
298
+
299
+ [27] Adam Fisch, Tal Schuster, T. Jaakkola, and Regina Barzilay. Conformal prediction sets with limited false positives. ArXiv, abs/2202.07650, 2022.
300
+
301
+ [28] Mor Geva, Avi Caciularu, Kevin Ro Wang, and Yoav Goldberg. Transformer feed-forward layers build predictions by promoting concepts in the vocabulary space. 2022.
302
+
303
+ [29] Alex Graves. Adaptive computation time for recurrent neural networks. 2016.
304
+
305
+ [30] Caglar Gulcehre, Orhan Firat, Kelvin Xu, Kyunghyun Cho, and Yoshua Bengio. On integrating a language model into neural machine translation. Computer Speech & Language, 45:137– 148, 2017. ISSN 0885-2308. doi: https://doi.org/10.1016/j.csl.2017.01.014. URL https: //www.sciencedirect.com/science/article/pii/S0885230816301395.
306
+
307
+ [31] Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. In C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc., 2015. URL https://proceedings.neurips.cc/paper/2015/file/ afdec7005cc9f14302cd0474fd0f3c96-Paper.pdf.
308
+
309
+ [32] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. ArXiv, abs/1503.02531, 2015.
310
+
311
+ [33] Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58:13–30, 1963.
312
+
313
+ [34] Lu Hou, Zhiqi Huang, Lifeng Shang, Xin Jiang, Xiao Chen, and Qun Liu. Dynabert: Dynamic bert with adaptive width and depth. Advances in Neural Information Processing Systems, 33: 9782–9793, 2020.
314
+
315
+ [35] Yacine Jernite, Edouard Grave, Armand Joulin, and Tomas Mikolov. Variable computation in recurrent neural networks. arXiv preprint arXiv:1611.06188, 2016.
316
+
317
+ [36] Xiaoqi Jiao, Yichun Yin, Lifeng Shang, Xin Jiang, Xiao Chen, Linlin Li, Fang Wang, and Qun Liu. Tinybert: Distilling bert for natural language understanding. arXiv preprint arXiv:1909.10351, 2019.
318
+
319
+ [37] Jungo Kasai, Nikolaos Pappas, Hao Peng, James Cross, and Noah Smith. Deep encoder, shallow decoder: Reevaluating non-autoregressive machine translation. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id $\equiv$ KpfasTaLUpq.
320
+
321
+ [38] Gyuwan Kim and Kyunghyun Cho. Length-adaptive transformer: Train once with length drop, use anytime with search. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 6501–6511, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.508. URL https://aclanthology.org/2021.acl-long.508.
322
+
323
+ [39] Sneha Kudugunta, Yanping Huang, Ankur Bapna, Maxim Krikun, Dmitry Lepikhin, MinhThang Luong, and Orhan Firat. Beyond distillation: Task-level mixture-of-experts for efficient inference. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3577–3599, Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.findings-emnlp.304. URL https://aclanthology. org/2021.findings-emnlp.304.
324
+
325
+ [40] Imad Lakim, Ebtesam Almazrouei, Ibrahim Abualhaol, Merouane Debbah, and Julien Launay. A holistic assessment of the carbon footprint of noor, a very large Arabic language model. In Proceedings of BigScience Episode #5 – Workshop on Challenges & Perspectives in Creating Large Language Models, pages 84–94, virtual+Dublin, May 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.bigscience-1.8.
326
+
327
+ [41] Tao Lei. When attention meets fast recurrence: Training language models with reduced compute. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 7633–7648, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.602. URL https://aclanthology.org/2021.emnlp-main.602.
328
+
329
+ [42] Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen. {GS}hard: Scaling giant models with conditional computation and automatic sharding. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ qrwe7XHTmYb.
330
+
331
+ [43] Lei Li, Yankai Lin, Deli Chen, Shuhuai Ren, Peng Li, Jie Zhou, and Xu Sun. Cascadebert: Accelerating inference of pre-trained language models via calibrated complete models cascade. arXiv preprint arXiv:2012.14682, 2020.
332
+
333
+ [44] Weijie Liu, Peng Zhou, Zhe Zhao, Zhiruo Wang, Haotang Deng, and Qi Ju. Fastbert: a self-distilling bert with adaptive inference time. arXiv preprint arXiv:2004.02178, 2020.
334
+
335
+ [45] Xiangyang Liu, Tianxiang Sun, Junliang He, Lingling Wu, Xinyu Zhang, Hao Jiang, Zhao Cao, Xuanjing Huang, and Xipeng Qiu. Towards efficient nlp: A standard evaluation and a strong baseline. arXiv preprint arXiv:2110.07038, 2021.
336
+
337
+ [46] Yijin Liu, Fandong Meng, Jie Zhou, Yufeng Chen, and Jinan Xu. Faster depth-adaptive transformers. In AAAI, 2021.
338
+
339
+ [47] Zhuang Liu, Zhiqiu Xu, Hung-Ju Wang, Trevor Darrell, and Evan Shelhamer. Anytime dense prediction with confidence adaptivity. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\equiv$ kNKFOXleuC.
340
+
341
+ [48] Charles Lu and Jayasheree Kalpathy-Cramer. Distribution-free federated learning with conformal predictions. ArXiv, abs/2110.07661, 2021.
342
+
343
+ [49] Nafise Sadat Moosavi, Angela Fan, Vered Shwartz, Goran Glavaš, Shafiq Joty, Alex Wang, and Thomas Wolf, editors. Proceedings of SustaiNLP: Workshop on Simple and Efficient Natural Language Processing, Online, November 2020. Association for Computational Linguistics. URL https://aclanthology.org/2020.sustainlp-1.0.
344
+
345
+ [50] Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pages 311–318, Philadelphia, Pennsylvania, USA, July 2002. Association for Computational Linguistics. doi: 10.3115/1073083.1073135. URL https: //aclanthology.org/P02-1040.
346
+
347
+ [51] Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 2227–2237, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1202. URL https://aclanthology.org/N18-1202.
348
+
349
+ [52] Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
350
+
351
+ [53] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. 2019.
352
+
353
+ [54] Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2383–2392, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264. URL https://aclanthology.org/D16-1264.
354
+
355
+ [55] Adam Roberts, Hyung Won Chung, Anselm Levskaya, Gaurav Mishra, James Bradbury, Daniel Andor, Sharan Narang, Brian Lester, Colin Gaffney, Afroz Mohiuddin, Curtis Hawthorne, Aitor Lewkowycz, Alex Salcianu, Marc van Zee, Jacob Austin, Sebastian Goodman, Livio Baldini Soares, Haitang Hu, Sasha Tsvyashchenko, Aakanksha Chowdhery, Jasmijn Bastings, Jannis Bulian, Xavier Garcia, Jianmo Ni, Andrew Chen, Kathleen Kenealy, Jonathan H. Clark, Stephan Lee, Dan Garrette, James Lee-Thorp, Colin Raffel, Noam Shazeer, Marvin Ritter, Maarten Bosma, Alexandre Passos, Jeremy Maitin-Shepard, Noah Fiedel, Mark Omernick, Brennan Saeta, Ryan Sepassi, Alexander Spiridonov, Joshua Newlan, and Andrea Gesmundo. Scaling up models and data with $\pm 5 \mathrm { x }$ and seqio. arXiv preprint arXiv:2203.17189, 2022. URL https://arxiv.org/abs/2203.17189.
356
+
357
+ [56] Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
358
+
359
+ [57] Tal Schuster, Adam Fisch, Tommi Jaakkola, and Regina Barzilay. Consistent accelerated inference via confident adaptive transformers. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 4962–4979, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021. emnlp-main.406. URL https://aclanthology.org/2021.emnlp-main.406.
360
+
361
+ [58] Tal Schuster, Ashwin Kalyan, Alex Polozov, and Adam Tauman Kalai. Programming puzzles. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ fe_hCc4RBrg.
362
+
363
+ [59] Roy Schwartz, Jesse Dodge, Noah A. Smith, and Oren Etzioni. Green ai. Communications of the ACM, 63(12):54–63, Nov 2020. ISSN 1557-7317. doi: 10.1145/3381831. URL http://dx.doi.org/10.1145/3381831.
364
+
365
+ [60] Roy Schwartz, Gabriel Stanovsky, Swabha Swayamdipta, Jesse Dodge, and Noah A. Smith. The right tool for the job: Matching model and instance complexities. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 6640–6651, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.593. URL https://aclanthology.org/2020.acl-main.593.
366
+
367
+ [61] Thibault Sellam, Dipanjan Das, and Ankur Parikh. BLEURT: Learning robust metrics for text generation. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7881–7892, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.704. URL https://aclanthology.org/2020. acl-main.704.
368
+
369
+ [62] Glenn Shafer and Vladimir Vovk. A tutorial on conformal prediction. Journal of Machine Learning Research (JMLR), 9:371–421, June 2008.
370
+
371
+ [63] Or Sharir, Barak Peleg, and Yoav Shoham. The cost of training nlp models: A concise overview. arXiv preprint: arXiv 2006.06138, 2020.
372
+
373
+ [64] Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. 2018. doi: 10.48550/ARXIV.1804.04235. URL https://arxiv.org/abs/1804. 04235.
374
+
375
+ [65] Sheng Shen, Zhen Dong, Jiayu Ye, Linjian Ma, Zhewei Yao, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Q-bert: Hessian based ultra low precision quantization of bert. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 8815–8821, 2020.
376
+
377
+ [66] Antoine Simoulin and Benoit Crabbé. How many layers and why? An analysis of the model depth in transformers. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: Student Research Workshop, pages 221–228, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-srw.23. URL https://aclanthology.org/2021.acl-srw.23.
378
+
379
+ [67] Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R. Brown, Adam Santoro, Aditya Gupta, and Garriga-Alonso et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. 2022. doi: 10.48550/ARXIV.2206.04615. URL https://arxiv.org/abs/2206.04615.
380
+
381
+ [68] Asa Cooper Stickland and Iain Murray. Bert and pals: Projected attention layers for efficient adaptation in multi-task learning. In International Conference on Machine Learning, pages 5986–5995. PMLR, 2019.
382
+
383
+ [69] Siqi Sun, Yu Cheng, Zhe Gan, and Jingjing Liu. Patient knowledge distillation for bert model compression. arXiv preprint arXiv:1908.09355, 2019.
384
+
385
+ [70] Tianxiang Sun, Xiangyang Liu, Wei Zhu, Zhichao Geng, Lingling Wu, Yilong He, Yuan Ni, Guotong Xie, Xuanjing Huang, and Xipeng Qiu. A simple hash-based early exiting approach for language understanding and generation. In Findings of the Association for Computational Linguistics: ACL 2022, pages 2409–2421, Dublin, Ireland, May 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.findings-acl.189.
386
+
387
+ [71] Zhiqing Sun, Hongkun Yu, Xiaodan Song, Renjie Liu, Yiming Yang, and Denny Zhou. Mobilebert: a compact task-agnostic bert for resource-limited devices. arXiv preprint arXiv:2004.02984, 2020.
388
+
389
+ [72] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. ACM Computing Surveys (CSUR), 2022.
390
+
391
+ [73] Yi Tay, Mostafa Dehghani, Vinh Q Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Neil Houlsby, and Donald Metzler. Unifying language learning paradigms. arXiv preprint arXiv:2205.05131, 2022.
392
+
393
+ [74] Surat Teerapittayanon, Bradley McDanel, and H. T. Kung. Branchynet: Fast inference via early exiting from deep neural networks. 2016 23rd International Conference on Pattern Recognition (ICPR), pages 2464–2469, 2016.
394
+
395
+ [75] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam M. Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, Yaguang Li, Hongrae Lee, Huaixiu Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Yanqi Zhou, Chung-Ching Chang, I. A. Krivokon, Willard James Rusch, Marc Pickett, Kathleen S. Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Hartz Søraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravindran Rajakumar, Alena Butryna, Matthew Lamm, V. O. Kuzmina, Joseph Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise Aguera-Arcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. Lamda: Language models for dialog applications. ArXiv, abs/2201.08239, 2022.
396
+
397
+ [76] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
398
+
399
+ [77] Vladimir Vovk, Alex Gammerman, and Glenn Shafer. Algorithmic Learning in a Random World. Springer-Verlag, Berlin, Heidelberg, 2005.
400
+
401
+ [78] Wenhui Wang, Furu Wei, Li Dong, Hangbo Bao, Nan Yang, and Ming Zhou. Minilm: Deep self-attention distillation for task-agnostic compression of pre-trained transformers. Advances in Neural Information Processing Systems, 33:5776–5788, 2020.
402
+
403
+ [79] Xin Wang, Fisher Yu, Zi-Yi Dou, and Joseph Gonzalez. Skipnet: Learning dynamic routing in convolutional networks. ArXiv, abs/1711.09485, 2018.
404
+
405
+ [80] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. 2022.
406
+
407
+ [81] John Wieting, Taylor Berg-Kirkpatrick, Kevin Gimpel, and Graham Neubig. Beyond BLEU:training neural machine translation with semantic similarity. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4344–4355, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1427. URL https://aclanthology.org/P19-1427.
408
+ [82] Yuhuai Wu, Markus Norman Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In International Conference on Learning Representations, 2022. URL https: //openreview.net/forum?id $= ^ { \prime }$ TrjbxzRcnf-.
409
+ [83] Ji Xin, Raphael Tang, Jaejun Lee, Yaoliang Yu, and Jimmy Lin. Deebert: Dynamic early exiting for accelerating bert inference. arXiv preprint arXiv:2004.12993, 2020.
410
+ [84] Ji Xin, Raphael Tang, Yaoliang Yu, and Jimmy Lin. BERxiT: Early exiting for BERT with better fine-tuning and extension to regression. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 91–104, Online, April 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.8. URL https://aclanthology.org/2021.eacl-main.8.
411
+ [85] Jingjing Xu, Wangchunshu Zhou, Zhiyi Fu, Hao Zhou, and Lei Li. A survey on green deep learning. ArXiv, abs/2111.05193, 2021.
412
+ [86] Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, and Colin Raffel. Byt5: Towards a token-free future with pre-trained byte-to-byte models. 2021. doi: 10.48550/ARXIV.2105.13626. URL https://arxiv.org/abs/ 2105.13626.
413
+ [87] Hongxu Yin, Arash Vahdat, José Manuel Álvarez, Arun Mallya, Jan Kautz, and Pavlo Molchanov. Adavit: Adaptive tokens for efficient vision transformer. ArXiv, abs/2112.07658, 2021.
414
+ [88] Margaux Zaffran, Aymeric Dieuleveut, Olivier F’eron, Yannig Goude, and Julie Josse. Adaptive conformal predictions for time series. ArXiv, abs/2202.07282, 2022.
415
+ [89] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. Opt: Open pre-trained transformer language models. 2022.
416
+ [90] Wangchunshu Zhou, Canwen Xu, Tao Ge, Julian McAuley, Ke Xu, and Furu Wei. Bert loses patience: Fast and robust inference with early exit. Advances in Neural Information Processing Systems, 33:18330–18341, 2020.
417
+ [91] Yanqi Zhou, Tao Lei, Hanxiao Liu, Nan Du, Yanping Huang, Vincent Zhao, Andrew Dai, Zhifeng Chen, Quoc Le, and James Laudon. Mixture-of-experts with expert choice routing. 2022. doi: 10.48550/ARXIV.2202.09368. URL https://arxiv.org/abs/2202.09368.
418
+ [92] Wei Zhu. Leebert: Learned early exit for bert with cross-level optimization. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 2968–2980, 2021.
md/dev/ucNDIDRNjjv/ucNDIDRNjjv.md ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Non-stationary Transformers: Exploring the Stationarity in Time Series Forecasting
2
+
3
+ Yong Liu∗, Haixu Wu∗, Jianmin Wang, Mingsheng LongB School of Software, BNRist, Tsinghua University, China {liuyong21,whx20}@mails.tsinghua.edu.cn, {jimwang,mingsheng}@tsinghua.edu.cn
4
+
5
+ # Abstract
6
+
7
+ Transformers have shown great power in time series forecasting due to their global-range modeling ability. However, their performance can degenerate terribly on non-stationary real-world data in which the joint distribution changes over time. Previous studies primarily adopt stationarization to attenuate the nonstationarity of original series for better predictability. But the stationarized series deprived of inherent non-stationarity can be less instructive for real-world bursty events forecasting. This problem, termed over-stationarization in this paper, leads Transformers to generate indistinguishable temporal attentions for different series and impedes the predictive capability of deep models. To tackle the dilemma between series predictability and model capability, we propose Non-stationary Transformers as a generic framework with two interdependent modules: Series Stationarization and De-stationary Attention. Concretely, Series Stationarization unifies the statistics of each input and converts the output with restored statistics for better predictability. To address the over-stationarization problem, Destationary Attention is devised to recover the intrinsic non-stationary information into temporal dependencies by approximating distinguishable attentions learned from raw series. Our Non-stationary Transformers framework consistently boosts mainstream Transformers by a large margin, which reduces MSE by $4 9 . 4 3 \%$ on Transformer, $4 7 . 3 4 \%$ on Informer, and $4 6 . 8 9 \%$ on Reformer, making them the state-of-the-art in time series forecasting. Code is available at this repository: https://github.com/thuml/Nonstationary_Transformers.
8
+
9
+ # 1 Introduction
10
+
11
+ Time series forecasting has become increasingly ubiquitous in real-world applications, such as weather forecasting, energy consumption planning, and financial risk assessment. Recently, Transformers [32] have achieved progressive breakthrough on extensive areas [11, 12, 10, 22]. Especially in time series forecasting, credited to their stacked structure and the capability of attention mechanisms, Transformers can naturally capture the temporal dependencies from deep multi-level features [37, 17, 20, 35], thereby fitting the series forecasting task perfectly.
12
+
13
+ Despite the remarkable architectural design, it is still challenging for Transformers to predict realworld time series because of the non-stationarity of data. Non-stationary time series is characterized by the continuous change of statistical properties and joint distribution over time, which makes the time series less predictable [6, 14]. Besides, it is a fundamental problem to make deep models generalize well on a varying distribution [26, 19, 5]. In previous work, it is generally acknowledged to pre-process the time series by stationarization [24, 27, 15], which can attenuate the non-stationarity of raw time series for better predictability and provide more stable data distribution for deep models.
14
+
15
+ ![](images/ab887f40e0f0381567f915353a567d5f34eacb881747b0173feea4be09570c12.jpg)
16
+ Figure 1: Visualization of learned temporal attentions for different series with varied mean $\mu$ and standard deviation $\sigma$ . (a) is from the vanilla Transformer [32] trained on raw series. (b) is from the Transformer trained on stationarized series, which presents similar attentions. (c) is from Nonstationary Transformers, which involves De-stationary Attention to avoid over-stationarization.
17
+
18
+ However, non-stationarity is the inherent property of real-world time series and also good guidance for discovering temporal dependencies for forecasting. Experimentally, we observe that training on the stationarized series will undermine the distinction of attentions learned by Transformers. While vanilla Transformers [32] can capture distinct temporal dependencies from different series in Figure 1(a), Transformers trained on the stationarized series tend to generate indistinguishable attentions in Figure 1(b). This problem, named by the over-stationarization, will bring unexpected side-effect that makes Transformers fail to capture eventful temporal dependencies, limit the model’s predictive ability, and even induce the model to generate outputs with huge non-stationarity deviation from the ground truth. Thus, how to attenuate time series non-stationarity towards better predictability and mitigate the over-stationarization problem for model capability simultaneously is the key problem to further improve the performance of forecasting.
19
+
20
+ In this paper, we explore the effect of stationarization in time series forecasting and propose Nonstationary Transformers as a general framework, which empowers Transformer [32] and its efficient variants [17, 37, 35] with great predictive ability for real-world time series. The proposed framework involves two interdependent modules: Series Stationarization to increase the predictability of nonstationary series and De-stationary Attention to alleviate over-stationarization. Technically, Series Stationarization adopts a simple but effective normalization strategy to unify the key statistics of each series without extra parameters. And De-stationary Attention approximates the attention of unstationarized data and compensates the intrinsic non-stationarity of raw series. Benefiting from the above designs, Non-stationary Transformers can take advantage of the great predictability of stationarized series and crucial temporal dependencies discovered from original non-stationary data. Our method achieves state-of-the-art performance on six real-world benchmarks and can generalize to various Transformers for further improvement. The contributions lie in three folds:
21
+
22
+ • We refine that the predictive capability of non-stationary series is essential in real-world forecasting. By detailed analysis, we find out that current stationarization approaches will lead to the over-stationarization problem, limiting the predictive capability of Transformers. • We propose Non-stationary Transformers as a generic framework, including Series Stationarization to make the series more predictable and De-stationary Attention to avoid the over-stationarization problem by re-incorporating the non-stationarity of original series. • Non-stationary Transformers consistently boosts four mainstream Transformers by a large margin and achieves state-of-the-art performance on six real-world benchmarks.
23
+
24
+ # 2 Related Work
25
+
26
+ # 2.1 Deep Models for Time Series Forecasting
27
+
28
+ In recent years, deep models with elaboratively designed architectures have achieved great progress in time series forecasting. RNN-based models [33, 36, 23, 29, 30] are proposed for application in an autoregressive manner for sequence modeling, but the recurrent structure can suffer from modeling long-term dependency. Soon afterward, Transformer [32] emerges and shows great power in sequence modeling. To overcome the quadratic computation growth on sequence length, subsequent works aim to reduce Self-Attention’s complexity. Especially in time series forecasting, Informer [37] extends Self-Attention with KL-divergence criterion to select dominant queries. Reformer [17] introduces local-sensitive hashing (LSH) to approximate attention by allocated similar queries. Not only improved by reduced complexity, the following models further develop delicate building blocks for time series forecasting. Autoformer [35] fuses the decomposition blocks into a canonical structure and develops Auto-Correlation to discover series-wise connections. Pyraformer [21] designs pyramid attention module (PAM) to capture temporal dependencies with different hierarchies. Other deep but Transformer-free models also achieve remarkable performance. N-BEATS [25] proposes the explicit decomposition of trend and seasonal terms with strong interpretability. N-HiTS [9] introduces hierarchical layout and multi-rate sampling for tackling time series with respective frequency bands. In this paper, different from previous works focusing on architectural design, we analyze the series forecasting task from the basic view of stationarity, which is an essential property of time series [6, 14]. It is also notable that as a general framework, our proposed Non-stationary Transformers can be easily applied to various Transformer-based models.
29
+
30
+ # 2.2 Stationarization for Time Series Forecasting
31
+
32
+ While stationarity is important to the predictability of time series [6, 14], real-world series always present non-stationarity. To tackle this problem, the classical statistical method ARIMA [7, 8] stationarizes the time series through differencing. As for deep models, since the distribution-varying problem accompanied by non-stationarity makes deep forecasting even more intractable, stationarization methods are widely explored and always adopted as the pre-processing for deep model inputs. Adaptive Norm [24] applies z-score normalization for each series fragment by global statistics of a sampled set. DAIN [27] employs a nonlinear neural network to adaptively stationarize time series with observed training distribution. RevIN [15] introduces a two-stage instance normalization [31] that transforms model input and output respectively to reduce the discrepancy of each series. In contrast, we find out that directly stationarizing time series will damage the model’s capability of modeling specific temporal dependency. Therefore, unlike previous methods, in addition to the stationarization, Non-stationary Transformers further develops De-stationary Attention to bring the intrinsic non-stationarity of the raw series back to attention.
33
+
34
+ # 3 Non-stationary Transformers
35
+
36
+ As aforementioned, stationarity is an important element of time series predictability. Previous “direct stationarization” designs can attenuate non-stationarity of series for better predictability, but they obviously neglect inherent properties of real-world series, which will result in the over-stationarization problem as stated in Figure 1. To deal with the dilemma, we go beyond previous works and propose Non-stationary Transformers as a generic framework. Our model involves two complementary parts: Series Stationarization to attenuate time series non-stationarity and De-stationary Attention to re-incorporate non-stationary information of raw series. Empowered by these designs, Non-stationary Transformers can improve data predictability and maintain model capability simultaneously.
37
+
38
+ # 3.1 Series Stationarization
39
+
40
+ Non-stationary time series make the forecasting task intractable for deep models because it is hard for them to generalize well on series with changed statistics during inference, typically varied mean and standard deviation. The pilot work, RevIN [15] applies instance normalization with learnable affine parameters to each input and restores the statistics to the corresponding output, which makes each series follow a similar distribution. Experimentally, we find that this design also works well without learnable parameters. Thus, we propose a more straightforward but effective design to wrap Transformers as the base model without extra parameters, naming by Series Stationarization. As is shown in Figure 2, it contains two corresponding operations: Normalization module at first to deal with the non-stationary series caused by varied mean and standard deviation, and De-normalization module at the end to transform the model outputs back with original statistics. Here are the details.
41
+
42
+ ![](images/8369470ffeb672b0e75e1a2cfa15243eaf9a083b4364ecb0d0388dd3c826dad6.jpg)
43
+ Figure 2: Non-stationary Transformers. Series Stationarization is adopted as a wrapper on the base model to normalize each incoming series and de-normalize the output. De-stationary Attention replaces the original Attention mechanism to approximate attention learned from unstationarized series, which rescales current temporal dependency weights with learned de-stationary factors $\tau , \Delta$ .
44
+
45
+ Normalization module To attenuate the non-stationarity of each input series, we conduct normalization on the temporal dimension by a sliding window over time. For each input series $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , . . . , x _ { S } ] ^ { \top } \in \mathbb { R } ^ { S \times C }$ , we transform it by translation and scaling operations and obtain $\mathbf { x } ^ { \prime } = [ x _ { 1 } ^ { \prime } , x _ { 2 } ^ { \prime } , . . . , x _ { S } ^ { \prime } ] ^ { \top } \in \mathbb { R } ^ { S \times C }$ , where $S$ and $C$ denote the sequence length and variable number respectively. The Normalization module can be formulated as follows:
46
+
47
+ $$
48
+ \mu _ { \mathbf { x } } = \frac { 1 } { S } \sum _ { i = 1 } ^ { S } x _ { i } , \sigma _ { \mathbf { x } } ^ { 2 } = \frac { 1 } { S } \sum _ { i = 1 } ^ { S } ( x _ { i } - \mu _ { \mathbf { x } } ) ^ { 2 } , x _ { i } ^ { \prime } = \frac { 1 } { \sigma _ { \mathbf { x } } } \odot ( x _ { i } - \mu _ { \mathbf { x } } ) ,
49
+ $$
50
+
51
+ where µx, σx ∈ RC×1, 1 means the element-wise division and $\odot$ is the element-wise product. Note that Normalization module decreases the distributional discrepancy among each input time series, making the distribution of the model input more stable.
52
+
53
+ De-normalization module As shown in Figure 2, after the base model $\mathcal { H }$ predicting the future value with length- $O$ , we adopt De-normalization to transform the model output $\mathbf { y } ^ { \prime } = [ \breve { y _ { 1 } ^ { \prime } } , y _ { 2 } ^ { \prime } , . . . , y _ { O } ^ { \prime } ] ^ { \top } \in$ $\mathbb { R } ^ { O \times C }$ with $\sigma _ { \mathbf { x } }$ and $\mu _ { \mathbf { x } }$ and obtain $\hat { \mathbf { y } } = [ \hat { y } _ { 1 } , \hat { y } _ { 2 } , . . . , \hat { y } _ { O } ] ^ { \intercal }$ as the eventual forecasting results. The De-normalization module can be formulated as follows:
54
+
55
+ $$
56
+ \mathbf { y } ^ { \prime } = \mathcal { H } ( \mathbf { x } ^ { \prime } ) , \hat { y } _ { i } = \sigma _ { \mathbf { x } } \odot ( y _ { i } ^ { \prime } + \mu _ { \mathbf { x } } ) .
57
+ $$
58
+
59
+ By means of the two-stage transformation, the base models will receive stationarized inputs, which follow a stable distribution and are easier to generalize. This design also makes the model equivariant to translational and scaling perturbance of time series, thereby benefiting real-world series forecasting.
60
+
61
+ # 3.2 De-stationary Attention
62
+
63
+ While the statistics of each time series are explicitly restored to the corresponding prediction, the non-stationarity of the original series cannot be fully recovered only by De-normalization. For instance, Series Stationarization can generate the same stationarized input $\mathbf { x } ^ { \prime }$ from distinct time series $\mathbf { x } _ { 1 }$ , $\mathbf { x } _ { 2 }$ (i.e. $\mathbf { x } _ { 2 } = \alpha \mathbf { x } _ { 1 } + \beta )$ , and the base model will get identical attention that fails to capture crucial temporal dependencies entangled with non-stationarity (Figure 1). In other words, the undermined effects caused by over-stationarization happen inside the deep model, especially in the calculation of attention. Furthermore, non-stationary time series are fragmented and normalized into several series chunks with the same mean and variance, which follow more similar distributions than the raw data before stationarization. Thus, the model is more likely to generate over-stationary and uneventful outputs, which is irreconcilable with the natural non-stationarity of the original series.
64
+
65
+ To tackle the over-stationarization problem caused by Series Stationarization, we propose a novel De-stationary Attention mechanism, which can approximate the attention that is obtained without stationarization and discover the particular temporal dependencies from original non-stationary data.
66
+
67
+ Analysis of the plain model As mentioned above, the over-stationarization problem is caused by the vanishment of inherent non-stationarity information, which will make the base model fail to capture eventful temporal dependencies for forecasting. Therefore, we try to approximate the attention learned from the original non-stationary series. We start from the formula of Self-Attention [32]:
68
+
69
+ $$
70
+ { \mathrm { A t t n } } ( \mathbf { Q } , \mathbf { K } , \mathbf { V } ) = { \mathrm { S o f t m a x } } \left( { \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { { \sqrt { d _ { k } } } } } \right) \mathbf { V } ,
71
+ $$
72
+
73
+ where $\mathbf { Q } , \mathbf { K } , \mathbf { V } \in \mathbb { R } ^ { S \times d _ { k } }$ are length- $S$ queries, keys and values of $d _ { k }$ -dimension respectively, and Softmax $( \cdot )$ is conducted row by row. To simplify the analysis, we assume the embedding and feed-forward layers $f$ to hold the linear properties2 and $f$ is conducted separately on each time point, that is, each query token in $\mathbf { Q } = [ q _ { 1 } , q _ { 2 } , . . . , q _ { S } ] ^ { \top }$ can be calculated as $q _ { i } = f ( x _ { i } )$ with respect to the input series $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , \cdots , x _ { S } ] ^ { \top }$ . Since it is a convention to conduct normalization on each time series variable to avoid certain variable that dominates the scale, we can further assume each variable of series $\mathbf { x }$ shares the same variance, and thus original $\sigma _ { \mathbf { x } } \in \mathbb { R } ^ { C \times 1 }$ is reduced to a scalar. After Normalization module, the model receives the stationarized input $\mathbf { x } ^ { \prime } = ( \mathbf { x } - \mathbf { 1 } \mu _ { \mathbf { x } } ^ { \top } ) / \sigma _ { \mathbf { x } }$ , where $\mathbf { 1 } \in \mathbb { R } ^ { S \times 1 }$ is an all-ones vector. Based on the linear property assumption, it can be proved that the Attention layer will receive $\mathbf { Q } ^ { \prime } = [ f ( x _ { 1 } ^ { \prime } ) , . . . , f ( x _ { S } ^ { \prime } ) ] ^ { \top } = ( \mathbf { \bar { Q } } - \mathbf { 1 } \mu _ { \mathbf { Q } } ^ { \top } ) / \sigma _ { \mathbf { x } }$ , where $\boldsymbol { \mu _ { \mathbf { Q } } } \in \mathbb { R } ^ { d _ { k } \times 1 }$ is the mean of $\mathbf { Q }$ along the temporal dimension (See Appendix for a detailed proof). And so is the corresponding transformed $\mathbf { K } ^ { \prime } , \mathbf { V } ^ { \prime }$ . Without Series Stationarization, the input of $\operatorname { S o f t m a x } ( \cdot )$ in Self-Attention should be $\mathbf { Q K } ^ { \top } / \sqrt { d _ { k } }$ , while now the attention is calculated based on $\mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime }$ :
74
+
75
+ $$
76
+ \begin{array} { c } { { \displaystyle { \bf Q } ^ { \prime } { \bf K } ^ { \prime \top } = \frac { 1 } { \sigma _ { \bf x } ^ { 2 } } \left( { \bf Q } { \bf K } ^ { \top } - { \bf 1 } ( \mu _ { \bf Q } ^ { \top } { \bf K } ^ { \top } ) - ( { \bf Q } \mu _ { \bf K } ) { \bf 1 } ^ { \top } + { \bf 1 } ( \mu _ { \bf Q } ^ { \top } \mu _ { \bf K } ) { \bf 1 } ^ { \top } \right) , } } \\ { { \mathrm { S o f t m a x } \left( \frac { { \bf Q } { \bf K } ^ { \top } } { \sqrt { d _ { k } } } \right) = \mathrm { S o f t m a x } \left( \frac { \sigma _ { \bf x } ^ { 2 } { \bf Q } ^ { \prime } { \bf K } ^ { \prime \top } + { \bf 1 } ( \mu _ { \bf Q } ^ { \top } { \bf K } ^ { \top } ) + ( { \bf Q } \mu _ { \bf K } ) { \bf 1 } ^ { \top } - { \bf 1 } ( \mu _ { \bf Q } ^ { \top } \mu _ { \bf K } ) { \bf 1 } ^ { \top } } { \sqrt { d _ { k } } } \right) . } } \end{array}
77
+ $$
78
+
79
+ We find that $\mathbf { Q } \mu _ { \mathbf { K } } \in \mathbb { R } ^ { S \times 1 }$ and $\mu _ { \mathbf { Q } } ^ { \top } \mu _ { \mathbf { K } } \in \mathbb { R }$ , and they are repeatedly operated on each column and element of $\sigma _ { \mathbf { x } } ^ { 2 } \mathbf { Q } ^ { \prime } { \mathbf { K ^ { \prime } } } ^ { \top } \in \mathbb { R } ^ { S \times S }$ respectively. Since Softmax $( \cdot )$ is invariant to the same translation on the row dimension of input, we have the following equation:
80
+
81
+ $$
82
+ \mathrm { S o f t m a x } \left( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { d _ { k } } } \right) = \mathrm { S o f t m a x } \left( \frac { \sigma _ { \mathbf { x } } ^ { 2 } \mathbf { Q } ^ { \prime } { \mathbf { K ^ { \prime } } } ^ { \top } + \mathbf { 1 } \mu _ { \mathbf { Q } } ^ { \top } \mathbf { K } ^ { \top } } { \sqrt { d _ { k } } } \right) .
83
+ $$
84
+
85
+ Equation 5 deduces a direct expression of the attention Softmax $\left( \mathbf { Q K } ^ { \top } / \sqrt { d _ { k } } \right)$ learned from raw series $\mathbf { x }$ . Except for the current $\mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime }$ from stationarized series $\mathbf { x } ^ { \prime }$ , this expression also requires the non-stationary information $\sigma _ { \mathbf { x } } , \mu _ { \mathbf { Q } } , \mathbf { K }$ that are eliminated by Series Stationarization.
86
+
87
+ De-stationary Attention To recover the original attention on non-stationary series, we attempt to bring the vanished non-stationary information back to its calculation. Based on Equation 5, the key is to approximate the positive scaling scalar $\tau = \sigma _ { \mathbf { x } } ^ { 2 } \in \mathbb { R } ^ { + }$ and shifting vector $\pmb { \Delta } \overset { \cdot } { = } \mathbf { K } \mu _ { \mathbf { Q } } \in \mathbb { R } ^ { S \times \bar { 1 } }$ , which are defined as $d e$ -stationary factors. Since the strict linear property hardly holds for a deep model, other than estimating and utilizing real factors with great effort, we try to learn de-stationary factors directly from the statistics of unstationarized $\mathbf { x } , \mathbf { Q }$ and $\mathbf { K }$ by a simple but effective multilayer perceptron layer. As we can only discover limited non-stationary information from current $\dot { \bf Q ^ { \prime } } , \bar { \bf K ^ { \prime } }$ , the unique and reasonable source to compensate non-stationarity is the original $\mathbf { x }$ without being normalized. Thus, as a direct deep learning implementation of Equation 5, we apply a multilayer perceptron as the projector to learn de-stationary factors $\tau , \Delta$ from the statistics $\mu _ { \mathbf { x } } , \sigma _ { \mathbf { x } }$ of unstationarized $\mathbf { x }$ individually. And the De-stationary Attention is calculated as follows:
88
+
89
+ $$
90
+ \begin{array} { c } { \log \tau = \mathrm { M L P } ( \boldsymbol { \sigma } _ { \mathbf { x } } , \mathbf { x } ) , \pmb { \Delta } = \mathrm { M L P } ( \mu _ { \mathbf { x } } , \mathbf { x } ) , } \\ { \mathrm { A t t n } ( \mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime } , \mathbf { V } ^ { \prime } , \tau , \pmb { \Delta } ) = \mathrm { S o f t m a x } \left( \frac { \tau \mathbf { { Q } ^ { \prime } } \mathbf { K } ^ { \prime } ^ { \top } + \mathbf { 1 } \pmb { \Delta } ^ { \top } } { \sqrt { d _ { k } } } \right) \mathbf { V } ^ { \prime } , } \end{array}
91
+ $$
92
+
93
+ where the de-stationary factors $\tau$ and $\pmb { \Delta }$ are shared by De-stationary Attention of all layers (Figure 2). De-stationary Attention mechanism learns the temporal dependencies from both stationarized series $\mathbf { Q } ^ { \prime }$ , $\mathbf { K } ^ { \prime }$ and non-stationary series $\mathbf { x }$ , $\mu _ { \mathbf { x } } , \sigma _ { \mathbf { x } }$ , and multiplies by the stationarized values $\mathbf { V } ^ { \prime }$ . Therefore, it can benefit from the predictability of stationarized series and maintain the inherent temporal dependencies of raw series simultaneously.
94
+
95
+ Overall architecture Following the prior use of Transformers [37, 35] in time series forecasting, we adopt the standard Encoder-Decoder structure (Figure 2), where the encoder is to extract information from past observations, and the decoder is to aggregate past information and refine the prediction from simple initialization. The canonical Non-stationary Transformer is wrapped by Series Stationarization to both the input and output of vanilla Transformer [32], and replacing the Self-Attention by our proposed De-stationary Attention, which can boost the non-stationary series predictive capability of the base model. For the Transformer variants [17, 37, 35], we transform the terms inside Softmax $( \cdot )$ with the de-stationary factors $\tau$ , $\pmb { \Delta }$ to re-integrate the non-stationary information (See Appendix for the implementation details).
96
+
97
+ # 4 Experiments
98
+
99
+ We conduct extensive experiments to evaluate the performance of Non-stationary Transformers on six real-world time series forecasting benchmarks and further validate the generality of the proposed framework on various mainstream Transformer variants.
100
+
101
+ Datasets Here are the descriptions of the datasets: (1) Electricity [3] records the hourly electricity consumption of 321 clients from 2012 to 2014. (2) ETT [37] contains the time series of oil destationary factors and power load collected by electricity transformers from July 2016 to July 2018. ETTm1 /ETTm2 are recorded every 15 minutes, and ETTh1/ETTh2 are recorded every hour. (3) Exchange [18] collects the panel data of daily exchange rates from 8 countries from 1990 to 2016. (4) ILI [1] collects the ratio of influenza-like illness patients versus the total patients in one week, which is reported weekly by Centers for Disease Control and Prevention of the United States from 2002 and 2021. (5) Traffic [2] contains hourly road occupancy rates measured by 862 sensors on San Francisco Bay area freeways from January 2015 to December 2016. (6) Weather [4] includes meteorological time series with 21 weather indicators collected every 10 minutes from the Weather Station of the Max Planck Biogeochemistry Institute in 2020.
102
+
103
+ Especially, in this paper, we adopt the Augmented Dick-Fuller (ADF) test statistic [13] as the metric to quantitatively measure the degree of stationarity. A smaller ADF test statistic indicates a higher degree of stationarity, which means the distribution is more stable. Table 1 summarizes the overall statistics of the datasets and lists them in ascending order by degree of stationarity. We follow the standard protocol that divides each dataset into the training, validation, and testing subsets according to the chronological order. The split ratio is 6:2:2 for the ETT dataset and 7:1:2 for others.
104
+
105
+ Table 1: Summary of datasets. Smaller ADF test statistic indicates more stationary dataset.
106
+
107
+ <table><tr><td>Dataset</td><td>VariableNumber</td><td>Sampling Frequency</td><td>Total Observations</td><td>ADF Test Statistic</td></tr><tr><td>Exchange</td><td>8</td><td>1 Day</td><td>7,588</td><td>-1.889</td></tr><tr><td>ILI</td><td>7</td><td>1Week</td><td>966</td><td>-5.406</td></tr><tr><td>ETTm2</td><td>7</td><td>15 Minutes</td><td>69,680</td><td>-6.225</td></tr><tr><td>Electricity</td><td>321</td><td>1 Hour</td><td>26,304</td><td>-8.483</td></tr><tr><td>Traffic</td><td>862</td><td>1 Hour</td><td>17,544</td><td>-15.046</td></tr><tr><td>Weather</td><td>21</td><td>10 Minutes</td><td>52.695</td><td>-26.661</td></tr></table>
108
+
109
+ Baselines We evaluate the vanilla Transformer [32] equipped by the Non-stationary Transformers framework in both multivariate and univariate settings to demonstrate its effectiveness. For multivariate forecasting, we include six state-of-the-art deep forecasting models: Autoformer [35], Pyraformer [21], Informer [37], LogTrans [20], Reformer [17] and LSTNet [18]. For univariate forecasting, we include seven competitive baselines: N-HiTS [9], N-BEATS [25], Autoformer [35], Pyraformer [21], Informer [37], Reformer [17] and ARIMA [7]. In addition, we adopt the proposed framework on both the canonical and efficient variants of Transformers: Transformer [32], Informer [37], Reformer [17] and Autoformer [35] to validate the generality of our framework.
110
+
111
+ Implementation details All the experiments are implemented with PyTorch [28] and conducted on a single NVIDIA TITAN V 12GB GPU. Each model is trained by ADAM [16] using L2 loss with the initial learning rate of $1 0 ^ { - 4 }$ and batch size of 32. Each Transformer-based model contains two encoder layers and one decoder layer. Considering the efficiency of hyperparameters search, we use two-layer perceptron projector with the hidden dimension varying in $\{ \bar { 6 4 } , \bar { 1 2 8 } , 2 5 6 \}$ in De-stationary Attention. We repeat each experiment three times with different random seeds and report the test MSE/MAE under different prediction lengths, and the standard deviations are also provided in Appendix. A lower MSE/MAE indicates better performance.
112
+
113
+ # 4.1 Main Results
114
+
115
+ Forecasting results As for multivariate forecasting results, the vanilla Transformer equipped with our framework consistently achieves state-of-the-art performance in all benchmarks and prediction lengths (Table 2). Notably, Non-stationary Transformer outperforms other deep models impressively on datasets characterized by high non-stationarity: under the prediction length of 336, we achieve $17 \%$ MSE reduction $\mathrm { ( 0 . 5 0 9 0 . 4 2 1 ) }$ ) on Exchange and $25 \%$ $2 . 6 6 9 2 . 0 1 0 \rangle$ on ILI compared to previous state-of-the-art results, which indicates that the potential of deep model is still constrained on non-stationary data. We also list the univariate results of two typical datasets with different stationarity in Table 3. Non-stationary Transformer still realizes remarkable forecasting performance.
116
+
117
+ Table 2: Forecasting results comparison under different prediction lengths $O \in \{ 9 6 , 1 9 2 , 3 3 6 , 7 2 0 \}$ The input sequence length is set to 36 for ILI and 96 for the others. Additional results (ETTm1, ETTh1, ETTh2) can be found in Appendix.
118
+
119
+ <table><tr><td colspan="2">Models</td><td colspan="2">Ours</td><td colspan="2"></td><td colspan="2">Autoformer [35] Pyraformer [21] Informer [37] LogTrans [20] Reformer [17] LSTNet [18]</td><td colspan="2"></td><td colspan="2"></td><td colspan="2"></td><td colspan="2"></td></tr><tr><td colspan="2">Metric</td><td>MSE MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td></td><td>MSE MAE</td><td></td><td>MSE</td><td>MAE</td><td>MSE MAE</td></tr><tr><td rowspan="3">ueepxg</td><td>96 192</td><td>0.111 0.219 0.335 0.300</td><td>0.237 0.197</td><td>0.323 0.369</td><td>0.852</td><td></td><td>0.780</td><td>0.847</td><td>0.752</td><td>0.968</td><td>0.812</td><td>1.065</td><td>0.829</td><td>1.551</td><td>1.058 1.028</td></tr><tr><td>336</td><td>0.421</td><td>0.476 0.509</td><td></td><td>0.524</td><td>0.993 1.240</td><td>0.858 0.958</td><td>1.204 1.672</td><td>0.895 1.036</td><td>1.040 1.659</td><td>0.851 1.081</td><td>1.188 1.357</td><td>0.906</td><td>1.477</td><td></td></tr><tr><td>720</td><td>1.092 0.769</td><td></td><td>1.447</td><td>0.941</td><td>1.711</td><td>1.093</td><td>2.478</td><td>1.310</td><td>1.941</td><td>1.127</td><td>1.510</td><td>0.976 1.016</td><td>1.507 2.285</td><td>1.031 1.243</td></tr><tr><td rowspan="3">I</td><td>24</td><td>2.294 0.945 3.483</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>1.287</td><td></td><td>5.800 1.693</td><td></td><td>5.764</td><td>1.677</td><td>4.480</td><td>1.444</td><td>4.400</td><td>1.382</td><td>6.026</td><td>1.770</td></tr><tr><td>36 48</td><td>1.825 0.848 3.103 2.010 0.900 2.669</td><td></td><td>1.148</td><td></td><td>6.043 1.733</td><td></td><td>4.755</td><td>1.467</td><td>4.799</td><td>1.467</td><td>4.783</td><td>1.448</td><td>5.340</td><td>1.668</td></tr><tr><td rowspan="3"></td><td>60</td><td>2.178 0.963 2.770</td><td></td><td>1.085 1.125</td><td></td><td>6.213 1.763</td><td>6.531 1.814 5.264</td><td>4.763</td><td>1.469</td><td>4.800</td><td>1.468</td><td>4.832</td><td>1.465</td><td>6.080 5.548</td><td>)1.787</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.564</td><td>5.278</td><td>1.560</td><td>4.882</td><td>1.483</td><td></td><td>1.720</td></tr><tr><td>96</td><td>[0.192 0.274 0.255</td><td></td><td>0.339</td><td></td><td>0.409 0.488</td><td></td><td>0.365</td><td>0.453</td><td>0.768</td><td>0.642</td><td>0.658</td><td>0.619</td><td>3.142</td><td>1.365</td></tr><tr><td rowspan="3">LLE</td><td>192</td><td>0.280 0.339</td><td>0.281</td><td>0.340</td><td>0.673</td><td>0.641</td><td></td><td>0.533</td><td>0.563</td><td>0.989</td><td>0.757</td><td>1.078</td><td>0.827</td><td>3.154</td><td>1.369</td></tr><tr><td>336</td><td>0.334 0.361</td><td>0.339</td><td>0.372</td><td></td><td>1.210</td><td>0.846</td><td>1.363</td><td>0.887</td><td>1.334</td><td>0.872</td><td>1.549</td><td>0.972</td><td>3.160</td><td>)1.369</td></tr><tr><td>720</td><td>0.417 0.413 0.422</td><td></td><td>0.419</td><td></td><td>4.044 1.526</td><td></td><td>53.379</td><td>1.388</td><td>3.048</td><td>1.328</td><td>2.631</td><td>1.242</td><td>3.171</td><td>1.368</td></tr><tr><td rowspan="3">ereera</td><td>96</td><td>[0.169 0.273 0.201</td><td></td><td>0.317</td><td></td><td>0.498 0.299</td><td></td><td>0.274</td><td>0.368</td><td>0.258</td><td>0.357</td><td>0.312</td><td>0.402</td><td>0.680 0.645</td><td></td></tr><tr><td>192</td><td>0.182 0.286</td><td>0.222</td><td></td><td>0.334</td><td>0.828</td><td>0.312</td><td>0.296</td><td>0.386</td><td>0.266</td><td>0.368</td><td>0.348</td><td>0.433</td><td></td><td></td></tr><tr><td>336</td><td>[0.200 0.304 0.231</td><td></td><td>0.338</td><td>1.476</td><td></td><td>0.326</td><td>0.300</td><td>0.394</td><td>0.280</td><td>0.380</td><td>0.350</td><td></td><td>0.725</td><td>0.676</td></tr><tr><td rowspan="3">YTfere</td><td>720</td><td>0.222 0.321</td><td>0.254</td><td>0.361</td><td>4.090</td><td></td><td>0.372</td><td>0.373</td><td>0.439</td><td>0.283</td><td>0.376</td><td>0.340</td><td>0.433 0.420</td><td>0.828 0.957</td><td>0.727 0.811</td></tr><tr><td>96</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>192</td><td>0.612 0.338 0.613 0.613 0.340 0.616</td><td></td><td>0.388</td><td>0.692</td><td>0.684 0.393</td><td></td><td>0.719</td><td>0.391</td><td>0.684</td><td>0.384</td><td>0.732</td><td>0.423</td><td>1.107</td><td>0.685</td></tr><tr><td rowspan="3"></td><td>336</td><td>0.618 0.328 0.622</td><td></td><td>0.382 0.337</td><td>0.699</td><td>0.394 0.396</td><td></td><td>0.696 50.777</td><td>0.379 0.420</td><td>0.685 0.733</td><td>0.390 0.408</td><td>0.733 0.742</td><td>0.420 0.420</td><td>1.157 1.216</td><td>0.706 50.730</td></tr><tr><td>720</td><td>0.653 0.355 0.660</td><td></td><td>0.408</td><td></td><td>0.712</td><td>0.404</td><td>0.864</td><td>0.472</td><td>0.717</td><td>0.396</td><td>0.755</td><td>0.423</td><td>1.481</td><td>0.805</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="3">Waaaeee</td><td>96 192</td><td>|0.173 0.223(</td><td>0.266</td><td>0.336</td><td></td><td>0.354</td><td>0.392</td><td>0.300</td><td>0.384</td><td>0.458</td><td>0.490</td><td>0.689</td><td>0.596</td><td>0.594</td><td>0.587</td></tr><tr><td>336</td><td>0.245 0.285 0.307</td><td></td><td></td><td>0.367</td><td>0.673</td><td>0.597</td><td>0.598</td><td>0.544</td><td>0.658</td><td>0.589</td><td>0.752</td><td>0.638</td><td>0.560</td><td>)0.565</td></tr><tr><td>720 0.414 0.410 0.419</td><td>0.321 0.338 0.359</td><td></td><td>0.395</td><td>0.428</td><td>0.634 0.592</td><td>0.942 0.723</td><td>0.578 1.059</td><td>0.523 0.741</td><td>0.797 0.869</td><td>0.652 0.675</td><td>0.639</td><td>0.596</td><td>0.597 0.587</td><td>0.618 0.599</td></tr></table>
120
+
121
+ Framework generality We apply our framework to four mainstream Transformers and report the performance promotion of each model (Table 4). Our method consistently improves the forecasting ability of different models. Overall, it achieves averaged $4 9 . 4 3 \%$ promotion on Transformer, $4 7 . 3 4 \%$ on Informer, $4 6 . 8 9 \%$ on Reformer and $1 0 . 5 7 \%$ on Autoformer, making each of them surpass previous state-of-the-art. Compared to native blocks of the models, there is hardly any parameter and computation increase by applying our framework (See Appendix for details), and thereby their computational complexities can be preserved. It validates that Non-stationary Transformer is an effective and lightweight framework that can be widely applied to Transformer-based models and enhances their non-stationary predictability to achieve state-of-the-art performance.
122
+
123
+ Table 3: Univariate results under different prediction lengths $O \in \{ 9 6 , 1 9 2 , 3 3 6 , 7 2 0 \}$ on two typical datasets with strong non-stationary. The input sequence length is set to 96.
124
+
125
+ <table><tr><td colspan="2">Models</td><td>Ours</td><td></td><td>N-HiTS [9] N-BEATS [25] Autoformer [35] Pyraformer [21] Informer [37] Reformer[17] ARIMA [6]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="2">Metric</td><td></td><td>MSE MAE MSE MAE MSE</td><td></td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td></td><td>MSE MAE</td></tr><tr><td rowspan="4">eppg</td><td>96</td><td>|0.104 0.235 0.114 0.248 0.156</td><td></td><td></td><td>0.299</td><td>0.241</td><td>0.387</td><td>0.290</td><td>0.439</td><td>0.591</td><td>0.615</td><td>1.327</td><td></td><td>0.944</td><td>0.112 0.245</td></tr><tr><td>192</td><td></td><td>0.230 0.375 0.250 0.387 0.669</td><td></td><td>0.665</td><td>0.273</td><td>0.403</td><td>0.594</td><td>0.644</td><td>1.183</td><td>0.912</td><td></td><td>1.258</td><td>0.924</td><td>0.304 0.404</td></tr><tr><td>336</td><td></td><td>0.432 0.509 0.434 0.516 0.611</td><td></td><td>0.605</td><td>0.508</td><td>0.539</td><td>0.962</td><td>0.824</td><td>1.367</td><td>0.984</td><td>2.179</td><td></td><td>1.296</td><td>0.736 0.598</td></tr><tr><td></td><td>720</td><td>0.782 0.682 1.061 0.773 1.111</td><td></td><td></td><td>0.860</td><td>0.991</td><td>0.768</td><td>1.285</td><td>0.958</td><td>1.872</td><td>1.072</td><td>1.280</td><td>0.953</td><td>1.871 0.935</td></tr><tr><td rowspan="3">LL</td><td>96</td><td>0.069 0.193 0.092 0.232 0.082 0.219</td><td></td><td></td><td></td><td>0.065</td><td>0.189</td><td>0.074(</td><td>0.208 0.088</td><td></td><td>0.225</td><td>0.131</td><td></td><td></td></tr><tr><td>192</td><td>0.1090.249 0.128 0.276 0.120</td><td></td><td></td><td>)0.268</td><td>0.118</td><td>0.256</td><td>0.116</td><td>0.252</td><td>0.132</td><td>0.283</td><td>0.186</td><td>0.288 0.354</td><td>0.211 0.362 0.261 0.406</td></tr><tr><td>336</td><td>0.139 0.286 0.165 0.314 0.226 0.370 0.154</td><td></td><td></td><td></td><td></td><td>0.305</td><td>0.143 0.295</td><td></td><td>0.180</td><td>0.336</td><td>0.220</td><td>0.381</td><td></td></tr><tr><td></td><td>720</td><td></td><td>0.180 0.331 0.243 0.397 0.188</td><td></td><td>0.338</td><td>0.182</td><td>0.335</td><td>0.197</td><td>0.338</td><td>0.300</td><td>0.435</td><td>0.267</td><td>0.430</td><td>0.317 0.448 0.366 0.487</td></tr></table>
126
+
127
+ Table 4: Performance promotion by applying the proposed framework to Transformer and its variants. We report the averaged MSE/MAE of all prediction lengths (stated in Table 2) and the relative MSE reduction ratios (Promotion) by our framework. Full results (under all prediction lengths and promotion on ETSformer [34], FEDformer [38]) can be found in Appendix.
128
+
129
+ <table><tr><td rowspan="2">Dataset Model</td><td colspan="2">Exchange</td><td colspan="2">ILI</td><td colspan="2">ETTm2</td><td colspan="2">Electricity</td><td colspan="2">Weather</td></tr><tr><td>MSE</td><td>MAE MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE MAE</td><td>Traffic MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>Transformer + Ours</td><td>1.425 0.457</td><td>0.915 0.449</td><td>4.864 1.460 2.077 0.914</td><td>1.501 0.306</td><td>0.869 0.347</td><td>0.277 0.193</td><td>0.372 0.665 0.296 0.628</td><td>0.363 0.345</td><td>0.657 0.288</td><td>0.573 0.314</td></tr><tr><td>Promotion</td><td></td><td>67.93%</td><td>57.30%</td><td></td><td>79.61%</td><td>30.32%</td><td></td><td>5.56%</td><td>56.16%</td><td></td></tr><tr><td>Informer + Ours</td><td>1.550 0.496</td><td>0.998 0.460</td><td>5.137 1.544 2.125 0.928</td><td>1.410 0.460</td><td>)0.823 0.434</td><td>0.311 0.226</td><td>0.397 0.330 0.719</td><td>0.7640.416 0.409</td><td>0.634 0.275</td><td>0.548 0.302</td></tr><tr><td>Promotion</td><td>68.00%</td><td></td><td>58.63%</td><td></td><td>67.38%</td><td>27.33%</td><td></td><td>5.89%</td><td>56.78%</td><td></td></tr><tr><td>Reformer + Ours</td><td>1.280 0.462</td><td>0.932 0.468</td><td>4.724 1.443 2.865 1.065</td><td>1.479 0.493</td><td>0.915 0.441</td><td>0.338 0.206</td><td>0.429 0.741</td><td>0.423</td><td>0.803</td><td>0.656</td></tr><tr><td>Promotion</td><td></td><td>63.91%</td><td>39.35%</td><td></td><td>66.67%</td><td>39.05%</td><td>0.308 0.682</td><td>0.372 7.96%</td><td>0.286 64.38%</td><td>0.308</td></tr><tr><td>Autoformer + Ours</td><td>0.613 0.487</td><td>0.539 0.491</td><td>3.006 1.161 2.545 1.039</td><td>0.324 0.305</td><td>0.368 0.345</td><td>0.227 0.2160.315</td><td>0.338</td><td>0.628 0.379</td><td>0.338</td><td>0.382</td></tr><tr><td>Promotion</td><td>20.55%</td><td></td><td>15.34%</td><td></td><td>5.86%</td><td>4.85%</td><td></td><td>0.619 0.364 1.43%</td><td>0.286 15.38%</td><td>0.310</td></tr></table>
130
+
131
+ # 4.2 Ablation Study
132
+
133
+ Quality evaluation To explore the role of each module in our proposed framework, we compare the prediction results on ETTm2 obtained by three models: vanilla Transformer, Transformer with only Series Stationarization, and our Non-stationary Transformer. In Figure 3, we find out that the two modules strengthen the non-stationary forecasting ability of Transformer from different perspectives. Series Stationarization focuses on the alignment of statistical properties among each series input that benefits Transformer a lot to generalize on out-of-distribution data. However, as is shown in Figure 3(b), the over-stationarized circumstance for training makes the deep model more likely to output uneventful series with significant high stationarity and neglect the nature of non-stationary real-world data. With the aid of De-stationary Attention, the model gives concern back to the inherent non-stationarity of real-world time series. It is beneficial for an accurate prediction of the detailed series variation, which is vital in real-world time series forecasting.
134
+
135
+ ![](images/c70cb32525741e3996ee6ef346159e7b3420119ca3d08daa721bf129004f26d5.jpg)
136
+ Figure 3: Visualization of ETTm2 predictions given by different models.
137
+
138
+ Table 5: Forecasting results obtained by applying different methods to Transformer and Reformer. We report the averaged MSE/MAE of all prediction lengths (stated in Table 2) for comparison. Complete results can be found in Appendix.
139
+
140
+ <table><tr><td>Base Models</td><td colspan="6">Transformer</td><td colspan="5">Reformer</td></tr><tr><td>Methods</td><td colspan="2">+ RevIN [15]</td><td colspan="2">+ Series Stationarization</td><td colspan="2">+ Ours</td><td>+ RevIN [15]</td><td colspan="2">+ Series Stationarization</td><td colspan="2">+ Ours</td></tr><tr><td>Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>Exchange</td><td>0.567</td><td>0.487</td><td>0.569</td><td>0.488</td><td>0.461</td><td>0.454</td><td>0.469 0.472</td><td>0.470</td><td>0.473</td><td>0.462</td><td>0.468</td></tr><tr><td>ILI</td><td>2.205</td><td>0.934</td><td>2.206</td><td>0.934</td><td>2.077</td><td>0.914</td><td>3.024 1.096</td><td>3.023</td><td>1.096</td><td>2.865</td><td>1.065</td></tr><tr><td>ETTm2</td><td>0.460</td><td>0.416</td><td>0.461</td><td>0.416</td><td>0.306</td><td>0.347</td><td>0.542 0.459</td><td>0.537</td><td>0.459</td><td>0.493</td><td>0.441</td></tr><tr><td>Electricity</td><td>0.197</td><td>0.298</td><td>0.197</td><td>0.298</td><td>0.193</td><td>0.296</td><td>0.208 0.309</td><td>0.207</td><td>0.309</td><td>0.206</td><td>0.308</td></tr><tr><td>Traffic</td><td>0.643</td><td>0.352</td><td>0.641</td><td>0.352</td><td>0.628</td><td>0.345</td><td>0.687 0.378</td><td>0.691</td><td>0.380</td><td>0.682</td><td>0.372</td></tr><tr><td>Weather</td><td>0.301</td><td>0.316</td><td>0.304</td><td>0.317</td><td>0.288</td><td>0.314</td><td>0.291 0.309</td><td>0.292</td><td>0.309</td><td>0.286</td><td>0.308</td></tr></table>
141
+
142
+ Quantitative performance In addition to the above case study, we also provide quantitative forecasting performance comparison with stationarization methods: a deep method RevIN [15] and Series Stationarization (Section 3.1). As is shown in Table 5, the forecasting results assisted by RevIN and Series Stationarization are basically the same, which indicates that the parameter-free version of normalization in our framework performs sufficiently to stationarize time series. Besides, the proposed De-stationary Attention in Non-stationary Transformers further boosts the performance and achieves the best in all six benchmarks. The MSE reduction brought by De-stationary Attention becomes significant, especially when the dataset is highly non-stationary (Exchange: $0 . 5 6 9 0 . 4 6 1$ , ETTm2: $0 . 4 6 1 0 . 3 0 6 )$ . The comparison reveals that simply stationarizing time series still limits the predictive capability of Transformers, and the complementary mechanisms in Non-stationary Transformers can properly release the models’ potential for non-stationary series forecasting.
143
+
144
+ # 4.3 Model Analysis
145
+
146
+ Over-stationarization problem To verify the over-stationarization problem from a statistical view, we train Transformers with the aforementioned methods respectively, arrange all predicted time series in chronological order and compare the degree of stationarity with the ground truth (Figure 4). While models solely equipped with stationarization methods tend to output series with unexpected high degree of stationarity, the results assisted by De-stationary Attention are close to the actual value (relative stationarity $\dot { \in } [ 9 7 \% , 1 0 3 \% ] )$ . Besides, as the degree of series stationarity increases, the overstationarization problem becomes more significant. The huge discrepancy of the degree of stationarity can account for the inferior performance of Transformer with only stationarization. And it also demonstrates that De-stationary Attention as an internal renovation alleviates over-stationarization.
147
+
148
+ ![](images/b9b85c925a2b767965a00bd5d0d856bb4943a2c847c9b186ae8d166ac40b6c14.jpg)
149
+ Figure 4: Relative stationarity is calculated as the ratio of ADF test statistics between the model predictions and ground truth. From left to right, the dataset is increasingly non-stationary. While models equipped with only stationarization tend to output highly stationary series, our method gives predictions with stationarity closer to ground truth.
150
+
151
+ Exploring of Non-stationary Information Re-incorporation It is notable that by specifying over-stationarization as less distinguishable attention, we narrow down our design space into the attention calculation mechanism. To explore other approaches to retrieve non-stationary information, we conduct experiments by re-incorporating the $\mu$ and $\sigma$ into feed-forward layers (DeFF), which is the left part of the Transformer architecture. In detail, we feed learned $\mu$ and $\sigma$ into each feed-forward layer iteratively. As is shown in Table 6, re-incorporating non-stationarity is necessary only when the inputs are stationarized (Stationary), which is beneficial for forecasting but will lead to stationarity discrepancy of model outputs. And our proposed design (Stat $^ +$ DeAttn) makes further promotion and achieves the best in most cases $( 7 7 \% )$ . In addition to the theoretical analysis, experimental results further validate the effectiveness of our design in re-incorporating non-stationarity on attention.
152
+
153
+ Table 6: Ablation of framework design. Baseline means vanilla Transformer, Stationary means adding Series Stationarization, DeFF means re-incorporating non-stationarity on feed-forward layers, DeAttn means re-incorporating by De-stationary Attention, $S t a t + D e F F$ means adding Series Stationarization and re-incorporating on feed-forward layers. Stat $^ +$ DeAttn means our proposed framework.
154
+
155
+ <table><tr><td rowspan=2 colspan=9>Models Baseline Stationary DeFF DeAttn Stat + DeFF Stat + DeAttnMetric MSE MAEMSEMAE MSE MAE MSE MAE MSE MAEMSEMAE</td></tr><tr><td rowspan=1 colspan=1>MSEMAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSEMAE</td></tr><tr><td rowspan=4 colspan=1>peg</td><td rowspan=1 colspan=1>96</td><td rowspan=1 colspan=2>0.5670.591</td><td rowspan=1 colspan=1>0.1360.258</td><td rowspan=1 colspan=1>0.7840.696</td><td rowspan=1 colspan=1>0.611 0.613</td><td rowspan=1 colspan=1>0.1160.243</td><td rowspan=2 colspan=1>0.1110.2370.2190.335</td></tr><tr><td rowspan=2 colspan=1>192336</td><td rowspan=1 colspan=2>1.1500.825</td><td rowspan=1 colspan=1>0.2390.348</td><td rowspan=1 colspan=1>1.1620.866</td><td rowspan=1 colspan=1>1.2020.840</td><td rowspan=1 colspan=1>0.2800.383</td></tr><tr><td rowspan=1 colspan=2>1.792 1.084</td><td rowspan=1 colspan=1>0.4250.479</td><td rowspan=1 colspan=1>1.3460.963</td><td rowspan=1 colspan=1>1.5160.981</td><td rowspan=1 colspan=1>0.371 0.452</td><td rowspan=1 colspan=1>0.421 0.476</td></tr><tr><td rowspan=1 colspan=1>720</td><td rowspan=1 colspan=2>2.191 1.159</td><td rowspan=1 colspan=1>1.4750.865</td><td rowspan=1 colspan=1>2.0421.163</td><td rowspan=1 colspan=1>2.8941.377</td><td rowspan=1 colspan=1>0.9340.704</td><td rowspan=1 colspan=1>1.0920.769</td></tr><tr><td rowspan=4 colspan=1>目</td><td rowspan=4 colspan=1>24364860</td><td rowspan=4 colspan=2>4.7481.4304.671 1.4304.9941.4825.041 1.499</td><td rowspan=1 colspan=1>2.5730.980</td><td rowspan=1 colspan=1>4.8501.445</td><td rowspan=1 colspan=1>4.7341.424</td><td rowspan=1 colspan=1>2.4040.985</td><td rowspan=1 colspan=1>2.2940.945</td></tr><tr><td rowspan=1 colspan=1>1.9550.870</td><td rowspan=1 colspan=1>4.848 1.452</td><td rowspan=1 colspan=1>4.9271.482</td><td rowspan=3 colspan=1>2.5850.9832.4960.9912.6671.059</td><td rowspan=3 colspan=1>1.8250.8482.0100.9002.1780.963</td></tr><tr><td rowspan=1 colspan=1>2.0570.902</td><td rowspan=1 colspan=1>4.9031.466</td><td rowspan=1 colspan=1>4.9961.483</td></tr><tr><td rowspan=1 colspan=1>2.2380.982</td><td rowspan=1 colspan=1>5.1961.524</td><td rowspan=1 colspan=1>5.1841.519</td></tr><tr><td rowspan=4 colspan=1>LII</td><td rowspan=1 colspan=1>96</td><td rowspan=2 colspan=2>0.5720.5521.1610.793</td><td rowspan=1 colspan=1>0.2530.311</td><td rowspan=1 colspan=1>0.7670.635</td><td rowspan=1 colspan=1>0.3040.406</td><td rowspan=1 colspan=1>0.2750.329</td><td rowspan=2 colspan=1>0.1920.2740.2800.339</td></tr><tr><td rowspan=3 colspan=1>192336720</td><td rowspan=3 colspan=2>1.1610.7931.2090.8423.0611.289</td><td rowspan=1 colspan=1>0.4530.404</td><td rowspan=1 colspan=1>0.9600.717</td><td rowspan=1 colspan=1>0.8200.652</td><td rowspan=1 colspan=1>0.4060.403</td></tr><tr><td rowspan=2 colspan=1>0.5460.4610.5930.489</td><td rowspan=2 colspan=1>1.1590.8113.1871.308</td><td rowspan=1 colspan=1>1.4060.883</td><td rowspan=2 colspan=1>0.5020.4650.6940.575</td><td rowspan=2 colspan=1>0.3340.3610.4170.413</td></tr><tr><td rowspan=1 colspan=1>2.8581.108</td></tr><tr><td rowspan=4 colspan=1>riea</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=4 colspan=2>0.2600.3580.2660.3670.2800.3750.3020.386</td><td rowspan=2 colspan=1>0.1710.2750.1920.296</td><td rowspan=1 colspan=1>0.2600.356</td><td rowspan=1 colspan=1>0.2530.351</td><td rowspan=1 colspan=1>0.1700.274</td><td rowspan=3 colspan=1>0.1690.2730.1820.2860.2000.304</td></tr><tr><td rowspan=1 colspan=1>0.2640.365</td><td rowspan=1 colspan=1>0.2570.358</td><td rowspan=2 colspan=1>0.1880.2930.2060.309</td></tr><tr><td rowspan=1 colspan=1>0.2080.306</td><td rowspan=1 colspan=1>0.2770.374</td><td rowspan=1 colspan=1>0.2700.365</td></tr><tr><td rowspan=1 colspan=1>0.2160.315</td><td rowspan=1 colspan=1>0.2990.384</td><td rowspan=1 colspan=1>0.2950.380</td><td rowspan=1 colspan=1>0.2230.323</td><td rowspan=1 colspan=1>0.2220.321</td></tr><tr><td rowspan=4 colspan=1>[Ttere</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=2 colspan=2>0.6470.3570.6490.356</td><td rowspan=1 colspan=1>0.6140.337</td><td rowspan=1 colspan=1>0.6460.353</td><td rowspan=1 colspan=1>0.6500.358</td><td rowspan=1 colspan=1>0.6050.333</td><td rowspan=1 colspan=1>0.6120.338</td></tr><tr><td rowspan=1 colspan=1>0.356</td><td rowspan=1 colspan=1>0.6370.351</td><td rowspan=1 colspan=1>0.6450.352</td><td rowspan=1 colspan=1>0.6550.358</td><td rowspan=1 colspan=1>0.6170.342</td><td rowspan=1 colspan=1>0.6130.340</td></tr><tr><td rowspan=2 colspan=2>0.667 0.3640.6970.376</td><td rowspan=2 colspan=1>0.6530.3590.6610.360</td><td rowspan=1 colspan=1>0.6720.360</td><td rowspan=1 colspan=1>0.6560.355</td><td rowspan=1 colspan=1>0.6350.349</td><td rowspan=2 colspan=1>0.6180.3280.6530.355</td></tr><tr><td rowspan=1 colspan=1>0.6950.376</td><td rowspan=1 colspan=1>0.6810.366</td><td rowspan=1 colspan=1>0.6490.351</td></tr><tr><td rowspan=4 colspan=1>waaaeer</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=4 colspan=2>0.395 0.4270.6190.5600.6890.5940.9260.710</td><td rowspan=2 colspan=1>0.1750.2250.2730.297</td><td rowspan=1 colspan=1>0.4170.445</td><td rowspan=1 colspan=1>0.2960.364</td><td rowspan=2 colspan=1>0.1780.2260.2560.295</td><td rowspan=2 colspan=1>0.1730.2230.2450.285</td></tr><tr><td rowspan=1 colspan=1>0.6990.604</td><td rowspan=1 colspan=1>0.4800.464</td></tr><tr><td rowspan=2 colspan=1>0.3330.3250.4360.420</td><td rowspan=1 colspan=1>0.7730.620</td><td rowspan=1 colspan=1>0.5810.519</td><td rowspan=1 colspan=1>0.3380.351</td><td rowspan=1 colspan=1>0.3210.338</td></tr><tr><td rowspan=1 colspan=1>1.0080.718</td><td rowspan=1 colspan=1>0.7950.642</td><td rowspan=1 colspan=1>0.4170.412</td><td rowspan=1 colspan=1>0.4140.410</td></tr></table>
156
+
157
+ # 5 Conclusion
158
+
159
+ This paper addresses time series forecasting from the view of stationarity. Unlike previous studies that simply attenuate non-stationarity leading to over-stationarization, we propose an efficient way to increase series stationarity and renovate the internal mechanism to re-incorporate non-stationary information, thus boosting data predictability and model predictive capability simultaneously. Experimentally, our method shows great generality and performance on six real-world benchmarks. And detailed derivations and ablations are provided to testify the effectiveness of each component in our proposed Non-stationary Transformers framework. In the future, we will explore a more model-agnostic solution for the over-stationarization problem.
160
+
161
+ # Acknowledgments
162
+
163
+ This work was supported by the National Key Research and Development Plan (2021YFC3000905), National Natural Science Foundation of China (62022050 and 62021002), Beijing Nova Program (Z201100006820041), and BNRist Innovation Fund (BNR2021RC01002).
164
+
165
+ References
166
+ [1] Illness Dataset. https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html.
167
+ [2] Traffic Dataset. http://pems.dot.ca.gov/.
168
+ [3] UCI Electricity Load Time Series Dataset. https://archive.ics.uci.edu/ml/datasets/ ElectricityLoadDiagrams20112014.
169
+ [4] Weather Dataset. https://www.bgc-jena.mpg.de/wetter/.
170
+ [5] Kartik Ahuja, Ethan Caballero, Dinghuai Zhang, Jean-Christophe Gagnon-Audet, Yoshua Bengio, Ioannis Mitliagkas, and Irina Rish. Invariance principle meets information bottleneck for out-of-distribution generalization. NeurIPS, 2021.
171
+ [6] O. Anderson and M. Kendall. Time-series. 2nd edn. J. R. Stat. Soc. (Series D), 1976.
172
+ [7] G. E. P. Box and Gwilym M. Jenkins. Time series analysis, forecasting and control. 1970.
173
+ [8] George EP Box and Gwilym M Jenkins. Some recent advances in forecasting and control. J. R. Stat. Soc. (Series-C), 1968.
174
+ [9] Cristian Challu, Kin G Olivares, Boris N Oreshkin, Federico Garza, Max Mergenthaler, and Artur Dubrawski. N-hits: Neural hierarchical interpolation for time series forecasting. arXiv preprint arXiv:2201.12886, 2022.
175
+ [10] Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. NeurIPS, 2021.
176
+ [11] J. Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
177
+ [12] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
178
+ [13] Graham Elliott, Thomas J. Rothenberg, and James H. Stock. Efficient tests for an autoregressive unit root. Econometrica, 1996.
179
+ [14] Rob J Hyndman and George Athanasopoulos. Forecasting: principles and practice. OTexts, 2018.
180
+ [15] Taesung Kim, Jinhee Kim, Yunwon Tae, Cheonbok Park, Jang-Ho Choi, and Jaegul Choo. Reversible instance normalization for accurate time-series forecasting against distribution shift. In ICLR, 2022.
181
+ [16] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
182
+ [17] Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020.
183
+ [18] Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long-and short-term temporal patterns with deep neural networks. In SIGIR, 2018.
184
+ [19] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In ICCV, 2017.
185
+ [20] Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. In NeurIPS, 2019.
186
+ [21] Shizhan Liu, Hang Yu, Cong Liao, Jianguo Li, Weiyao Lin, Alex X Liu, and Schahram Dustdar. Pyraformer: Low-complexity pyramidal attention for long-range time series modeling and forecasting. In ICLR, 2021.
187
+ [22] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV, 2021.
188
+ [23] Danielle C Maddix, Yuyang Wang, and Alex Smola. Deep factors with gaussian processes for forecasting. arXiv preprint arXiv:1812.00098, 2018.
189
+ [24] Eduardo Ogasawara, Leonardo C. Martinez, Daniel de Oliveira, Geraldo Zimbrão, Gisele L. Pappa, and Marta Mattoso. Adaptive normalization: A novel data normalization approach for non-stationary time series. In IJCNN, 2010.
190
+ [25] Boris N Oreshkin, Dmitri Carpov, Nicolas Chapados, and Yoshua Bengio. N-BEATS: Neural basis expansion analysis for interpretable time series forecasting. ICLR, 2019.
191
+ [26] Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. TKDE, 2009.
192
+ [27] Nikolaos Passalis, Anastasios Tefas, Juho Kanniainen, Moncef Gabbouj, and Alexandros Iosifidis. Deep adaptive input normalization for time series forecasting. TNNLS, 2019.
193
+ [28] Adam Paszke, S. Gross, Francisco Massa, A. Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Z. Lin, N. Gimelshein, L. Antiga, Alban Desmaison, Andreas Köpf, Edward Yang, Zach DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
194
+ [29] Syama Sundar Rangapuram, Matthias W Seeger, Jan Gasthaus, Lorenzo Stella, Yuyang Wang, and Tim Januschowski. Deep state space models for time series forecasting. In NeurIPS, 2018.
195
+ [30] David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. DeepAR: Probabilistic forecasting with autoregressive recurrent networks. Int. J. Forecast., 2020.
196
+ [31] Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
197
+ [32] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
198
+ [33] Ruofeng Wen, Kari Torkkola, Balakrishnan Narayanaswamy, and Dhruv Madeka. A multi-horizon quantile recurrent forecaster. NeurIPS, 2017.
199
+ [34] Gerald Woo, Chenghao Liu, Doyen Sahoo, Akshat Kumar, and Steven C. H. Hoi. Etsformer: Exponential smoothing transformers for time-series forecasting. arXiv preprint arXiv:1406.1078, 2022.
200
+ [35] Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long. Autoformer: Decomposition transformers with Auto-Correlation for long-term series forecasting. In NeurIPS, 2021.
201
+ [36] Rose Yu, Stephan Zheng, Anima Anandkumar, and Yisong Yue. Long-term forecasting using tensor-train rnns. arXiv preprint arXiv:1711.00073, 2017.
202
+ [37] Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI, 2021.
203
+ [38] Tian Zhou, Ziqing Ma, Qingsong Wen, Xue Wang, Liang Sun, and Rong Jin. FEDformer: Frequency enhanced decomposed transformer for long-term series forecasting. In ICML, 2022.
204
+
205
+ # Checklist
206
+
207
+ 1. For all authors...
208
+
209
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1.
210
+ (b) Did you describe the limitations of your work? [Yes] See Section 7 of the Appendix.
211
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6 of the Appendix.
212
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
213
+
214
+ 2. If you are including theoretical results...
215
+
216
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 1 of the Appendix. (b) Did you include complete proofs of all theoretical results? [Yes] See Section 1 of the Appendix.
217
+
218
+ 3. If you ran experiments...
219
+
220
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We provide the data link and code in https://github.com/thuml/Nonstationary_Transformers.
221
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.1 of the Appendix.
222
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Table 4 of the Appendix.
223
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.
224
+
225
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
226
+
227
+ (a) If your work uses existing assets, did you cite the creators? [Yes] The data source is described in Section 4.
228
+ (b) Did you mention the license of the assets? [N/A]
229
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We provide the code in https://github.com/thuml/Nonstationary_Transformers.
230
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
231
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
232
+
233
+ 5. If you used crowdsourcing or conducted research with human subjects...
234
+
235
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
236
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
237
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/znNmsN_O7Sh/znNmsN_O7Sh.md ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Object Scene Representation Transformer
2
+
3
+ Mehdi S. M. Sajjadi, Daniel Duckworth⇤, Aravindh Mahendran⇤, Sjoerd van Steenkiste⇤, Filip Pavetic, Mario Lu ´ ciˇ c, Leonidas J. Guibas, Klaus Greff, Thomas Kipf ´ ⇤
4
+
5
+ Google Research
6
+
7
+ # Abstract
8
+
9
+ A compositional understanding of the world in terms of objects and their geometry in 3D space is considered a cornerstone of human cognition. Facilitating the learning of such a representation in neural networks holds promise for substantially improving labeled data efficiency. As a key step in this direction, we make progress on the problem of learning 3D-consistent decompositions of complex scenes into individual objects in an unsupervised fashion. We introduce Object Scene Representation Transformer (OSRT), a 3D-centric model in which individual object representations naturally emerge through novel view synthesis. OSRT scales to significantly more complex scenes with larger diversity of objects and backgrounds than existing methods. At the same time, it is multiple orders of magnitude faster at compositional rendering thanks to its light field parametrization and the novel Slot Mixer decoder. We believe this work will not only accelerate future architecture exploration and scaling efforts, but it will also serve as a useful tool for both object-centric as well as neural scene representation learning communities.
10
+
11
+ # 1 Introduction
12
+
13
+ As humans, we interact with a physical world that is composed of macroscopic objects1 situated in 3D environments. The development of an object-centric, geometric understanding of the world is considered a cornerstone of human cognition [32]: we perceive scenes in terms of discrete objects and their parts, and our understanding of 3D scene geometry is essential for reasoning about relations between objects and for skillfully interacting with them.
14
+
15
+ Replicating these capabilities in machine learning models has been a major focus in computer vision and related fields [12, 22, 34], yet the classical paradigm of supervised learning poses several challenges: explicit supervision requires carefully annotated data at a large scale, and is subject to obstacles such as rare or novel object categories. Further, obtaining accurate ground-truth 3D scene and object geometry is challenging and expensive. Learning about compositional geometry merely by observing scenes and occasionally interacting with them—in the simplest case by moving a camera through a scene—without relying on direct supervision is an attractive alternative.
16
+
17
+ As objects in the physical world are situated in 3D space, there has been a growing interest in combining recent advances in 3D neural rendering [25] and representation learning [7, 20] with object-centric inductive biases to jointly learn to represent objects and their 3D geometry without direct supervision [26, 33, 40]. A particularly promising setting for learning both about objects and 3D scene geometry from RGB supervision alone is that of novel view synthesis (NVS), where the task is to predict a scene’s appearance from unobserved view points. This task not only encourages a model to learn a geometrically-consistent representation of a scene, but has the potential to serve as an additional inductive bias for discovering objects without supervision.
18
+
19
+ ![](images/823948cd318f42798edfc9419eaa397c0228f8e16307a39d0a2af37b8364ce39.jpg)
20
+ Figure 1: OSRT overview – A set of input views of a novel scene are processed by the SRT Encoder, yielding the Set-Latent Scene Representation (SLSR). The Slot Attention module converts the SLSR into the object-centric Slot Scene Representation. Finally, arbitrary views with 3D-consistent object instance decompositions are efficiently rendered by the novel Slot Mixer. The entire model is trained end-to-end with an L2 loss and no additional regularizers. Details in Sec. 2.
21
+
22
+ Prior methods combining object-centric inductive biases with 3D rendering techniques for NVS [26, 33, 40] however fail to generalize to scenes of high visual complexity and face a significant shortcoming in terms of computational cost and memory requirements: common object-centric models decode each object independently, adding a significant multiplicative factor to the already expensive volumetric rendering procedure which requires hundreds of decoding steps. This requirement of executing thousands of decoding passes for each rendered pixel is a major limitation that prohibits scaling this class of methods to more powerful models and thus to more complex scenes.
23
+
24
+ In this work, we propose Object Scene Representation Transformer (OSRT), an end-to-end model for object-centric 3D scene representation learning. The integrated Slot Attention [23] module allows it to learn a scene representation that is decomposed into slots, each representing an object or part of the background. OSRT is based on SRT, utilizing a light field parameterization of space to predict pixel values directly from a latent scene representation in a single forward pass. Instead of rendering each slot independently, we introduce the novel Slot Mixer, a highly-efficient object-aware decoder that requires just a single forward pass per rendered pixel, irrespective of the number of slots in the model. In summary, OSRT allows for highly scalable learning of object-centric 3D scene representations without supervision.
25
+
26
+ Our core contributions are as follows:
27
+
28
+ • We present OSRT, a model for 3D-centric representation learning, enabling efficient and scalable object discovery in 3D scenes from RGB supervision. The model is trained purely with the simple L2 loss and does not necessitate further regularizers or additional knowledge such as depth maps [33] or explicit background handling [40]. As part of OSRT, we propose the novel Slot Mixer, a highly efficient object-aware decoder that scales to large numbers of objects in a scene with little computational overhead.
29
+ • We study several properties of the proposed method, including robustness studies and advantages of using NVS to facilitate scene decomposition in complex datasets.
30
+ • In a range of experiments from easier previously proposed, to complex many-object scenes, we demonstrate that OSRT achieves state-of-the-art object decomposition, outperforming prior methods both quantitatively and in terms of efficiency.
31
+
32
+ # 2 Method
33
+
34
+ We begin this section with a description of the proposed Object Scene Representation Transformer (OSRT) shown in Fig. 1 and its novel Slot Mixer decoder, and conclude with a discussion of possible alternative design choices.
35
+
36
+ # 2.1 Novel view synthesis
37
+
38
+ The starting point for our investigations is the Scene Representation Transformer (SRT) [29] as a geometry-free novel view synthesis (NVS) backbone that provides instant novel-scene generalization and scalability to complex datasets. SRT is based on an encoder-decoder architecture.
39
+
40
+ A data point consists of a set of RGB input images $\{ I _ { i } \in \mathbb { R } ^ { H \times W \times 3 } \}$ from the same scene.2 A convolutional network CNN independently encodes each image into a feature map, all of which are finally flattened and combined into a single set of tokens. An Encoder Transformer $\mathcal { E }$ then performs self-attention on this feature set, ultimately yielding the Set-Latent Scene Representation (SLSR)
41
+
42
+ $$
43
+ \{ \mathbf { z } _ { j } \in \mathbb { R } ^ { d } \} = \mathcal { E } _ { \boldsymbol { \theta } } \big ( \{ \mathbf { C } \mathbf { N } \mathbf { N } _ { \boldsymbol { \theta } } ( \mathbf { I } _ { i } ) \} \big ) .
44
+ $$
45
+
46
+ Novel views are rendered using a 6D light-field parametrization $\mathbf { r } = ( \mathbf { o } , \mathbf { d } )$ of the scene. Each pixel to be rendered is described by the camera position o and the normalized ray direction $\mathbf { d }$ pointing from the camera through the center of the pixel in the image plane. As shown in Fig. 2 (left), the Decoder Transformer $\mathcal { D }$ uses these rays $\mathbf { r }$ as queries to attend into the SLSR, thereby aggregating localized information from the scene, and ultimately produces the RGB color prediction
47
+
48
+ $$
49
+ C ( \mathbf { r } ) = \mathcal { D } _ { \boldsymbol { \theta } } ( \mathbf { r } \mid \{ \mathbf { z } _ { j } \} ) .
50
+ $$
51
+
52
+ Given a dataset of images $\{ \mathbf { I } _ { s , i } ^ { \mathrm { g t } } \}$ from different scenes indexed by $s$ , the model is trained end-to-end using an L2 reconstruction loss for novel views:
53
+
54
+ $$
55
+ \underset { \theta } { \arg \operatorname* { m i n } } \ \sum _ { s } \mathbb { E } _ { \mathbf { r } \sim \mathbf { I } _ { s , i } ^ { \mathrm { g t } } } \| C ( \mathbf { r } ) - \mathbf { I } _ { s , i } ^ { \mathrm { g t } } ( \mathbf { r } ) \| _ { 2 } ^ { 2 } .
56
+ $$
57
+
58
+ # 2.2 Scene decomposition
59
+
60
+ SRT’s latent representation, the SLSR, has been shown to contain enough information to perform downstream tasks such as semi-supervised semantic segmentation [29]. However, the size of the SLSR is directly determined by the number and resolution of the input images, and there is no clear one-to-one correspondence between the SLSR tokens and objects in the scene.
61
+
62
+ To obtain an object-centric scene representation, we incorporate the Slot Attention [23] module into our architecture. Slot Attention converts the SLSR $\{ \mathbf { z } _ { j } \}$ into the Slot Scene Representation (SlotSR), a set of object slots $\{ \mathbf { s } _ { n } \in \mathbb { R } ^ { h } \}$ . Different from the size of the SLSR, the size $N$ of the SlotSR is chosen by the user.
63
+
64
+ We initialize the set of object slots using learned embeddings $\{ \hat { \mathbf { s } } _ { n } \in \mathbb { R } ^ { h } \}$ . The Slot Attention module then takes the following form for learned linear projections $W _ { v }$ , $W _ { z }$ , and $W _ { s }$ and a learned update function $\mathcal { U } _ { \theta }$ :
65
+
66
+ $$
67
+ \mathbf { s } _ { n } = \mathcal { U } _ { \theta } \left( \hat { \mathbf { s } } _ { n } , \frac { \sum _ { j = 1 } ^ { J } \mathbf { A } _ { n , j } W _ { v } \mathbf { z } _ { j } } { \sum _ { j = 1 } ^ { J } \mathbf { A } _ { n , j } } \right) , \quad \mathrm { w i t h } \quad \mathbf { A } _ { n , j } = \frac { \exp \left( ( W _ { s } \hat { \mathbf { s } } _ { n } ) ^ { T } W _ { z } \mathbf { z } _ { j } \right) } { \sum _ { l = 1 } ^ { N } \exp \left( ( W _ { s } \hat { \mathbf { s } } _ { l } ) ^ { T } W _ { z } \mathbf { z } _ { j } \right) } .
68
+ $$
69
+
70
+ The attention matrix $\mathbf { A }$ is used to aggregate input tokens using a weighted mean. Different from commonly used cross-attention [36], it is normalized over the output axis, i.e., the set of slots, instead of the input tokens. This enforces an exclusive grouping of input tokens into object slots, which serves as an inductive bias for decomposing the SLSR into individual per-object representations. Following Locatello et al. [23], we use a gated update for $\mathcal { U } _ { \theta }$ in the form of a GRU [6] followed by a residual MLP and we apply LayerNorm [2] to both inputs and slots.
71
+
72
+ # 2.3 Efficient object-centric decoding
73
+
74
+ To be able to extract arbitrary-view object decompositions from the model, we propose the novel Slot Mixer (SM): a powerful, yet efficient object-centric decoder. The SM module is shown in Fig. 2 (center) and consists of three components: Allocation Transformer, Mixing Block, and Render MLP.
75
+
76
+ Allocation Transformer. The goal of the Allocation Transformer is to derive which slots are relevant for the given ray $\mathbf { r } = ( \mathbf { o } , \mathbf { d } )$ . In essence, this module derives object location and boundaries and resolves occlusions. Its architecture is similar to SRT’s Decoder Transformer. It is a transformer that uses the target ray $\mathbf { r }$ as the query to repeatedly attend into and aggregate features from the SlotSR:
77
+
78
+ $$
79
+ \mathbf { x } = \mathcal { D } _ { \boldsymbol { \theta } } ( \mathbf { r } \mid \{ \mathbf { s } _ { n } \} )
80
+ $$
81
+
82
+ Most compute in the Allocation Transformer is spent on the query, allowing it to scale gracefully to large numbers of objects in the SlotSR. However, unlike in SRT, its output is not used directly for the RGB color estimate.
83
+
84
+ ![](images/881b831bc3d21936c6271dc3d99791c93a54d5570218114d3c9fa21365a78d5a.jpg)
85
+ Figure 2: Decoder architectures – Comparison between SRT, the novel Slot Mixer (SM), and Spatial Broadcast (SB) decoders. The SRT decoder uses an efficient Transformer that scales gracefully to large numbers of objects, but it fails to produce novel-view object decompositions. The commonly used SB model decodes each slot independently, leading to high memory and computational requirements. The proposed SM decoder combines SRT’s efficiency with SB’s object decomposition capabilities. Details in Secs. 2.3 and 2.4.
86
+
87
+ Mixing Block. Instead, the resulting feature $\mathbf { x }$ is passed to the Mixing Block, which computes a normalized dot-product similarity w with the SlotSR matrix ${ \bf S } \in \mathbb { R } ^ { N \times \mathbb { Y } }$ , i.e., the slots in arbitrary, but fixed order. This similarity is then used to compute a weighted mean of the original slots:
88
+
89
+ $$
90
+ Q = W _ { Q } { \bf x } , \quad K = W _ { K } { \bf S } ^ { T } , \qquad { \bf w } = \mathrm { s o f t m a x } ( K ^ { T } Q ) , \qquad { \bar { \bf s } } = { \bf w } ^ { T } { \bf S } ,
91
+ $$
92
+
93
+ where $W _ { Q }$ and $W _ { K }$ are learned linear projections. Notably, the weight $\mathrm { w } _ { i }$ of each slot is scalar, and unlike standard attention layers, no linear maps are computed for the slots, i.e. the Allocation Transformer is solely responsible for mixing the slots, not for decoding them. The slot weights can be seen as novel-view object assignments that are useful for visual inspection of the learned representation and for quantitative evaluation, see Sec. 4.
94
+
95
+ Render MLP. Finally, the Render MLP decodes the original query ray $\mathbf { r }$ conditioned on the weighted mean ¯s of the SlotSR into the RGB color prediction:
96
+
97
+ $$
98
+ C ( \mathbf { r } ) = \mathcal { M } _ { \theta } ( \mathbf { r } \mid \bar { \mathbf { s } } )
99
+ $$
100
+
101
+ We call the resulting model as shown in Fig. 1 with the SRT encoder, incorporated Slot Attention module and the Slot Mixer decoder Object Scene Representation Transformer (OSRT). All parameters are trained end-to-end using the L2 reconstruction loss as in Eq. (3).
102
+
103
+ # 2.4 Alternative decoder architecture
104
+
105
+ Our novel Slot Mixer differs significantly from the standard choice in the literature where Spatial Broadcast (SB) decoders [37] (Fig. 2, right) are most commonly used in conjunction with Slot Attention [23, 33, 40]. We present an adaptation thereof to OSRT as an alternative to the SM decoder.
106
+
107
+ In SB decoders, the query ray is decoded for each slot ${ \bf s } _ { n }$ independently using a shared MLP $\mathcal { M }$
108
+
109
+ $$
110
+ \mathbf { C } _ { n , \mathbf { r } } , \alpha _ { n , \mathbf { r } } = \mathcal { M } _ { \boldsymbol { \theta } } ( \mathbf { r } \mid \mathbf { s } _ { n } )
111
+ $$
112
+
113
+ For each ray $\mathbf { r }$ , this produces color estimates ${ \bf { C } _ { r } } ~ \in { \mathbb { R } ^ { N } }$ and logits $\alpha _ { \mathbf { r } } ~ \in ~ \mathbb { R } ^ { N }$ with each value corresponding to a different slot. The final RGB color estimate is then calculated by a normalized, weighted mean:
114
+
115
+ $$
116
+ \mathbf { w } = { \mathrm { s o f t m a x } } ( \alpha _ { \mathbf { r } } ) , \qquad C ( \mathbf { r } ) = \mathbf { w } ^ { T } \mathbf { C _ { r } }
117
+ $$
118
+
119
+ In the SB decoder, the slots therefore compete for each pixel through a softmax operation.
120
+
121
+ We note a major disadvantage of this popular decoder design: it does not scale gracefully to larger numbers of objects or slots, as the full decoder has to be run on each slot. This implies a linear increase in memory and computational requirements of the entire decoder, which is often inhibitive,
122
+
123
+ especially in training. In practice, most pixels are fully explained by a single slot, i.e. almost all of the compute of the decoder is spent on resolving the most prominent slot, and the rest go unused.
124
+
125
+ The proposed Slot Mixer solves this by employing the scalable Allocation Transformer for blending between slots more efficiently, while only a single weighted mean of all slots must be fully decoded by the Render MLP. We further investigate the choice of decoders empirically in Sec. 4.2.
126
+
127
+ # 3 Related works
128
+
129
+ Neural rendering. Neural rendering is a large, promising field that investigates the use of machine learning for graphics applications [34]. Recently, NeRF [25] has sparked a renewed wave of interest in this field by optimizing an MLP to parameterize a single volumetric scene representation and demonstrating photo-realistic results on real-world scenes, later also for uncurated in-the-wild data [24]. Further methods based on NeRF are able to generalize across scenes by means of reprojecting 3D points into 2D feature maps [35, 39], though they lack a global 3D-based scene representation that could be readily used for downstream applications.
130
+
131
+ Meanwhile, there have been early successes with global latent models [15, 31], though these rarely scale beyond simple datasets of single oriented objects on uniform backgrounds [20]. Alternative approaches produce higher-quality results by employing a computationally expensive auto-regressive generative mechanisms that does not produce spatially or temporally consistent results [28]. Recently, the Scene Representation Transformer (SRT) [29] has been proposed as a global-latent model that efficiently scales to highly complex scenes by means of replacing the volumetric parametrization with a light field formulation.
132
+
133
+ Object-centric learning. Prior works on object-centric learning, such as MONet [3], IODINE [9], SPACE [21] and Slot Attention [23] have demonstrated that it is possible to learn models that decompose images into objects using simple unsupervised image reconstruction objectives. These methods typically use a structured latent space and employ dedicated inductive biases in their architectures and image decoders. To handle depth and occlusion in 3D scenes, these methods typically employ a generative model which handles occlusion via alpha-blending [9, 23] or by, e.g., generating objects ordered by their distance to the camera [1, 21]. We refer to the survey by Greff et al. [10] for an overview. Recent progress in this line of research applies these core inductive biases to work on images of more complex scenes [30] or video data [17, 19]. In our OSRT model, we make use of the ubiquitous Slot Attention [23] module because of its efficiency and effectiveness.
134
+
135
+ 3D object-centric methods. Several recent works have extended self-supervised object-centric methods to 3D scenes [5, 33, 40]. One of the first such approaches is ROOTS [5], a probabilistic generative model that represents the scene in terms of a 3D feature map, where each 3D "patch" describes the presence (or absence) of an object. Each discovered object is independently rendered using a GQN [7] decoder and the final image is recomposed using Spatial Transformer Networks [14].
136
+
137
+ Further prior works that are the most relevant to our method are ObSuRF [33] and uORF [40], both combining learned volumetric representations [25] with Slot Attention [23] and Spatial Broadcast decoders [37]. Both methods have been shown to be capable of modeling 3D scenes of slightly higher complexity than CLEVR [16].
138
+
139
+ ObSuRF’s architecture is based on NeRF-VAE [20]. It bypasses the extraordinary memory requirements of the Spatial Broadcast decoder combined with volumetric rendering during training by using ground-truth depth information, thereby needing only 2 samples per ray instead of hundreds. During inference, at the absence of ground-truth depth information, ObSuRF however suffers from the expected high computational cost of object-centric volumetric rendering.
140
+
141
+ uORF is based on an encoder-decoder architecture that explicitly handles foreground (FG) and background (BG) separately through a set of built-in inductive biases and assumptions on the dataset. For instance, the dedicated BG slot is parameterized differently, and FG slots are encouraged to only produce density inside a manually specified area of the scene. The model is trained using a combination of perceptual losses, and optionally also with an adversarial loss [8].
142
+
143
+ In order to obtain the results for ObSuRF and uORF, we used the available official implementations, and consulted the respective authors of both methods to ensure correct adaptation to new datasets.
144
+
145
+ Finally, a separate line of work considers purely generative object-centric 3D rendering without the ability to render novel views of a specifically provided input scene. GIRAFFE [26] addresses this problem by combining volumetric rendering with a GAN-based [8] loss. It separately parameterizes object appearance and 3D pose for controllable image synthesis. Inspired thereof, INFERNO [4] combines a generative model with a Slot Attention-based inference model to learn object-centric 3D scene representations. We do not explicitly compare to INFERNO as it is similar to ObSuRF and uORF, while only shown capable of modeling CLEVR-like scenes of lower visual complexity.
146
+
147
+ # 4 Experiments
148
+
149
+ To investigate OSRT’s capabilities, we evaluate it on a range of datasets. After confirming that the proposed method outperforms existing methods on their comparably simple datasets, we move on to a more realistic, highly challenging dataset for all further investigations. We evaluate models by their novel view reconstruction quality and unsupervised scene decomposition capabilities qualitatively and quantitatively. We further investigate OSRT’s computational requirements compared to the baselines and close this section with some further analysis into which ingredients are crucial to enable OSRT’s unsupervised scene decomposition qualities in challenging settings.
150
+
151
+ Setting and evaluation metrics. The models are trained in a novel view synthesis (NVS) setup: on a dataset of scenes, we train the models to produce novel views of the same scene parameterized by target camera poses. For evaluation, we run the models on a held-out set of test scenes and render multiple novel views per scene.
152
+
153
+ As quantitative metrics, we report PSNR for pixel-accurate reconstruction quality and adopt the standard foreground Adjusted Rand Index (FG-ARI) [13, 27] to measure object decomposition. Crucially, we compute FG-ARI on all rendered views together, such that object instances must be consistent between different views. This makes our metric sensitive to 3D-inconsistencies that may especially plague light field models which do not explicitly enforce this in contrast to volumetric methods. We analyze and discuss this choice further in Sec. 4.2.
154
+
155
+ For qualitative inspection of the inferred scene decompositions, we visualize for each rendered pixel the slot with the highest weight $\mathrm { w } _ { i }$ and color-code the slots accordingly.
156
+
157
+ Datasets. We run experiments on several datasets in increasing order of complexity.
158
+
159
+ CLEVR-3D [33]. This is a recently proposed multicamera variant of the CLEVR dataset, which is popular for evaluating object decomposition due to its simple structure and unambiguous objects. Each scene consists of 3–6 basic geometric shapes of 2 sizes and 8 colors randomly positioned on a gray background. The dataset has ${ \sim } 3 5 \mathrm { k }$ training and 100 test scenes, each with 3 fixed views: the two target views are the default CLEVR input view rotated by $1 2 0 ^ { \circ }$ and $2 4 0 ^ { \circ }$ , respectively.
160
+
161
+ ![](images/f4d89a27ae6d11145ce33c4978203536f12a0e2898873b169f44ebaae36e477b.jpg)
162
+ Figure 3: Example views of scenes from CLEVR-3D (left) and MSN-Easy (right).
163
+
164
+ MultiShapeNet-Easy (MSN-Easy) [33]. This dataset is similar in structure to CLEVR-3D, however, 2–4 upright ShapeNet objects sampled from the chair, table and cabinet classes (for a total of ${ \sim } 1 2 \mathrm { k }$ objects) now replace the geometric solids. The dataset has 70k training and 100 test scenes.
165
+
166
+ MultiShapeNet-Hard (MSN-Hard) [29]. MSN-Hard has been proposed as a highly challenging dataset for novel view synthesis. In each scene, 16-32 ShapeNet objects are scattered in random orientations. Realistic backgrounds and HDR environment maps are sampled from a total set of 382 assets. The cameras are randomly scattered on a half-sphere around the scene with varying distance to the objects. It is a highly demanding dataset due to its use of photo-realistic ray tracing [11], complex arrangements of tightly-packed objects of varying size, challenging backgrounds, and nontrivial camera poses including almost horizontal views of the scene. The dataset has 1M training scenes, each with 10 views, and we use a test set of 1000 scenes. The ${ \sim } 5 1 \mathrm { k }$ unique ShapeNet objects are taken from all classes, and they are separated into a train and test split, such that the test set not only contains novel arrangements, but also novel objects. We re-generated the dataset as the original provided by Sajjadi et al. [29] does not include ground-truth instance labels necessary for our quantitative evaluation. We will make the dataset publicly available.
167
+
168
+ Table 1: Quantitative results – OSRT outperforms ObSuRF across all metrics and datasets with the exception of CLEVR-3D, where FG-ARI is nearly identical. On MSN-Hard, OSRT is able to encode multiple input views to further improve object decomposition and reconstruction performance.
169
+
170
+ <table><tr><td rowspan="2"></td><td colspan="2">CLEVR-3D [33]</td><td colspan="2">MSN-Easy [33]</td><td colspan="3">MSN-Hard [29]</td></tr><tr><td>ObSuRF</td><td>OSRT(1)</td><td>ObSuRF</td><td>OSRT(1)</td><td>ObSuRF</td><td>OSRT(1)</td><td>OSRT(5)</td></tr><tr><td>PSNR</td><td>33.69</td><td>39.98</td><td>27.41</td><td>29.74</td><td>16.50</td><td>20.52</td><td>23.54</td></tr><tr><td>FG-ARI</td><td>0.978</td><td>0.976</td><td>0.940</td><td>0.954</td><td>0.280</td><td>0.619</td><td>0.812</td></tr></table>
171
+
172
+ # 4.1 Comparison with prior work
173
+
174
+ Tab. 1 shows a comparison between OSRT and the strong ObSuRF [33] baseline. On the simpler datasets CLEVR-3D and MSN-Easy, ObSuRF produces reasonable reconstructions with accurate decomposition, though OSRT achieves significantly higher PSNR and similar FG-ARI.
175
+
176
+ On the more realistic MSN-Hard, ObSuRF achieves only low PSNR and FG-ARI. OSRT on the other hand still performs solidly on both metrics. Furthermore, while ObSuRF can only be conditioned on a single image, OSRT is optionally able to ingest several. We report numbers for OSRT (5), our model with 5 input views, on the same dataset and see that it substantially improves both reconstruction and decomposition quality.
177
+
178
+ At the same time, OSRT renders novel views at 32.5 fps (frames per second), more than $3 0 0 0 \times$ faster than ObSuRF which only achieves 0.01 fps, both measured on an Nvidia V100 GPU. This speedup is the result of two multiplicative factors: OSRT’s light field formulation is ${ \sim } 1 0 0 \times$ faster than volumetric rendering and the novel Slot Mixer is ${ \sim } 3 0 \times$ faster than the SB decoder here. Finally, OSRT does not need ground-truth depth information during training.
179
+
180
+ Fig. 4 shows qualitative results for the realistic MSN-Hard dataset. It is evident that ObSuRF has reached its limits, producing blurry images with suboptimal scene decompositions. OSRT on the other hand still performs solidly, producing much higher-quality images and decomposing scenes reasonably well from a single input image. With more images, renders become sharper and decompositions more accurate.
181
+
182
+ As the second relevant prior method, we have performed experiments with uORF [40]. Despite guidance from the authors, uORF failed to scale meaningfully to the most interesting MSN-Hard dataset. This mainly resulted from a lack of model capacity. Additionally, the large number of objects in this setting led to prohibitive memory requirements of the method, forcing us to lower model capacity even further, or to run the model with fewer slots to be able to fit it even on an Nvidia A100 GPU with 40 GB of VRAM. We describe this further with results in the appendix.
183
+
184
+ # 4.2 Ablations and model analysis
185
+
186
+ We conduct several studies into the behavior of the proposed model including changes to architecture, training setup, or data distribution. Unless stated otherwise, all investigations in this section are conducted on the MSN-Hard dataset with 5 input views. Further qualitative results for these experiments are provided in the appendix.
187
+
188
+ Decoder architecture. As described in Sec. 2.4 and shown in Fig. 2, the novel Slot Mixer decoder differs significantly from the default SRT decoder [29], as well as from the Spatial Broadcast (SB) decoder that is commonly used in conjunction with Slot Attention. To show the strengths of the SM decoder, we compare it with these alternative decoders switched in to the model, see Tab. 2.
189
+
190
+ Table 2: OSRT decoder variants – Slot Mixer combines SRT’s efficiency with SB’s object decomposition abilities. Results on simpler datasets are shown in Tab. 4.
191
+
192
+ <table><tr><td>MSN-Hard</td><td>PSNR</td><td>FG-ARI</td><td>FPS</td></tr><tr><td>SRT Decoder</td><td>24.40</td><td>0.330</td><td>40.98</td></tr><tr><td>Spatial Broadcast (SB)</td><td>23.35</td><td>0.801</td><td>1.39</td></tr><tr><td>Slot Mixer (SM)</td><td>23.54</td><td>0.812</td><td>32.47</td></tr></table>
193
+
194
+ ![](images/e445d55a94ebcb274867e9754e888c26b1c36ecce77e18ee89c426264098916a.jpg)
195
+ Figure 4: Qualitative results on MSN-Hard – Comparison of our method with one and five input views with ObSuRF, which can only operate on a single image. OSRT produces sharper renders with better scene decompositions.
196
+
197
+ While the SRT decoder achieves slightly higher reconstruction quality due to the powerful transformer, it does not yield useful object decompositions as a result of the global information aggregation across all slots, disincentivizing object separation in the slots. It is the key design choice in Slot Mixer to only use a transformer for slot mixing, but not for decoding the slots, that leads to good decomposition.
198
+
199
+ The SB decoder performs similarly to Slot Mixer both in terms of reconstruction and decomposition. However, due to the slot-wise decoding, it requires considerably more memory, which can often be prohibitive during training, and hamper scalability to more complex datasets or large numbers of objects. For the same reason, it also requires significantly more compute at training and for inference.
200
+
201
+ Role of novel view synthesis. Our experiments have demonstrated OSRT’s strengths in the default novel view synthesis (NVS) setup. We now investigate the role of NVS on scene decomposition, on the complex MSN-Hard dataset.
202
+
203
+ To this end, we surgically remove the NVS component from the method, while keeping all other factors unchanged, by training OSRT with the input views equaling the target views to be reconstructed. This effectively turns OSRT into a multi-2D image auto-encoder, albeit with 3D-centric poses rather than pure 2D positional encoding for ray parametrization.
204
+
205
+ The resulting method achieves a much better PSNR of 28.14, 4.60 db higher than OSRT in the NVS setup (23.54). This is expected, as the model only needs to reconstruct the target images rather than needing to generate arbitrary novel views of the scene. However, the model fails to decompose the scene into objects, only achieving an FG-ARI of 0.198 compared to OSRT’s FG-ARI of 0.812, demonstrating the advantage of using NVS as an auxiliary task for unsupervised scene decomposition.
206
+
207
+ ![](images/7dbba4588315f53526a58d4b34f47536466d8dcca0fa75d788c027e142cac270.jpg)
208
+ Figure 5: OSRT trained on MSN-Hard (in color) is evaluated with grayscale input images at test time. We observe that the model generalizes remarkably well to this out-of-distribution setting. This indicates that OSRT does not just rely on color for decomposition.
209
+
210
+ Robustness. We begin with a closer glance at the results obtained by OSRT (5) on MSN-Hard based on the number of objects in the scene. We find that the FG-ARI scores for scenes with the smallest (16) and largest (31) number of objects are within an acceptable range: 0.854 vs. 0.753.
211
+
212
+ To explore whether OSRT mainly relies on RGB color for scene decomposition, we evaluate it on a grayscale version of the difficult test set of MSN-Hard. Note that the model was trained on RGB and has not encountered grayscale images at all during training. We find that OSRT generalizes remarkably well to this out-of-distribution setting, still producing satisfactory reconstructions and scene decompositions that are almost up to par with the colored test set at FG-ARI of 0.780 vs. 0.812 on the default RGB images. Fig. 5 shows an example result for this experiment.
213
+
214
+ We also consider to what extent OSRT is capable of leveraging additional context at test time in the form of additional input views. We train OSRT (3) with three input views and then evaluate it using three (PSNR: 22.75, FG-ARI: 0.794) and five input views (PSNR: 23.47, FG-ARI: 0.813). These results clearly indicate that additional input views can be used to boost performance at test-time.
215
+
216
+ Finally, we train OSRT in two setups inspired by SRT variants [29]: UpOSRT, trained without input view poses, and VOSRT, using volumetric rendering. We find that both of these achieve good reconstruction quality at PSNR’s of 22.42 and 21.38 and meaningful scene decompositions at 0.798 and 0.767 FG-ARI, respectively.
217
+
218
+ Scene editing. We investigate OSRT’s ability for simple scene editing. Fig. 6 (left) shows the a novel view rendered by OSRT. When the slot corresponding to the large object is removed from the SlotSR (center), the rendered image reveals previously occluded objects. We can go one step further by adding a slot from a different scene (right) to the SlotSR, leading to the object being rendered in place with correct occlusions.
219
+
220
+ ![](images/55441065263a5e3ba19826405811a1f3584f30fa3e18faf1653765839054db6b.jpg)
221
+ Figure 6: Novel view (left) with a slot removed (center) or a slot added from another scene (right).
222
+
223
+ 3D consistency. An important question with regards to novel view synthesis is whether the resulting scene and object decomposition are 3D-consistent. Prior work has demonstrated SRT’s spatial consistency despite its light field formulation [29]. Here, we investigate OSRT 3D-consistency with regards to the learned decomposition.
224
+
225
+ To measure this quantitatively, we compute the ratio between the FG-ARI as reported previously— computed on all views together—and the 2D-FG-ARI which is the average of the FG-ARI scores for each individual target view. While FG-ARI takes into account 3D consistency, 2D-FG-ARI is unaffected by 3D inconsistencies such as permuting slot-assignments between views. By definition, 2D-FG-ARI is an upper bound on FG-ARI. Hence, an FG-ARI ratio of 1.0 indicates that the novel views are perfectly 3D-consistent, while lower values indicate that some inconsistency took place.
226
+
227
+ We observe that our approach consistently achieves very high 3D consistency in scene decompositions, with an FG-ARI ratio of 0.940 on the challenging MSN-Hard dataset. With 5 input views, OSRT achieves an even higher ratio of 0.987. Despite its volumetric parametrization, we find that ObSuRF often fails to produce consistent assignments with an FG-ARI ratio of only 0.707.
228
+
229
+ Table 3: OSRT generalization on CLEVR-3D – OSRT trained on scenes with 3-6 objects is tested on scenes with 3–6, and 7-10 objects, respectively. Both with learned and random slot initializations, OSRT generalizes reasonably to the presented out-of distribution (OOD) setting with more objects than during training. The slight drop in performance is mostly a result of more pixels being covered by objects rather than the simpler background.
230
+
231
+ <table><tr><td>3-6 objects (IID)</td><td>PSNR</td><td>FG-ARI</td></tr><tr><td>Learned init.</td><td>40.84</td><td>0.996</td></tr><tr><td>Random init.</td><td>38.14</td><td>0.988</td></tr></table>
232
+
233
+ <table><tr><td>7-10 objects (OOD)</td><td>PSNR</td><td>FG-ARI</td></tr><tr><td>Learned init.</td><td>33.03</td><td>0.955</td></tr><tr><td>Random init.</td><td>33.36</td><td>0.968</td></tr></table>
234
+
235
+ Out-of-distribution generalization. We investigate the ability of the model to generalize to more objects at test time than were observed at training time. To this end, we trained OSRT either with 7 randomly initialized slots, or with 11 slots using a learned initialization, on CLEVR-3D scenes containing up to 6 objects. At test time, we evaluate on scenes containing 7-10 objects by using 11 slots for both model variants.
236
+
237
+ The results are shown in Tab. 3. We find that generalization performance in terms of PSNR and FG-ARI is similarly good for both models, with a slight advantage for the model variant with random slot initialization. In terms of in-distribution performance, learned initialization appears to have an advantage in both metrics.
238
+
239
+ # 4.3 Limitations
240
+
241
+ In our experimental evaluation of OSRT, we came across the following two limitations that are worth highlighting: 1) while the object segmentation masks produced by OSRT often tightly enclose the underlying object, this is not always the case and we find that emergent masks can "bleed" into the background, and 2) OSRT can, for some architectural choices, fall into a failure mode in which it produces a 3D-spatial Voronoi tessellation of the scene instead of clear object segmentation, resulting in a substantial drop in FG-ARI.
242
+
243
+ While the alternative, yet much more inefficient, SB decoder does not seem to be affected by this, mask bleeding [9] effects and tesselation failure modes [18] are not uncommon in object-centric models. We show more examples and comparisons between the different architectures in the appendix.
244
+
245
+ # 5 Conclusion
246
+
247
+ We present Object Scene Representation Transformer (OSRT), an efficient and scalable architecture for unsupervised neural scene decomposition and rendering. By leveraging recent advances in object-centric and neural scene representation learning, OSRT enables decomposition of complex visual scenes, far beyond what existing methods are able to address. Moreover, its novel Slot Mixer decoder enables highly efficient novel view synthesis, making OSRT more than $3 0 0 0 \times$ faster than prior works. Future work has the potential to elevate such methods beyond modeling static scenes, instead allowing for moving objects. We believe that our contributions will significantly support model design and scaling efforts for object-centric geometric scene understanding.
248
+
249
+ # Acknowledgments
250
+
251
+ We thank Karl Stelzner and Hong-Xing Yu for their responsive feedback and guidance on the respective baselines, Mike Mozer for helpful feedback on the manuscript, Noha Radwan and Etienne Pot for help and guidance with datasets, and the anonymous reviewers for the helpful feedback.
252
+
253
+ References
254
+ [1] Titas Anciukevicius, Christoph H Lampert, and Paul Henderson. Object-centric image generation with factored depths, locations, and appearances. arXiv preprint arXiv:2004.00642, 2020.
255
+ [2] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. NeurIPS Deep Learning Symposium, 2016.
256
+ [3] Christopher P Burgess, Loic Matthey, Nicholas Watters, Rishabh Kabra, Irina Higgins, Matt Botvinick, and Alexander Lerchner. Monet: Unsupervised scene decomposition and representation. arXiv preprint arXiv:1901.11390, 2019.
257
+ [4] Lluis Castrejon, Nicolas Ballas, and Aaron Courville. Inferno: Inferring object-centric 3d scene representations without supervision, 2021. URL https://openreview.net/forum?id $\ c =$ YVa8X_2I1b.
258
+ [5] Chang Chen, Fei Deng, and Sungjin Ahn. Roots: Object-centric representation and rendering of 3d scenes. J. Mach. Learn. Res., 22:259–1, 2021.
259
+ [6] Kyunghyun Cho, Bart van Merriënboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder–decoder for statistical machine translation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2014.
260
+ [7] SM Ali Eslami, Danilo Jimenez Rezende, Frederic Besse, Fabio Viola, Ari S Morcos, Marta Garnelo, Avraham Ruderman, Andrei A Rusu, Ivo Danihelka, Karol Gregor, et al. Neural scene representation and rendering. Science, 2018.
261
+ [8] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In NeurIPS, 2014.
262
+ [9] Klaus Greff, Raphaël Lopez Kaufman, Rishabh Kabra, Nick Watters, Christopher Burgess, Daniel Zoran, Loic Matthey, Matthew Botvinick, and Alexander Lerchner. Multi-object representation learning with iterative variational inference. In ICML, 2019.
263
+ [10] Klaus Greff, Sjoerd Van Steenkiste, and Jürgen Schmidhuber. On the binding problem in artificial neural networks. arXiv preprint arXiv:2012.05208, 2020.
264
+ [11] Klaus Greff, Francois Belletti, Lucas Beyer, Carl Doersch, Yilun Du, Daniel Duckworth, David J Fleet, Dan Gnanapragasam, Florian Golemo, Charles Herrmann, Thomas Kipf, Abhijit Kundu, Dmitry Lagun, Issam Laradji, Hsueh-Ti (Derek) Liu, Henning Meyer, Yishu Miao, Derek Nowrouzezahrai, Cengiz Oztireli, Etienne Pot, Noha Radwan, Daniel Rebain, Sara Sabour, Mehdi S. M. Sajjadi, Matan Sela, Vincent Sitzmann, Austin Stone, Deqing Sun, Suhani Vora, Ziyu Wang, Tianhao Wu, Kwang Moo Yi, Fangcheng Zhong, and Andrea Tagliasacchi. Kubric: A Scalable Dataset Generator. In CVPR, 2022.
265
+ [12] Richard Hartley and Andrew Zisserman. Multiple view geometry in computer vision. Cambridge University Press, 2003.
266
+ [13] Lawrence Hubert and Phipps Arabie. Comparing partitions. Journal of Classification, 1985.
267
+ [14] Max Jaderberg, Karen Simonyan, Andrew Zisserman, and Koray Kavukcuoglu. Spatial transformer networks. 28, 2015.
268
+ [15] Wongbong Jang and Lourdes Agapito. CodeNeRF: Disentangled Neural Radiance Fields for Object Categories. In ICCV, 2021.
269
+ [16] Justin Johnson, Bharath Hariharan, Laurens Van Der Maaten, Li Fei-Fei, C Lawrence Zitnick, and Ross Girshick. CLEVR: A diagnostic dataset for compositional language and elementary visual reasoning. In CVPR, pages 2901–2910, 2017.
270
+ [17] Rishabh Kabra, Daniel Zoran, Goker Erdogan, Loic Matthey, Antonia Creswell, Matt Botvinick, Alexander Lerchner, and Chris Burgess. Simone: View-invariant, temporally-abstracted object representations via unsupervised video decomposition. In NeurIPS, volume 34, 2021.
271
+ [18] Laurynas Karazija, Iro Laina, and Christian Rupprecht. ClevrTex: A texture-rich benchmark for unsupervised multi-object segmentation. In NeurIPS Track on Datasets and Benchmarks, 2021.
272
+ [19] Thomas Kipf, Gamaleldin F Elsayed, Aravindh Mahendran, Austin Stone, Sara Sabour, Georg Heigold, Rico Jonschkowski, Alexey Dosovitskiy, and Klaus Greff. Conditional object-centric learning from video. In ICLR, 2022.
273
+ [20] Adam Kosiorek, Heiko Strathmann, Daniel Zoran, Pol Moreno, Rosalia Schneider, Sona Mokrá, and Danilo Rezende. NeRF-VAE: A Geometry Aware 3D Scene Generative Model. In ICML, 2021.
274
+ [21] Zhixuan Lin, Yi-Fu Wu, Skand Vishwanath Peri, Weihao Sun, Gautam Singh, Fei Deng, Jindong Jiang, and Sungjin Ahn. SPACE: Unsupervised object-oriented scene representation via spatial attention and decomposition. In ICLR, 2020.
275
+ [22] Li Liu, Wanli Ouyang, Xiaogang Wang, Paul Fieguth, Jie Chen, Xinwang Liu, and Matti Pietikäinen. Deep learning for generic object detection: A survey. IJCV, 2020.
276
+ [23] Francesco Locatello, Dirk Weissenborn, Thomas Unterthiner, Aravindh Mahendran, Georg Heigold, Jakob Uszkoreit, Alexey Dosovitskiy, and Thomas Kipf. Object-centric learning with slot attention. In NeurIPS, 2020.
277
+ [24] Ricardo Martin-Brualla, Noha Radwan, Mehdi S. M. Sajjadi, Jonathan Barron, Alexey Dosovitskiy, and Daniel Duckworth. NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections. In CVPR, 2021.
278
+ [25] Ben Mildenhall, Pratul Srinivasan, Matthew Tancik, Jonathan Barron, Ravi Ramamoorthi, and Ren Ng. NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis. In ECCV, 2020.
279
+ [26] Michael Niemeyer and Andreas Geiger. GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields. In CVPR, 2021.
280
+ [27] William M Rand. Objective criteria for the evaluation of clustering methods. Journal of the American Statistical Association, 66(336), 1971.
281
+ [28] Robin Rombach, Patrick Esser, and Björn Ommer. Geometry-free view synthesis: Transformers and no 3d priors. In ICCV, 2021.
282
+ [29] Mehdi S. M. Sajjadi, Henning Meyer, Etienne Pot, Urs Bergmann, Klaus Greff, Noha Radwan, Suhani Vora, Mario Lucic, Daniel Duckworth, Alexey Dosovitskiy, Jakob Uszkoreit, Thomas Funkhouser, and Andrea Tagliasacchi. Scene Representation Transformer: Geometry-Free Novel View Synthesis Through Set-Latent Scene Representations. In CVPR, 2022.
283
+ [30] Gautam Singh, Fei Deng, and Sungjin Ahn. Illiterate dall-e learns to compose. In ICLR, 2022.
284
+ [31] Vincent Sitzmann, Michael Zollhöfer, and Gordon Wetzstein. Scene Representation Networks: Continuous 3D-Structure-Aware Neural Scene Representations. In NeurIPS, 2019.
285
+ [32] Elizabeth S Spelke and Katherine D Kinzler. Core knowledge. Developmental science, 10(1):89–96, 2007.
286
+ [33] Karl Stelzner, Kristian Kersting, and Adam R Kosiorek. Decomposing 3d scenes into objects via unsupervised volume segmentation. arXiv preprint arXiv:2104.01148, 2021.
287
+ [34] Ayush Tewari, Justus Thies, Ben Mildenhall, Pratul Srinivasan, Edgar Tretschk, Yifan Wang, Christoph Lassner, Vincent Sitzmann, Ricardo Martin-Brualla, Stephen Lombardi, et al. Advances in neural rendering. Eurographics, 2022.
288
+ [35] Alex Trevithick and Bo Yang. GRF: Learning a General Radiance Field for 3D Scene Representation and Rendering. In ICCV, 2021.
289
+ [36] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
290
+ [37] Nicholas Watters, Loic Matthey, Christopher P Burgess, and Alexander Lerchner. Spatial broadcast decoder: A simple architecture for learning disentangled representations in vaes. arXiv preprint arXiv:1901.07017, 2019.
291
+ [38] Ruibin Xiong, Yunchang Yang, Di He, Kai Zheng, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, and Tieyan Liu. On layer normalization in the transformer architecture. In ICML, 2020.
292
+ [39] Alex Yu, Vickie Ye, Matthew Tancik, and Angjoo Kanazawa. pixelNeRF: Neural Radiance Fields from One or Few Images. In CVPR, 2021.
293
+ [40] Hong-Xing Yu, Leonidas J Guibas, and Jiajun Wu. Unsupervised discovery of object radiance fields. In ICLR, 2022.
294
+
295
+ # Checklist
296
+
297
+ 1. For all authors...
298
+
299
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
300
+ (b) Did you describe the limitations of your work? [Yes] See section titled Limitations.
301
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See appendix.
302
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
303
+
304
+ 2. If you are including theoretical results...
305
+
306
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
307
+
308
+ 3. If you ran experiments...
309
+
310
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] The new MSN-Hard dataset is published on the website.
311
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See experimental section and appendix.
312
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The experiments require lot of compute and so use only a single seed.
313
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See experimental section and appendix.
314
+
315
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
316
+
317
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
318
+ (b) Did you mention the license of the assets? [Yes]
319
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] The new MSN-hard dataset is published on the website.
320
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
321
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] We only use synthetically generated datasets of common household objects.
322
+
323
+ 5. If you used crowdsourcing or conducted research with human subjects...
324
+
325
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
326
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
327
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
parse/train/0oabwyZbOu/0oabwyZbOu_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b50c8d364d615ca5826f504049c59518858ede391fa463d052d134a45ed400f5
3
+ size 5482183
parse/train/0oabwyZbOu/0oabwyZbOu_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d46094786339626d6977aec3756132831967179c77144f4fd48ab1f9ebca54d
3
+ size 5261219
parse/train/0oabwyZbOu/0oabwyZbOu_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf2c2dc44291cfe77b3a82ea683eb5dd0caa40a36c580aff6caee9bb9ac49e08
3
+ size 5491320
parse/train/4AWko4A35ss/4AWko4A35ss_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db8f9a1717889d353e3696358495fcd2fee75e589f67576cad7c6de8afa92e80
3
+ size 1189015
parse/train/4AWko4A35ss/4AWko4A35ss_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb48dbdd4fe426b784245a728a8007f9f06e8e6cb30a7acb98d4bcd54b0d2ab9
3
+ size 1022915
parse/train/4AWko4A35ss/4AWko4A35ss_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83a729614204f573d4da2cdaeebc644eb36151664cfe70c322e11c91c1f5c5b8
3
+ size 1193067
parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c567430dcc689e42134494fcfb0684ca5a8d03a2db7cef7d45f59779d201fbf7
3
+ size 1546471
parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d625c96cda190fd1f2151bf375950f7e239427aaa8c04850917c8c969dd9c33c
3
+ size 632372
parse/train/4i23Bjlh4Y9/4i23Bjlh4Y9_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8dc65f0b5a0434983adb25a8a20cca5762a221384fcaf1e6e246731a42f5579
3
+ size 1574898
parse/train/B1gabhRcYX/B1gabhRcYX_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78cb79437f483286ae554e38a48b84549c1e261da152284a7d817539aa43792e
3
+ size 13513598
parse/train/B1gabhRcYX/B1gabhRcYX_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff31ab4a49079feab3481be24d5a735d492237733c3727763ebd5633f79a7416
3
+ size 13306767
parse/train/B1gabhRcYX/B1gabhRcYX_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ada1fd2702504dfe8839bc4607f556c40a0c7dc9f0c54d2730c9e9a4160d612
3
+ size 13516376
parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ffaaad8b89c567cd6b616d58208c7375f18d06d73af3f6f53d592c8a10321645
3
+ size 555207
parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75a9b9063d622d08ab1fe7e7ea2aefbccbafc7d3858f90c050e286702d674199
3
+ size 439778
parse/train/BBIbj9w8Lvj8F/BBIbj9w8Lvj8F_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21c0e3cf6039b718a601ac0e685eccd037f2bad734bb74fea3c92aae42be5324
3
+ size 559821
parse/train/BJ8vJebC-/BJ8vJebC-_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e0b08eefcb01175cb7f4fdf3494550ec9a7c04b7e1a0f8f2fced1f719141082
3
+ size 768770
parse/train/BJ8vJebC-/BJ8vJebC-_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:192f34775a40f05154ef6074b95532aaaca82bea8cedde614eebe6a2b666ea7f
3
+ size 627168
parse/train/BJ8vJebC-/BJ8vJebC-_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0cf19bb983dc2e7520643ef4aa684f9376ce5c974c6e5f5034899d9132ccf8f6
3
+ size 765805
parse/train/BJC_jUqxe/BJC_jUqxe_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b958e14dedb3679be38605e3d7822c6170a25261999961eece79930c3a787c41
3
+ size 2731908
parse/train/BJC_jUqxe/BJC_jUqxe_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42ea416cb0ef401311f507468b0d37cbf2f7e6e9f3e0f2334efe00feb1055b24
3
+ size 2609435
parse/train/BJC_jUqxe/BJC_jUqxe_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f39c200c84ab20f7c9c582bc437dbd1fe16381dc1a541a3c521da312acda501
3
+ size 2735697