arXiv preprint 2024Preference consistency

ContraSolver: Self-Alignment of Language Models by Resolving Internal Preference Contradictions

Xu Zhang1*, Xunjian Yin1*, Xiaojun Wan1

1 Peking University · * Equal contribution

A model's preferences can contradict each other; ContraSolver finds cycles in those judgments and selects reliable comparisons to improve alignment through DPO.

Result
AdvBench safe-response rate for Llama-2-7b-chat: 90.00% vs 85.96% for Max-Confidence selection of the same number of pairs; human-judged harmless rate 91.0% vs 86.0%.
New vs prior
Self-alignment methods such as ReST train on all of a model’s self-labeled preference pairs; this work selects pairs by resolving contradictory cycles in the model’s preference graph.
Limitation
The method assumes that higher-confidence preferences are more reliable, which the paper notes is not scientifically validated, and it cannot represent ties between responses.
ContraSolver identifies cycles and selects reliable comparisons from a preference graph.
ContraSolver identifies cycles and selects reliable comparisons from a preference graph. Full size ↗

A collection of plausible judgments can be inconsistent

DPO (direct preference optimization) assumes that each response has one latent reward, which implies a strict ordering of the responses to a prompt. Yet a model judging pairs separately can prefer A to B, B to C and C to A; each judgment looks plausible, but together they conflict.

Selecting pairs by confidence alone ignores where a comparison sits in this structure, keeping redundant preferences and missing those that explain a contradiction. ContraSolver treats the responses as a directed graph whose edges are preferences, so a directed cycle exposes a conflict that no single ranking can represent.

Closest prior work

Self-alignment methods such as ReST (Gulcehre et al., 2023) and Guo et al. (2024) train a model on pairwise preferences it generates itself, and, as the paper argues, trust all of those labels regardless of the model’s proficiency. A separate line of work questions whether preferences are transitive and studies learning under a general preference oracle, for example Nash learning from human feedback (Munos et al., 2023). ContraSolver stays within DPO but uses the cycles in a self-annotated preference graph to decide which self-labeled pairs to train on.

Train on the evidence surrounding a contradiction

The algorithm first builds a maximum spanning tree of the strongest comparisons. A reverse pass examines the remaining edges from low to high confidence: an edge that closes a directed cycle is marked contradictory, and the edges on that cycle become candidate training pairs. A forward pass adds stronger edges that give a new ordering and skips those already implied by a path.

Algorithm 1 · illustrative judgments

Which of the model’s own judgments become training pairs?

Five responses to one prompt and ten pairwise judgments. Flip a judgment or change its illustrative confidence: the paper’s graph algorithm reruns and reports the spanning tree, the contradictions, the resulting order, and the pairs it would use for DPO. Play replays the run on the current graph one decision at a time.

One prompt, five sampled continuations · illustrative

Continue the movie review positively: “Another laughably lame and senseless …”

  1. A…premise, but the cast turns it into a warm, genuinely funny film.
  2. B…plot, yet the final act is surprisingly moving.
  3. C…script, with a few good jokes along the way.
  4. D…sequel that I had forgotten by the next morning.
  5. E…mess. I walked out halfway through.

The prefix comes from the paper’s case study (Appendix, Table 8); the continuations are written for this demo. The model judges each pair by asking which continuation is more positive (Table 5), averaging over both answer orders. Its confidence is the edge weight. In this example two judgments, D ≻ B and E ≻ C, disagree with the evident order of the texts.

Preference graph over five responsesArrows point to the less preferred response. DPO pairs: B ≻ C, C ≻ D, D ≻ E. Contradictory: D ≻ B, E ≻ C.
Heuristic edge: DPO pairKept, not trainedContradictoryImplied, skippedNot yet examinedArrow: preferred → less preferred.
DPO pairs · 3 of 10 judgments
B ≻ C, C ≻ D, D ≻ E
Contradictory, not trained
D ≻ B, E ≻ C
Resolved order
A ≻ B ≻ C ≻ D ≻ E
  1. A ≻ B 0.70 Added, pass 3 · not trained
  2. A ≻ C 0.80 Added, pass 2 · not trained
  3. A ≻ D 0.76 Implied, skipped in pass 3
  4. A ≻ E 0.95 Spanning tree · not trained
  5. B ≻ C 0.90 Spanning tree · DPO pair
  6. D ≻ B 0.59 Contradictory, pass 1
  7. B ≻ E 0.92 Spanning tree · not trained
  8. C ≻ D 0.88 Spanning tree · DPO pair
  9. E ≻ C 0.64 Contradictory, pass 2
  10. D ≻ E 0.86 Added, pass 1 · DPO pair

What the algorithm did

  1. Tree Kruskal keeps the strongest connected comparisons: A ≻ E 0.95, B ≻ E 0.92, B ≻ C 0.90, C ≻ D 0.88.
  2. Pass 1 Reverse loop: D ≻ B 0.59 contradicts the kept chain B ≻ C ≻ D and is marked contradictory; heuristic: B ≻ C, C ≻ D. Forward loop: adds D ≻ E 0.86.
  3. Pass 2 Reverse loop: E ≻ C 0.64 contradicts the kept chain C ≻ D ≻ E and is marked contradictory; heuristic: C ≻ D, D ≻ E. Forward loop: adds A ≻ C 0.80.
  4. Pass 3 Reverse loop: no remaining edge closes a cycle. Forward loop: skips A ≻ D 0.76 (already implied); adds A ≻ B 0.70.

