A Sequence-Oblivious Generation Method for Context-Aware Hashtag Recommendation

Junmo Kang, Jeonghwan Kim, Suwon Shin, Sung-Hyon Myaeng

Abstract

Tag recommendation relies on either a ranking function for top-$k$ tags or an autoregressive generation method. However, previous methods neglect one of two seemingly conflicting yet desirable characteristics of a tag set: orderlessness and inter-dependency. While the ranking approach fails to address the inter-dependency among tags when they are ranked, the autoregressive approach fails to take orderlessness into account because it is designed to utilize sequential relations among tokens. We propose a sequence-oblivious generation method for tag recommendation, in which the next tag to be generated is independent of the order of the generated tags and the order of the ground truth tags occurring in training data. Empirical results on two different domains, Instagram and Stack Overflow, show that our method is significantly superior to the previous approaches.

Introduction

Hashtag recommendation is a critical task for content discoverability on social media and technical platforms. Traditionally, this problem has been framed in two ways: as a Ranking task or an Autoregressive (AR) Generation task.

Ranking methods treat tags as independent entities, failing to capture the semantic inter-dependency between them (e.g., the co-occurrence of #sunset and #beach). Conversely, AR models, borrowed from natural language processing, treat tags as a sequence. This introduces artificial constraints because tag sets are inherently orderless; the set {#beach, #sunset} is semantically identical to {#sunset, #beach}. Forcing a specific sequence during training can confuse models and degrade performance.

Conceptual comparison of Ranking, Autoregressive, and the proposed Sequence-Oblivious Generation (SOG) approaches.

To address these limitations, we introduce Sequence-Oblivious Generation (SOG). SOG bridges the gap by treating tags as an interdependent but unordered set, allowing for flexible generation that respects the natural structure of hashtag data.

Methodology: Sequence-Oblivious Generation

SOG utilizes a Transformer Encoder (BERT) rather than a traditional decoder. The core of the method lies in three technical innovations:

1. Iterative Masked Prediction

Instead of predicting a sequence, SOG uses a [MASK] token to predict the next most relevant tag. Once a tag is generated, it is appended to the input context, and the model iteratively predicts the next [MASK] until a termination condition is met. This ensures that every previously generated tag has an equal influence on the next choice, regardless of its position.

2. 1-to-M Training

Standard AR models use 1-to-1 mapping, where the model is penalized if it does not predict the exact next tag in a ground-truth sequence. SOG employs a 1-to-M (one-to-many) mapping strategy. During training, the model is encouraged to predict any of the remaining correct tags at any given step. This is achieved using KL-divergence loss, which treats all valid remaining tags as equally probable targets.

3. Early Multi-modal Fusion

For multi-modal contexts like Instagram, SOG performs early fusion by converting all inputs—including image captions, location names, and timestamps—into text tokens. These are fed into BERT simultaneously, allowing the self-attention mechanism to learn complex cross-modal correlations.

The SOG model architecture illustrating multi-modal input fusion and the iterative BERT-based generation process.

Experimental Results

We evaluated SOG against state-of-the-art baselines on two datasets: Instagram (~88k multi-modal posts) and Stack Overflow (~81k text-centric posts).

  • Performance: SOG significantly outperformed both ranking and AR models. On Instagram, SOG achieved a Precision@1 of 51.85%, a substantial lead over ranking (41.78%) and AR (37.34%). On Stack Overflow, SOG reached 67.87% Precision@1.
  • Search Strategy: Interestingly, while natural language tasks often benefit from Beam Search, we found that Greedy Search is superior for tag recommendation. Because tags lack strict syntax, trying to find a globally likely "sequence" via Beam Search often distracts from finding the most relevant individual tags.
  • Ablation Study: Removing multi-modal components (image, time, or location) led to performance drops, confirming that the early fusion approach effectively leverages contextual metadata.

Conclusion

Sequence-Oblivious Generation (SOG) successfully addresses the conflict between orderlessness and inter-dependency in hashtag recommendation. By leveraging the bidirectional attention of BERT and a 1-to-M training objective, SOG provides a more natural and effective framework for generating tag sets. Future work will explore applying this framework to other non-sequential tasks such as multi-label classification and e-commerce set recommendations.

Summary updated

Abstract

Tag recommendation relies on either a ranking function for top-$k$ tags or an autoregressive generation method. However, the previous methods neglect one of two seemingly conflicting yet desirable characteristics of a tag set: orderlessness and inter-dependency. While the ranking approach fails to address the inter-dependency among tags when they are ranked, the autoregressive approach fails to take orderlessness into account because it is designed to utilize sequential relations among tokens. We propose a sequence-oblivious generation method for tag recommendation, in which the next tag to be generated is independent of the order of the generated tags and the order of the ground truth tags occurring in training data. Empirical results on two different domains, Instagram and Stack Overflow, show that our method is significantly superior to the previous approaches.
BibTeX
@inproceedings{kang2021sequence,
  author = {Junmo Kang and Jeonghwan Kim and Suwon Shin and Sung-Hyon Myaeng},
  title = {{A Sequence-Oblivious Generation Method for Context-Aware Hashtag Recommendation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=LWC49N2QPP},
}
Figure