Searcharxiv⌕ Search

arXiv subjects

Xiaohu Yang

Publications and source records attributed to Xiaohu Yang.

At least 91 records · Page 5Linked to original sources

Automated Unit Test Refactoring

Test smells arise from poor design practices and insufficient domain knowledge, which can lower the quality of test code and make it harder to maintain and update. Manually refactoring test smells is time-consuming and error-prone, highlighting the necessity for automated approaches. Current rule-based refactoring methods often struggle in scenarios not covered by predefined rules and lack the flexibility needed to handle diverse cases effectively. In this paper, we propose a novel approach called UTRefactor, a context-enhanced, LLM-based framework for automatic test refactoring in Java projects. UTRefactor extracts relevant context from test code and leverages an external knowledge base that includes test smell definitions, descriptions, and DSL-based refactoring rules. By simulating the manual refactoring process through a chain-of-thought approach, UTRefactor guides the LLM to eliminate test smells in a step-by-step process, ensuring both accuracy and consistency throughout the refactoring. Additionally, we implement a checkpoint mechanism to facilitate comprehensive refactoring, particularly when multiple smells are present. We evaluate UTRefactor on 879 tests from six open-source Java projects, reducing the number of test smells from 2,375 to 265, achieving an 89% reduction. UTRefactor outperforms direct LLM-based refactoring methods by 61.82% in smell elimination and significantly surpasses the performance of a rule-based test smell refactoring tool. Our results demonstrate the effectiveness of UTRefactor in enhancing test code quality while minimizing manual involvement.

cs.SE↗

SecPE: Secure Prompt Ensembling for Private and Robust Large Language Models

With the growing popularity of LLMs among the general public users, privacy-preserving and adversarial robustness have become two pressing demands for LLM-based services, which have largely been pursued separately but rarely jointly. In this paper, to the best of our knowledge, we are among the first attempts towards robust and private LLM inference by tightly integrating two disconnected fields: private inference and prompt ensembling. The former protects users' privacy by encrypting inference data transmitted and processed by LLMs, while the latter enhances adversarial robustness by yielding an aggregated output from multiple prompted LLM responses. Although widely recognized as effective individually, private inference for prompt ensembling together entails new challenges that render the naive combination of existing techniques inefficient. To overcome the hurdles, we propose SecPE, which designs efficient fully homomorphic encryption (FHE) counterparts for the core algorithmic building blocks of prompt ensembling. We conduct extensive experiments on 8 tasks to evaluate the accuracy, robustness, and efficiency of SecPE. The results show that SecPE maintains high clean accuracy and offers better robustness at the expense of merely $2.5\%$ efficiency overhead compared to baseline private inference methods, indicating a satisfactory ``accuracy-robustness-efficiency'' tradeoff. For the efficiency of the encrypted Argmax operation that incurs major slowdown for prompt ensembling, SecPE is 35.4x faster than the state-of-the-art peers, which can be of independent interest beyond this work.

cs.CR↗

From Halos to Galaxies. X: Decoding Galaxy SEDs with Physical Priors and Accurate Star Formation History Reconstruction

The spectral energy distribution (SED) of galaxies is essential for deriving fundamental properties like stellar mass and star formation history (SFH). However, conventional methods, including both parametric and non-parametric approaches, often fail to accurately recover the observed cosmic star formation rate (SFR) density due to oversimplified or unrealistic assumptions about SFH and their inability to account for the complex SFH variations across different galaxy populations. To address this issue, we introduce a novel approach that improves galaxy broadband SED analysis by incorporating physical priors derived from hydrodynamical simulations. Tests using IllustrisTNG simulations demonstrate that our method can reliably determine galaxy physical properties from broadband photometry, including stellar mass within 0.05 dex, current SFR within 0.3 dex, and fractional stellar formation time within 0.2 dex, with a negligible fraction of catastrophic failures. When applied to the Sloan Digital Sky Survey (SDSS) main photometric galaxy sample with spectroscopic redshift, our estimates of stellar mass and SFR are consistent with the widely used MPA-JHU and GSWLC catalogs. Notably, using the derived SFHs of individual SDSS galaxies, we estimate the cosmic SFR density and stellar mass density with remarkable consistency to direct observations up to $z \sim 6$. This demonstrates a significant advancement in deriving SFHs from SEDs that closely align with observational data. Consequently, our method can reliably recover observed spectral indices such as $\rm D_{\rm n}(4000)$ and $\rm Hδ_{\rm A}$ by synthesizing the full spectra of galaxies using the estimated SFHs and metal enrichment histories, relying solely on broadband photometry as input. Furthermore, this method is extremely computationally efficient compared to conventional approaches.

