Structuring Semantic Embeddings for Principle Evaluation: A Prototype-Guided Contrastive Learning Approach
Authors: Che Shen, Junwei Su, Lingpeng Kong, Chuan Wu
Organizations: Department of Computer Science The University of Hong Kong, Hong Kong, China · School of Artificial Intelligence and Data Science University of Science and Technology of China, Hefei, Anhui, China
Reliable post-hoc evaluation asks whether already generated text satisfies a target criterion after generation. In this paper we study a focused frozen-embedding setting using principle-evaluation proxy tasks: toxicity detection, fine-grained emotion categorization, and ordinal review rating. General-purpose text embeddings are widely deployed for such tasks, but broad semantic similarity can place semantically similar yet task-distinct examples in overlapping regions of the representation space. We introduce Prototype-Guided Contrastive Learning (PGCL), a prototype-guided geometric regularization module built on top of frozen text embeddings. The module combines a semantic stream, a prototype-anchor attention stream, supervised contrastive learning, offset-based prototype-margin regularization, and stream regularization to produce a compact task-adapted representation without updating the base encoder. Controlled experiments show that PGCL improves over raw frozen embeddings on all three datasets and gives the clearest direct-baseline margin on AmazonReviews, while remaining competitive with strong direct frozen metric-learning baselines on GoEmotions and ToxicComment. We also add supervised residual-adapter, encoder-LoRA, full fine-tuning, objective ablation, sensitivity, and fully logged few-shot LLM protocol diagnostics to define the boundary of the claim. The theoretical analysis is revised as a sufficient-condition account for prototype-margin behavior under explicit assumptions in the prototype-mapping space, rather than as an unconditional training or final-embedding separation guarantee.
Figures & tables
Dataset
Train
Validation
Test
GoEmotions
5126
906
881
AmazonReviews
2271
487
487
ToxicComment
44256
15073
22609
Table 1: Fixed split sizes used in the revised leakage-control audit.
Metric
Emb. Type
SVM
RF
LR
XGBoost
Transformer
Precision
Raw Emb.
0.748 ± 0.049
0.733 ± 0.059
0.737 ± 0.031
0.747 ± 0.020
0.785 ± 0.031
Opt. Emb.
0.787 ± 0.035
0.789 ± 0.036
0.791 ± 0.033
0.773 ± 0.028
0.787 ± 0.029
Recall
Raw Emb.
0.721 ± 0.045
0.737 ± 0.031
0.722 ± 0.031
0.741 ± 0.014
0.763 ± 0.024
Opt. Emb.
0.764 ± 0.034
0.769 ± 0.039
0.772 ± 0.033
0.765 ± 0.039
0.769 ± 0.031
F1
Raw Emb.
0.729 ± 0.046
0.722 ± 0.035
0.726 ± 0.031
0.737 ± 0.018
0.764 ± 0.036
Opt. Emb.
0.770 ± 0.033
0.767 ± 0.036
0.776 ± 0.032
0.764 ± 0.026
0.770 ± 0.030
Table 2: Overall (Avg. Principle) Performance on GoEmotions Five-Principle Set (Mean ± Std. Dev.)
Table 6: Direct metric-learning and prototype baselines under the same frozen-embedding linear-probe protocol. Values are test weighted F1.
Dataset
Comparison
Difference
95% CI
AmazonReviews
PGCL − best direct SupCon
0.0904
[0.0443, 0.1377]
GoEmotions
PGCL − best direct center loss
0.0256
[0.0011, 0.0473]
ToxicComment
PGCL − best direct center loss
0.0009
[-0.0012, 0.0029]
Table 7: Paired bootstrap differences in weighted F1. Positive CIs support a positive PGCL difference; ToxicComment is reported as a small competitive margin.
Dataset
PGCL ref.
Frozen residual adapter
Encoder-LoRA
Full fine-tuning
AmazonReviews
0.727
0.614
0.573
0.589
GoEmotions
0.772
0.786
0.831
0.820
ToxicComment
0.953
0.925
0.959
0.965
Table 8: Separate supervised adaptation diagnostics. Values are test weighted F1. Encoder-LoRA and full fine-tuning update an MPNet encoder and are not part of the frozen-embedding direct-baseline table.
Table 10: Audited local qwen3.6:27b few-shot LLM protocol telemetry.
Embedding
W/B ratio ( ↓ )
Silhouette ( ↑ )
Class overlap ( ↓ )
GQI ( ↑ )
Raw Embeddings
8.760
0.018
0.563
< 0.000
Unsupervised SimCSE
1.010
0.010
0.491
-0.0005
Standard Supervised
0.458
0.158
0.286
0.0614
PGCL (Ours)
0.358
0.203
0.253
0.0975
Table 11: Quantitative Geometric Quality and GQI Comparison on Amazon Reviews
Figure 2: t-SNE comparison of embedding spaces. Raw embeddings (a, c) show overlap among related labels. PGCL optimized embeddings (b, d) show more organized task-specific structure and a visible ordinal pattern for Amazon Reviews.
Configuration
Disappt.
Sad.
Disapprv.
Grat.
Apprv.
Average
Only Contrastive Loss
0.37
0.75
0.72
0.92
0.74
0.75
Only Offset Loss
0.40
0.75
0.72
0.94
0.77
0.77
Without Contrastive Loss
0.42
0.77
0.72
0.94
0.77
0.77
Without Offset Loss
0.44
0.71
0.73
0.93
0.76
0.77
Raw Embeddings
0.36
0.64
0.66
0.93
0.72
0.72
PGCL (Full Model)
0.49
0.77
0.72
0.94
0.76
0.78
Table 12: Ablation study on GoEmotions (F1 score Mean). Disappt.-Disappointment, Sad.-Sadness, Disapprv.-Disapproval, Grat.-Gratitude, Apprv.-Approval.
Dataset
Full
w/o offset
w/o contrast.
w/o orth.
Magnitude
AmazonReviews
0.569
0.541
0.643
0.571
0.577
GoEmotions
0.748
0.753
0.748
0.756
N/A
ToxicComment
0.944
0.936
0.944
0.946
N/A
Table 13: Same-provenance objective ablation across datasets. Values are test weighted F1.
Dataset
Full
wo=0.5
wo=2.0
wr=1.0
wr=10.0
Best interaction
AmazonReviews
0.584
0.525
0.664
0.578
0.577
Class+offset: 0.637
GoEmotions
0.745
0.757
0.758
0.756
0.744
Class+contrastive(+offset): 0.754
ToxicComment
0.945
0.941
0.947
0.949
0.945
Class+contrastive+offset: 0.946
Table 14: Objective sensitivity and interaction diagnostics. Values are test weighted F1.
Dataset
Full ref.
Attn. only
Sem./no-attn.
Fixed proto.
Fixed α
w/o orth.
AmazonReviews
0.6217
0.5073
0.6225
0.6170
0.6253
0.6148
GoEmotions
0.7519
0.7718
0.7371
0.7544
0.7481
0.7507
ToxicComment
0.9494
0.9146
0.9483
0.9469
0.9472
0.9500
Table 15: Architecture-level diagnostics. Values are weighted F1 means across available seeds unless noted.
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Principle
Emb. Type
SVM
RF
LR
XGBoost
Transformer
Disappt.
Raw Emb.
0.387 ± 0.090
0.237 ± 0.202
0.375 ± 0.054
0.359 ± 0.144
0.315 ± 0.073
Opt. Emb.
0.482 ± 0.102
0.410 ± 0.087
0.479 ± 0.106
0.439 ± 0.099
0.386 ± 0.117
Sad.
Raw Emb.
0.643 ± 0.059
0.728 ± 0.069
0.672 ± 0.081
0.711 ± 0.082
0.711 ± 0.087
Opt. Emb.
0.687 ± 0.048
0.734 ± 0.031
0.721 ± 0.054
0.698 ± 0.031
0.714 ± 0.034
Disapprv.
Raw Emb.
0.663 ± 0.074
0.691 ± 0.050
0.652 ± 0.070
0.703 ± 0.032
0.677 ± 0.055
Opt. Emb.
0.720 ± 0.074
0.740 ± 0.064
0.728 ± 0.063
0.724 ± 0.082
0.733 ± 0.059
Appendix
Table 16: Per-Principle F1 Performance on GoEmotions Five-Principle Set (Mean ± Std. Dev.). Principles are abbreviated as Disappt., Sad., Disapprv., Grat., Apprv.
Ratings
Emb. Type
SVM
RF
LR
XGBoost
Transformer
1 - S
Raw Emb.
0.712 ± 0.219
0.772 ± 0.166
0.713 ± 0.208
0.744 ± 0.235
0.731 ± 0.209
Opt. Emb.
0.869 ± 0.112
0.874 ± 0.085
0.875 ± 0.084
0.894 ± 0.093
0.888 ± 0.090
2 - S
Raw Emb.
0.277 ± 0.118
0.204 ± 0.213
0.297 ± 0.168
0.288 ± 0.221
0.432 ± 0.163
Opt. Emb.
0.691 ± 0.187
0.708 ± 0.315
0.667 ± 0.176
0.760 ± 0.170
0.711 ± 0.141
3 - S
Raw Emb.
0.433 ± 0.158
0.556 ± 0.176
0.503 ± 0.081
0.520 ± 0.141
0.584 ± 0.085
Opt. Emb.
0.669 ± 0.106
0.697 ± 0.073
0.662 ± 0.112
0.657 ± 0.076
0.696 ± 0.143
Appendix
Table 17: Classification F1 Performance per Rating on Amazon Reviews (Mean ± Std. Dev.)
Metric
Emb. Type
SVM
RF
LR
XGBoost
Transformer
1-S MSE
Raw Emb.
0.483 ± 0.531
0.750 ± 1.207
0.567 ± 0.533
0.957 ± 1.145
0.350 ± 0.449
Opt. Emb.
0.177 ± 0.260
0.360 ± 0.543
0.140 ± 0.254
0.420 ± 0.555
0.157 ± 0.250
2-S MSE
Raw Emb.
1.080 ± 0.867
1.415 ± 0.880
1.250 ± 0.972
1.465 ± 0.912
1.025 ± 1.072
Opt. Emb.
0.290 ± 0.386
0.435 ± 0.547
0.405 ± 0.334
0.335 ± 0.338
0.265 ± 0.363
3-S MSE
Raw Emb.
0.726 ± 0.431
0.623 ± 0.235
0.804 ± 0.378
0.712 ± 0.269
0.539 ± 0.236
Opt. Emb.
0.386 ± 0.260
0.442 ± 0.312
0.442 ± 0.367
0.509 ± 0.361
0.376 ± 0.261
Appendix
Table 18: Ordinal Regression MSE Performance per Rating on Amazon Reviews (Mean ± Std. Dev.)
Fine-tuning LLM-based text embedders via contrastive learning maps inputs and outputs into a new representational space, discarding the LLM's output semantics. We propose LLM2Vec-Gen, a self-supervised alternative that instead produces embeddings directly in the LLM's output space by learning to represent the model's potential response. Specifically, trainable special tokens are appended to the input and optimized to compress the LLM's own response into a fixed-length embedding, guided by an unsupervised embedding teacher and a reconstruction objective. Crucially, the LLM backbone remains frozen and training requires only unlabeled queries. LLM2Vec-Gen achieves state-of-the-art self-supervised performance on the Massive Text Embedding Benchmark (MTEB), improving by 8.8% over the unsupervised embedding teacher. Since the embeddings preserve the LLM's response-space semantics, they inherit capabilities such as safety alignment (up to 22.6% reduction in harmful content retrieval) and reasoning (up to 35.6% improvement on reasoning-intensive retrieval). Finally, the learned embeddings are also interpretable: they can be decoded back into text to reveal their semantic content. Our code, data, and pretrained models are publicly available at https://github.com/McGill-NLP/llm2vec-gen.
Parishad BehnamGhader, Vaibhav Adlakha, Fabian David Schmidt +3
McGill University · Mila–Quebec AI Institute · ServiceNow Research +3
We report a systematic dissociation in modern text embedders: sentiment is almost perfectly decodable from their embeddings, yet almost entirely absent from their metric. Across eleven frozen encoders spanning 2021 to 2026, including 2026-generation models and the 4B-parameter LLM embedder Qwen3-Embedding-4B, a linear probe recovers sentence polarity at up to 91.3% accuracy while cosine similarity separates polarity by a margin of only 0.003-0.064. Qwen3-Embedding-4B, the strongest probe in the panel, reaches 91.3% probe accuracy but only 64.3 retrieval MAP. Because retrieval, clustering, deduplication, and retrieval-augmented generation operate on the metric rather than on a trained probe, these systems are effectively blind to information their encoder demonstrably contains. A task-conditioning control suggests this reflects the pretraining objective rather than a prompting artifact: conditioning Jina-v5 on its classification task rather than its retrieval task recovers only about half of the MAP gain that injection achieves on the same weights (63.2 to 73.8, versus 85.1), and leaves the alignment gap essentially unchanged. Sentiment-Injected Sentence Embeddings (SISE) train a small (0.13M-0.69M-parameter) supervised-contrastive head on a frozen encoder in seconds on a CPU, using the labelled training set. The head improves every encoder released since 2022 on full-data probe accuracy (up to +5.8 points), retrieval MAP (up to +26.0) and polarity margin (7-61x). This is a specialization, not a free gain: the compact 128-d head loses 38-41 Spearman points on STS-B, while a fused variant that concatenates it with the base embedding loses 2.4-12.0. With the head, a 0.6B encoder at 128 dimensions matches a 4B encoder given the same head (91.8 vs. 90.3 MAP). We release a CPU-reproducible pipeline and a reusable diagnostic, the Attribute Alignment Gap.
Extracting conditional text embeddings from large language models (LLMs) is a promising paradigm, as it requires neither additional data nor fine-tuning. Existing methods incorporate conditions into prompts to guide LLMs to focus on specific aspects and elicit conditional text embeddings. However, relying solely on prompts often fails to produce high-quality conditional text embeddings, as they remain entangled with general text embeddings, ultimately degrading their quality. To this end, we propose an inference-time, plug-and-play Self-Contrastive Steering (SCS) method that constructs unconditional general text embeddings and uses them to refine conditional text embeddings, making them more focused on the target condition. Specifically, we modify the attention mask and positional encodings to mask the condition, thereby obtaining unconditional text embeddings and intervening in the multi-head self-attention computation process. Notably, our method is highly efficient, requiring only a single additional multi-head self-attention computation at inference time. Extensive experiments on clustering, Semantic Textual Similarity, and triplet alignment datasets demonstrate that our method can seamlessly improve the performance of existing prompt-based methods across different LLMs in a training-free and plug-and-play manner. Our code will be released at https://github.com/zifengcheng/SCS
Zifeng Cheng, Lingyun Qian, Zhiwei Jiang +5
State Key Laboratory for Novel Software Technology, Nanjing University · National University of Singapore