COFAR: Commonsense and Factual Reasoning in
Image Search

Prajwal Gatti1, Abhirama Subramanyam Penamakuri1, Revant Teotia2, Anand Mishra1,

Shubhashis Sengupta3, Roshni Ramnani3

1Indian Institute of Technology Jodhpur, 2Columbia University, 3Accenture Labs


[Paper] [Code] [Poster] [Short Talk] [Slides] [arXiv]



One characteristic that makes humans superior to modern artificially intelligent models is the ability to interpret images beyond what is visually apparent. Consider the following two natural language search queries – (i) “a queue of customers patiently waiting to buy ice cream” and (ii) “a queue of tourists going to see a famous Mughal architecture in India”. Interpreting these queries requires one to reason with (i) Commonsense such as interpreting people as customers or tourists, actions as waiting to buy or going to see; and (ii) Fact or world knowledge associated with named visual entities, for example, whether the store in the image sells ice cream or whether the landmark in the image is a Mughal architecture located in India. Such reasoning goes beyond just visual recognition. To enable both commonsense and factual reasoning in the image search, we present a unified framework namely Knowledge Retrieval-Augmented Multimodal Transformer (KRAMT) that treats the named visual entities in an image as a gateway to encyclopedic knowledge and leverages them along with natural language query to ground relevant knowledge. Further, KRAMT seamlessly integrates visual content and grounded knowledge to learn alignment between images and search queries. This unified framework is then used to perform image search requiring commonsense and factual reasoning. The retrieval performance of KRAMT is evaluated and compared with related approaches on a new dataset we introduce – namely COFAR.


  • Introduced a novel task of Image Search requiring Commonsense and Factual Reasoning associated with visual named entities.
  • Introduced a novel dataset COFAR containing 25K+ images having 40K+ search queries.
  • Proposed KRAMT: Knowledge-Retrieval Augmented Multimodal Transformer that performs named visual entity linking followed by retrieval of related factual knowledge to find the matching image from a database of images.

Dataset Downloads

Explore COFAR dataset: [Gallery]
  1. Dataset Images [Image URLs] (585 KB)
  2. Train Data [Image-Caption pairs] (313 KB)
  3. Test Data
    1. COFAR-unified (285 KB)
    2. COFAR-brand (265 KB)
    3. COFAR-celeb (71 KB)
    4. COFAR-landmark (20 KB)
  4. Knowledge Bases
    1. KB-brand (274 KB)
    2. KB-celeb (553 KB)
    3. KB-landmark (431 KB)
  5. Image Feature Extraction [Script]


Please cite our work as follows:

  author    = "Gatti, Prajwal and 
              Penamakuri, Abhirama Subramanyam and
              Teotia, Revant and
              Mishra, Anand and
              Sengupta, Shubhashis and
              Ramnani, Roshni",
  title     = "COFAR: Commonsense and Factual Reasoning in Image Search",
  booktitle = "AACL-IJCNLP",
  year      = "2022",


Abhirama S. Penamakuri is supported by Prime Minister Research Fellowship (PMRF), Minsitry of Education, Government of India.
We thank Accenture Labs for supporting this work.