1. Introduction
The automotive industry is undergoing a fundamental transformation driven by electrification, autonomous driving, and increasing software content in modern vehicles. The AUTomotive Open System ARchitecture (AUTOSAR) has emerged as the industry standard for managing this complexity, providing a layered software architecture that decouples application logic from hardware dependencies [
1]. AUTOSAR enables modular, scalable, and reusable software development across electronic control units (ECUs), reducing development costs while supporting the integration of advanced functionalities across vehicle platforms.
A critical yet underappreciated aspect of AUTOSAR development is the configuration of Basic Software (BSW) modules. Each BSW module requires an AUTOSAR XML (ARXML) configuration file that specifies parameters, container hierarchies, and inter-module references according to the AUTOSAR ECU Configuration (ECUC) specification [
2]. These configuration files are notoriously verbose—a single Watchdog Manager configuration can span thousands of XML lines—and must satisfy complex structural and semantic constraints to ensure correct system behavior. Manual configuration is therefore time-consuming, error-prone, and a significant bottleneck in the development process, particularly for safety-critical modules that must comply with ISO 26262 [
3].
Large language models (LLMs) have recently demonstrated remarkable capabilities in structured output generation, including code synthesis, data transformation, and domain-specific content creation [
4,
5]. These models, built upon the Transformer architecture [
6] and refined through instruction tuning, can learn complex mappings between natural language specifications and structured outputs. The success of LLMs in software engineering tasks—from code completion to test generation—suggests their potential applicability to automated configuration generation.
However, applying LLMs directly to ARXML generation presents a fundamental challenge: the extreme verbosity of the target format. A typical WdgM ARXML configuration contains extensive boilerplate, deeply nested XML structures, and repetitive namespace declarations that consume the majority of output tokens without carrying proportional semantic content. Current LLMs, even with extended context windows, struggle to generate such lengthy structured outputs with the precision required for machine-parseable configuration files. Token-level errors in XML—a mismatched tag, an incorrect namespace, or a malformed reference—render the entire output invalid.
To address this challenge, we propose a two-stage approach: (1) fine-tune an open-source LLM to generate a compact JSON intermediate representation that captures only the semantically meaningful configuration parameters, reducing output requirements by approximately 8–10×, and (2) deterministically expand this compact representation into fully compliant ARXML using domain knowledge encoded in an expansion function. This decomposition leverages the LLM’s strength in understanding natural language and generating concise structured output, while delegating the mechanical, boilerplate-heavy expansion to deterministic code that guarantees structural validity.
The principal contributions of this paper are:
A novel compact JSON intermediate representation for WdgM configurations that reduces LLM output token requirements by approximately 8–10× while preserving all semantically meaningful parameters;
A synthetic dataset construction methodology based on compositional generation with five complexity tiers and 30+ diverse prompt templates;
A hierarchical evaluation pipeline—comprising schema validation with referential integrity enforcement, structural completeness, parameter accuracy, and semantic constraint satisfaction—tailored to AUTOSAR configuration assessment;
A comparative evaluation of three open-source LLMs (Qwen3-8B, Ministral-3-8B-Instruct, and Llama 3.1 8B) fine-tuned with QLoRA for AUTOSAR configuration generation.
While the proposed approach is designed to be applicable to any AUTOSAR BSW module whose configuration follows the ECUC container hierarchy, we select the Watchdog Manager (WdgM) as the proof-of-concept target for three reasons: (1) it is a safety-critical module governed by ISO 26262, making configuration correctness paramount; (2) its configuration exhibits rich combinatorial complexity—multiple supervision types, mode-dependent behavior, and cross-referencing between checkpoints, entities, and transition graphs—providing a challenging and representative test case; and (3) the WdgM’s self-contained configuration scope (no mandatory cross-module dependencies) allows isolated evaluation of the generation pipeline without confounding factors from inter-module interactions.
2. Background
2.1. AUTOSAR Architecture
AUTOSAR defines a standardized layered software architecture for automotive ECUs that separates application software from the underlying hardware [
1,
7]. The standard exists in two variants: the Classic Platform (CP), targeting resource-constrained deeply embedded ECUs with static configurations, and the Adaptive Platform (AP), designed for high-performance computing ECUs running POSIX-based operating systems. This paper focuses exclusively on the Classic Platform, which remains the dominant architecture for safety-critical powertrain, chassis, and body control functions. The CP architecture comprises three principal layers: the Application Layer, the Runtime Environment (RTE), and the Basic Software (BSW). The Application Layer contains software components (SW-Cs) implementing vehicle functions, which communicate through standardized ports and interfaces. The RTE serves as middleware, providing communication services between software components and the BSW layer, abstracting the underlying infrastructure.
The BSW layer is further decomposed into the Services Layer, the ECU Abstraction Layer, the Microcontroller Abstraction Layer (MCAL), and the Complex Device Drivers. The Services Layer provides high-level services including operating system, memory, communication, and diagnostic services. Each BSW module is configured through ARXML files that conform to the ECU Configuration (ECUC) specification [
2]. The ECUC specification defines a meta-model in which each BSW module publishes a Parameter Definition (ParamDef) schema describing its configurable containers and parameters, and individual configurations are instances of that schema. ARXML is the schema-governed XML format that serializes these configuration instances, encoding parameters within nested container hierarchies where each element must reference a defined definition path in the AUTOSAR schema. The verbosity inherent to XML, combined with deep container nesting and extensive cross-referencing, makes ARXML files notably lengthy relative to their semantic content.
The ECUC configuration model follows a container-based hierarchy in which each configuration element is an instance of a schema-defined container type [
2]. Containers hold sub-containers and parameter values, forming trees that mirror the module’s logical structure. Parameters are strongly typed:
ECUC-NUMERICAL-PARAM-VALUE for integers and floats,
ECUC-TEXTUAL-PARAM-VALUE for strings, and
ECUC-BOOLEAN-PARAM-VALUE for flags. Each container and parameter carries a
DEFINITION-REF attribute that links it to its schema definition via an absolute path (e.g.,
/AUTOSAR/EcucDefs/WdgM/WdgMGeneral). Cross-references between containers—such as a supervision configuration referencing a checkpoint defined elsewhere—use
ECUC-REFERENCE-VALUE elements with a destination path. This rigid schema-instance relationship means that the structural boilerplate—container wrappers, definition paths, namespace declarations, and closing tags—is fully determined by the semantic parameter values. Only the values themselves (names, identifiers, numeric parameters, and reference targets) vary between configurations, a property that is central to the intermediate representation approach proposed in this paper.
In practice, BSW configuration is performed using specialized vendor tools such as Vector DaVinci Configurator, EB tresos Studio, ETAS ISOLAR, or Siemens Capital Embedded Integrator AR Classic, which provide graphical interfaces for navigating parameter hierarchies and validating constraints against the ECUC schema [
8]. These tools are proprietary, require per-seat licenses, and demand significant domain expertise to operate effectively. Configuration remains a largely manual process within these tools: engineers navigate complex container trees, set individual parameters, and resolve cross-references by hand. For organizations without access to commercial toolchains—or for rapid prototyping, education, and early-stage development—the barrier to producing valid ARXML configurations is substantial, motivating the exploration of automated generation approaches.
2.2. Watchdog Manager
The Watchdog Manager (WdgM) is a BSW module in the AUTOSAR Services Layer responsible for monitoring the execution integrity of software entities [
9]. It provides a hardware-independent supervision interface that abstracts the underlying watchdog hardware, enabling systematic detection of software faults in safety-critical systems compliant with ISO 26262 [
3].
The WdgM implements three distinct supervision mechanisms [
9].
Alive supervision monitors periodic tasks by counting checkpoint arrivals within a supervision reference cycle. The WdgM compares the observed count against an expected value with configurable minimum and maximum margins, creating a tolerance window
,
. If the count falls outside this window, the supervision reports a failure, detecting both under-execution (task stalled or blocked) and over-execution (task running more frequently than intended).
Deadline supervision monitors aperiodic or event-driven execution by measuring wall-clock time between a designated start checkpoint and stop checkpoint. Both minimum and maximum time bounds must be specified, enabling detection of premature completion (which may indicate skipped processing) as well as late completion (which may indicate resource starvation or deadlocks).
Logical supervision validates control flow correctness using directed transition graphs in which nodes represent checkpoints and edges represent permitted transitions. At runtime, the WdgM tracks the last-reported checkpoint for each graph and raises a supervision error if a transition occurs that is not in the permitted set, thereby detecting sequence errors, unexpected jumps, and corrupted execution paths. The specification distinguishes two scopes: internal transitions occur within a single supervised entity, validating intra-task control flow, while external transitions span multiple supervised entities, enabling cross-task control flow validation for pipelines or handoff sequences where execution must follow a prescribed inter-entity order.
The WdgM organizes monitoring around Supervised Entities (SEs), which are logical software units that require supervision. Each SE is identified by a unique entity ID (range 0–65,535) and contains one or more checkpoints—instrumentation points embedded in the supervised code, each carrying a checkpoint ID in the same range. Every SE must designate an initial checkpoint and a final checkpoint that mark the entry and exit points of its monitored execution path. SEs are not rigidly bound to specific AUTOSAR components; they can span software components, BSW modules, or complex device drivers, providing flexible monitoring granularity. The WdgM configuration specifies which supervision mechanisms apply to each SE, the parameters governing each mechanism, and the mode-dependent behavior through WdgM modes that define active supervision sets for different operating states.
The WdgM organizes its runtime behavior around
modes, which represent distinct operational states of the system [
9]. Each mode is identified by a mode ID (range 0–255) and activates a specific set of supervised entities together with their associated supervision configurations. Exactly one mode must be designated as the initial mode, which is active at system startup. Each mode carries a
supervision cycle parameter that defines the base time period for alive supervision counting, and an
expired supervision cycle tolerance that specifies how many consecutive expired cycles are permitted before declaring a supervision failure. The mode mechanism enables the same supervised entity to be monitored with different parameters under different operating conditions—for instance, tighter timing constraints during normal operation and relaxed bounds during startup or degraded modes.
The configuration complexity of the WdgM arises from the combinatorial relationships between these elements: each mode can activate different subsets of supervised entities, each SE can employ multiple supervision types simultaneously, and referential integrity must be maintained across checkpoints, transition graphs, and mode assignments.
Within the ISO 26262 functional safety framework, the WdgM serves as a safety mechanism for detecting systematic and random software faults during runtime [
3,
9]. By providing independent monitoring of software execution, the WdgM contributes to achieving the required Automotive Safety Integrity Level (ASIL) for safety-critical functions. Configuration errors in the WdgM—such as incorrect supervision parameters, missing checkpoints, or broken referential integrity between modes and entities—can compromise the safety mechanism’s effectiveness, potentially leaving software faults undetected. This makes configuration correctness a safety-relevant concern and underscores the value of automated generation approaches that can guarantee structural validity.
2.3. Large Language Models
Modern large language models are built upon the Transformer architecture introduced by Vaswani et al. [
6], which employs self-attention mechanisms to capture long-range dependencies in sequential data. Decoder-only Transformer models, trained on large text corpora using next-token prediction, have proven highly effective at generating coherent and contextually appropriate text, including structured formats such as code and markup. Brown et al. [
10] demonstrated that scaling model size unlocks few-shot learning capabilities, and subsequent work has shown that larger models exhibit emergent abilities—qualitative improvements in task performance that appear at certain scale thresholds [
11].
Instruction tuning and reinforcement learning from human feedback (RLHF) [
12] further align pretrained models with user intent, enabling them to follow complex specifications and produce task-specific outputs. Models such as Qwen3 [
13], Ministral 3 [
14], and Llama 3.1 [
15] represent the current generation of open-weight LLMs that achieve competitive performance with proprietary alternatives across a range of generation tasks. Qwen3 features hybrid thinking modes that support both extended chain-of-thought reasoning and fast direct response within a single architecture, with a 32 K native context window (extendable to 128 K via YaRN). Ministral 3 is a multimodal model distilled from the larger Mistral Small 3.1 (24 B) via cascade distillation [
14], succeeding the earlier Mistral 7B [
16] in the small-model category. It features an 8.4 B-parameter language backbone alongside a vision encoder, a 256 K context window, and is designed for efficient edge deployment with strong structured output generation capabilities. Llama 3.1 [
15], the latest in the Llama series [
17,
18], offers a 128 K token context window and strong multilingual and coding capabilities, and has been widely adopted as a base model for domain-specific fine-tuning.
A key enabler for domain-specific adaptation is parameter-efficient fine-tuning (PEFT). Low-Rank Adaptation (LoRA) [
19] introduces trainable low-rank decomposition matrices alongside frozen pretrained weights, dramatically reducing the number of trainable parameters while preserving model capacity. Quantized LoRA (QLoRA) [
20] extends this approach by quantizing the base model to 4-bit precision (NormalFloat4) and applying LoRA adapters on the quantized weights, enabling fine-tuning of 7–8 billion parameter models on a single consumer GPU with minimal quality degradation. These techniques make it practical to specialize LLMs for narrow domains such as AUTOSAR configuration generation without requiring large-scale compute infrastructure.
While LLMs excel at natural language generation, producing structured outputs such as code, XML, or JSON presents distinct challenges related to syntactic validity, schema conformance, and referential consistency. Unlike natural language where minor errors are tolerable, structured formats require exact syntactic correctness—a single mismatched bracket, unclosed tag, or malformed reference can invalidate the entire output. Chen et al. [
21] demonstrated that LLMs trained on code can achieve strong performance on programming tasks, and subsequent code-specialized models such as Code Llama [
22] and Qwen2.5-Coder [
23] have shown that domain-specific training data significantly improves structured generation quality. A comprehensive survey by Fan et al. [
5] identifies output length and structural complexity as key factors that degrade generation accuracy, with error rates increasing substantially for longer and more deeply nested outputs.
Recent work has explored intermediate representations (IRs) as a strategy for improving LLM performance on structured generation tasks. Rather than generating the full verbose target format directly, the LLM produces a compact semantic representation that is then expanded deterministically into the target format. DeLorenzo et al. [
24] applied this principle to hardware description generation, and Paul et al. [
25] demonstrated that compiler IRs can serve as a bridge language to improve multilingual code generation. Both works validate the broader principle that decomposing generation into a semantic-capture phase and a mechanical-expansion phase improves both accuracy and efficiency. We discuss these approaches in detail in
Section 3.
3. Related Work
The application of large language models to automotive software engineering is an emerging area of research with several recent contributions spanning code generation, model engineering, and formal verification.
Kirchner and Knoll [
26] investigated the use of GPT-4 for generating safety-critical automotive functions, specifically an adaptive cruise control (ACC) implementation in C++. Their pipeline incorporates static analysis using Microsoft’s Static Driver Verifier and adherence to AUTOSAR coding standards. Through cyclic prompting and iterative testing, they demonstrated that LLMs can produce syntactically correct automotive code that satisfies safety constraints. However, their work focuses on application-level C++ code generation rather than BSW configuration, and relies on proprietary models.
In the domain of model-driven engineering, Petrovic et al. [
27] explored LLM-assisted metamodel engineering for automotive design. They employed GPT-4o to automatically generate Eclipse EMF Ecore metamodels from textual requirements, iteratively refining the output through visual feedback using PlantUML diagrams. Their approach demonstrates the potential of LLMs to work with structured modeling languages following AUTOSAR principles, though their focus on metamodel creation differs substantially from configuration generation for specific BSW modules.
Pan et al. [
28] proposed an agentic workflow that combines LLMs with formal methods for automotive software development. Their approach uses GPT-4o to extract event chain models from natural language requirements, then employs LLMs to generate both implementation code and formal system models that enable rigorous verification through simulation. This hybrid approach of combining generative AI with formal validation is complementary to our work, though it targets a different stage of the development process.
El-Gnainy et al. [
29] addressed AI-enhanced AUTOSAR configuration directly, employing a YAML intermediate representation to reduce token consumption when mapping English descriptions to ARXML, and training an AI model on 12,000 samples with reported 100% conversion accuracy. Their work represents the closest prior effort to our own in targeting AUTOSAR configuration automation with an intermediate representation. Our approach differs in several respects: (1) we use a compact JSON schema with Pydantic validation that enforces referential integrity at generation time, rather than a loosely structured YAML format; (2) we introduce a compositional dataset methodology with controlled complexity tiers and structural diversity constraints; (3) we propose a hierarchical evaluation pipeline with domain-specific metrics beyond binary accuracy; and (4) we provide a comparative evaluation of three open-weight models fine-tuned with QLoRA.
Beyond the automotive domain, several recent works have demonstrated the value of intermediate representations for improving LLM generation of structured outputs. DeLorenzo et al. [
24] proposed Abstractions-of-Thought (AoT), a prompting framework that uses structured intermediate representations to guide LLMs in generating Verilog hardware descriptions from natural language specifications. By separating functional decomposition from code syntax through an IR layer, AoT achieved 1.8–5.2× token reduction while improving functional correctness over chain-of-thought and tree-of-thought baselines. Our approach shares the IR decomposition philosophy but differs in three key aspects: we target a configuration format rather than behavioral code, we employ fine-tuning rather than prompting, and our deterministic expansion guarantees structural validity by construction.
Paul et al. [
25] demonstrated that compiler intermediate representations can serve as a bridge language to improve multilingual code generation. Their IRCoder models, trained on a parallel corpus of source code and LLVM IR, showed consistent gains in code completion, understanding, and cross-lingual transfer. This work validates the broader principle that intermediate representations improve LLM generation quality for structured outputs, supporting our use of compact JSON as a semantic bridge between natural language and ARXML.
Unlike prior work that focuses on application code generation, metamodel engineering, or workflow automation, our approach directly targets the generation of validated ARXML configurations for a safety-critical BSW module. The key differentiators are: (1) a compact intermediate representation that addresses the verbosity challenge specific to ARXML, achieving approximately 8–10× token reduction with deterministic reconstruction guarantees, (2) compositional dataset construction with controlled complexity tiers, and (3) a hierarchical evaluation pipeline that goes beyond syntactic correctness to assess semantic validity of the generated configurations. To our knowledge, this is the first work to combine three elements that prior efforts address only in isolation: fine-tuned
open-weight models (rather than proprietary GPT-4-class APIs as in [
26,
27,
28]), a
schema-validated intermediate representation that enforces referential integrity at generation time (rather than the unconstrained YAML of [
29]), and a
deterministic expansion stage that guarantees structural conformance by construction. This combination targets a deployment profile distinct from prior automotive-LLM work: 8 B-parameter open-weight models fine-tuned and run on a single GPU, with structural validity guaranteed by the expansion stage rather than relying on the scale of a proprietary model.
4. Materials and Methods
4.1. Problem Formulation
We formulate the task of automated WdgM configuration generation as a conditional generation problem. Given a natural language description d specifying the desired WdgM behavior—including supervision modes, supervised entities, checkpoint configurations, and timing parameters—the goal is to produce a valid ARXML configuration file x that (1) conforms to the AUTOSAR ECUC schema for the WdgM module, (2) satisfies all referential integrity constraints between configuration elements, and (3) correctly implements the supervision semantics described in d.
Formally, we seek to learn a mapping , where is the space of natural language descriptions and is the space of valid WdgM ARXML configurations. Rather than learning this mapping directly, we decompose it as , where maps descriptions to compact JSON representations and is a deterministic expansion function that transforms compact representations into ARXML.
4.2. System Architecture
The proposed system follows a pipeline architecture consisting of five stages:
Natural Language Input: The user provides a textual description of the desired WdgM configuration, specifying supervision requirements, entity definitions, and timing constraints;
LLM Generation: A fine-tuned LLM processes the input and generates a compact JSON representation containing only the semantically meaningful configuration parameters;
Validation: The generated JSON is validated against a predefined schema using Pydantic models that enforce structural constraints, type correctness, and referential integrity;
Deterministic Expansion: A rule-based expansion function transforms the validated compact JSON into full ARXML, inserting boilerplate elements, namespace declarations, container hierarchies, and definition paths;
Output: The resulting ARXML file conforms to the AUTOSAR ECUC schema and can be imported directly into AUTOSAR configuration tools.
This decomposition isolates the creative, language-understanding task (stages 1–2) from the mechanical, rule-governed transformation (stages 3–5), allowing each component to be optimized independently.
Figure 1 illustrates the overall pipeline.
4.3. Compact Output Representation
The compact intermediate representation is the central innovation of our approach. Full ARXML configurations for the WdgM module are extremely verbose: a configuration with three supervised entities and two modes typically spans 2000–4000 tokens when encoded as XML. Analysis of typical WdgM ARXML files reveals that approximately 85–90% of tokens consist of structural boilerplate—namespace prefixes, container type declarations, definition path references, and closing tags—that is fully deterministic given the semantic parameters.
Our compact JSON representation retains only the parameters that carry semantic content: supervision type selections, timing values, checkpoint identifiers, transition edges, and mode assignments. Listing 1 illustrates the compact format for a simple configuration, while Listing 2 shows the corresponding ARXML excerpt.
| Listing 1. Compact JSON representation (excerpt). |
- 1
{ - 2
"general": {"dev_error": true, - 3
"immediate_reset": false}, - 4
"entities": [ - 5
{"name": "SE_Main", "eid": 0, - 6
"checkpoints": [ - 7
{"name":"CP_Init","cp_id":0}, - 8
{"name":"CP_Run","cp_id":1}], - 9
"init_cp": "CP_Init", - 10
"final_cp": "CP_Run", - 11
"transitions": [ - 12
{"source":"CP_Init","dest":"CP_Run"}] - 13
}], - 14
"modes": [ - 15
{"name": "RunMode", "mid": 0, - 16
"cycle": 0.02, - 17
"initial": true, - 18
"alive": [ - 19
{"entity": "SE_Main", - 20
"checkpoint": "CP_Init", - 21
"expected": 1, - 22
"max_margin": 1, "min_margin": 1, - 23
"ref_cycle": 5}], - 24
"deadline": [ - 25
{"entity": "SE_Main", - 26
"start_cp": "CP_Init", - 27
"stop_cp": "CP_Run", - 28
"deadline_min": 0.005, - 29
"deadline_max": 0.015}] - 30
}] - 31
}
|
| Listing 2. Corresponding ARXML excerpt (abbreviated). |
![Applsci 16 08443 i001 Applsci 16 08443 i001]() |
The compact representation requires approximately 300–600 tokens for typical configurations, compared to 2000–5000 tokens for the equivalent ARXML—a reduction of approximately 8–10×. This reduction is critical for practical LLM generation: it brings the output within the comfortable generation range of 7–8B parameter models while maintaining all information needed for deterministic reconstruction.
The deterministic expansion function g reconstructs the full ARXML container hierarchy from the compact representation through a three-stage process, as shown in Algorithm 1.
| Algorithm 1 Deterministic expansion |
Require: Validated CompactConfig c Ensure: Valid ARXML string 1: Stage 1: Entity expansion 2: for each entity e in c.entities do 3: Create WdgMSupervisedEntity with entity_id 4: for each checkpoint in e.checkpoints do 5: Create WdgMCheckpoint sub-container 6: end for 7: Set initial/final checkpoint references using path: 8: /Config/WdgM/WdgMGeneral/{entity}/{cp} 9: for each transition t in e.internal_transitions do 10: Create WdgMInternalTransition with source/dest refs 11: end for 12: end for 13: Stage 2: Mode expansion 14: for each mode m in c.modes do 15: Create WdgMMode with mode_id, supervision_cycle 16: for each supervision in alive, deadline, ext. logical do 17: Create typed sub-container with parameter values 18: Insert cross-references to entity checkpoints 19: end for 20: end for 21: Stage 3: Assembly 22: Wrap entities in WdgMGeneral with boolean parameters from c.general 23: Wrap modes in WdgMConfigSet with initial mode reference 24: Wrap in AUTOSAR root with schema location 25: Serialize Pydantic-XML model tree to ARXML 26: return ARXML string
|
Figure 2 illustrates the same three-stage process as a flowchart.
In Stage 1, each compact entity is expanded into a WdgMSupervisedEntity container with nested WdgMCheckpoint and WdgMInternalTransition sub-containers. All cross-references are constructed as deterministic short-name paths (e.g., /Config/WdgM/WdgMGeneral/SE_Main/CP_Init), and each container receives the appropriate DEFINITION-REF pointing to the corresponding ECUC parameter definition.
In Stage 2, each compact mode is expanded into a WdgMMode container. Supervision configurations are created as typed sub-containers (WdgMAliveSupervision, WdgMDeadlineSupervision, or WdgMExternalLogicalSupervision), each containing the relevant parameter values and checkpoint references that point back to entities defined in Stage 1.
In Stage 3, the expanded entities and modes are assembled into the full AUTOSAR container hierarchy (WdgMGeneral → WdgMConfigSet → root AUTOSAR element) and serialized to XML. The entire expansion is implemented using Pydantic-XML models that enforce type constraints during construction, providing an additional validation layer before serialization. Because the expansion is entirely rule-based and depends only on the WdgM ECUC schema definition, it introduces no ambiguity and guarantees structural conformance by construction.
4.4. Dataset Construction
We construct a synthetic training dataset of approximately 6050 samples using a compositional generation approach based on deterministic structural enumeration. Rather than hand-crafting individual examples or relying on purely random sampling within tier bounds, we enumerate all valid structural patterns—combinations of entity count, mode count, and supervision type—and generate controlled variants for each pattern. To ensure structural diversity, each configuration is assigned a fingerprint encoding its shape (e.g., E2M1C4_A+D denotes 2 entities, 1 mode, 4 checkpoints, alive and deadline supervisions), and no more than 50 samples share the same fingerprint. This produces 1301 unique structural patterns across the dataset, preventing pattern dominance and encouraging the model to generalize across configurations. The configuration space itself—its parameter ranges, naming conventions, and admissible structural combinations—was informed by a real customer (OEM) WdgM project, so that the generated samples reflect realistic usage while the compositional enumeration broadens coverage systematically beyond any single project. To corroborate this externally and independently of our own validators, a representative sample of the generated configurations was subjected to two checks: it was validated for schema and consistency conformance using Capital Embedded Integrator AR Classic (version 2408), an industrial Siemens AUTOSAR configuration tool, and it was reviewed by a domain expert at a Tier-2 supplier that develops WdgM software, who confirmed its consistency with production WdgM configurations.
4.4.1. Complexity Tiers
The dataset is organized into five complexity tiers to ensure the model learns to handle configurations ranging from minimal to highly complex.
Table 1 summarizes the tier definitions, sample counts, and unique fingerprints per tier.
Figure 3 illustrates the sample and structural diversity distribution. Note that the Simple tier yields fewer samples than higher tiers (350 vs. its 600 target) because its limited structural space—only 1 entity and 1 mode—saturates the fingerprint cap early.
4.4.2. Parameter Variation
Within each tier, configuration parameters are sampled from domain-appropriate ranges. Alive supervision parameters include expected alive indications (1–10), minimum and maximum margins (±1–5), and reference cycles (1–20). Deadline supervision bounds range from 1 ms to 500 ms. Logical supervision graphs vary from simple linear chains to branching topologies with 2–6 transitions. Entity and checkpoint identifiers are drawn from a vocabulary of meaningful automotive names (e.g., SE_EngineCtrl, CP_Init, CP_Shutdown).
4.4.3. Prompt Diversification
To ensure robustness to varied natural language inputs, each configuration is paired with a prompt drawn from a library of 30+ templates spanning five categories: (1) direct specification (“Configure a WdgM with…”), (2) requirement-style (“The system shall monitor…”), (3) conversational (“I need a watchdog setup that…”), (4) tabular (parameters listed in structured form), and (5) scenario-based (“For an engine control application with 20ms cycle time…”).
4.5. Model Selection and Fine-Tuning
We evaluate three open-source LLMs selected for their strong performance on code and structured generation tasks within the 8 B parameter range:
Qwen3-8B [
13]: Alibaba’s model featuring hybrid thinking modes, supporting both extended chain-of-thought reasoning and fast direct response. During fine-tuning, thinking mode is explicitly disabled so the model learns to produce compact JSON directly without intermediate reasoning tokens.
Ministral-3-8B-Instruct [
14]: Mistral AI’s latest small model, distilled from the 24 B Mistral Small 3.1 via cascade distillation. It is a multimodal architecture with an 8.4 B-parameter language backbone and a Pixtral vision encoder; only the language model layers are fine-tuned in our experiments.
Llama 3.1 8B Instruct [
15]: Meta’s instruction-tuned model with a 128 K context window and strong multilingual and coding capabilities.
All models are fine-tuned using QLoRA [
20] with the following configuration: LoRA rank
, scaling factor
, and dropout
. For Qwen3-8B and Llama 3.1 8B, LoRA adapters are applied to all linear layers and the base model is quantized to 4-bit NormalFloat (NF4) precision with double quantization enabled. For Ministral-3-8B-Instruct, which uses a multimodal architecture, adapters target only the language model’s attention and MLP projections (
q_proj,
k_proj,
v_proj,
o_proj,
gate_proj,
up_proj,
down_proj), and the base model is loaded in FP8 precision with dequantization. Training proceeds for 3 epochs using the paged AdamW 32-bit optimizer with weight decay of 0.01, a cosine learning rate schedule, peak learning rate of
, 50 warmup steps, and bf16 mixed precision. The effective batch size is 8 (per-device batch size of 4 with gradient accumulation over 2 steps). The maximum sequence length is 2048 tokens with sample packing enabled to maximize GPU utilization. Flash Attention 2 is used for all models to accelerate training.
Each training sample is formatted as an instruction-following conversation with a system prompt that establishes the model’s role as an AUTOSAR configuration expert, a user message containing the natural language description, and an assistant response containing a compact JSON output.
4.6. Hardware and Software
All fine-tuning experiments are conducted on a single NVIDIA L40S GPU (NVIDIA Corporation, Santa Clara, CA, USA; 48 GB VRAM), using PyTorch 2.10.0 with CUDA 12.6. We use the Hugging Face Transformers [
30] (v5.2.0) and Datasets [
31] (v4.5.0) libraries with PEFT (Parameter-Efficient Fine-Tuning, v0.18.1) and BitsAndBytes (v0.49.2) for QLoRA implementation. Training is managed through the SFTTrainer from the TRL (Transformer Reinforcement Learning, v0.28.0) library. Inference is performed using the Transformers
model.generate() API with greedy decoding.
4.7. Baselines
We compare fine-tuned models against the following baselines:
Zero-shot: Each base model is prompted with the task description and system prompt without any fine-tuning, to measure the inherent capability of pretrained models for this domain;
Few-shot (three-shot): Each base model receives three in-context examples spanning different complexity levels—a simple alive-only configuration, a mixed alive and deadline configuration, and a multi-entity configuration with external logical supervision—representing the best performance achievable without fine-tuning.
4.8. Evaluation Metrics
We employ a hierarchical evaluation pipeline with seven levels, where each level gates the next. If a sample fails at an earlier level, subsequent metrics are not computed.
4.8.1. Validation Metrics
JSON Parsability: The percentage of generated outputs that parse as valid JSON. Markdown code fences are stripped before parsing;
Schema Validation Rate: The percentage of parseable outputs that conform to the CompactConfig Pydantic schema, which enforces type constraints and referential integrity (e.g., checkpoint names referenced in supervisions must exist in their respective entities).
Roundtrip Validation Rate: The percentage of schema-valid outputs that survive deterministic expansion to a full AUTOSAR model and re-validation, confirming the configuration is structurally sound from end to end.
4.8.2. Domain-Specific Metrics
The following metrics are computed only for schema-valid outputs:
Structural Completeness (SC): Whether the generated output has the correct number of entities, modes, and supervision types compared to the reference. Per-mode supervision counts (alive, deadline, external logical) are also evaluated as fractional accuracy scores.
Parameter Accuracy (PA): The fraction of configuration parameters that match the ground truth. Matching is exact for discrete values (integers, strings, booleans) and uses a 5% relative tolerance for floating-point values (e.g., supervision cycle, deadlines). Parameters are matched by their identifiers: entities by eid, modes by mid, checkpoints by cp_id, and supervisions by entity name.
Semantic Constraint Satisfaction (SCS): A boolean check that domain-specific constraints are satisfied, including: unique entity IDs and names, unique mode IDs and names, unique checkpoint IDs within each entity, and positive supervision cycle values.
4.8.3. Overall Score
A weighted composite score combines the metrics: samples that fail JSON parsing score 0, schema-only validation scores 0.1, roundtrip-only scores 0.2, and valid samples score , where SC is the structural completeness fraction and PA is parameter accuracy.
The weighting reflects a graded notion of configuration usefulness in which validity, completeness, and correctness form a strict hierarchy. The base reward of 0.3 for any output that survives deterministic expansion (roundtrip-valid) recognizes that producing a schema-conformant, structurally sound configuration from a verbose target format is itself the principal obstacle for LLMs and a prerequisite for any downstream use. The remaining 0.7 is split between structural completeness (0.3) and parameter accuracy (0.4), with parameter accuracy weighted higher because correct parameter values—supervision timings, expected alive counts, mode assignments—are the ultimate functional requirement: a structurally complete configuration carrying incorrect timing values is not merely incomplete but potentially unsafe, whereas a structurally incomplete configuration is more readily detected and repaired. To confirm that our conclusions do not hinge on the specific weights, we recomputed the overall score under six alternative weighting schemes spanning base rewards of – and structural-completeness/parameter-accuracy splits ranging from to . The relative ranking of the three fine-tuned models (Llama 3.1 8B > Qwen3-8B > Ministral-3-8B) is preserved under every scheme tested, indicating that the model comparison is robust to the precise choice of weights.
4.8.4. Test Set
The evaluation test set comprises 200 samples curated across 10 categories (20 samples each): alive only, deadline only, mixed supervision, internal transition, external logical, multi-mode, complex, paraphrased prompts, out-of-distribution prompts, and edge cases. These samples are held out from training and generated using entity/checkpoint names and prompt templates not seen during training to assess generalization.
5. Results and Discussion
5.1. Overall Model Comparison
Table 2 presents the overall performance of all three fine-tuned models on the held-out test set of 200 samples.
All three models achieve ≥99.5% JSON parsability and ≥93% schema validity, confirming that fine-tuning effectively teaches the compact JSON format and its structural constraints. The models achieve closely comparable performance: Llama 3.1 8B attains the highest overall score (0.836), Ministral-3-8B the highest parameter accuracy (73.8%), and Qwen3-8B the highest schema validity (98.0%). All models reach 100% semantic constraint satisfaction on schema-valid outputs.
The narrow performance gap across models (0.815–0.836 overall) suggests that fine-tuning on a well-structured domain-specific dataset largely equalizes differences in base model architecture and pretraining data. Qwen3-8B’s slight structural validity advantage may stem from its hybrid thinking architecture, which even with thinking mode disabled may retain stronger internal reasoning about schema constraints. Ministral-3-8B’s parameter accuracy edge likely benefits from its cascade distillation training, which preserves the teacher model’s precision on structured outputs.
5.2. Per-Category Performance
Table 3 shows the per-category performance of Llama 3.1 8B (best overall score) broken down by the 10 test categories.
The model achieves strong performance across all categories, with Complex (0.929) and Mixed Supervision (0.920) scoring highest. Notably, the Complex category—which involves three–six entities, two–four modes, and all three supervision types simultaneously—achieves 100% schema validity and 82.2% parameter accuracy, indicating that the model handles structurally demanding configurations effectively. Out-of-distribution (0.860) and internal transition (0.834) also perform well, demonstrating good generalization to unseen prompts and multi-entity configurations.
The weakest category is edge cases (0.728), reflecting the inherent difficulty of boundary conditions and unusual parameter combinations. Multi-mode (0.796) and deadline only (0.798) show slightly lower schema validity (90–95%), suggesting that mode-switching configurations and isolated deadline supervisions present modest challenges for the model.
5.3. Baseline Comparison
Table 4 compares zero-shot, three-shot, and fine-tuned performance across all three models.
The baseline comparison reveals several key findings. First, zero-shot performance is near-zero for all models: while JSON parsability ranges from 93–99%, no model produces schema-valid output without examples or fine-tuning, confirming that the WdgM compact schema is too specialized for general-purpose LLMs.
Second, the three-shot baselines show markedly different behavior across models. Ministral-3-8B is the strongest few-shot learner (0.533 overall, 51% schema validity), while Qwen3-8B’s few-shot performance is severely degraded by its thinking mode—only 16% of outputs parse as valid JSON, as the model interleaves reasoning tokens with the JSON output. Llama 3.1 8B achieves moderate few-shot performance (0.500 overall, 53.5% schema validity).
Third, the three-shot baselines achieve higher parameter accuracy (88–94%) than fine-tuned models (72–74%) on schema-valid outputs. This occurs because few-shot models closely mimic the provided examples, producing accurate parameter values when they succeed but failing entirely on structurally dissimilar configurations. Fine-tuned models generalize across a broader range of structural patterns, achieving substantially higher schema validity (93–98% vs. 15–53.5%) and overall scores (0.815–0.836 vs. 0.142–0.533).
This comparison constitutes an ablation of the
fine-tuning component of our approach: holding the compact intermediate representation fixed, it isolates the effect of fine-tuning against in-context learning, and shows that fine-tuning is necessary to attain reliable schema validity (an 8.4× overall-score improvement over zero-shot and a 57% improvement over three-shot).
Section 5.4 complements this with an ablation of the
representation component, holding fine-tuning fixed and removing the compact IR.
5.4. Ablation: Effect of the Compact Intermediate Representation
To isolate the contribution of the compact IR—the central design choice of our approach—we compare it against an otherwise identical pipeline in which the model is fine-tuned to generate the full ARXML directly, bypassing the intermediate representation. This ablation holds the fine-tuning component fixed (same base model, Llama 3.1 8B; same QLoRA configuration; same prompts and configurations) and varies only the generation target. To score the direct-ARXML outputs with the identical hierarchical pipeline, generated ARXML is parsed back into the compact schema and evaluated against the same references; a perfect ARXML output recovers an overall score of 1.0 under this procedure, so any degradation reflects generation quality rather than parsing.
The first finding is one of
feasibility. Because a typical WdgM ARXML configuration is approximately an order of magnitude longer than its compact representation (
Section 4.3), the direct-ARXML targets are too long to generate for all but the simpler configurations: across the training distribution, only about 37% of configurations produce ARXML that fits within an 8192-token generation window, and within the test set the entire
complex category is infeasible (its references exceed the window), leaving 180 of 200 test samples on which direct generation can even be attempted. This length barrier is itself a direct quantification of why the compact IR is necessary: the representation is not merely a convenience but a precondition for generating valid configurations within the practical output limits of 8 B-parameter models.
The second finding concerns
quality where direct generation is feasible. We fine-tune Llama 3.1 8B to emit ARXML directly on the window-feasible training subset—using the same base model, QLoRA configuration, and number of epochs as the compact-IR model, so that only the generation target differs—and evaluate it on the 180 feasible test samples.
Table 5 reports the comparison on this identical subset. Removing the compact IR collapses performance: schema validity falls from 97.2% to 0.6%, and the overall score from 0.825 to 0.004.
Critically, this collapse is not merely an artifact of output length. A failure-mode analysis of the direct-ARXML outputs shows that the model does learn the surface form of the target—100% of outputs open an AUTOSAR element, 82% reach the closing tag, and 66% are strictly well-formed XML—yet only 0.6% are schema-conformant. The dominant failure is structural: even in well-formed outputs, the model hallucinates incorrect ECUC container tags (e.g., ECUC-CONTAINER-CONFIGURATION in place of ECUC-CONTAINER-VALUE), invents definition-reference paths, and misplaces parameter containers. A secondary failure is truncation: 17.8% of outputs exhaust the generation budget before completing the document. In other words, the model reproduces the format of ARXML but cannot reliably reproduce its dense, schema-governed structure across thousands of tokens—precisely the boilerplate that the deterministic expansion stage supplies correctly by construction. This confirms that the compact IR is not an incidental optimization but the component that makes reliable generation possible: it confines the model to the semantically meaningful parameters it can learn, and delegates the error-prone structural scaffolding to code.
Beyond correctness, the compact IR also yields a substantial inference-cost advantage. On the feasible test subset (NVIDIA L40S, greedy decoding), the IR model produces a configuration in 6.6 s on average (224 generated tokens), whereas the direct-ARXML model requires 122.9 s (4889 generated tokens)—an 18.7× reduction in latency and a 21.8× reduction in generated tokens. Direct ARXML generation is therefore not only far less reliable but also too slow for interactive use within a configuration tool, whereas the IR pipeline returns a result in a few seconds.
5.5. Training Dynamics
Figure 4 shows the training loss curves for all three models over the course of training. All models exhibit rapid convergence within the first 100–150 steps, dropping from initial losses of 0.86–1.25 to the 0.19–0.23 range, followed by a long plateau with minimal further improvement.
Ministral-3-8B converges to the lowest plateau loss (∼0.19), while Qwen3-8B and Llama 3.1 8B plateau at slightly higher losses (∼0.20–0.21). Interestingly, the lowest training loss does not directly predict the best evaluation performance: Llama 3.1 8B achieves the highest overall score (0.836) despite a marginally higher training loss, suggesting that generalization capacity matters more than training loss minimization for this task. The absence of divergence or loss spikes indicates that three epochs of training is appropriate for this dataset size, with no evidence of overfitting.
5.6. Error Analysis
Although schema validity is high (93–98%), the remaining failures reveal two dominant error modes. First, structural omission: models occasionally omit required fields (e.g., missing ext_logical list in modes or dropping the cycle_tol parameter), causing Pydantic validation to reject the output. Second, cross-reference errors: models generate checkpoint or entity names in supervision configurations that do not match the names defined in the entity section, breaking referential integrity. These errors are most prevalent in the deadline only and multi-mode categories, where schema validity drops to 90–95%.
Notably, JSON syntax errors are virtually absent across all three models (≥99.5% parsability), indicating that the fine-tuning process reliably teaches the surface-level JSON format. The remaining errors are semantic rather than syntactic, suggesting that further improvements should focus on constraint-aware generation or post-generation repair strategies.
5.7. Expert Assessment
To complement the automated metrics, a domain expert at a Tier-2 supplier that develops WdgM software reviewed a sample of the fine-tuned models’ generated configurations. The expert judged them consistent with production WdgM configurations and usable as a starting point for engineering refinement, corroborating that the quantitative scores reflect practically meaningful output quality rather than agreement with synthetic ground truth alone.
5.8. Limitations
While the results demonstrate the effectiveness of the proposed approach, several limitations should be made explicit to delimit the scope of our claims.
Single-module validation. Our evaluation targets a single BSW module, the Watchdog Manager. We selected WdgM deliberately as a demanding and representative proof of concept rather than a minimal one: it exercises the core ECUC constructs that our pipeline manipulates—multi-level nested containers (supervised entities holding checkpoints and internal transitions; modes holding typed supervisions), integer and floating-point parameters, boolean parameters, several distinct reference types, and cross-container references that must preserve referential integrity. Because the compact representation and the deterministic expansion operate on these generic container-based constructs of the ECUC meta-model rather than on any WdgM-specific semantics, the approach is expected to transfer to other ECUC-based modules: adapting it to a new module is a matter of specifying that module’s compact schema and expansion mappings, not of altering the method itself. We emphasize, however, that this generality is at present an argument from the module-agnostic construction of the pipeline rather than an experimentally established result—we have validated it only on WdgM, and modules with substantially larger parameter spaces (e.g., Com, Os) would require correspondingly larger schema and expansion definitions. Empirical validation on additional modules is left to future work (
Section 5.9).
Synthetic training and evaluation data. Both the training set and the held-out test set are synthetically generated through compositional enumeration of the WdgM configuration space. The configuration space was informed by a real customer (OEM) WdgM project, and a representative sample of the generated configurations was confirmed to be schema- and consistency-conformant by the industrial Capital Embedded Integrator AR Classic tool and reviewed by a domain expert at a Tier-2 WdgM supplier (
Section 4.4). The construction is intended to span the space of valid configurations rather than to replicate any single project: because real configurations vary substantially across OEMs, suppliers, and projects, there is no single “real distribution” to match, and a benchmark that systematically covers the configuration space is in this sense broader than any individual customer’s dataset. We nonetheless do not claim to reproduce every stylistic convention of a specific industrial project—production ARXML may exhibit vendor-specific parameter usages, legacy structures, and natural-language requirement phrasings outside our generated distribution—so the reported accuracies should be read as performance on a controlled, representative benchmark rather than as a direct estimate of field performance on a particular customer’s data.
Absence of in-deployment and safety validation. While the generated configurations pass automated schema and consistency checks and were reviewed by a domain expert (
Section 4.4 and
Section 5.7), this does not substitute for validation in a deployed setting. We do not evaluate the configurations on real vehicle projects, nor are they validated against on-target runtime behavior. In particular, our evaluation does not establish functional safety adequacy in a deployed system, which would require integration testing and assessment within an ISO 26262 safety process. Expert desk review confirms that the configurations are plausible and standard-conformant; it is not a substitute for this deployment-grade and safety-process validation.
Inference cost characterization. We report aggregate inference latency for both the IR pipeline and the direct-ARXML ablation in
Section 5.4 (6.6 s per configuration for the IR model). A finer-grained characterization of latency and throughput as a function of output length, complexity tier, and decoding strategy—and across deployment hardware beyond the single L40S used here—remains future work.
5.9. Future Work
The limitations above motivate several concrete directions. Cross-module generalization is the most immediate: applying the compact-representation methodology to additional ECUC-based BSW modules (e.g., BswM, ComM, CanIf) would empirically test the generality that our construction suggests. Validation on real configurations would pair the synthetic benchmark with a curated set of anonymized industrial ARXML files and a structured expert review, quantifying the synthetic-to-real distribution gap and the practical acceptability of generated outputs to integration engineers. Runtime and safety validation would expand evaluation from static structural correctness toward representative case studies that exercise generated configurations on target, situating the approach within an ISO 26262 workflow. We also plan to report a full inference-cost profile, to investigate multi-module generation with cross-module dependency maintenance, to integrate the system as a plugin for commercial AUTOSAR configuration tools, and to explore retrieval-augmented generation that leverages existing project configurations as context.
6. Conclusions
This paper presented a novel approach to automating AUTOSAR Watchdog Manager configuration generation by fine-tuning open-source large language models with a compact JSON intermediate representation. The key finding of our work is that the compact representation, which reduces output token requirements by approximately 8–10× compared to full ARXML, is critical for enabling LLMs to generate valid, complete configurations within practical generation limits.
We introduced a compositional dataset construction methodology spanning five complexity tiers with diverse natural language prompts, and proposed a hierarchical evaluation pipeline—schema validation with referential integrity enforcement, structural completeness, parameter accuracy, and semantic constraint satisfaction—that provides meaningful assessment of configuration quality beyond surface-level text similarity. Our comparative evaluation of three open-source models (Qwen3-8B, Ministral-3-8B-Instruct, and Llama 3.1 8B) fine-tuned with QLoRA demonstrates that all three models achieve closely comparable performance (0.815–0.836 overall score), with Llama 3.1 8B scoring highest at 0.836 with 97.5% schema validity and 72% parameter accuracy. Fine-tuning improves overall score by 8.4× over zero-shot baselines and 57% over three-shot baselines, while achieving substantially higher schema validity (93–98% vs. 15–53.5%).
The decomposition of the generation task into LLM-driven semantic extraction and deterministic structural expansion is, by construction, a module-agnostic strategy for applying LLMs to verbose, schema-governed output formats, since the expansion stage depends only on the generic ECUC container model rather than on WdgM-specific semantics. We demonstrate this strategy on the Watchdog Manager as a safety-critical proof of concept; empirical validation on additional BSW modules, and on real industrial configurations, remains important future work, as detailed in
Section 5.8 and
Section 5.9. By isolating the creative understanding task from the mechanical transformation, the approach combines the flexibility of neural generation with the reliability of rule-based reconstruction, while keeping the model footprint small enough for single-GPU fine-tuning and deployment.