/ Модель

Характеристики

Лицензия
MIT
Архитектура
fga · dense
Библиотека
transformers
Опубликована
26 июл 2026

fga

Вопросы по изображениюИзображение, текст → текст3 профессии

FGA — модель визуального диалога, которая ранжирует варианты ответа на вопросы об изображении с учётом истории беседы.

14скачиваний за 30 дней3лайкавеса обновлены26 июл 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Factor Graph Attention (FGA) — модель для визуального диалога, официальная реализация метода, представленного на CVPR 2019. Она оценивает 100 кандидатных ответов на вопрос о содержимом изображения с учётом подписи, истории диалога и визуальных регионов. Архитектура объединяет унарные, внутримодальные, парные и априорные факторы внимания; для истории из девяти раундов веса факторов разделяются. В чекпойнте 52,4 млн параметров.

Модель обучена и оценена на VisDial v1.0; этот чекпойнт настроен на метрику MRR и показывает MRR 66,01 на валидационном разбиении. Она предназначена для ранжирования ответов в диалоге об изображении, а также может служить основой для экспериментов с мультимодальным вниманием. Для работы нужны предварительно обработанные диалоги и отдельные признаки изображений Faster R-CNN размером 37 × 2048; признаки изображений в репозитории не распространяются. Лицензия — MIT.

Сценарии применения

  • Ранжирование ответов в многошаговом диалоге об изображении
  • Подбор наиболее вероятного ответа из списка кандидатов VisDial
  • Оценка влияния истории вопросов и ответов на понимание изображения
  • Эксперименты с факторно-графовым вниманием в мультимодальных моделях

Ограничения

Модель оценивает фиксированный список из 100 кандидатных ответов и требует предварительно извлечённых признаков изображений; они не входят в репозиторий. Этот чекпойнт оптимизирован по MRR, тогда как вариант fga-ndcg ориентирован на NDCG.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Factor Graph Attention

  • A general multimodal attention approach inspired by probabilistic graphical models.
  • Achieves a state-of-the-art performance (MRR) on visual dialog task.

This is the official implementation of Factor Graph Attention. (Appeared in CVPR'19). Code: idansc/fga.

This checkpoint targets MRR. For the NDCG-oriented variant, finetuned on the dense relevance annotations, see Idan/fga-ndcg (NDCG 69.07 against this model's 56.46, at the cost of MRR).

Use cases of FGA:

How it works

Every modality is a set of entities with an embedding each — the 100 candidate answers, the question words, the caption words, the image regions, and the question and answer of each history round. Attention over a modality is the softmax of a sum of learned potentials, exactly as in a factor graph:

  • unary — how salient an entity is on its own,
  • self — how an entity relates to the other entities of the same modality,
  • pairwise — how an entity relates to the entities of every other modality,
  • prior — an external bias, such as sentence-length cues.

The potentials are stacked and combined by a learned, bias-free Conv1d, so the model learns how much to weight each factor. The nine history rounds share one set of factor weights, which is what keeps the interaction affordable.

The model can easily run on a single GPU :) — 52.4M parameters.

Results

Evaluation is done on VisDialv1.0.

VisDial v1.0 contains 1 dialog with 10 question-answer pairs (starting from an image caption) on ~130k images from COCO-trainval and Flickr, totalling ~1.3 million question-answer pairs.

These are the measured numbers for the weights in this repository, on the v1.0 validation split:

MetricR@1R@5R@10MRRMean rankNDCG
This checkpoint (epoch 5)52.4682.9590.9766.013.9256.46
Paper53——66——
5×FGA ensemble (paper)56——69——

Trained for 10 epochs on 8×L40S, ~3 hours. MRR peaks at epoch 5 while NDCG keeps improving to epoch 10 (58.19) — the two metrics disagree, which is the tension the 2020 challenge submission addressed.

Two things differ from the original run and are folded into the small R@1 gap. The image features were re-extracted, because every published copy of the originals has gone offline; the detector is the same one the paper used (Faster R-CNN, ResNeXt-101, fine-tuned on Visual Genome, 36 proposals). And evaluation no longer applies dropout: the original called F.dropout without forwarding self.training, so scoring was mildly stochastic even under model.eval().

Usage

from fga import FGAForVisualDialog

model = FGAForVisualDialog.from_pretrained("Idan/fga")

outputs = model(
    question_input_ids=...,          # (batch, 21)
    option_input_ids=...,            # (batch, 100, 21)
    history_question_input_ids=...,  # (batch, 9, 21)
    history_answer_input_ids=...,    # (batch, 9, 21)
    caption_input_ids=...,           # (batch, 41)
    question_lengths=...,
    option_lengths=...,
    caption_lengths=...,
    image_features=...,              # (batch, 37, 2048)
)
ranking = outputs.logits.argsort(dim=-1, descending=True)

Install with pip install git+https://github.com/idansc/fga.git.

Pass output_attentions=True to get the per-modality attention distributions for visualization.

The attention block is the reusable part of the paper and knows nothing about Visual Dialog — it is an ordinary torch.nn layer over any set of modalities:

from fga import FactorGraphAttention, Modality

attention = FactorGraphAttention(embed_dims=[512, 2048], num_entities=[20, 36])
pooled_text, pooled_image = attention(text, image)

# or declared by name, with weight sharing stated separately
history = [Modality(f"history_{i}", dim=128, size=21, connected_to=("text", "image"))
           for i in range(1, 10)]
attention = FactorGraphAttention.from_modalities(
    [Modality("text", dim=512, size=20), Modality("image", dim=2048, size=36), *history],
    share_weights=[[m.name for m in history]],
    use_prior=True,
)

The same layer backs the paper's follow-ups in video dialog, spatial navigation and video retrieval; their argument names (util_e, sizes, high_order_utils, *_flag) are all still accepted.

Data

Preprocessed dialogs: Idan/visdial-fga-preprocessed.

Image features are not distributed with the model — it expects an h5 with {split}_features of shape (num_images, 37, 2048). See the original paper for performance differences. I recommend using the FRCNN features, mainly because it is finetuned on the relevant VisualGenome dataset. The repository has scripts to regenerate them from the images.

Citation

Please cite Factor Graph Attention if you use this work in your research:

@inproceedings{schwartz2019factor,
  title={Factor graph attention},
  author={Schwartz, Idan and Yu, Seunghak and Hazan, Tamir and Schwing, Alexander G},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={2039--2048},
  year={2019}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Нельзя запустить

Архитектура fga неизвестна transformers в образе рантайма.

Класс архитектуры
FGAForVisualDialog
Ревизия весов
fba45b0

0 моделей