Manuscript Offprint

arXiv:2610.38605

Efficient Group-Penalty k-means for Text Clustering with Noisy LLM-Generated Constraints

Feiteng Nie, Yuan Sun, Shengkun Zhu, Sheng Wang, Zhiyong Peng

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

k-means provides a simple and efficient foundation for text clustering, but embedding alone can miss task-specific semantic boundaries. Must-link (ML) and cannot-link (CL) constraints can correct such errors, yet conventional constrained clustering assumes that these relations are already supplied. LLMs can generate them without task-specific labels, but exhaustive querying is costly and their judgments can be incorrect. We present GPKMEANS, an efficient Group-Penalty k-means method for text clustering with noisy LLM-generated constraints. GPKMEANS uses LLM as an offline local pairwise annotator, querying selected anchor-candidate pairs for sparse ML links and constructing set-valued CL evidence without all-pairs queries. It converts connected components of the ML-link graph and the generated CL sets into groups with normalized, bounded soft penalties, limiting each group's influence independently of its size. Cached coordinate descent is proposed to efficiently solve the constraints clustering problem. We prove finite-step convergence and derive deterministic and probabilistic oracle-referenced bounds that relate objective distortion to the penalty coefficients and to the group-level error probabilities of the generated constraints. Across nine datasets, GPKMEANS uses fewer LLM calls and yields more accurate constraints. It achieves the best average ACC, NMI, and ARI with an approximate 30× speedup over state-of-the-art constrained clustering methods.

1 INTRODUCTION

Text clustering is an important primitive for organizing and analyzing textual records in data management, with applications including topic discovery, recommendation, anomaly detection, and community analysis [16, 39, 51]. In a typical pipeline, pretrained encoders first map texts into a continuous embedding space, after which k-means partitions the resulting representations in a simple and scalable manner [7, 36, 37, 50, 55]. However, geometric proximity in the embedding space does not always coincide with task-specific semantic similarity. Texts expressing distinct intents may exhibit nearly identical lexical patterns and highly similar embeddings, whereas texts expressing the same intent may differ substantially in surface form, and k-means lacks the external evidence needed to identify and correct such errors.

Pairwise side information provides a natural source of such evidence. A must-link (ML) indicates that two samples should be assigned to the same cluster, whereas a cannot-link (CL) indicates that they should be separated. Constrained-clustering methods incorporate these relations to guide the clustering process [10, 11, 13, 18, 53]. Traditionally, pairwise relations are elicited from human annotators and domain experts [9, 11, 54], while benchmark evaluations often

Figure

Figure 1: An example from BANKING77 with two refund-related intents. k-means can misplace a text across the two intents, and LLM-generated pairwise constraints can include both useful and incorrect must-link constraints.

construct them from ground-truth labels [10, 13, 53]. However, existing methods assume predefined constraints and do not address how to acquire them without labels or human supervision.

LLMs have shown promise in data cleaning and integration [42], motivating their use to acquire semantic relations from text without task-specific gold labels [1, 14, 21]. Consider a small example containing two refund-related intents in Figure 1. Although the texts share similar refund vocabulary, the intended user actions differ, so embedding-based k-means can cross the local semantic boundary and assign a delayed-refund query to the refund-request cluster. Local LLM constraints can help reveal this boundary by linking semantically matched examples. However, the same lexical overlap can also induce an incorrect cross-intent ML constraint, pulling the assignment in the wrong direction. Thus, even k-means with generated ML and CL constraints can produce undesirable results when those constraints are treated as hard rules.

LLMs provide semantic guidance for text clustering through label generation, representation refinement, and textual cluster descriptions or centroids [22, 48, 52, 61, 62]. However, directly assigning clusters with LLMs can produce inconsistent labels and semantic boundaries across batches and iterations [40]. When the corpus exceeds the context window, no single call can observe all samples, making it difficult to enforce cross-batch consistency and making repeated inference costly [24]. Using an LLM as a local pairwise annotator offers a more focused alternative, but it shifts rather than eliminates the difficulty. Exhaustive pair querying remains prohibitively expensive, so a limited query budget can be allocated to a part of the selected data; the resulting relations are globally sparse yet may be locally redundant or erroneous [2]. The resulting data management challenge is to improve semantic grouping under a limited query budget while controlling the influence of noisy relations and the computational cost of clustering. LSCK uses LLM-generated ML and CL constraints to correct local errors in embedding-based clustering [30], while other methods use cluster descriptions, few-shot guidance, label inference, or summary centroids to assist clustering [22, 48, 52, 61, 62]. However, strong

*Sheng Wang is the corresponding author.

enforcement of noisy LLM-generated constraints can distort clustering, while computationally expensive constrained optimization can limit scalability.

Various algorithms have been proposed for clustering with hard or soft ML and CL constraints [10, 12, 13, 19, 29, 53]. COPKMEANS can fail to produce a valid partition when no feasible assignment is found [19, 53]. PCCC accommodates uncertain relations through soft penalties, but solves mixed-integer assignment problems that can incur substantial computational cost [12]. These limitations motivate a method that tolerates noisy constraints while retaining efficient local updates.

To address this challenge, we propose GPKMEANS, an efficient Group-Penalty k-means method for organizing text collections using sparse, noisy LLM-generated constraints. GPKMEANS follows three stages. First, it selects anchors within preliminary k-means clusters by favoring large centroid margins and proximity to their assigned centroids, queries their neighbors for sparse ML constraints, and constructs set-valued CL constraints without querying all text pairs. Second, it converts connected components of the generated ML-link graph and the generated CL sets into typed constraint groups and incorporates them into the k-means objective through normalized soft penalties. Third, GPKMEANS efficiently solves the resulting constraints k-means problem using cached coordinate descent. Cached cluster and group statistics allow candidate reassignments to be evaluated from only the affected objective terms, avoiding repeated global constrained optimization. Together with bounded penalties, GPKMEANS exploits reliable constraints while limiting the influence of noisy groups.

Our contributions are as follows:

  • We propose GPKMEANS, an efficient Group-Penalty k-means method that incorporates noisy LLM-generated ML and CL constraints into the assignment objective through normalized, bounded soft penalties rather than hard rules.
  • We develop an anchor-based querying strategy that constructs connected-component ML groups and uses cached coordinate descent to efficiently solve the constraints clustering problem.
  • We establish finite-step convergence and derive bounds that quantify how noisy constraints affect the objective as the ML and CL penalty coefficients vary.
  • We demonstrate the effectiveness and efficiency of GP-KMEANS over nine datasets in our experimental evaluations. Our experimental findings indicate that GPKMEANS achieves the highest averaged ACC, NMI, and ARI, while running approximately 30x faster than the fastest constrained-clustering baseline considered.

References (19)