Skip to main content
QUICK REVIEW

[Paper Review] FRANC: A Lightweight Framework for High-Quality Code Generation

Mohammed Latif Siddiq, Beatrice Casey|arXiv (Cornell University)|Jul 17, 2023
Software Engineering ResearchComputer Science6 citations
TL;DR

FRANC is a lightweight, model-agnostic framework that improves code quality from LLM-based code generation via static filtering, quality-aware ranking, and prompt engineering. It boosts compilability by 9–46% in Java and 10–43% in Python, improves NDCG@10 by 0.0763, and repairs 80% of problematic prompts with minimal latency (0.08–1.98 seconds).

ABSTRACT

In recent years, the use of automated source code generation utilizing transformer-based generative models has expanded, and these models can generate functional code according to the requirements of the developers. However, recent research revealed that these automatically generated source codes can contain vulnerabilities and other quality issues. Despite researchers' and practitioners' attempts to enhance code generation models, retraining and fine-tuning large language models is time-consuming and resource-intensive. Thus, we describe FRANC, a lightweight framework for recommending more secure and high-quality source code derived from transformer-based code generation models. FRANC includes a static filter to make the generated code compilable with heuristics and a quality-aware ranker to sort the code snippets based on a quality score. Moreover, the framework uses prompt engineering to fix persistent quality issues. We evaluated the framework with five Python and Java code generation models and six prompt datasets, including a newly created one in this work (SOEval). The static filter improves 9% to 46% Java suggestions and 10% to 43% Python suggestions regarding compilability. The average improvement over the NDCG@10 score for the ranking system is 0.0763, and the repairing techniques repair the highest 80% of prompts. FRANC takes, on average, 1.98 seconds for Java; for Python, it takes 0.08 seconds.

Motivation & Objective

  • Address the growing problem of security vulnerabilities and low-quality code in LLM-generated source code.
  • Reduce the need for costly fine-tuning of large language models by introducing a lightweight post-processing framework.
  • Enable developers to obtain higher-quality, compilable, and secure code without retraining models.
  • Provide a configurable, model-agnostic solution that integrates static filtering, quality scoring, and prompt-based repair.
  • Demonstrate effectiveness across diverse code generation models and real-world prompts in Python and Java.

Proposed method

  • Apply a static filter to remove or repair non-compilable code using heuristics, improving syntactic correctness.
  • Integrate off-the-shelf static analysis tools (e.g., Pmd, Checkstyle, Spotbugs) to detect code smells and vulnerabilities for quality scoring.
  • Implement a quality-aware ranker that scores and ranks code snippets based on aggregated quality metrics from multiple tools.
  • Use LLM-powered prompt engineering to generate repair suggestions for low-quality code, focusing on persistent issues.
  • Design a modular, model-agnostic pipeline that processes prompts through filtering, ranking, and repair stages without model fine-tuning.
  • Leverage a new 70-prompt dataset derived from Stack Overflow to evaluate real-world applicability and robustness.

Experimental results

Research questions

  • RQ1To what extent can a lightweight framework improve the compilability of LLM-generated code without model fine-tuning?
  • RQ2How effective is the quality-aware ranking system in identifying the highest-quality code snippets across diverse models and prompts?
  • RQ3Can prompt engineering techniques automatically repair persistent quality issues in generated code?
  • RQ4How does FRANC perform across different programming languages (Python and Java) and code generation models?
  • RQ5What is the runtime overhead of FRANC when applied to real-time code generation workflows?

Key findings

  • The static filter improved code compilability by 9% to 46% for Java and 10% to 43% for Python across multiple models.
  • The quality-aware ranker achieved an average improvement of 0.0763 in NDCG@10, indicating stronger alignment with human-assessed relevance.
  • Prompt engineering techniques successfully repaired the highest 80% of problematic prompts, demonstrating effectiveness in fixing recurring quality issues.
  • FRANC achieved low latency, processing Python code in 0.08 seconds and Java code in 1.98 seconds on average, making it suitable for real-time use.
  • The framework demonstrated strong generalization across five code generation models (CodeParrot, InCoder, CodeGen, PolyCoder, GPT-3.5-turbo) and diverse prompt sets.
  • The replication package, including the new FRANC prompt dataset, is publicly available at https://github.com/s2e-lab/FRANC for reproducibility and extension.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.