astro-ph.GA↗

From Halos to Galaxies. VI. Improved halo mass estimation for SDSS groups and measurement of the halo mass function

In $Λ$CDM cosmology, galaxies form and evolve in their host dark matter (DM) halos. Halo mass is crucial for understanding the halo-galaxy connection. The abundance matching (AM) technique has been widely used to derive the halo masses of galaxy groups. However, quenching of the central galaxy can decouple the coevolution of its stellar mass and DM halo mass. Different halo assembly histories can also result in significantly different final stellar mass of the central galaxies. These processes can introduce substantial uncertainties in the halo masses derived from the AM method, particularly leading to a systematic bias between groups with star-forming centrals (blue groups) and passive centrals (red groups). To improve, we developed a new machine learning (ML) algorithm that accounts for these effects and is trained on simulations. Our results show that the ML method eliminates the systematic bias in the derived halo masses for blue and red groups and is, on average, $\sim1/3$ more accurate than the AM method. With careful calibration of observable quantities from simulations and observations from SDSS, we apply our ML model to the SDSS Yang et al. groups to derive their halo masses down to $10^{11.5}\mathrm{M_\odot}$ or even lower. The derived SDSS group halo mass function agrees well with the theoretical predictions, and the derived stellar-to-halo mass relations for both red and blue groups matches well with those obtained from direct weak lensing measurements. These new halo mass estimates enable more accurate investigation of the galaxy-halo connection and the role of the halos in galaxy evolution.

astro-ph.GA↗

Improving the Ability of Pre-trained Language Model by Imparting Large Language Model's Experience

Large Language Models (LLMs) and pre-trained Language Models (LMs) have achieved impressive success on many software engineering tasks (e.g., code completion and code generation). By leveraging huge existing code corpora (e.g., GitHub), these models can understand the patterns in source code and use these patterns to predict code properties. However, LLMs under few-shot learning perform poorly on non-generative tasks (e.g., fault localization and vulnerability localization), and fine-tuning LLMs is time-consuming and costly for end users and small organizations. Furthermore, the performance of fine-tuning LMs for non-generative tasks is impressive, yet it heavily depends on the amount and quality of data. As a result, the current lack of data and the high cost of collecting it in real-world scenarios further limit the applicability of LMs. In this paper, we leverage the powerful generation capabilities of LLMs to enhance pre-trained LMs. Specifically, we use LLMs to generate domain-specific data, thereby improving the performance of pre-trained LMs on the target tasks. We conduct experiments by combining different LLMs in our generation phase and introducing various LMs to learn from the LLM-generated data. Then, we compare the performance of these LMs before and after learning the data. We find that LLM-generated data significantly enhances the performance of LMs. The improvement can reach up to 58.36% for fault localization and up to 6.09% for clone detection.

cs.SE↗

Cosmological distance forecasts for the CSST Galaxy Survey using BAO peaks

The measurement of cosmological distances using baryon acoustic oscillations (BAO) is crucial for studying the universe's expansion. The Chinese Space Station Telescope (CSST) galaxy redshift survey, with its vast volume and sky coverage, provides an opportunity to address key challenges in cosmology. However, redshift uncertainties in galaxy surveys can degrade both angular and radial distance estimates. In this study, we forecast the precision of BAO distance measurements using mock CSST galaxy samples, applying a two-point correlation function (2PCF) wedge approach to mitigate redshift errors. We simulate redshift uncertainties of $σ_0 = 0.003$ and $σ_0 = 0.006$, representative of expected CSST errors, and examine their effects on the BAO peak and distance scaling factors, $α_\perp$ and $α_\parallel$, across redshift bins within $0.0 < z \leqslant 1.0$. The wedge 2PCF method proves more effective in detecting the BAO peak compared to the monopole 2PCF, particularly for $σ_0 = 0.006$. Constraints on the BAO peaks show that $α_\perp$ is well constrained around 1.0, regardless of $σ_0$, with precision between 1% and 3% across redshift bins. In contrast, $α_\parallel$ measurements are more sensitive to increases in $σ_0$. For $σ_0 = 0.003$, the results remain close to the fiducial value, with uncertainties ranging between 4% and 9%; for $σ_0 = 0.006$, significant deviations from the fiducial value are observed. We also study the ability to measure parameters $(Ω_m, H_0r_\mathrm{d})$ using distance measurements, proving robust constraints as a cosmological probe under CSST-like redshift uncertainties.