Confidences are illustrative inputs; the graph computation is the paper’s Algorithm 1 (Section 3.3), run in your browser. Play replays the same run one decision at a time: Kruskal’s tree edges strongest first, then in each pass the reverse loop weakest first and the forward loop strongest first. Only heuristic edges become DPO pairs, so kept edges that lie on no cycle, such as the tree edge A ≻ E, are not trained on, and a fully consistent graph contributes no pairs. The resolved order is the kept graph with contradictory edges reversed (Property 2). Every confidence stays above the paper’s filter δ = 0.51; equal confidences are ordered by list position, which the paper does not specify. No model is queried or trained.

DPO then trains on these supporting (heuristic) edges, not on flipped contradictory ones, in the expectation that learning the reliable comparisons also corrects the weaker, inconsistent judgments.

Higher confidence is thus treated as stronger evidence. A confidently wrong judgment can enter the spanning tree, flag a correct comparison as contradictory and become a training pair, giving an order that is consistent but wrong.

  1. 01

    Collect model preferences

    Sample responses and construct a directed graph from the model's pairwise judgments.

  2. 02

    Identify conflicting cycles

    Start with a maximum spanning tree and use confidence scores to locate contradictory edges.

  3. 03

    Train on reliable comparisons

    Select supporting preference pairs for DPO, encouraging the model to resolve weaker contradictions.

Consistency improves, but it is not fully solved

Measured · Table 4

How often a prompt’s self-judged preference graph contains a cycle

Share of training prompts with at least one contradiction, before and after DPO on ContraSolver-selected pairs. The graph nodes are the same sampled responses used for data construction.

Table 4: share of training prompts with a cyclic preference graph, without and with ContraSolver.
Llama-2-7b-chat
SafeEdit 13.30% → 10.40%
Alpaca 17.50% → 14.30%
IMDb 22.10% → 19.70%
TL;DR 14.70% → 12.00%
Vicuna-7b
SafeEdit 30.60% → 18.90%
Alpaca 26.60% → 15.30%
IMDb 32.80% → 26.60%
TL;DR 19.80% → 14.30%

Values from Table 4. Cycles decrease on all eight model–dataset pairs but remain in 10.40–26.60% of prompts; the measurement uses training prompts, not new responses.

Random and Max-Confidence selection (keep the most confident pairs) use as many pairs as ContraSolver, so the comparison isolates which pairs are chosen. On positive-sentiment generation, Llama-2-7b-chat reaches 87.2% with ContraSolver, 80.3% with Max-Confidence and 79.5% with random selection.

The graph analysis measures consistency directly: for both models and all four datasets, fewer training prompts have a cyclic preference graph after self-alignment, but many cycles remain. The analysis reuses the original responses on training prompts, so it does not test new responses.

Table 1 (Llama-2-7b-chat rows). Safe-response rate (%) over three sampled responses per prompt, higher is better, computed by substring matching; Llama-2-7b-chat after DPO on pairs chosen by each selection method (Vanilla = no self-alignment). Random and Max-Confidence select the same number of preference pairs as ContraSolver, and substring matching is an automatic proxy for safety. Source ↗

MethodSafeEdit (test)AdvBenchMaliciousInstruct
Vanilla56.67%65.77%62.00%
Random56.22%71.92%70.00%
Max-Confidence62.96%85.96%83.00%
ContraSolver68.37%90.00%84.00%

Method proposed in the paper

Scope. Results rely on the model’s own preference labels and on automatic metrics: substring matching for safety and GPT-4 judgments for instruction following and summarization. Read the study ↗

Further reading in the paperGraph algorithm and DPO selection · Section 3 ↗Matched selection baselines and consistency analysis · Sections 4–5 ↗
Research summary

While substantial advancements have been made in developing large language models (LLMs), achieving control over their behavior can be difficult. Direct preference optimization (DPO) assumes the existence of a latent reward function to evaluate the responses of LLMs. This assumption indicates a strict preference ordering of different responses to the same input. However, there always exist contradictions of preference in LLMs according to our experimental observations. In this paper, we construct a graph structure of the preference relationship among different responses with self-annotation to find contradictions in the preference order. We propose ContraSolver, an algorithm that traverses all edges on the preference graph to identify those that might cause contradictions. ContraSolver initializes the graph with a maximum spanning tree and identifies contradictory edges, prioritizing the resolution of low-confidence preferences while preserving high-confidence ones. Experimental results on four different generation tasks show that the performance of different LLMs can be largely improved through our completely unsupervised self-alignment. Furthermore, by analyzing the preference graphs of LLMs with and without self-alignment by ContraSolver, we quantify the reduction in contradictions, suggesting that resolving preference contradictions is crucial for achieving better alignment performance.

Full paper ↗
Citation BibTeX
@misc{zhang2024contrasolverselfalignmentlanguagemodels,
    title={ContraSolver: Self-Alignment of Language Models by Resolving Internal Preference Contradictions},
    author={Xu Zhang and Xunjian Yin and Xiaojun Wan},
    year={2024},
    eprint={2406.08842},
    archivePrefix={arXiv},
    primaryClass={cs.CL},
    url={https://arxiv.org/abs/2406.08842}
}