Idan commited on
Commit
07d2bcd
·
verified ·
1 Parent(s): e955607

Add Factor Graph Attention weights (VisDial v1.0, MRR 66.01)

Browse files
Files changed (1) hide show
  1. README.md +16 -6
README.md CHANGED
@@ -129,18 +129,28 @@ Pass `output_attentions=True` to get the per-utility attention distributions for
129
  visualization.
130
 
131
  The attention block is the reusable part of the paper and knows nothing about Visual
132
- Dialog — give it any set of utilities:
133
 
134
  ```python
135
- from fga.attention import Atten, Utility
136
 
137
- attention = Atten.from_utilities([
138
- Utility("text", dim=512, size=20),
139
- Utility("image", dim=2048, size=36),
140
- Utility("history", dim=128, size=21, repeats=9, connected_to=("text", "image")),
 
 
 
 
141
  ], use_prior=True)
142
  ```
143
 
 
 
 
 
 
 
144
  ## Data
145
 
146
  Preprocessed dialogs: [`Idan/visdial-fga-preprocessed`](https://huggingface.co/datasets/Idan/visdial-fga-preprocessed).
 
129
  visualization.
130
 
131
  The attention block is the reusable part of the paper and knows nothing about Visual
132
+ Dialog — it is an ordinary `torch.nn` layer over any set of modalities:
133
 
134
  ```python
135
+ from fga import FactorGraphAttention, Modality
136
 
137
+ attention = FactorGraphAttention(embed_dims=[512, 2048], num_entities=[20, 36])
138
+ pooled_text, pooled_image = attention(text, image)
139
+
140
+ # or declared by name, with a repeated modality sharing factor weights
141
+ attention = FactorGraphAttention.from_modalities([
142
+ Modality("text", dim=512, size=20),
143
+ Modality("image", dim=2048, size=36),
144
+ Modality("history", dim=128, size=21, repeats=9, connected_to=("text", "image")),
145
  ], use_prior=True)
146
  ```
147
 
148
+ The same layer backs the paper's follow-ups in
149
+ [video dialog](https://github.com/idansc/simple-avsd),
150
+ [spatial navigation](https://github.com/barmayo/spatial_attention) and
151
+ [video retrieval](https://github.com/AmeenAli/VideoMatch); their argument names
152
+ (`util_e`, `sizes`, `high_order_utils`, `*_flag`) are all still accepted.
153
+
154
  ## Data
155
 
156
  Preprocessed dialogs: [`Idan/visdial-fga-preprocessed`](https://huggingface.co/datasets/Idan/visdial-fga-preprocessed).