astro-ph.CO↗

Enhancing LLM's Ability to Generate More Repository-Aware Unit Tests Through Precise Contextual Information Injection

Though many learning-based approaches have been proposed for unit test generation and achieved remarkable performance, they still have limitations in relying on task-specific datasets. Recently, Large Language Models (LLMs) guided by prompt engineering have gained attention for their ability to handle a broad range of tasks, including unit test generation. Despite their success, LLMs may exhibit hallucinations when generating unit tests for focal methods or functions due to their lack of awareness regarding the project's global context. These hallucinations may manifest as calls to non-existent methods, as well as incorrect parameters or return values, such as mismatched parameter types or numbers. While many studies have explored the role of context, they often extract fixed patterns of context for different models and focal methods, which may not be suitable for all generation processes (e.g., excessive irrelevant context could lead to redundancy, preventing the model from focusing on essential information). To overcome this limitation, we propose RATester, which enhances the LLM's ability to generate more repository-aware unit tests through global contextual information injection. To equip LLMs with global knowledge similar to that of human testers, we integrate the language server gopls, which provides essential features (e.g., definition lookup) to assist the LLM. When RATester encounters an unfamiliar identifier (e.g., an unfamiliar struct name), it first leverages gopls to fetch relevant definitions and documentation comments, and then uses this global knowledge to guide the LLM. By utilizing gopls, RATester enriches the LLM's knowledge of the project's global context, thereby reducing hallucinations during unit test generation.

cs.SE↗

Robust detection of hot intragroup medium in optically selected, poor galaxy groups by eROSITA

Over the last several decades, extensive research has been conducted on the baryon cycles within cosmic structures, encompassing a broad mass range from dwarf galaxies to galaxy clusters. However, a notable gap in understanding the cosmic baryon cycle is the poor galaxy groups with halo masses around $10^{13}\ M_{\odot}$ (e.g., McGaugh et al. 2010). Poor galaxy groups, like our own Local Group, are prevalent throughout the universe, yet robust detection of their hot, X-ray emitting intragroup medium (IGrM) has remained elusive. The presence of this hot IGrM is crucial for addressing the long-standing "missing baryons" problem. Previous ROSAT-based studies were limited by a small number of X-ray bright samples, thus restricting the scope of their findings. Here we show a robust detection of this hot IGrM in a large, optically selected poor groups sample, based on the stacked X-ray images from the eROSITA Final Equatorial Depth Survey. These groups are identified in DESI LS with a mass range of log($M_\mathrm{halo}/h^{-1}M_{\odot}$) = 11.5-13.5 and a redshift range of z = 0.1-0.5. Additionally, our results indicate that despite its presence in virtually groups at all sizes, this gas component is still not sufficient to recover the universal baryon fraction, and hence the "missing baryons" problem still persists in poor galaxy groups.

astro-ph.GA↗

A first measurement of galaxy merger rate increasing in dynamically colder protoclusters at cosmic noon

The process of galaxy cluster formation likely leaves an imprint on the properties of its individual member galaxies. Understanding this process is essential for uncovering the evolutionary connections between galaxies and cosmic structures. Here we study a sample of ten protoclusters at z~2-3 in different dynamical states that we estimate based on spectroscopic data of their members. We combine the dynamical information with HST imaging to measure galaxy sizes and pair fractions. Our analysis reveals a clear anti-correlation between the velocity dispersion of the protocluster and its galaxy pair fractions (indicative of merger rates). The velocity dispersion also anti-correlates with the dispersion in size among of the member galaxies. These correlations may be explained by protoclusters in colder dynamical states maintaining a velocity dispersion and galaxy number density that boosts galaxy mergers, which in turn contributes to the structural expansion and compaction of galaxies. Our findings offer constraints for cosmological models regarding the evolution of galaxy morphology across different stages in the assembly of protoclusters.

