Abstract
Web Image Context Extraction (WICE) consists in obtaining the textual information describing an image using the content of the surrounding webpage. A common preprocessing step before performing WICE is to render the content of the webpage. When done at a large scale (e.g., for search engine indexation), it may become very computationally costly (up to several seconds per page). To avoid this cost, we introduce a novel WICE approach that combines Graph Neural Networks (GNNs) and Natural Language Processing models. Our method relies on a graph model containing both node types and text as features. The model is fed through several blocks of GNNs to extract the textual context. Since no labeled WICE dataset with ground truth exists, we train and evaluate the GNNs on a proxy task that consists in finding the semantically closest text to the image caption. We then interpret importance weights to find the most relevant text nodes and define them as the image context. Thanks to GNNs, our model is able to encode both structural and semantic information from the webpage. We show that our approach gives promising results to help address the large-scale WICE problem using only HTML data.
Introduction
When search engines index images, understanding the surrounding context is vital for accurate retrieval. This task, known as Web Image Context Extraction (WICE), involves identifying which specific text blocks on a webpage describe a given image. Traditionally, state-of-the-art systems rely on visual rendering—using a headless browser to determine the physical proximity of text to an image. However, rendering is a significant computational bottleneck, often taking seconds per page, which is impractical for large-scale web crawling.
This paper proposes a more efficient alternative: a graph-based method that operates directly on the HTML's Document Object Model (DOM) tree. By combining Graph Neural Networks (GNNs) with sentence embeddings, the authors achieve high accuracy without the overhead of full visual rendering.
Methodology
The core of the approach is treating the DOM tree as a graph where nodes represent HTML elements.
Graph Construction and Features
Each node in the graph is characterized by:
- Node Types: One-hot encoded categories such as headers, paragraphs, or lists.
- Sentence Embeddings: Textual content is transformed into high-dimensional vectors using a multilingual Sentence-BERT (SBERT) model.
The Proxy Task and wGCN
A major hurdle in WICE is the lack of large-scale labeled datasets. To overcome this, the authors utilize a proxy task. They identify images that already possess captions or alt-text and train the model to predict the embedding of that reference text based on the rest of the page's structure and content.
The primary innovation is the weight-GCN (wGCN) architecture. Unlike standard GCNs, wGCN learns to assign an importance weight ($w_i$) to every text node. The final output is a weighted average of all text embeddings on the page. During inference, the node with the highest weight is extracted as the most likely context.
Experimental Results
The model was evaluated using a dataset of approximately 120,000 webpages from the Qwant News search index. The researchers tested two data split scenarios: by individual webpages and by entire websites, the latter testing the model's ability to generalize to unseen site structures.
Performance Comparison
The wGCN model significantly outperformed traditional heuristics and other GNN architectures. As shown in the table below, common heuristics like "text after image" or using the page "title" performed poorly, often failing to beat random selection.
In the proxy task, wGCN achieved a cosine similarity loss of 0.339, outperforming standard GCNs (0.406) and Graph Attention Networks (0.439). Crucially, the authors found a 0.96 Pearson correlation between success in the proxy task and success in the actual WICE task, validating their training strategy.
Efficiency
The proposed method is highly efficient, processing a page in approximately 0.429 seconds. Compared to visual rendering, which typically exceeds 1 second, this represents a 3x speedup—a critical factor for production-scale indexing.
Conclusion
By leveraging the structural information of the DOM tree and the semantic power of sentence embeddings, the wGCN model provides a robust and efficient solution for large-scale image context extraction. While performance drops slightly on entirely new website structures (loss increased to 0.441), the approach offers a significant improvement over traditional text-based heuristics and avoids the high cost of visual rendering. Future work may explore incorporating "lightweight" visual features, such as bounding box coordinates, to further bridge the gap between HTML-only and visual-based methods.
Summary updated