Modeling Comparative Logical Relation with Contrastive Learning for Text Generation

Yuhao Dan, Junfeng Tian, Jie Zhou, Ming Yan, Ji Zhang, Qin Chen, Liang He

TL;DR

Researchers have introduced CoLo (Comparative Logic), a novel framework that uses two-stage contrastive learning to help AI models generate text based on complex comparisons between entities. Alongside this method, they released CLRD, the first high-quality human-annotated Chinese dataset specifically designed for comparative logical relations in data-to-text generation.

What Problem Does This Paper Address?

Data-to-Text (D2T) generation is the task of turning structured data (like a table of product specs) into natural language. While current models are great at describing a single product or simple "associative" links (e.g., "This movie was directed by X"), they struggle with Comparative Logical Relations (CLRs).

In the real world, we don't just list facts; we compare. We say, "Product A is better than Product B in terms of price, but Product B has better quality." This is difficult for AI because it requires a deep understanding of:

  1. Entity Order: Swapping "A" and "B" completely changes the meaning.
  2. Multi-element Alignment: The model must correctly link the specific aspect (e.g., price) with the correct opinion (e.g., cheaper) for the right entity.
  3. Logical Consistency: Standard models often hallucinate or lose track of who is being compared to whom by the end of a sentence.

Methods

The authors propose the CoLo method, which injects comparative logic into the model via two stages of contrastive learning:

  1. Contrastive Sample Construction: To teach the model what not to do, they created "hard" negative samples. For a given comparison, they generated versions where they swapped the entities, substituted the aspect (e.g., changing "price" to "fragrance"), or flipped the opinion (using antonyms).
  2. Contrastive Encoding (CE): In the encoder stage, the model is trained to ensure that the mathematical representation (embedding) of a correct comparison is very different from the representation of a "swapped" or "incorrect" comparison. This forces the model to be sensitive to entity order.
  3. Contrastive Decoding (CD): This stage ensures the generated text actually follows the input logic. It aligns the decoder's hidden states with the encoder's logical representations, acting as a "guardrail" to keep the generation on track.

Datasets

The paper introduces the Chinese Comparative Logical Relation Dataset (CLRD).

  • Size: 15,104 data points.
  • Content: E-commerce beauty product reviews containing rich comparisons.
  • Uniqueness: Unlike existing datasets (like WebNLG or E2E) which focus on single entities or simple relations, CLRD requires describing multiple entities and their specific comparative logic. It also features much longer average text lengths (~120 words), making it a more rigorous benchmark.

Key Insights and Ideas

  • The "Order-Insensitivity" Gap: The authors found that standard pre-trained models are surprisingly insensitive to the order of entities in a tuple. CoLo’s "Entity Swapping" contrastive strategy was specifically designed to break this habit.
  • Small Models, Big Logic: By using contrastive learning, a relatively small model (0.58B parameters) can achieve logical consistency scores (Entailment and Coverage) that rival or approach much larger models like GPT-3.5.
  • Two Stages are Better Than One: The ablation studies showed that removing either the Contrastive Encoding or the Contrastive Decoding led to a significant drop in performance. You need the model to understand the logic (Encoding) and adhere to it during writing (Decoding).

Key Results

  • Automatic Evaluation: CoLo outperformed strong baselines like BART and mT5 across almost all metrics. Most notably, it achieved a 55.88 Entailment score, significantly higher than mT5 (48.24), proving it follows the input logic more faithfully.
  • Comparison with GPT-3.5: While GPT-3.5 is a much larger "black box" model, CoLo (at only 0.58B parameters) achieved over 85% of GPT-3.5's performance on logical metrics while actually outperforming it on traditional translation metrics like BLEU and ROUGE-L (likely due to fine-tuning on domain-specific data).
  • Human Evaluation: Human judges rated CoLo higher than all other trainable baselines in Fluency, Entity accuracy, and Relation correctness.

Limitations and Future Work

  • Complexity of Relations: The current work focuses on relatively straightforward "A is better than B" relations. The authors acknowledge that real-world logic can be much more "entangled" and complex.
  • Sample Construction: While the current perturbation strategies (swapping, substitution) are effective, the authors suggest that exploring even more sophisticated ways to construct contrastive samples could further boost performance.
  • Language Scope: The current dataset and evaluation are focused on Chinese; extending this framework to other languages and more diverse domains (beyond e-commerce) remains a future goal.

Summary updated

BibTeX
@inproceedings{dan2024modeling,
  author = {Yuhao Dan and Junfeng Tian and Jie Zhou and Ming Yan and Ji Zhang and Qin Chen and Liang He},
  title = {{Modeling Comparative Logical Relation with Contrastive Learning for Text Generation}},
  booktitle = {NLPCC},
  year = {2024},
  url = {https://openreview.net/forum?id=ET5rd4S9Di},
}

Loading related content...

Figure