astro-ph.GA↗

What You See Is What You Get: Attention-based Self-guided Automatic Unit Test Generation

Software defects heavily affect software's functionalities and may cause huge losses. Recently, many AI-based approaches have been proposed to detect defects, which can be divided into two categories: software defect prediction and automatic unit test generation. While these approaches have made great progress in software defect detection, they still have several limitations in practical application, including the low confidence of prediction models and the inefficiency of unit testing models. To address these limitations, we propose a WYSIWYG (i.e., What You See Is What You Get) approach: Attention-based Self-guided Automatic Unit Test GenERation (AUGER), which contains two stages: defect detection and error triggering. In the former stage, AUGER first detects the proneness of defects. Then, in the latter stage, it guides to generate unit tests for triggering such an error with the help of critical information obtained by the former stage. To evaluate the effectiveness of AUGER, we conduct a large-scale experiment by comparing with the state-of-the-art (SOTA) approaches on the widely used datasets (i.e., Bears, Bugs.jar, and Defects4J). AUGER makes great improvements by 4.7% to 35.3% and 17.7% to 40.4% in terms of F1-score and Precision in defect detection, and can trigger 23 to 84 more errors than SOTAs in unit test generation. Besides, we also conduct a further study to verify the generalization in practical usage by collecting a new dataset from real-world projects.

cs.SE↗

Distinguishing LLM-generated from Human-written Code by Contrastive Learning

Large language models (LLMs), such as ChatGPT released by OpenAI, have attracted significant attention from both industry and academia due to their demonstrated ability to generate high-quality content for various tasks. Despite the impressive capabilities of LLMs, there are growing concerns regarding their potential risks in various fields, such as news, education, and software engineering. Recently, several commercial and open-source LLM-generated content detectors have been proposed, which, however, are primarily designed for detecting natural language content without considering the specific characteristics of program code. This paper aims to fill this gap by proposing a novel ChatGPT-generated code detector, CodeGPTSensor, based on a contrastive learning framework and a semantic encoder built with UniXcoder. To assess the effectiveness of CodeGPTSensor on differentiating ChatGPT-generated code from human-written code, we first curate a large-scale Human and Machine comparison Corpus (HMCorp), which includes 550K pairs of human-written and ChatGPT-generated code (i.e., 288K Python code pairs and 222K Java code pairs). Based on the HMCorp dataset, our qualitative and quantitative analysis of the characteristics of ChatGPT-generated code reveals the challenge and opportunity of distinguishing ChatGPT-generated code from human-written code with their representative features. Our experimental results indicate that CodeGPTSensor can effectively identify ChatGPT-generated code, outperforming all selected baselines.

cs.SE↗

Accurately Estimating Redshifts from CSST Slitless Spectroscopic Survey using Deep Learning

Chinese Space Station Telescope (CSST) has the capability to conduct slitless spectroscopic survey simultaneously with photometric survey. The spectroscopic survey will measure slitless spectra, potentially providing more accurate estimations of galaxy properties, particularly redshifts, compared to using broadband photometry. CSST relies on these accurate redshifts to perform baryon acoustic oscilliation (BAO) and other probes to constrain the cosmological parameters. However, due to low resolution and signal-to-noise ratio of slitless spectra, measurement of redshifts is significantly challenging.} In this study, we employ a Bayesian neural network (BNN) to assess the accuracy of redshift estimations from slitless spectra anticipated to be observed by CSST. The simulation of slitless spectra is based on real observational data from the early data release of the Dark Energy Spectroscopic Instrument (DESI-EDR) and the 16th data release of the Baryon Oscillation Spectroscopic Survey (BOSS-DR16), combined with the 9th data release of the DESI Legacy Survey (DESI LS DR9). The BNN is constructed employing transfer learning technique, by appending two Bayesian layers after a convolutional neural network (CNN), leveraging the features learned from the slitless spectra and corresponding redshifts. Our network can provide redshift estimates along with corresponding uncertainties, achieving an accuracy of $σ_{\rm NMAD} = 0.00063$, outlier percentage $η=0.92\%$ and weighted mean uncertainty $\bar{E} = 0.00228$. These results successfully fulfill the requirement of $σ_{\rm NMAD} < 0.005$ for BAO and other studies employing CSST slitless spectroscopic surveys.

