# INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulness

Source: [INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulness](<https://www.sota2.com/research/paper/68fa756b1e209131cea67bd7>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-01-02T07:39:54.605Z

Authors: Hung Le, Yingbo Zhou, Caiming Xiong, Silvio Savarese, Doyen Sahoo

Published: 2024-06-23T15:55:07.000Z

## Abstract

Large language models (LLMs) for code are typically trained to align with natural language instructions to closely follow their intentions and requirements. However, in many practical scenarios, it becomes increasingly challenging for these models to navigate the intricate boundary between helpfulness and safety, especially against highly complex yet potentially malicious instructions. In this work, we introduce INDICT: a new framework that empowers LLMs with Internal Dialogues of Critiques for both safety and helpfulness guidance. The internal dialogue is a dual cooperative system between a safety-driven critic and a helpfulness-driven critic. Each critic provides analysis against the given task and corresponding generated response, equipped with external knowledge queried through relevant code snippets and tools like web search and code interpreter. We engage the dual critic system in both code generation stage as well as code execution stage, providing preemptive and post-hoc guidance respectively to LLMs. We evaluated INDICT on 8 diverse tasks across 8 programming languages from 5 benchmarks, using LLMs from 7B to 70B parameters. We observed that our approach can provide an advanced level of critiques of both safety and helpfulness analysis, significantly improving the quality of output codes ($+10\\%$ absolute improvements in all models).

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Insecure Coding Practice on CyberSecEval Instruction 1.0](<https://www.sota2.com/research/sota/insecure-coding-practice-on-cyberseceval-instruction-1-0.md>): Insecure Coding Practice; CyberSecEval Instruction 1.0; C Score: 72.1.

- [Code Helpfulness Evaluation on CVS (test)](<https://www.sota2.com/research/sota/code-helpfulness-evaluation-on-cvs-test.md>): Code Helpfulness Evaluation; CVS (test); C++ Success Rate: 0.66.

- [Secure Code Generation on CVS (test)](<https://www.sota2.com/research/sota/secure-code-generation-on-cvs-test.md>): Secure Code Generation; CVS (test); C++ Success Rate: 98.

- [Insecure Coding Practice on CyberSecEval Autocomplete 1](<https://www.sota2.com/research/sota/insecure-coding-practice-on-cyberseceval-autocomplete-1.md>): Insecure Coding Practice; CyberSecEval Autocomplete 1; C: 83.7.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2407.02518>)

[PDF](<https://arxiv.org/pdf/2407.02518.pdf>)

[Implementation](<https://github.com/SalesforceAIResearch/indict_code_gen>)
