On Codex Prompt Engineering for OCL Generation: An Empirical Study
Not on the map. Why?
Abstract (arXiv)
The Object Constraint Language (OCL) is a declarative language that adds constraints and object query expressions to MOF models. Despite its potential to provide precision and conciseness to UML models, the unfamiliar syntax of OCL has hindered its adoption. Recent advancements in LLMs, such as GPT-3, have shown their capability in many NLP tasks, including semantic parsing and text generation. Codex, a GPT-3 descendant, has been fine-tuned on publicly available code from GitHub and can generate code in many programming languages. We investigate the reliability of OCL constraints generated by Codex from natural language specifications. To achieve this, we compiled a dataset of 15 UML models and 168 specifications and crafted a prompt template with slots to populate with UML information and the target task, using both zero- and few-shot learning methods. By measuring the syntactic validity and execution accuracy metrics of the generated OCL constraints, we found that enriching the prompts with UML information and enabling few-shot learning increases the reliability of the generated OCL constraints. Furthermore, the results reveal a close similarity based on sentence embedding between the generated OCL constraints and the human-written ones in the ground truth, implying a level of clarity and understandability in the generated OCL constraints by Codex.
Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). Builds on 9 of its 29 references that are in the map. First posted on arXiv 28 Mar 2023.
Builds on
9 of 29 references.
References · 9
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,049
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
- 2020MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformerscited by 1,414
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2022BashExplainer: Retrieval-Augmented Bash Code Comment Generation based on Fine-tuned CodeBERTcited by 9
Built on by
Citing papers per year: 2024: 2; 2025: 5; 2026: 1.
8 papers.
- 2025Agent READMEs: An Empirical Study of Context Files for Agentic Codingcited by 21
- 2024Exploring Prompt Engineering: A Systematic Review with SWOT Analysiscited by 5
- 2024PathOCL: Path-Based Prompt Augmentation for OCL Generation with GPT-4cited by 4
- 2025Do Prompt Patterns Affect Code Quality? A First Empirical Assessment of ChatGPT-Generated Codecited by 4
- 2025Optimizing Retrieval Augmented Generation for Object Constraint Languagecited by 4
- 2025SHERPA: A Model-Driven Framework for Large Language Model Executioncited by 1
- 2026Leveraging LLMs to support co-evolution between definitions and instances of textual DSLs: A Systematic Evaluationcited by 1
- 2025Unify and Triumph: Polyglot, Diverse, and Self-Consistent Generation of Unit Tests with LLMscited by 0
- 2026Leveraging LLMs to support co-evolution between definitions and instances of textual DSLs: A Systematic Evaluation12 Feb 2026
- 2025Agent READMEs: An Empirical Study of Context Files for Agentic Coding17 Nov 2025
- 2025SHERPA: A Model-Driven Framework for Large Language Model Execution29 Aug 2025
- 2025Optimizing Retrieval Augmented Generation for Object Constraint Language19 May 2025
- 2025Do Prompt Patterns Affect Code Quality? A First Empirical Assessment of ChatGPT-Generated Code18 Apr 2025
- 2025Unify and Triumph: Polyglot, Diverse, and Self-Consistent Generation of Unit Tests with LLMs20 Mar 2025
- 2024Exploring Prompt Engineering: A Systematic Review with SWOT Analysis9 Oct 2024
- 2024PathOCL: Path-Based Prompt Augmentation for OCL Generation with GPT-421 May 2024