CodeGuard: Improving LLM Guardrails in CS Education
On the map: LLM safety and security → Safety alignment, refusal and guardrails
Abstract (arXiv)
Large language models (LLMs) are increasingly embedded in Computer Science (CS) classrooms to automate code generation, feedback, and assessment. However, their susceptibility to adversarial or ill-intentioned prompts threatens student learning and academic integrity. To cope with this important issue, we evaluate existing off-the-shelf LLMs in handling unsafe and irrelevant prompts within the domain of CS education. We identify important shortcomings in existing LLM guardrails which motivates us to propose CodeGuard, a comprehensive guardrail framework for educational AI systems. CodeGuard includes (i) a first-of-its-kind taxonomy for classifying prompts; (ii) the CodeGuard dataset, a collection of 8,000 prompts spanning the taxonomy; and (iii) PromptShield, a lightweight sentence-encoder model fine-tuned to detect unsafe prompts in real time. Experiments show that PromptShield achieves 0.93 F1 score, surpassing existing guardrail methods. Additionally, further experimentation reveals that CodeGuard reduces potentially harmful or policy-violating code completions by 30-65% without degrading performance on legitimate educational tasks. The code, datasets, and evaluation scripts are made freely available to the community.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Safety alignment, refusal and guardrails, one of 12 directions in LLM safety and security. Builds on 18 of its 63 references that are in the map. First posted on arXiv 22 Jan 2026.
Builds on
18 of 63 references.
Closest ancestors · 2
Same direction, newest first
- 2025Aegis2.0: A Diverse AI Safety Dataset and Risks Taxonomy for Alignment of LLM Guardrails15 Jan
- 2023CodeHelp: Using Large Language Models with Guardrails for Scalable Support in Programming Classes14 Aug
Other references · 16
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversationscited by 1,124
- 2021Ethical and social risks of harm from Language Modelscited by 957
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Railscited by 347
- 2023LaMini-LM: A Diverse Herd of Distilled Models from Large-Scale Instructionscited by 124
- 2020The Cost of Training NLP Models: A Concise Overviewcited by 97
- 2024Language Models for Text Classification: Is In-Context Learning Enough?cited by 39
- 2023StudentEval: A Benchmark of Student-Written Prompts for Large Language Models of Codecited by 32
4 more
- 2023Exploring the Role of AI Assistants in Computer Science Education: Methods, Implications, and Instructor Perspectivescited by 12
- 2024CSEPrompts: A Benchmark of Introductory Computer Science Promptscited by 3
- 2024Code LLMs: A Taxonomy-based Surveycited by 3
- 2026Guardrails for trust, safety, and ethical development and deployment of Large Language Models (LLM)cited by 2
Built on by
Citing papers per year: 2026: 1.
1 paper.