astro-ph.CO↗

The conditional colour-magnitude distribution: II. A comparison of galaxy colour and luminosity distribution in galaxy groups

The Conditional Colour-Magnitude Distribution (CCMD) is a comprehensive formalism of the colour-magnitude-halo mass relation of galaxies. With joint modelling of a large sample of SDSS galaxies in fine bins of galaxy colour and luminosity, Xu et al. inferred parameters of a CCMD model that well reproduces colour- and luminosity-dependent abundance and clustering of present-day galaxies. In this work, we provide a test and investigation of the CCMD model by studying the colour and luminosity distribution of galaxies in galaxy groups. An apples-to-apples comparison of group galaxies is achieved by applying the same galaxy group finder to identify groups from the CCMD galaxy mocks and from the SDSS data, avoiding any systematic effect of group finding and mass assignment on the comparison. We find an overall nice agreement in the conditional luminosity function (CLF), the conditional colour function (CCF), and the CCMD of galaxies in galaxy groups inferred from CCMD mock and SDSS data. We also discuss the subtle differences revealed by the comparison. In addition, using two external catalogues constructed to only include central galaxies with halo mass measured through weak lensing, we find that their colour-magnitude distribution shows two distinct and orthogonal components, in line with the prediction of the CCMD model. Our results suggest that the CCMD model provides a good description of halo mass dependent galaxy colour and luminosity distribution. The halo and CCMD mock catalogues are made publicly available to facilitate other investigations.

astro-ph.GA↗

Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence Tasks

Recent studies proposed to leverage large language models (LLMs) with In-Context Learning (ICL) to handle code intelligence tasks without fine-tuning. ICL employs task instructions and a set of examples as demonstrations to guide the model in generating accurate answers without updating its parameters. While ICL has proven effective for code intelligence tasks, its performance heavily relies on the selected examples. Previous work has achieved some success in using BM25 to retrieve examples for code intelligence tasks. However, existing approaches lack the ability to understand the semantic and structural information of queries, resulting in less helpful demonstrations. Moreover, they do not adapt well to the complex and dynamic nature of user queries in diverse domains. In this paper, we introduce a novel approach named Instructive Code Retriever (ICR), which is designed to retrieve examples that enhance model inference across various code intelligence tasks and datasets. We enable ICR to learn the semantic and structural information of the corpus by a tree-based loss function. To better understand the correlation between queries and examples, we incorporate the feedback from LLMs to guide the training of the retriever. Experimental results demonstrate that our retriever significantly outperforms state-of-the-art approaches. We evaluate our model's effectiveness on various tasks, i.e., code summarization, program synthesis, and bug fixing. Compared to previous state-of-the-art algorithms, our method achieved improvements of 50.0% and 90.0% in terms of BLEU-4 for two code summarization datasets, 74.6% CodeBLEU on program synthesis dataset, and increases of 3.6 and 3.2 BLEU-4 on two bug fixing datasets.

cs.SE↗

The mass and redshift dependence of halo star clustering

We adopt the two point correlation function (2PCF) as a statistical tool to quantify the spatial clustering of halo stars, for galaxy systems spanning a wide range in host halo virial mass ($11.25<\log_{10}M_{200c}/\mathrm{M}_\odot<15$) and redshifts ($0<z<1.5$) from the IllustrisTNG simulations. Consistent with a previous study \cite[][Paper I]{2024ApJ...961..223Z}, we identify clear correlations between the strength of the 2PCF signals and galaxy formation redshifts, but over a much wider mass range. We find that such correlations are slightly stronger at higher redshifts, and get weakened with the increase of host halo mass. We demonstrate that the spatial clustering of halo stars is affected by two factors: 1) the clustering gets gradually weakened as time passes (phase mixing); 2) newly accreted stars at more recent times would increase the clustering. For more massive galaxy systems, they assemble late and the newly accreted stars would increase the clustering. The late assembly of massive systems may also help to explain the weaker correlations between the 2PCF signals and the galaxy formation redshifts in massive halos, as their 2PCFs are affected more by recently accreted stars, while formation redshift characterizes mass accretion on a much longer timescale. We find that the orbits of satellite galaxies in more massive halos maintain larger radial anisotropy, reflecting the more active accretion state of their hosts while also contributing to their stronger mass loss rates.

