Abstract
Automated Fiber Placement (AFP) is a critical process in composite manufacturing, where precise fiber tow placement is essential for achieving high-quality and high-performance engineering components. However, deviations in process variables frequently lead to defects such as gaps and overlaps, which can compromise structural integrity. While various monitoring techniques exist, accurately predicting and understanding the formation of these defects from complex sensor data remains challenging. This work introduces a novel application of a Transformer-based deep learning architecture to enhance the estimation of gap widths in AFP. Leveraging a publicly available industrial AFP dataset, our methodology incorporates a customized positional encoding scheme to effectively integrate the critical spatial context of the tow layup process. The model’s predictive performance was evaluated, achieving a Mean Absolute Percentage Error (MAPE) of 1.04% and an R-squared () value of 0.9143, demonstrating its capability for accurate gap width estimation. Furthermore, SHapley Additive exPlanations (SHAP) analysis was employed to assess the complex interplay between sources of manufacturing process variation. This study establishes the Transformer architecture as a promising and interpretable data-driven tool for AFP process monitoring. The results serve as a proof of concept for attention-based virtual metrology, offering a pathway towards deeper process understanding and defect mitigation.
1. Introduction
Automated Fiber Placement (AFP) has emerged as a pivotal manufacturing technology for high-performance composite structures, particularly in the aerospace industry, due to its ability to produce highly customized layups with tailored mechanical properties [1]. A key determinant of part quality in AFP is the accurate control of gap width between adjacent fiber tows, defined as strips of pre-impregnated composite material. Even small deviations in tow placement can result in gaps, where tow edges fail to meet, or overlaps, where one tow partially covers another. Both defect types introduce local stress concentrations, disrupt load transfer between plies and degrade stiffness and strength, ultimately compromising the structural integrity and service performance of the final component [1,2,3]. From a manufacturing perspective, gaps and overlaps constitute a dominant class of AFP defects observed in industrial practice [4]. Their occurrence directly impacts production cost and throughput, as components exhibiting excessive gap width deviations often require extensive post-process inspection, repair or rejection. Current industrial workflows therefore rely heavily on retrospective quality assurance, including manual inspection and rework cycles, which can consume a substantial fraction of total AFP production time and significantly diminish the productivity gains expected from automation [2]. Accurate in-process prediction of gap width is therefore critical: it enables early detection of defect formation, supports corrective action before defects propagate across subsequent plies, and reduces dependence on costly downstream inspection and rework. Improving gap width predictability thus directly contributes to enhanced structural reliability, reduced scrap and rework rates and lower overall manufacturing cost [1,3,5].
To understand the challenge of gap prediction, one must consider the physical mechanics of the AFP process. A robotic placement head deposits composite tows onto a mold under controlled compaction [1]. Ideally, adjacent tows are placed with consistent spacing defined by the robot’s programmed path. However, in reality, the process is subject to numerous stochastic variations. Machine kinematic inaccuracies and fluctuations in material tackiness can cause the tows to slip or drift laterally beneath the compaction roller during deposition [1].
Traditional approaches for monitoring and controlling gap widths, such as post-deposition visual inspection or manual measurement, are typically labor-intensive, operator-dependent and sensitive to environmental conditions, resulting in limited reliability and repeatability [2]. Although modern AFP systems increasingly incorporate sensors for in-process data acquisition [3], enabling the possibility of real-time monitoring, the accurate prediction and mitigation of gap-related defects remains an open challenge.
Current approaches to modeling these defects face distinct limitations. Analytical models, while physically grounded, often rely on idealized kinematic assumptions. They frequently struggle to capture the noisy, non-linear and stochastic interactions present in raw industrial sensor data, leading to reduced accuracy in real-world environments [6].
On the other hand, data-driven Deep Learning (DL) methods, such as Convolutional Neural Networks (CNNs) or Recurrent Neural Networks (RNNs), have demonstrated strong predictive capabilities. However, these standard architectures often operate as “black boxes”, providing accurate predictions without revealing the underlying drivers of the defects [6,7]. Furthermore, RNNs and Long Short-Term Memory (LSTM) networks process data sequentially, which can create information bottlenecks and obscure the global spatial dependencies critical to the AFP layup process [8]. This lack of interpretability and spatial context poses a significant barrier to their adoption for process certification [6].
This work addresses these challenges by exploring the application of a Transformer-based DL architecture. Unlike sequential models, the Transformer employs self-attention mechanisms to process the entire spatial sequence in parallel. We hypothesize that this architecture can more effectively model the intricate, non-local relationships between sensor readings (such as tow width and robot position) and gap dimensions while simultaneously offering the transparency required for root-cause analysis.
This study employs a publicly available dataset of industrial AFP process data [9] to develop and evaluate the proposed model. Furthermore, to enhance the understanding of the model’s predictions and gain insights into the manufacturing process itself, SHapley Additive exPlanations (SHAP) analysis is employed to assess the influence of individual input features on gap width estimation.
The main contributions of this work are:
- The novel application of a Transformer-based deep learning architecture for the estimation of gap widths in the AFP process, which, to the best of our knowledge, represents a novel approach to incorporating spatial context into AFP defect estimation.
- The development of a domain-specific positional encoding scheme that effectively incorporates the X and Y spatial coordinates. This allows the Transformer to distinguish between tool-location-dependent errors (global context) and tow interaction errors (local context), a methodology adaptable to other spatially dependent manufacturing processes.
- A comprehensive feature importance analysis using SHAP values, providing interpretable insights into the complex interplay of AFP process variables and their impact on gap formation, with a particular focus on identifying key factors associated with variation.
- Demonstration of the model’s strong predictive performance in estimating gap widths, offering a data-driven pathway towards improved process understanding and the potential for enhanced in-process quality control.
This paper is structured as follows: Section 2 reviews related work in AFP defect detection and relevant Artificial Intelligence (AI) applications. Section 3 details the proposed methodology, including the dataset overview, data preprocessing, the Transformer model architecture with its adapted positional encoding and the experimental setup. Section 4 presents and discusses the gap width estimation results and the insights derived from the SHAP analysis. Finally, Section 5 concludes this paper, summarizing the key findings and suggesting directions for future research.
2. Related Work
The pursuit of enhanced quality control in AFP has spurred significant research into in-process monitoring and defect detection. Various sensor technologies and data analysis techniques have been explored to identify and mitigate defects such as gaps, overlaps and wrinkles, which can compromise the integrity of composite structures.
2.1. Sensor-Based Monitoring and Defect Detection in AFP
A variety of sensors are employed for AFP monitoring. Optical methods, including high-resolution laser scanners and cameras (operating in visible, near-infrared and mid/far-infrared spectra), are widely used to capture surface characteristics, fiber placement accuracy and geometric deviations [2,10]. Laser Line Scanners (LLSs), for instance, have been used to measure tow geometry, edge positions and surface profiles, enabling the detection of gaps, overlaps and other surface anomalies [5,11,12]. Machine vision systems, often coupled with these sensors, apply image processing and computer vision algorithms to segment defect regions and extract critical features [2,12,13]. Beyond optical methods, thermography has also been explored as a distinct research direction for identifying thermal variations indicative of defects or inconsistencies in the layup [12]. Force and pressure sensors integrated into the AFP head can also provide data on compaction quality, which indirectly relates to defect formation [1,3].
While these sensor systems provide rich data, subsequent analysis is crucial. Traditional signal processing techniques (e.g., Fourier analysis) help filter noise and extract defect-correlated features [11]. However, the complexity and volume of data generated, coupled with the subtle nature of some defects, have driven the adoption of more advanced data-driven approaches.
2.2. Machine Learning for AFP Process Monitoring and Defect Analysis
Machine Learning (ML), particularly DL, has shown considerable promise in automating defect detection and classification in AFP. CNNs have been applied to image-based data from cameras and LLSs to identify and classify defects with increasing accuracy [12,14,15]. For instance, studies have demonstrated the use of CNNs for segmenting defect regions from laser scanner depth maps [15] and classifying various defect types using RGB color values from vision systems [16]. Explainable Artificial Intelligence (XAI) methods, such as SHAP, are also beginning to be applied to understand the decision-making processes of these complex models, enhancing trust and providing insights into defect causality [12].
Given the sequential nature of the AFP process, where the state at one point in time or position can influence subsequent states, time-series analysis techniques are particularly relevant. RNNs, including LSTM and Gated Recurrent Unit (GRU) architectures, have been successful in various manufacturing applications for tasks like predictive maintenance, anomaly detection and forecasting, owing to their ability to model temporal dependencies [8,17,18,19,20,21]. Given the sequential nature of AFP sensor data, these architectures provide a relevant baseline for comparison; however, they often lack the explicit spatial interpretability provided by attention mechanisms.
2.3. Challenges and Opportunities
Despite these advancements, several challenges persist. The development of robust AI models is often hampered by the limited availability of large, diverse and well-annotated AFP datasets that cover a wide range of materials, defect types and process conditions [12]. Ensuring data quality from sensors operating in harsh industrial environments is another concern [12,13]. Furthermore, many existing models may not fully capture the long-range dependencies and complex spatio-temporal interrelations present in multivariate AFP sensor data. The computational demands for real-time processing of large data streams also requires efficient algorithms [12,13]. While CNNs are powerful for image-based defect detection, they do not inherently capture the numerical process variable correlations over time. Similarly, while RNNs and LSTMs address sequential dependencies, they process data linearly, which can lead to information bottlenecks when relating the current tow’s state to spatially adjacent (but temporally distant) previous tows. This landscape presents an opportunity for novel architectures capable of overcoming these limitations. The Transformer architecture, originally developed for natural language processing [22], has recently shown state-of-the-art performance in time-series forecasting, outperforming traditional RNNs in capturing complex dependencies [23]. The Transformer architecture distinguishes itself by using self-attention to process these relationships in parallel, preserving global context more effectively than recurrent methods. Its attention mechanism allows the model to weigh the importance of different parts of an input sequence dynamically, making it a strong candidate for analyzing the nuanced interplay of sensor data in AFP. However, as noted in our Introduction, its application to AFP gap width estimation remains unexplored, representing a key research gap this study aims to address.
3. Methodology
This section details the dataset, data preprocessing steps, the proposed Transformer-based model architecture, hyperparameter selection and the evaluation metrics used in this study. A schematic overview of the proposed workflow, detailing the transition from data acquisition to model evaluation, is presented in Figure 1.
Figure 1.
Detailed Methodological Workflow.
3.1. Dataset Overview and Experimental Setup
This work employs a publicly available industrial AFP dataset originally presented by Pantoji et al. [9]. The dataset was generated from experiments conducted at TU Delft’s SAM XL lab, with the primary objective of their investigation being the simultaneous measurement of various factors contributing to gap and overlap variations during the AFP layup process. While Pantoji et al. [9] used this data to develop and validate a probabilistic simulation model for predicting gap defects, the present work employs this same dataset to develop and evaluate an alternative, data-driven gap width estimation model using a Transformer-based deep learning approach.
The experimental setup described in [9] consisted of an AFP-XS head from ADD Composites (Finland) mounted on a KUKA KR 210 R2700 robot manipulator. The AFP head was equipped with a silicone compaction roller (31 mm width, 40 mm diameter, Shore hardness 45 A) and an Infrared (IR) heater to enhance tow tackiness. A 6.35 mm wide unidirectional thermoset composite tow (standard modulus carbon fiber with an epoxy matrix) was used. The experiment involved a single continuous campaign of laying 31 straight lines of composite tow, each approximately 1 m long, onto a 1.5 m × 1 m steel plate tool. The deposition speed was up to 200 mm/s. Layups were performed unidirectionally along the X-axis, with the programmed Y-coordinates of each tow varying to create a nominal programmed gap of 6.15 mm between adjacent tows. The Z-coordinate was set to ensure sufficient compaction force, which was measured at 377 N during the experiment; the IR heater was set to 80% power and tape tension was regulated at 6.7 N.
The measurement system, as detailed in [9], included several sensors mounted on the AFP head to record data during deposition (depicted in Figure 2):
Figure 2.
Sensors setup on the AFP head. Layup is in the positive X direction [9].
- A Laser Tracker (Leica AT960 MR) to measure the AFP head’s position.
- A camera (Ximea xiC USB 3.1 Gen1 MC050MG-SY-UB) to capture the tow’s position on the compaction roller.
- Two Laser Line Scanners (LLS A: MicroEpsilon 3060-25 and LLS B: MicroEpsilon 3010-25) to measure the tow profile before the compaction roller (LLS A) and after deposition on the surface (LLS B).
The target variable for the prediction task in our study is the . As reported in [9], these actual gap widths were measured by traversing an LLS over the entire length of each pair of adjacently laid tows after all tows had been laid down. This post-process measurement provides the ground truth for the gap dimensions that our model aims to estimate using in-process sensor data. A description of each variable is provided in Table 1.
Table 1.
Description of variables present in the dataset.
Robot positioning error followed a logistic distribution with a total range of 0.54 mm (8.5% of specified width) and a standard deviation of 0.07 mm. Tow lateral movement exhibited an Extreme Value distribution with a range of 1.4 mm (22% of tow width) and a standard deviation of 0.22 mm. Tow width variation followed a normal distribution, with a range of 0.63 mm before compaction and 0.48 mm after compaction. Although the nominal programmed gap was 6.15 mm, the combined effect of these variations resulted in measured gaps with a mean of 6.24 mm and a standard deviation of 0.33 mm. Observed gaps spanned approximately 5.0 mm to 7.3 mm, with the 90th and 99th percentiles at 6.59 mm and 7.21 mm, respectively. This spread captures nominal conditions as well as compliant and defect-prone scenarios.
3.2. Data Preprocessing, Feature Engineering and Data Splitting
The raw data acquired from the AFP sensors underwent several preprocessing steps to prepare it for the Transformer model. These steps included data synchronization, feature engineering, data splitting and normalization, guided by the specific structure of the provided dataset [9] and the requirements of the Transformer architecture.
3.2.1. Data Synchronization and Feature Engineering
A fundamental aspect of the methodology employed in this study was the synchronization of sensor data along the deposition path of the AFP head. Each row in this dataset represents a synchronized set of measurements at a specific longitudinal X-coordinate along the deposition path and encapsulates information from both the current tow segment being deposited and the corresponding segment of the previously laid adjacent tow. This structure inherently provides a comparative context at each spatial location. The data was sorted by the X-coordinate to maintain the deposition sequence.
The following features were engineered or selected as inputs to the model:
- Features related to the previously laid tow:
- –
- : Measured width of the previous tow (mm).
- –
- : Measured width of the previous tow after its compaction (mm).
- –
- : Measured lateral movement of the previous tow on the roller during its deposition (mm).
- –
- : Measured Y-axis deviation of the AFP head from the programmed path during the deposition of the previous tow (mm).
- Features related to the current tow being deposited:
- –
- : Measured width of the current incoming tow (mm).
- –
- : Measured width of the current tow after compaction (mm).
- –
- : Measured lateral movement of the current tow on the roller (mm).
- –
- : Measured Y-axis deviation of the AFP head from the programmed path during the deposition of the current tow (mm).
- Engineered relational feature:
- –
- : The relative Y-coordinate difference between the centerline of the current tow () and the centerline of the previous tow (), calculated as .
It is important to distinguish this engineered feature (), which captures the local relative proximity, from the absolute spatial context provided later by the positional encoding. The latter allows the model to identify global dependencies, such as specific regions on the tool or robot arm extensions (correlated with absolute coordinates) that may systematically induce defects, preventing information redundancy.
Feature selection was guided by AFP physics. The variable serves as a direct proxy for material-level effects, including slippage and tack failure at the roller interface. In contrast, reflects machine-level kinematic errors of the robot arm. Together, these features allow the model to disentangle material-induced defects from robot-induced inaccuracies.
The target variable for our prediction task is (mm), representing the actual measured gap width between the current and previous tows at that X-coordinate.
3.2.2. Data Splitting
To ensure a robust evaluation of the model’s generalization capabilities and to prevent data leakage, the dataset was split into training, validation and testing sets. Given the sequential and spatial nature of AFP data, where measurements from adjacent locations or subsequent tows are likely correlated, a simple random split is less ideal than a strategy that respects the process order [6]. Therefore, for the results reported in this paper, we adopted a chronological splitting strategy based on the 31 individual tows laid during the experiment referenced in [9].
The data from the 31 tows were divided as follows:
- Training Set: Data from the first 22 tows (approximately 70% of the tows) were used for training the model.
- Validation Set: Data from the next 4 tows (approximately 15% of the tows) were used for hyperparameter tuning.
- Test Set: Data from the final 5 tows (approximately 15% of the tows) were held out and used exclusively for evaluating the performance of the final selected model.
Crucially, this chronological split ensures no data leakage: the model is evaluated on tows that were deposited physically and temporally after the training data, mimicking a real-world production scenario.
All reported performance metrics in Section 4 are based solely on this unseen test set.
To mitigate the impact of differing scales and distributions among the input features and to aid in model convergence, feature normalization was employed using a Standard Scaler, which standardizes features by removing the mean and scaling to unit variance.
3.3. Transformer Model Architecture and Training
This section outlines the rationale for selecting the Transformer architecture, details its specific components as implemented for AFP gap width estimation and describes the hyperparameter selection and training procedures.
3.3.1. Model Rationale and Overview
The AFP process, as represented by the feature-engineered dataset, poses a unique modeling challenge in which each spatial point is described by a rich set of features comparing the characteristics of the current tow with those of previously deposited tows. Understanding the contribution of each feature in the context of its precise spatial location (defined by the X and Y coordinates of the current and adjacent tows) is therefore critical for accurate gap width estimation and process interpretability.
Traditional DL approaches for modeling such structured and sequential data, including LSTMs networks, rely on recurrent connections to propagate information through the sequence. While effective in many time-series applications, LSTMs models suffer from information bottlenecks when dependencies span long sequences and their latent representations are often difficult to interpret in terms of physical process variables. These limitations are particularly restrictive in manufacturing applications, where both long-range dependencies and model transparency are essential. This is particularly advantageous in AFP, where a defect might result from a sharp interaction between a specific kinematic deviation and material width, rather than a smooth temporal trend.
The Transformer architecture [22] was chosen for its powerful attention mechanism. Unlike recurrent models, Transformers employ a self-attention mechanism that enables the entire sequence of sensor-derived features to be processed in parallel. This mechanism assigns learnable attention weights to individual input features irrespective of their position in the sequence, allowing the model to capture long-range and non-local dependencies without recurrence. The self-attention mechanism is employed to model the complex, non-linear interactions between the heterogeneous input features (sensor readings) and their spatial context. By integrating a custom positional encoding (incorporating X and Y coordinates), the self-attention mechanism gains “spatial awareness”. Unlike static weights in standard regression, attention dynamically adapts feature relevance based on each data point’s spatial context, making it well suited for modeling the complex relationships governing AFP gap formation. Moreover, the explicit attention weights support the interpretability analysis presented in Section 4, providing insight into the physical drivers of gap variability.
The overall model consists of an input embedding layer, a custom positional encoding layer, a multi-layer Transformer encoder and a final linear regression layer to predict the gap width.
3.3.2. Model Architecture Components
The model was implemented using PyTorch (v2.5.1). The architecture comprises the following key components:
- 1.
- Input Embedding: The input features are projected into a 64-dimensional embedding space using a linear layer.
- 2.
- Custom Positional Encoding: To incorporate spatial context, unique positional encodings derived from the absolute X-coordinate and the Y-coordinates of both current () and previous () tows are generated and added to the input embeddings. This allows the model to differentiate points based on their manufacturing location.
- 3.
- Transformer Encoder Core: The spatially aware embeddings are processed by a stack of three Transformer encoder layers. The model is configured with a multi-head self-attention mechanism (4 heads, ) and a position-wise feed-forward network (256 dimensions). To mitigate the risk of convergence to local optima and prevent overfitting, the architecture incorporates Layer Normalization and Residual Connections after each sub-layer. Additionally, a Dropout rate of 0.1 is applied. These mechanisms stabilize the gradient flow, allowing the Adam optimizer to effectively navigate the loss landscape.
- 4.
- Output Regressor: The 64-dimensional output from the Transformer encoder stack is passed through a final linear layer to predict a single scalar value representing the estimated gap width.
The understanding of spatial relationships and sequential context is not derived from the Transformer processing a long sequence of points over time, as is typical in traditional time-series forecasting using LSTMs. Instead, it is primarily achieved through two key mechanisms. First, each input vector contains rich feature representations that capture comparative information between the current and previous tows at a specific X-coordinate. Second, explicit positional encoding is applied, incorporating unique positional information derived from the and coordinates. This encoding enables the model to interpret both the absolute and relative spatial positions of each data point.
While the attention mechanism internally determines these feature interdependencies, we employ SHAP (Section 4) to quantify and visualize the resulting feature contributions, effectively translating the model’s internal attention focus into physically interpretable insights for AFP.
3.3.3. Hyperparameter Selection and Training Details
The selection of hyperparameters for the Transformer model was guided by common practices in literature [24] and refined through a systematic grid search on the validation set. The primary criterion for selection was the minimization of Mean Squared Error (MSE) on the dedicated validation set. The search space included: Embedding Dimensions ; Attention Heads ; Encoder Layers ; and Learning Rates . The final configuration (, , ) was selected based on minimizing the validation MSE.
The model was trained using the following setup:
- Loss Function: Mean Squared Error was used to quantify the difference between the predicted gap width and the actual gap width.
- Optimizer: The Adam optimizer was employed with a learning rate of 0.001.
- Epochs: The model was trained for 100 epochs.
- Batch Size: A batch size of 32 was used.
- Training Environment: The model was implemented in Python using the PyTorch (v2.5.1) library. Training was performed on a machine equipped with an Intel i9-13950HX (24 cores), 64 GB of RAM and an NVIDIA RTX 4000 12GB GPU, running Windows 11.
The total training time for 100 epochs was approximately 1 h and 20 min.
4. Results and Discussion
This section presents the evaluation of the proposed Transformer-based model for estimating AFP gap widths. The analysis includes both quantitative metrics and qualitative assessments of prediction accuracy, followed by an exploration of feature importance using SHAP analysis. These insights help to elucidate the model’s decision-making process and its relevance for process understanding and control.
All results are based on the model’s performance on an unseen test set.
4.1. Transformer Model Performance Evaluation
The model’s predictive performance was quantified using several standard evaluation metrics, offering an assessment of its accuracy and generalization ability. The following metrics were employed:
- Mean Absolute Error (MAE): The average of the absolute differences between predicted and actual values. It is calculated as follows:where is the actual value, is the predicted value and n is the number of samples. MAE is expressed in the same units as the target variable (e.g., mm for gap width).
- Mean Squared Error (MSE): The average of the squared differences between predicted and actual values. It is calculated as follows:MSE penalizes larger errors more heavily and is expressed in squared units of the target variable (e.g., mm2).
- Root Mean Squared Error (RMSE): The square root of the MSE, providing an error metric in the same units as the target variable (e.g., mm).
- R-squared (): The coefficient of determination, representing the proportion of the variance in the dependent variable that is predictable from the independent variables. It ranges from 0 to 1, with higher values indicating a better fit.where is the mean of the actual values.
- Mean Absolute Percentage Error (MAPE): The average of the absolute percentage differences between predicted and actual values. It is a dimensionless measure of prediction accuracy.
The results are presented in Table 2. The Transformer model achieved an MAE of 0.07540 mm, indicating that, on average, its predictions were within approximately 0.075 mm of the actual gap width on the unseen test data. This corresponds to about 1.2% of the programmed gap width of 6.15 mm. In an industrial context, where gap tolerances are typically in the range of 0.5 mm depending on the structural application [2], this MAE suggests the model provides sufficient precision to identify out-of-tolerance events. The RMSE of 0.1139 mm, which penalizes larger errors more heavily, further underscores the model’s precision. A high value of 0.9143 suggests that the model can explain approximately 91.43% of the variance in the actual gap width, demonstrating a good fit and robust generalization to new data. The MAPE of 1.04% provides a relative measure of this high accuracy. It should be noted that MAPE can be sensitive to small denominator values. Given that the target variable (gap width) captures physical dimensions where sub-millimeter precision is critical, the MAE and RMSE (expressed in mm) provide a physically meaningful representation of the model’s suitability for manufacturing tolerances. These results highlight the Transformer architecture’s effectiveness in capturing the complex relationships within the AFP sensor data for this specific task.
Table 2.
Transformer Model: Performance Metrics.
The original study by Pantoji et al. [9], from which the dataset was sourced, employed a probabilistic simulation approach based on fitting statistical distributions to individual measured sources of manufacturing variability. While their method showed a strong correlation between simulated and experimentally measured gap distributions, a direct quantitative comparison of error metrics (like MAE or RMSE) is challenging due to the different modeling paradigms (statistical simulation vs. end-to-end regression). Their work focused on understanding the contribution of individual error sources to the overall gap distribution, whereas our approach aims to directly estimate the gap width at specific locations using a data-driven model. Our model offers a complementary approach by providing direct point-wise estimations.
To visualize the model’s predictive accuracy, the predicted gap widths were plotted against the actual gap widths—Figure 3.
Figure 3.
Transformer Model: Predicted Gap Width vs. True Gap Width.
The scatter plot in Figure 3 reveals a strong positive correlation between the predicted and actual values, with most data points clustering closely around the perfect prediction line. Some minor deviations are noticeable, particularly for points further from the programmed gap of 6.15 mm. This shows the model’s ability to predict gap widths across the observed range accurately.
Furthermore, the predicted and true gap widths were plotted against the sample index for 50 data points—Figure 4. The time-series plot illustrates a good correlation between the predicted and measured gap width trajectories. The model effectively captures general trends and fluctuations in the gap width. Although there are some minor discrepancies, the overall trend indicates a strong predictive capacity within this phase of the deposition process.
Figure 4.
Transformer Model: Predicted Gap Width and True Gap Width for 50 sample points.
The error distribution analysis in Figure 5 shows the prediction errors of the model are mainly centered around zero, with a slight negative skew. The peak frequency occurs at a marginally negative error value. This suggests a minor tendency to underestimate the width of the gap.
Figure 5.
Transformer Model: Distribution of Prediction Errors.
The analysis of prediction error versus predicted gap width (Figure 6) shows a random scatter of residuals around the zero line, with no clear patterns or trends.
Figure 6.
Transformer Model: Prediction Error vs. Predicted Value.
4.2. Feature Importance Analysis Using SHAP Values
To gain deeper insights into the model’s decision-making process and to understand the influence of different input features on the predicted gap width, a SHapley Additive exPlanations (SHAP) analysis was conducted [25,26]. SHAP is a game-theory-based approach that assigns an importance value (SHAP value) to each feature for each individual prediction, indicating its contribution to pushing the model’s output away from a baseline value. This method is particularly valuable for interpreting complex models like Transformers and has been highlighted as suitable for AFP applications [6].
4.2.1. Scope of SHAP Analysis
Four variables were examined: tow width (), tow width after compaction (), tow lateral movement on the roller (), and y-axis deviation (). These features were selected as they represent measurable parameters directly associated with the tow being laid and are commonly investigated in AFP process analysis.
SHAP values quantified the contribution of each feature to individual predictions, allowing for an interpretation of the model’s learned behavior on both global and local scales. It is important to note that, while SHAP values reveal the influence of features on model predictions, the feature values displayed in SHAP visualizations reflect a standardized feature space. This is a result from normalization during model training and thus are not directly representative of their original quantitative values.
4.2.2. Global Feature Importance
The global importance of each feature was initially assessed using a SHAP summary plot—Figure 7. This plot displays the average magnitude of the SHAP values and revealed that all four investigated features contribute to the model’s predictions.
Figure 7.
SHAP global feature importance (average impact on output) for predicted gap width.
As shown in Figure 7, (lateral movement of the current tow on the roller) exhibits the highest average SHAP value, indicating it has the most substantial impact on the model’s gap width predictions among the visualized features. This is followed by (AFP head’s Y-axis deviation for the current tow), then (current tow’s width after compaction) and finally (current incoming tow width). This hierarchy suggests that variations in tow placement accuracy ( and ) are strongly associated with predicted gap width, aligning with physical expectations of the AFP process.
4.2.3. Dependence Plots and Feature Interactions
Next, SHAP dependence plots (Figure 8) were devised to provide granular look into the relationship between each feature’s value and its corresponding SHAP value. These plots help to visualize how each feature influences the model’s predictions and to identify potential interactions with other features.
Figure 8.
SHAP dependence plots for predicted gap width.
The dependence plot for (Figure 8a) exhibits a slightly positive overall trend, although with scatter in the data points. This suggests that, as increases, the predicted gap width tends to increase as well. However, the scatter indicates that this relationship is not strictly linear and that other factors may be influencing the impact of on the prediction. Additionally, the dependence plot presents further information through a color scale. In this case, the color scale represents and reveals a trend: lower values of (blue dots) are associated with lower SHAP values for , while higher values of (pink dots) indicate higher SHAP values. This suggests a potential positive influence of on the predicted gap width appears to be more pronounced when is high. This could imply that when the camera deviation is significant, even small increases in tow width can lead to larger gaps, perhaps because the placement is already compromised.
The dependence plot for (Figure 8c) exhibits a highly linear positive relationship with minimal scatter. The data points closely follow a straight line with a positive slope, indicating that the increase in has a high positive contribution to the predicted gap width. This dominance aligns with the physical reality of the AFP process: the camera measures the lateral position of the tow on the compaction roller immediately before deposition. Unlike , which measures the robot head’s position in the global coordinate system, captures the actual material slippage relative to the tool center point. The model has correctly identified that this material-tool interface measurement is the most direct physical determinant of the final placement accuracy, effectively serving as a proxy for the true deposition path. This observation is consistent with the findings reported in [9].
In contrast, the dependence plot for (Figure 8d) reveals a perceptible negative linear trend with some scatter. While deviations in the robot’s Y-position generally correlate with gap changes, the relationship is less precise. Physically, this suggests that the robot’s encoder values are a secondary proxy; a robot can be perfectly positioned, but if the tow slips on the roller (as captured by the camera), a defect could still occur. The Transformer’s attention mechanism successfully discerns this hierarchy, prioritizing the direct material measurement () over the kinematic proxy ().
Regarding the geometric features, the plot for (Figure 8b) displays a clear negative linear trend. This represents a direct geometric relationship: effective compaction contributes to tow lateral spread. As the tow spreads wider ( increases), it physically occupies more space on the substrate, naturally reducing the magnitude of the gap between itself and the adjacent tow.
The dependence plot suggests an interaction with . The contribution of seems to be more significant when is already high, indicating a potential compounding effect of these two factors. In addition, and exhibit relatively strong linear trends (negative and positive, respectively), indicating clear and consistent relationships with the predicted gap width. The model is evidently sensitive to tow lateral movement on the roller () and the effectiveness of compaction (), which aligns with the physical realities of the AFP process.
While Figure 8a shows that increasing the incoming is associated with larger gaps, Figure 8b reveals that a greater corresponds to smaller gaps, an apparent contradiction that can be reconciled by considering the different stages and roles these variables represent in the deposition process.
The is an outcome measure; a larger value here directly and intuitively means more material is filling the intended space, hence a smaller gap. The incoming , however, is an input material characteristic. Its influence on the final gap is not direct but is mediated by the deposition process. As seen in Figure 8a, the positive trend (wider incoming tow->larger gap) is particularly evident when is high. This suggests that if a wider tow is not placed accurately, it might be more prone to undesirable behaviors (e.g., slight buckling, edge lifting or simply deviating further due to its width if guidance is imperfect) that effectively increase the gap or the model learns that instances with wider tows in this dataset often coincided with other unideal placement conditions. Conversely, if placement is perfect (low ), the impact of incoming tow width might be neutral or even slightly negative (gap reducing).
4.2.4. Beeswarm Plot Analysis
The SHAP beeswarm plot (Figure 9) provides a global overview of feature importance and their impact on the model’s predictions. Each point on the plot represents an instance in the dataset, with its horizontal position indicating the SHAP value for a particular feature and its color representing the corresponding feature value (red for high, blue for low).
Figure 9.
SHAP’s summary plot for predicted gap width.
The feature is the most influential and presents a wide spread of its SHAP values. A clear trend is observable: high values (red dots) have a high positive contribution to predicted gap width. Conversely, low values (blue dots) have a negative contribution to the prediction. This confirms the critical role of tow lateral movement on the roller.
The second most important feature, , exhibits a negatively skewed distribution. High values of (red dots) are associated with negative SHAP values and negatively contribute to the predicted gap width. Intermediate values (purple dots) of , indicating proximity to the intended path, are associated with SHAP values close to zero, having a small contribution to the prediction. This highlights the importance of maintaining the tow’s position along the intended y-axis.
The feature shows a moderate impact, with a distribution skewed slightly towards negative SHAP values. High values (red dots) are primarily associated with negative contribution towards predicted gap width, indicating that effective compaction indicates smaller gaps.
The exhibits the lowest importance among the four features. It has a small distribution and slightly skewed towards negative SHAP values. This suggests that, within the range of this dataset, variations in have a less pronounced impact, compared to other factors.
4.2.5. Insights from SHAP Analysis
The SHAP analysis provides valuable, interpretable insights into the Transformer model’s behavior, aligning with and extending physical understanding of the AFP process. It confirms that tow placement accuracy ( and ) are critical factors influencing gap formation. The analysis also shows the nuanced role of tow width, distinguishing between the effect of incoming tow width (conditional on placement) and the more direct effect of the tow’s width after compaction. This level of interpretability demonstrates the potential of combining advanced DL models with Explainable AI techniques like SHAP to not only predict but also to better understand and ultimately improve complex manufacturing processes.
4.3. Estimation for Process Control and Practical Implications
The development of an accurate gap width estimation model, as demonstrated in this work, carries significant implications for enhancing AFP process control and overall part quality. This section discusses the nature of the model’s estimation, its potential for near-real-time application and its practical value in an industrial AFP setting.
4.3.1. Nature of the Gap Width Estimation
It is important to clarify that the model developed in this study provides an estimation of the gap width concurrently with the deposition process. It does not predict the gap width far ahead of the deposition point in a forecasting manner. Instead, for each spatial data point along the deposition path (defined by the X-coordinate and incorporating features from both current and previous tows), the model leverages the sensor data collected up to and including that specific location to estimate the gap width. The model effectively learns the complex, non-linear relationships between the rich set of input features and the resulting gap width that is later measured post-process.
The transformer architecture, and particularly its attention mechanism, is well-suited to this task. Although the estimation is concurrent, the model makes effective use of the sequence of past sensor data to provide context for the current estimation. The attention mechanism enables the model to discern which preceding sensor readings are most relevant to the current gap width, effectively capturing the complex interplay of factors that influence gap formation.
4.3.2. Potential for Near-Real-Time Feedback and Practical Value
Although LLS B already measures tow width after compaction, from which gap information could be derived, the value of the proposed model-based estimation lies in several aspects:
- 1.
- Estimation at the Point of Compaction: Direct, instantaneous physical measurement of the gap at the precise nip point of the compaction roller is often obstructed by the roller itself. LLS B, which measures tow width after compaction, is typically positioned slightly downstream from the roller [9]. Consequently, LLS B’s measurement occurs at a slightly later point, both spatially and temporally. Our model, by learning from upstream and current sensor data, provides an indirect estimation of the gap width as it is being formed at or very near the point of compaction. This offers an earlier insight into potential deviations than a solely downstream measurement might provide.
- 2.
- Sensor Fusion and Robustness: The model inherently performs a type of sensor fusion, integrating information from multiple sensors (LLS A, LLS B, camera, laser tracker). This multi-modal input can lead to a more robust estimation, potentially less susceptible to the noise or limitations of a single sensor in an industrial environment. It learns the collective influence of various parameters, offering a more holistic view of the conditions leading to gap formation.
- 3.
- Diagnostic Insights: Coupled with SHAP analysis, the model not only estimates the gap but also provides insights into why variations might be occurring. If the model predicts an undesirable gap, the SHAP values can indicate which input features are the primary drivers. This diagnostic capability is valuable for targeted corrective actions and deeper process understanding, which a simple geometric calculation from LLS B might not offer.
Regarding real-time applicability, the Transformer model, once trained, can perform inference relatively quickly. Given the model’s architecture and the computational hardware used for training, the inference time for a single data point (or a batch of points) is expected to be in the order of milliseconds. While a precise inference time per prediction was not exhaustively benchmarked in this study, the computational efficiency of feed-forward passes in trained Transformer models is well-established. This suggests a strong potential for near-real-time feedback.
However, the implementation and validation of a closed-loop control system incorporating this model for real-time, in-process adjustments is a significant undertaking and is considered a direction for future work. Achieving true real-time control would require integrating the model into the AFP machine’s control architecture, ensuring synchronized data pipelines and developing control logic to act upon the model’s estimations, all of which are beyond the scope of the current study, which focuses on the development and validation of the estimation model itself. In summary, this model-based estimation approach offers a valuable complement to direct sensor measurements.
Notably, the model was developed and validated using data from straight layups of a single material type on a flat tool, focusing specifically on the first ply deposition. Consequently, the results should be viewed as a proof of concept. The model’s generalization to complex curvatures, steering paths, different tackiness levels or multi-ply buildup has not yet been assessed and remains a subject for future research.
5. Conclusions
This work successfully addressed the challenge of accurately estimating gap widths in AFP by developing and evaluating a novel Transformer-based deep learning architecture. Using a publicly available industrial dataset [9], this study demonstrated the potential of this advanced AI approach to model the complex, non-linear relationships inherent in AFP sensor data.
The proposed Transformer model demonstrated strong predictive performance, achieving an MAE of 0.07540 mm and an value of 0.9143 on the unseen test set. This indicates a high degree of accuracy in estimating gap widths, corresponding to an average deviation of 1.04% (MAPE) from the actual values. Furthermore, a comprehensive SHAP analysis provided valuable insights into the model’s decision-making process, highlighting that tow placement accuracy is a critical factor influencing gap formation. The SHAP analysis also elucidated the nuanced impact of incoming tow width versus tow width after compaction, revealing complex interactions with placement parameters.
The key contributions of this research are:
- The first-known application of a Transformer-based deep learning architecture for gap width estimation in the AFP process, demonstrating its suitability for this manufacturing challenge.
- The development of a domain-specific positional encoding scheme that effectively incorporates the critical X and Y spatial coordinates of both current and previous tows, providing essential context to the model.
- The use of SHAP analysis to interpret the Transformer model, offering insights into the drivers of gap formation and validating the model’s learned behavior against physical process understanding.
- The demonstration of a robust data-driven methodology for AFP process monitoring that has the potential to enhance understanding and move towards more proactive quality control.
While the results are promising, this study serves as a proof of concept and has certain limitations. The model was developed and validated using data from straight layups of a single material type on a specific AFP system, focusing on the first ply deposition with a specific set of experimental conditions. Therefore, the model’s generalization capabilities to more complex scenarios, such as curved parts, different composite materials, varying process parameters and the cumulative effects across multiple plies, require further investigation. Additionally, while this work demonstrated the feasibility and interpretability of the Transformer, a comprehensive benchmarking study comparing these results against traditional architectures (e.g., LSTM) on identical data splits remains a necessary future step to strictly quantify performance gains. While such comparisons present avenues for future research, the primary objective of this study was to demonstrate the superior interpretability of attention maps in decoding spatial defect dependencies, a capability often obscured in traditional “black-box” sequential models, rather than solely optimizing for the lowest possible regression error.
Future work should focus on several key areas. Firstly, extending the model and evaluation to encompass a broader range of AFP conditions, including complex geometries and diverse materials, is crucial for assessing wider industrial applicability. Secondly, the promising inference speed of the Transformer model warrants further investigation into its real-time implementation. This would involve integrating the model into an AFP system’s control loop to enable in-process adjustments and move towards adaptive, closed-loop quality control, which remains a significant but important challenge. Further refinement of feature engineering and exploration of additional sensor inputs could also enhance predictive accuracy.
In conclusion, this study establishes the Transformer architecture as a tool for AFP gap width estimation. By providing accurate and interpretable feedback on defect formation, this research contributes to the ongoing efforts to transform AFP into a more efficient, reliable and self-correcting manufacturing paradigm, ultimately supporting the wider adoption of high-performance composite structures.
Author Contributions
D.C.: Conceptualization, Methodology, Software, Formal analysis, Data Curation, Writing—Original Draft, Writing—Review & Editing. A.R.S.: Conceptualization, Methodology, Writing—Review & Editing, Supervision. N.C.: Conceptualization, Writing—Review & Editing, Supervision. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no specific grant from any funding agency.
Data Availability Statement
Data will be made available on request.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Brasington, A.; Sacco, C.; Halbritter, J.; Wehbe, R.; Harik, R. Automated fiber placement: A review of history, current technologies, and future paths forward. Compos. Part C Open Access 2021, 6, 100182. [Google Scholar] [CrossRef] [Scilit]
- Meister, S.; Wermes, M.A.M.; Stuve, J.; Groves, R.M. Review of image segmentation techniques for layup defect detection in the Automated Fiber Placement process: A comprehensive study to improve AFP inspection. J. Intell. Manuf. 2021, 32, 2099–2119. [Google Scholar] [CrossRef] [Scilit]
- Rudberg, T.; Nielson, J.; Henscheid, M.; Cemenska, J. Improving AFP cell performance. SAE Int. J. Aerosp. 2014, 7, 317–321. [Google Scholar] [CrossRef] [Scilit]
- Del Rossi, D.; Cadran, V.; Thakur, P.; Palardy-Sim, M.; Lapalme, M.; Lessard, L. Experimental investigation of the effect of half gap/half overlap defects on the strength of composite structures fabricated using automated fibre placement (AFP). Compos. Part A Appl. Sci. Manuf. 2021, 150, 106610. [Google Scholar] [CrossRef] [Scilit]
- Yadav, N.; Schledjewski, R. Review of in-process defect monitoring for automated tape laying. Compos. Part A Appl. Sci. Manuf. 2023, 173, 107654. [Google Scholar] [CrossRef] [Scilit]
- Meister, S.; Wermes, M.; Stüve, J.; Groves, R.M. Investigations on Explainable Artificial Intelligence methods for the deep learning classification of fibre layup defect in the automated composite manufacturing. Compos. Part Eng. 2021, 224, 109160. [Google Scholar] [CrossRef] [Scilit]
- Stojkovic, M.; Butt, J. Industry 4.0 Implementation Framework for the Composite Manufacturing Industry. J. Compos. Sci. 2022, 6, 258. [Google Scholar] [CrossRef] [Scilit]
- Lachekhab, F.; Benzaoui, M.; Tadjer, S.A.; Bensmaine, A.; Hamma, H. LSTM-Autoencoder Deep Learning Model for Anomaly Detection in Electric Motor. Energies 2024, 17, 2340. [Google Scholar] [CrossRef] [Scilit]
- Pantoji, S.; Kassapoglou, C.; Peeters, D. Predicting gaps and overlaps in Automated Fiber Placement composites by measuring sources of manufacturing process variations. Compos. Part B Eng. 2025, 291, 111891. [Google Scholar] [CrossRef] [Scilit]
- Druiff, P. Data-Driven Manufacturing in the Automated Lay-Up of Composites. Ph.D. Thesis, University of Bristol, Bristol, UK, 2023; 466p. [Google Scholar]
- Schmitt, R.; Mersmann, C.; Damm, B. In-Process 3D Laser Measurement to Control the Fiber Tape-Laying for Composite Production; SPIE: San Francisco, CA, USA, 2010; Volume 7723, pp. 216–225. [Google Scholar]
- Schuster, A.; Mayer, M.; Willmeroth, M.; Brandt, L.; Kupke, M. Inline quality control for thermoplastic automated fibre placement. Procedia Manuf. 2020, 51, 505–511. [Google Scholar] [CrossRef] [Scilit]
- Sacco, C.; Radwan, A.B.; Anderson, A.; Harik, R.; Gregory, E. Machine learning in composites manufacturing: A case study of Automated Fiber Placement inspection. Compos. Struct. 2020, 250, 112514. [Google Scholar] [CrossRef] [Scilit]
- Tang, Y.; Wang, Q.; Cheng, L.; Li, J.; Ke, Y. An in-process inspection method integrating deep learning and classical algorithm for automated fiber placement. Compos. Struct. 2022, 300, 116051. [Google Scholar] [CrossRef] [Scilit]
- Zambal, S.; Heindl, C.; Eitzinger, C.; Scharinger, J. End-to-End Defect Detection in Automated Fiber Placement Based on Artificially Generated Data; SPIE: San Francisco, CA, USA, 2019; Volume 11172, pp. 371–378. [Google Scholar]
- Sacco, C.; Brasington, A.; Saidy, C.; Kirkpatrick, M.; Halbritter, J.; Wehbe, R.; Harik, R. On the effect of manual rework in AFP quality control for a doubly-curved part. Compos. Part B Eng. 2021, 227, 109432. [Google Scholar] [CrossRef] [Scilit]
- Pagano, D. A predictive maintenance model using long short-term memory neural networks and Bayesian inference. Decis. Anal. J. 2023, 6, 100174. [Google Scholar] [CrossRef] [Scilit]
- Wang, Z.; Zhou, C.; Liu, Y.; Huang, K.; Yang, C. Cluster-based industrial KPIs forecasting considering the periodicity and holiday effect using LSTM network and MSVR. Adv. Eng. Inform. 2023, 56, 101916. [Google Scholar] [CrossRef] [Scilit]
- Chabane, A.N.; Sahnoun, M.; Bettayeb, B. Forecasting KPIs of Production Systems Using LSTM Networks. In Proceedings of the 2021 1st International Conference on Cyber Management and Engineering (CyMaEn), Virtual, 26–28 May 2021; IEEE: Piscataway, NJ, USA, 2021; pp. 1–6. [Google Scholar]
- Zhao, R.; Wang, D.; Yan, R.; Mao, K.; Shen, F.; Wang, J. Machine health monitoring using local feature-based gated recurrent unit networks. IEEE Trans. Ind. Electron. 2017, 65, 1539–1548. [Google Scholar] [CrossRef] [Scilit]
- Xu, D.; Zhang, Z.; Shi, J. Failure prediction using gated recurrent unit and autoencoder in complex manufacturing process. In Proceedings of the 2022 4th World Symposium on Artificial Intelligence (WSAI), Jilin, China, 23–25 June 2022; IEEE: Piscataway, NJ, USA, 2022; pp. 68–73. [Google Scholar]
- Vaswani, A. Attention is all you need. In Proceedings of the 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA, 4–9 December 2017. [Google Scholar]
- Wen, Q.; Zhou, T.; Zhang, C.; Chen, W.; Ma, Z.; Yan, J.; Sun, L. Transformers in time series: A survey. arXiv 2022. [Google Scholar] [CrossRef] [Scilit]
- Chen, Y.; Song, X.; Lee, C.; Wang, Z.; Zhang, R.; Dohan, D.; Kawakami, K.; Kochanski, G.; Doucet, A.; Ranzato, M.; et al. Towards learning universal hyperparameter optimizers with transformers. Adv. Neural Inf. Process. Syst. 2022, 35, 32053–32068. [Google Scholar]
- Lundberg, S.M.; Lee, S. A unified approach to interpreting model predictions. arXiv 2017. [Google Scholar] [CrossRef] [Scilit]
- Ponce-Bobadilla, A.V.; Schmitt, V.; Maier, C.S.; Mensing, S.; Stodtmann, S. Practical guide to SHAP analysis: Explaining supervised machine learning model predictions in drug development. Clin. Transl. Sci. 2024, 17, e70056. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.