astro-ph.GA↗

Statistical properties of filaments in the cosmic web

In the context of the cosmological and constrained ELUCID simulation, this study explores the statistical characteristics of filaments within the cosmic web, focussing on aspects such as the distribution of filament lengths and their radial density profiles. Using the classification of the cosmic web environment through the Hessian matrix of the density field, our primary focus is on how cosmic structures react to the two variables $R_{\rm s}$ and $λ_{\rm th}$. The findings show that the volume fractions of knots, filaments, sheets, and voids are highly influenced by the threshold parameter $λ_{\rm th}$, with only a slight influence from the smoothing length $R_{\rm s}$. The central axis of the cylindrical filament is pinpointed using the medial-axis thinning algorithm of the COWS method. It is observed that median filament lengths tend to increase as the smoothing lengths increase. Analysis of filament length functions at different values of $R_{\rm s}$ indicates a reduction in shorter filaments and an increase in longer filaments as $R_{\rm s}$ increases, peaking around $2.5R_{\rm s}$. The study also shows that the radial density profiles of filaments are markedly affected by the parameters $R_{\rm s}$ and $λ_{\rm th}$, showing a valley at approximately $2R_{\rm s}$, with increases in the threshold leading to higher amplitudes of the density profile. Moreover, shorter filaments tend to have denser profiles than their longer counterparts.

astro-ph.CO↗

ThinkRepair: Self-Directed Automated Program Repair

Though many approaches have been proposed for Automated Program Repair (APR) and indeed achieved remarkable performance, they still have limitations in fixing bugs that require analyzing and reasoning about the logic of the buggy program. Recently, large language models (LLMs) instructed by prompt engineering have attracted much attention for their powerful ability to address many kinds of tasks including bug-fixing. However, the quality of the prompt will highly affect the ability of LLMs and manually constructing high-quality prompts is a costly endeavor. To address this limitation, we propose a self-directed LLM-based automated program repair, ThinkRepair, with two main phases: collection phase and fixing phase. The former phase automatically collects various chains of thoughts that constitute pre-fixed knowledge by instructing LLMs with the Chain-of-Thought (CoT) prompt. The latter phase targets fixing a bug by first selecting examples for few-shot learning and second automatically interacting with LLMs, optionally appending with feedback of testing information. Evaluations on two widely studied datasets (Defects4J and QuixBugs) by comparing ThinkRepair with 12 SOTA APRs indicate the priority of ThinkRepair in fixing bugs. Notably, ThinkRepair fixes 98 bugs and improves baselines by 27%-344.4% on Defects4J V1.2. On Defects4J V2.0, ThinkRepair fixes 12-65 more bugs than the SOTA APRs. Additionally, ThinkRepair also makes a considerable improvement on QuixBugs (31 for Java and 21 for Python at most).

cs.SE↗

Establishing HI mass v.s. stellar mass and halo mass scaling relations using an abundance matching method

We combined data from the Sloan Digital Sky Survey (SDSS) and the Arecibo Legacy Fast ALFA Survey (ALFALFA) to establish the HI mass vs. stellar mass and halo mass scaling relations using an abundance matching method that is free of the Malmquist bias. To enable abundance matching, a cross-match between the SDSS DR7 galaxy group sample and the ALFALFA HI sources provides a catalog of 16,520 HI-galaxy pairs within 14,270 galaxy groups (halos). By applying the observational completeness reductions for both optical and HI observations, we used the remaining 8,180 ALFALFA matched sources to construct the model constraints. Taking into account the dependence of HI mass on both the galaxy and group properties, we establish two sets of scaling relations: one with a combination of stellar mass, $({g-r})$ color and halo mass, and the other with stellar mass, specific star-formation rate ($\rm sSFR$), and halo mass. We demonstrate that our models can reproduce the HI mass component as both a stellar and halo mass. Additional tests showed that the conditional HI mass distributions as a function of the cosmic web type and the satellite fractions were well recovered.

astro-ph.GA↗