# Team QUST at SemEval-2024 Task 8: A Comprehensive Study of Monolingual and
Multilingual Approaches for Detecting AI-generated Text

Xiaoman Xu, Xiangrun Li, Taihang Wang, Jianxiang Tian, Ye Jiang
College of Information Science and Technology
Qingdao University of Science and Technology, China

###### Abstract

This paper presents the participation of team QUST in Task 8 SemEval 2024. We
first performed data augmentation and cleaning on the dataset to enhance model
training efficiency and accuracy. In the monolingual task, we evaluated
traditional deep-learning methods, multiscale positive-unlabeled framework
(MPU), fine-tuning, adapters and ensemble methods. Then, we selected the top-
performing models based on their accuracy from the monolingual models and
evaluated them in subtasks A and B. The final model construction employed a
stacking ensemble that combined fine-tuning with MPU. Our system achieved 8th
(scored 8th in terms of accuracy, officially ranked 13th) place in the
official test set in multilingual settings of subtask A. We release our system
code at:https://github.com/warmth27/SemEval2024_QUST

Team QUST at SemEval-2024 Task 8: A Comprehensive Study of Monolingual and
Multilingual Approaches for Detecting AI-generated Text

Xiaoman Xu, Xiangrun Li, Taihang Wang, Jianxiang Tian, Ye Jiang College of
Information Science and Technology Qingdao University of Science and
Technology, China

##  1 Introduction

Large language models (LLMs) enable quick, coherent responses and content
creation but also raise ethical concerns about misinformation and academic
integrity Wang et al. (2023). To differentiate between machine-generated and
human-created content, previous study Guo and Yu (2023) has been extensively
discussed in industry and academic works.

Semeval 2024’s Task 8 Wang et al. (2024a) encourages the participants to
develop an automatic system for detecting AI-generated text by leveraging an
extended version of the M4 dataset Wang et al. (2023, 2024b). We engaged in
subtasks A and B, during which we encountered the challenges of overcoming
linguistic differences, data scarcity, and inadequate cross-lingual
generalization capabilities. Furthermore, existing multilingual models are
less discussed in detecting AI-generated text, compared to monolingual ones,
which further exacerbates the difficulty in model selection.

Meanwhile, we found that the multilingual dataset in subtask A contains data
from both monolingual data and subtask B, as shown in Figure 1. To enhance the
diversity and scale of the text dataset, we performed back-translation on the
multilingual training set to increase the volume of monolingual data and
conducted data cleaning to improve data quality.

Figure 1: The data distribution in subtask A and B.

In our approach to subtasks A and B, we initially applied deep learning
methods for a swift assessment in subtask A and proceeded to fine-tune
multiple pre-trained language models (PLMs), inspired by recent studies
highlighting the efficacy of fine-tuning methods in text classification.
However, the training cost of the fine-tuning method is relatively high. We
further utilize the Adapter Hu et al. (2021) to parameter efficiency fine-tune
(PEFT) Hu et al. (2021) the model while preserving its performance. We also
noted that despite the reduced training time, the performance of adapter
models was not consistently stable, showing variability across experiments.
Given the critical importance of model performance, decided not to utilize
adapters in the testing phase.

To enhance model performance and generalizability, we adopted a stacking-based
ensemble learning method, utilizing the logits from the top two performing
models as inputs for a linear layer to generate final predictions. Finally,
our experimental results on the test set show that integrating data
augmentation and ensemble learning significantly improves model efficacy in
task-specific settings.

##  2 System description

###  2.1 MPU framework

Recent research on machine-generated text recognition has evolved into
treating it as a binary classification problem, with the latest advancements
including the Multiscale Positive-Unlabeled (MPU) Tian et al. (2023) training
framework. This approach introduces a length-sensitive MPU loss combined with
abstract recurrent models and a text multi-scale module, significantly
enhancing detection performance for short texts.

Upon analyzing the text lengths in official datasets, As shown in table 2, we
observed a predominance of short texts, with those exceeding 512 characters
making up a quarter of the total. This insight highlighted the MPU framework’s
suitability for subtask A. The MPU model, previously tested only on the HC3
Guo et al. (2023) Chinese and English datasets, needed assessment for its
effectiveness on multilingual datasets. To address this, we integrated the MPU
framework with the XLM-Roberta (XLM-R) model to enhance its adaptability for
multilingual tasks and employed stacking ensemble techniques, yielding
significant improvements in our experimental outcomes.

###  2.2 Fine-tuning

Fine-tuning PLMs such as BERT or RoBERTa have been extensively discussed in
text classification tasks Jiang (2023); Jiang et al. (2023, 2020). Recently,
the DeBERTa model He et al. (2020) is an enhancement built upon the
foundations of BERT and RoBERTa through the incorporation of a disentangled
attention mechanism and an enhanced masked decoder. We utilized the DeBERTa
model and performed fine-tuning on it in our experiment. Although fine-tuning
PLMs to specific domains or downstream tasks is a crucial and common practice,
fully fine-tuning its large number of parameters becomes time-consuming and
costly.

###  2.3 Adapter

In our experiments, due to the substantial size of the DeBERTa model and the
size of the official datasets, each fine-tuning run required a significant
amount of time. Adapter-based fine-tuning is an approach to fine-tuning a PLM
that involves freezing the most of layers and inserting low-dimensional
adapter modules into each layer to improve parameter efficiency. Research has
shown that introducing adapters reduces the number of trainable parameters to
3.6%, with only a marginal performance drop of 0.4% Houlsby et al. (2019).
Furthermore, in some cases, models applying adapters perform even better Bapna
et al. (2019).

In our task, we employed the LoRA (Low-Rank Adapter) method Hu et al. (2021),
which injects trainable rank-decomposition matrices into each layer of the
Transformer architecture, effectively freezing the PLM’s weights. This
significantly reduces the number of trainable parameters for downstream tasks.
Therefore, we added a sequence classification head on top of the model to
adapt the PLMs to the classification task. This has reduced the training costs
and shortened the training time.

###  2.4 Stacking

Ensemble learning combines multiple base learners to form a predictive model
with enhanced generalization capabilities Sagi and Rokach (2018). Initially,
predictions are generated employing various machine learning algorithms. Then,
these predictions serve as inputs for a subsequent classifier. Upon training
the subsequent classifier, the integrated model is optimized to produce a new
prediction set.

##  3 Experimental setup

###  3.1 Data preprocessing

The subtasks A and B involving diverse domains and sources with both human and
machine-generated texts, we encountered chaotic symbols and extraneous content
such as hyperlinks, numerals, and escape characters. To improve data quality,
we undertook preprocessing steps including: removing special characters;
eliminating excessive whitespace and line breaks; discarding Unicode escape
characters and numerically formatted texts; removing hyperlinks; excluding
irrelevant text lines like those for sharing, surveys, comments, ads, terms of
use, and copyright notices; and deleting duplicate sentences. Notably, we
avoided removing escape characters from multilingual training and validation
sets to preserve original characters in non-English texts.

Subtask | v1 | v2 | v3
---|---|---|---
train | dev | train | dev | train | dev | test
Monolingual | 119,757 | 5,000 | 167,252 | 5,000 | 176,252 | 5,000 | 34,272
Multilingual | 172,417 | 4,000 | 172,417 | 4,000 | 176,417 | 4,000 | 42,378
subtask B | 71,027 | 3,000 | 105,908 | 3,000 | 176,252 | 3,000 | 18,000
Table 1: The overall data statistic. "v1" and "v2" respectively refer to the
original dataset, and the dataset processed after data augmentation. "v3"
refers to the training dataset that has undergone data augmentation and other
processing after the official test dataset was released.

Statistic SubA-mono SubA-multi SubB Train Dev Test Train Dev Test Train Dev
Test avg-sent 16.5 13.0 18.4 15.7 8.9 17.1 15.3 10.2 17.5 avg-sent-len 24.7
26.8 23.7 25.5 22.9 23.1 23.5 24.1 23.6 sent-len>512 16.7% 13.1% 23.5% 17.3%
1.2% 14.6% 15.2% 6.6% 18.9%

Table 2: The statistics of the v2 dataset. "avg-sent" represents the average
number of sentences per document, "avg-sent-len" represents the average number
of words per document, "sent-len>512" represents the percentage of documents
that their sent-len are greater than 512 words.

###  3.2 Data augmentation

We evaluated our models on the original dataset (v1) before the test set was
released. We found that the multilingual set contained training and validation
data for the monolingual and subtask B. To enlarge the monolingual dataset and
improve model performance, we removed 5000 monolingual validation entries from
the multilingual set, translated Chinese, Indonesian, Urdu, and Bulgarian data
to English using Google API, and then cleaned the data to produce a refined
dataset (v2).

we calculated the statistics of different versions of datasets, as shown in
Table 1. For the multi-class subtask B, we re-labeled the dataset based on
multilingual tags, addressing a severe imbalance by reducing instances in
overrepresented categories for balance. After receiving the test set, we
included the multilingual validation set into our training dataset and
performed the same enhancement processes, creating a v3 version for final
model training and prediction.

We further analyzed the augmented version of the v2 dataset, as shown in Table
2. This analysis includes the average sentence length and average text length,
as well as the proportion of texts exceeding 512 characters in length. The
average sentence count was obtained through sentence tokenization using the
sent-tokenize tool, while the average sentence length was calculated using the
word-tokenize tool from the NLTK python library. Model performance for
subtasks A and B was evaluated based on accuracy.

###  3.3 Monolingual models

In subtask A, submissions were made using two systems based on the different
language tracks. For the monolingual English track, the system consisted of
five approaches across ten models, as detailed in Table 3. The final
submission system employed a stacking ensemble method, which was composed of
the two best-performing models out of the ten.

In Table 3, these models had a learning rate of 1e-4, were trained for 3
epochs, and the best-performing models on the validation set were saved. For
the fine-tuned models, we adhered to the inherent 512-token length limitation
to ensure consistency in the input data and effective processing by the
models.

The final monolingual model selected the top-performing two models,
DeBERTa-v3-large and RoBERTa-base model based on MPU framework(RoBERTa-base-
MPU), for stacking ensemble learning. The learning rate for the ensemble model
remained set at 1e-4, trained for 1000 epochs. Only the best-performing
stacking model was retained, and the final predictions were based on this
optimal stacking model.

###  3.4 Multilingual models

In the multilingual track, we conducted experiments employing the top five
models that exhibited promising performance in monolingual contexts. We opted
to substitute the RoBERTa model with the XLM-R model, which is specifically
designed for multilingual tasks.

Derived from the RoBERTa architecture, the XLM-R model has undergone training
across 100 distinct languages, endowing it with multilingual capabilities.
This versatility enables the model to process and comprehend various languages
effectively, leading to notable enhancements in performance across diverse
cross-lingual transfer tasks. Subsequently, we identified the top two models
for integration through stacking ensemble. The integration of predictions from
these two models yielded superior predictive performance.

Following this, we trained the multilingual models on the v2 version of the
multilingual training dataset. We set the learning rate to 1e-4 and 3 epochs
while retaining the models that performed best on the validation set.

During the experimentation, we observed that the addition of adapters to the
DeBERTa-v3-large model resulted in unstable performance, while direct fine-
tuning of the DeBERTa-v3-large model exhibited better results. Based on this
observation, we ultimately chose to integrate the XLM-R-MPU model and the
DeBERTa-v3-large model. To achieve this, we saved the best models from each
training session and utilized these two optimal models to generate logits.
Subsequently, we merged the logits from both sets of models as part of the
training data for the stacking ensemble’s input linear layer. We set the
learning rate to 1e-4 and extended the training epochs to 1000 to ensure
thorough model training. Throughout this process, we continuously monitored
and retained the best-performing stacking model, which was ultimately applied
to the test set for final predictions.

###  3.5 Subtask B models

We extended the binary classification capabilities of the RoBERTa-base model
combined with the MPU method to address multi-class problems in subtask A,
employing a one-vs-rest strategy for six categories including human, ChatGPT,
etc. This resulted in six separate classifiers, with classification based on
the highest confidence level among positive predictions from these classifiers
for each category.

Following this, we opted for the consistently excellent performance of the
LoRA adapter-based DeBERTa-v3-large (DeBERTa-v3-Large-LoRA) model and applied
it to subtask B. Additionally, we introduced a new adapter-based RoBERTa-large
model. The model configurations were consistent with the monolingual models.
In the final ensemble model, we employed stacking with the DeBERTa-v3-Large-
LoRA and RoBERTa-large models. The learning rate was set to 1e-4, with a
training period of 3000 epochs, and only the model with the highest score was
retained.

##  4 Results

Methods | Models | Mon1 | Mon2 | Mul | SubB
---|---|---|---|---|---
Deep learning | CNN Jiang et al. (2019) | 0.762 | - | - | -
RNN Lin et al. (2017) | 0.729 | - | - | -
RCNN Lin et al. (2017) | 0.702 | - | - | -
Self-Attention Jiang and Wang (2023) | 0.762 | - | - | -
MPU | RoBERTa-base-MPU Tian et al. (2023) | 0.894 | 0.979 | - | -
XLM-R-MPU (Ours) | - | - | 0.798 | 0.7
Fine-tuning | DeBERTa-v3-base He et al. (2021) | 0.823 | - | - | -
DeBERTa-v3-large He et al. (2021) | 0.84 | 0.979 | 0.763 | -
longformer-base-4096 Beltagy et al. (2020) | 0.737 | - | - | -
BERT Devlin et al. (2018) | 0.769 | 0.955 | 0.654 | -
RoBERTa-base Liu et al. (2019) | - | - | - | 0.75
XLM-R Liu et al. (2019) | - | - | 0.72 | -
Adapter | DeBERTa-v3-Large-LoRA (Ours) | 0.843 | 0.948 | 0.669 | 0.858
Roberta-large-LoRA (Ours) | - | - | - | 0.862
Stacking | RoBERTa-base-MPU+DeBERTa-v3-large (Ours) | 0.96 | 0.99 | 0.795 | -
RoBERTa-large+DeBERTa-v3-large (Ours) | - | - | - | 0.94
Table 3: The overall accuracy comparison in subtask A and B. "Mon1", "Mul",
and "SubB" respectively represent the accuracy of monolingual models,
multilingual models, and subtask B models trained on the v1 dev set. "Mon2" is
the dev accuracy on the v2 dataset.

###  4.1 Monolingual results

Our evaluation work is divided into two main stages: first, the evaluation
based on the officially provided monolingual dataset (Mon1), and second, the
evaluation based on our back-translated and processed monolingual dataset
(Mon2).

In the Mon1 evaluation stage, we aimed for a quick baseline model
implementation, using traditional deep-learning methods. The results in Table
3 on the Mon1 dataset show that traditional models generally outperformed the
fine-tuned deep learning models, likely due to the small size of the official
monolingual dataset, which contains only about 110,000 entries. Consequently,
large models like RoBERTa-base may not be adequately trained, while smaller
models such as CNN or RNN could perform better by being less prone to
overfitting.

By integrating the MPU framework with the RoBERTa-base model, performance
improved by 20 percentage points over direct fine-tuning, highlighting MPU’s
benefits in boosting short-text performance and enhancing machine-generated
long text detection. Despite being designed for long documents, Longformer-
base-4096 underperformed compared to CNN and Self-Attention methods on the
Mon1 dataset.

The DeBERTa model, an advancement over BERT and RoBERTa, excelled in our
tests, especially after fine-tuning with adapters, which improved both
efficiency and performance, slightly surpassing the fully fine-tuned DeBERTa.
Stacking and re-predicting logits from the top two models led to a nearly 7%
improvement over the best single model, underscoring the effectiveness of
model fusion in increasing prediction accuracy and stability.

In the Mon2 evaluation stage, we retrained them on the Mon2 dataset after
selecting the top five best-performing models on the Mon1 dataset. After
retraining, the performance of the models on the Mon2 dataset improved by
approximately 20%. likely due to shorter texts enhancing feature detection,
noise reduction from removing poor-quality data, and increased dataset
diversity and size. These factors combined allowed the models to gain a deeper
understanding of language characteristics.

###  4.2 Multilingual results

Experiments performed on a refined multilingual dataset employing the
DeBERTa-v3-Large-LoRA model produced a performance score of merely 0.669,
notably inferior to the baseline model’s performance on the unprocessed
dataset. This discrepancy may stem from improperly removing crucial features
during the dataset cleaning process or introducing errors. Therefore, we opted
to directly train the selected model on the raw official multilingual dataset,
as detailed in Table 3 above. We found that the XLM-R model integrated with
the MPU framework outperformed the baseline XLM-R model by 7% on the dataset,
thus confirming the effectiveness of the MPU framework.

While the BERT model excels in monolingual tasks, its performance lags behind
the baseline by approximately 7% in multilingual tasks, suggesting that BERT
may be less suitable for multilingual classification tasks. The
DeBERTa-v3-large model, which is an improvement based on BERT and RoBERTa,
outperforms the baseline XLM-R by 3.55% on multilingual datasets. This
improvement can be attributed to DeBERTa’s optimizations to both
architectures, which prove particularly effective in multilingual processing,
enhancing the model’s learning capabilities and generalization.

In our experimental results table, we observe that the performance of the
DeBERTa-v3-Large-LoRA model is 5.1% lower than the baseline model, while also
exhibiting a 9.4% decrease compared to directly fine-tuning the
DeBERTa-v3-large model. This discrepancy in performance may stem from
significant differences in data distribution between the pre-training task and
incremental training.

Specifically, there exists a substantial difference in data distribution
between the DeBERTa model and the model fine-tuned via LoRA adapters,
resulting in insufficient parameter updates to effectively capture these
differences. This phenomenon suggests that although LoRA adapters offer a
parameter-efficient fine-tuning method, relying solely on limited parameter
adjustments may not suffice to achieve optimal performance in situations with
substantial disparities in data distribution.

The stacking results in the multilingual task failed to surpass the
performance of the XLM-R-MPU model, which could be attributed to the already
robust nature of XLM-R-MPU, potentially causing the ensemble model to overfit
on the training data, thereby reducing performance on validation or test data.
Another possibility is that the two top-performing models exhibit high
correlation in predictions (i.e., commonly making the same type of errors),
thus stacking them may not yield significant performance improvements.

###  4.3 Subtask B results

Table 3 indicates that the performance of the XLM-R-MPU model continues to
deteriorate on the dataset for subtask B, indicating poor results. This could
be attributed to the model originally being designed for binary classification
tasks and not being well-suited for multi-class tasks.

We found that by directly freezing the model and fine-tuning the adapter-based
DeBERTa-v3-Large (DeBERTa-v3-Large-LoRA) and RoBERTa-large (Roberta-large-
LoRA) models, the classification effectiveness significantly improved,
outperforming the official baseline by approximately 10 percentage points.The
use of the LoRA adapter allows models to more effectively utilize pre-trained
knowledge while avoiding over-fine-tuning and reducing the risk of overfitting
on specific tasks. After data cleaning, the pre-trained data used by
DeBERTa-v3-large and RoBERTa-large were closer to the target multi-class task,
potentially further enhancing their performance.

##  5 Ablations

We conducted ablation experiments using the DeBERTa-v3-large and Roberta-base
models on the Mon1 dataset. As shown in Table 4, the experimental results
indicate that the introduction of the MPU framework and stacking ensemble
method significantly improves the model’s performance, resulting in a notable
performance enhancement

However, despite the inclusion of the LoRA adapter, the performance
improvement is not significant. This could be attributed to the insufficient
number of parameters fine-tuned solely by the adapter when faced with complex
tasks, which hinders the model from learning additional knowledge effectively.

Methods | Results
---|---
DeBERTa-v3-large | 0.84
DeBERTa-v3-large w/ LoRA | 0.843
Roberta-base | 0.694
Roberta-base w/ MPU | 0.894
Stacking | 0.96
Table 4: Ablation experiments. "Stacking" refers to the aggregation of results
from the "DeBERTa-v3-large with LoRA" model and the "Roberta-base with MPU"
model.

##  6 Official test results

Our system ranks 8th on Semeval 2024 Task 8 official multilingual test set of
subtask A. It is noteworthy that, employing the same method, Only the model
trained on the multilingual dataset surpassed the baseline of 0.80 with a
score of 0.90, while models on monolingual datasets and Task B exhibited
comparatively inferior performance, with none of the submissions reaching the
respective domain baselines.

This phenomenon could be attributed to several factors. Firstly, although
monolingual validation sets were removed from the multilingual training set,
the processed multilingual training data may still share similarities with
monolingual validation sets. This could lead to superior model performance
during evaluation; however, due to disparities between the final test set data
and the processed multilingual data, models may fail to meet baseline
performance on the test set. Secondly, model training based on fine-tuning may
encounter instability and catastrophic forgetting issues, thus affecting the
model’s generalization ability. Therefore, even with the same model,
discrepancies in performance on official test sets may arise due to
differences between datasets, resulting in significant performance gaps.

##  7 Conclusion

In conclusion, our team developed three distinct systems for SemEval-2024 Task
8, targeting the monolingual and multilingual aspects of subtask A and
addressing subtask B. We achieve 8th place in the multilingual setting of
subtask A. We leveraged back-translation to expand the training datasets for
both monolingual and subtask B. The RoBERTa-base and XLM-R models, enhanced by
the MPU framework, showed improved detection of short texts in both
monolingual and multilingual settings. Finally, the stacking method allowed us
to combine the strengths of multiple models, improving our system’s predictive
accuracy. Future efforts will consider incorporating advancements in cross-
lingual pre-trained models in our subsequent work to further enhance the
model’s understanding of texts across diverse languages and cultural
backgrounds.

## Acknowledgements

This work is funded by the Natural Science Foundation of Shandong Province
under grant ZR2023QF151.

## References

  * Bapna et al. (2019) Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. 2019.  Simple, scalable adaptation for neural machine translation.  _arXiv preprint arXiv:1909.08478_.
  * Beltagy et al. (2020) Iz Beltagy, Matthew E. Peters, and Arman Cohan. 2020.  Longformer: The long-document transformer.  _arXiv:2004.05150_.
  * Devlin et al. (2018) Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018.  Bert: Pre-training of deep bidirectional transformers for language understanding.  _arXiv preprint arXiv:1810.04805_.
  * Guo et al. (2023) Biyang Guo, Xin Zhang, Ziyuan Wang, Minqi Jiang, Jinran Nie, Yuxuan Ding, Jianwei Yue, and Yupeng Wu. 2023.  How close is chatgpt to human experts? comparison corpus, evaluation, and detection.  _arXiv preprint._
  * Guo and Yu (2023) Zhen Guo and Shangdi Yu. 2023.  Authentigpt: Detecting machine-generated text via black-box language models denoising.  _arXiv preprint arXiv:2311.07700_.
  * He et al. (2021) Pengcheng He, Jianfeng Gao, and Weizhu Chen. 2021.  Debertav3: Improving deberta using electra-style pre-training with gradient-disentangled embedding sharing.
  * He et al. (2020) Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. 2020.  Deberta: Decoding-enhanced bert with disentangled attention.  _arXiv preprint arXiv:2006.03654_.
  * Houlsby et al. (2019) Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. 2019.  Parameter-efficient transfer learning for nlp.  In _International Conference on Machine Learning_ , pages 2790–2799. PMLR.
  * Hu et al. (2021) Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021.  Lora: Low-rank adaptation of large language models.  _arXiv preprint arXiv:2106.09685_.
  * Jiang (2023) Ye Jiang. 2023.  Team qust at semeval-2023 task 3: A comprehensive study of monolingual and multilingual approaches for detecting online news genre, framing and persuasion techniques.  _arXiv preprint arXiv:2304.04190_.
  * Jiang et al. (2019) Ye Jiang, Johann Petrak, Xingyi Song, Kalina Bontcheva, and Diana Maynard. 2019.  Team bertha von suttner at semeval-2019 task 4: Hyperpartisan news detection using elmo sentence representation convolutional network.  In _Proceedings of the 13th International Workshop on Semantic Evaluation_ , pages 840–844.
  * Jiang and Wang (2023) Ye Jiang and Yimin Wang. 2023.  Topic-aware hierarchical multi-attention network for text classification.  _International Journal of Machine Learning and Cybernetics_ , 14(5):1863–1875.
  * Jiang et al. (2020) Ye Jiang, Yimin Wang, Xingyi Song, and Diana Maynard. 2020.  Comparing topic-aware neural networks for bias detection of news.  In _ECAI 2020_ , pages 2054–2061. IOS Press.
  * Jiang et al. (2023) Ye Jiang, Xiaomin Yu, Yimin Wang, Xiaoman Xu, Xingyi Song, and Diana Maynard. 2023.  Similarity-aware multimodal prompt learning for fake news detection.  _arXiv preprint arXiv:2304.04187_.
  * Lin et al. (2017) Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen Zhou, and Yoshua Bengio. 2017.  A structured self-attentive sentence embedding.  _arXiv preprint arXiv:1703.03130_.
  * Liu et al. (2019) Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019.  Roberta: A robustly optimized BERT pretraining approach.  _CoRR_ , abs/1907.11692.
  * Sagi and Rokach (2018) Omer Sagi and Lior Rokach. 2018.  Ensemble learning: A survey.  _Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery_ , 8(4):e1249.
  * Tian et al. (2023) Yuchuan Tian, Hanting Chen, Xutao Wang, Zheyuan Bai, Qinghua Zhang, Ruifeng Li, Chao Xu, and Yunhe Wang. 2023.  Multiscale positive-unlabeled detection of ai-generated texts.  _arXiv preprint arXiv:2305.18149_.
  * Wang et al. (2023) Yuxia Wang, Jonibek Mansurov, Petar Ivanov, Jinyan Su, Artem Shelmanov, Akim Tsvigun, Chenxi Whitehouse, Osama Mohammed Afzal, Tarek Mahmoud, Alham Fikri Aji, et al. 2023.  M4: Multi-generator, multi-domain, and multi-lingual black-box machine-generated text detection.  _arXiv preprint arXiv:2305.14902_.
  * Wang et al. (2024a) Yuxia Wang, Jonibek Mansurov, Petar Ivanov, Jinyan Su, Artem Shelmanov, Akim Tsvigun, Chenxi Whitehouse, Osama Mohammed Afzal, Tarek Mahmoud, Giovanni Puccetti, Thomas Arnold, Alham Fikri Aji, Nizar Habash, Iryna Gurevych, and Preslav Nakov. 2024a.  Semeval-2024 task 8: Multigenerator, multidomain, and multilingual black-box machine-generated text detection.
  * Wang et al. (2024b) Yuxia Wang, Jonibek Mansurov, Petar Ivanov, Akim Tsvigun, Jinyan Su, Artem Shelmanov, Osama Mohammed Afzal, Tarek Mahmoud, Giovanni Puccetti, Thomas Arnold, Alham Fikri Aji, Nizar Habash, Iryna Gurevych, and Preslav Nakov. 2024b.  MG-Bench: Evaluation benchmark for black-box machine-generated text detection.


# Huygens’ Principle Reveals Dispersion in Inhomogeneous Media

Li Mingcong  Zhao Zhenming Corresponding<EMAIL_ADDRESS>
###### Abstract

Dispersion is an important factor of optical materials. Due to the effect of
techniques and equipment in the manufacturing process of optical materials,
the inhomogeneity of the material may be caused. In this paper, microsphere
optical media are used to replace the inhomogeneous zones, and Huygens’
principle is used to study the dispersion caused by the material
inhomogeneity. First, we study the effect of a single inhomogeneous zone, and
then the effect of a thin medium with a large number of inhomogeneous zones.
It is deduced that the dispersion law of a macro-optical medium is also
consistent with Cauchy formula. Finally, it is pointed out that Huygens’
principle is suitable for studying the interaction between light and
particles. Key words: Dispersion, Cauchy dispersion formula, Light-Matter
interaction, Huygens’ principle

##  1 Introduction

Dispersion is a common optical phenomenon. As early as 1666, Newton studied
dispersion using prisms[1] In 1837, Cauchy gave his dispersion formula[2]. In
1872, Sellmeier developed Cauchy dispersion formula and put forward the
Sellmeier equation, which is also an empirical formula[3]. Dispersion belongs
to light-matter interaction. According to current theory, the dispersive
properties of an optical medium depend on the interaction between the incident
light and the electrons in the medium, which is a typical interaction between
light and microscopic particles. From Huygens’ principle, where there are
waves, there are wavefronts and wavelets[4]. With the understanding about the
essence of Huygens’ principle[5], it was found that Huygens’ principle is
feasible for studying the interaction between light and microscopic particles,
and has been applied to the research of Rayleigh scattering[6], atomic
stimulated radiation[7] and photon absorption[8]. In this work, we use
Huygens’ principle to analyze the microscopic interaction between light and a
medium and the propagation of light in inhomogeneous media. It is found that
the inhomogeneity of optical media can lead to dispersion.

##  2 The influence of a single inhomogeneous zone on light propagation

Optical uniformity is an important index for optical materials. In common
optical media, there are local inhomogeneity in density or composition, which
leads to fluctuations in refractive index of materials. It is important to
study the effect of refractive index fluctuations on light propagation. We use
a microsphere with refractive index n and radius R to describe the local
refractive index fluctuations in a single inhomogeneous zone.

Figure 1: Influence of a microsphere on the wavefront

In Fig.1, the wavefront of the plane wave propagating along the $z$ axis is
changed by the microsphere, and the deformation degree of the wavefront is
related to the wavelength. When the light travels along the $c_{1}c_{2}$ path,
the influence of the microsphere on the optical path and phase is,

$\delta\left(r,\varphi\right)=k\left(n-1\right)\cdot 2R\cos\alpha$ (1)

where $k$ is the incident light wave number. The wavelength of the incident
light is $\lambda$ and the amplitude is $A$, so complex amplitude distribution
in the plane is given by

$U\left(r,\varphi,0\right)=At\left(r,\varphi\right)$ (2)

where $t(r,\varphi)$ is the transmittance function, which is

$t(r,\delta)=\left\\{\begin{matrix}1&r>R\\\ e^{i\delta}&r\leq
R\end{matrix}\right.$ (3)

Figure 2: The $r\mathrm{d}r\mathrm{d}\varphi$ area element emits Huygens
wavelet

In Fig.2, according to the parameters of the incident light and the
microsphere, the complex amplitude of the light at $z=0$ can be obtained.
Using Huygens’ principle, the amplitude of the light at point Q is

$U_{Q}=\frac{1}{i\lambda}\int\limits_{0}^{\infty}\int\limits_{0}^{2\pi}U(r,\varphi,0)\frac{e^{ik\rho}}{\rho}K(\theta)r\mathrm{d}r\mathrm{d}\varphi=\frac{A}{i\lambda}\int\limits_{0}^{\infty}\int\limits_{0}^{2\pi}t(r,\varphi)\frac{e^{ik\rho}}{\rho}K(\theta)r\mathrm{d}r\mathrm{d}\varphi$
(4)

where, $r\mathrm{d}r\mathrm{d}\varphi$ is the area element, $\rho$ is the
distance between the area element and point $Q$, and $K(\theta)$ is the
inclination factor. Expanding the transmittance function:

$t(r,\varphi)=\left\\{\begin{matrix}1&r>R\\\
e^{i\rho}=1+i\delta-\frac{\delta^{2}}{2}-\frac{i\delta^{3}}{6}+\frac{\delta^{4}}{24}+\frac{i\delta^{5}}{120}+\varepsilon(\delta)&r\leq
R\end{matrix}\right.$ (5)

Substituting Eq.(5) into Eq.(4) and retaining the first six terms gives:

$U_{Q}\approx
Ae^{ikz}+\frac{A}{i\lambda}\int\limits_{0}^{R}\int\limits_{0}^{2\pi}[i\delta-\frac{\delta^{2}}{2}-\frac{i\delta^{3}}{6}+\frac{\delta^{4}}{24}+\frac{i\delta^{5}}{120}]\frac{e^{ik\rho}}{\rho}K(\theta)r\mathrm{d}r\mathrm{d}\varphi$
(6)

The range of the wave front affected by the particle is very small. Therefore
$K(\theta)e^{ik\rho}/\rho$ can be regarded as a constant, and Eq.6 can be
written as:

$\displaystyle U_{Q}$
$\displaystyle=Ae^{ikz}+\frac{A}{i\lambda}K(\theta)\frac{e^{ik\rho}}{\rho}\int\limits_{0}^{R}\int\limits_{0}^{2\pi}[i\delta-\frac{\delta^{2}}{2}-\frac{i\delta^{3}}{6}+\frac{\delta^{4}}{24}+\frac{i\delta^{5}}{120}]r\mathrm{d}r\mathrm{d}\varphi$
(7)
$\displaystyle=U_{0}+\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[i\delta-\frac{\delta^{2}}{2}-\frac{i\delta^{3}}{6}+\frac{\delta^{4}}{24}+\frac{i\delta^{5}}{120}]r\mathrm{d}r$

In Eq.(7), the first term $Ae^{ikz}$ is the complex amplitude of the incident
light at point $Q$, and the following five terms are the complex amplitudes of
lights diffracted by the microsphere. We denote these five terms as
$U_{1}~{}U_{5}$ in turn.

$U_{1}=\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[i\delta]r\mathrm{d}r$
(8)
$U_{2}=\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[-\frac{\delta^{2}}{2}]r\mathrm{d}r$
(9)
$U_{3}=\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[-\frac{i\delta^{3}}{6}]r\mathrm{d}r$
(10)
$U_{4}=\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[\frac{\delta^{4}}{24}]r\mathrm{d}r$
(11)
$U_{5}=\frac{Ake^{ik\rho}}{i\rho}K(\theta)\int\limits_{0}^{R}[\frac{i\delta^{5}}{120}]r\mathrm{d}r$
(12)

Using the phase shift expression given in Eq.(1) and according to
$r=R\sin\alpha$, $\mathrm{d}r=R\cos\alpha\mathrm{d}\alpha$, and then
integrating we can get

$U_{1}=\frac{2(n-1)R^{3}k^{2}}{3}\frac{Ake^{ik\rho}}{i\rho}$ (13)
$U_{2}=\frac{i(n-1)^{2}R^{4}k^{3}}{2}\frac{Ake^{ik\rho}}{i\rho}$ (14)
$U_{3}=-\frac{4(n-1)^{3}R^{5}k^{4}}{15}\frac{Ake^{ik\rho}}{i\rho}$ (15)
$U_{4}=-\frac{i(n-1)^{4}R^{6}k^{5}}{9}\frac{Ake^{ik\rho}}{i\rho}$ (16)
$U_{5}=\frac{4(n-1)^{5}R^{7}k^{6}}{105}\frac{Ake^{ik\rho}}{i\rho}$ (17)

The phases of $U_{1}$, $U_{3}$, $U_{5}$ and $U_{0}$ are the same.
$i=e^{i\pi/2}$ in $U_{2}$ indicates that the phase of $U_{2}$ is $\pi/2$
behind that of $U_{0}$, and the $-i=e^{-i\pi/2}$ in $U_{4}$ shows that its
phase is $\pi/2$ ahead of that of $U_{0}$.

##  3 Property of inhomogeneous thin medium

Usually, there are a lot of non-uniform refractive index zones in an optical
medium. They are very tiny in dimension, but large in number, and evenly
distributed in a fine optical medium. To study the dispersion of such a
medium, we start with a layer of the medium.

Figure 3: Microsphere diffraction and equivalent substitution in a thin
monolayer medium

In Fig.3, the thickness of the monolayer medium is $l$, and the incident light
propagates along the $Z$-axis. The light is diffracted by the microsphere
located at point $P$. According to equations (13) - (17), the amplitude of the
diffraction light at point $O_{l}(0,0,l)$ is:

$\displaystyle U_{O_{l}}=$
$\displaystyle\frac{AK(\theta)e^{ik\rho_{\scriptscriptstyle
P}}}{i\rho_{\scriptscriptstyle
P}}[\frac{2k^{2}(n-1)R^{3}}{3}+\frac{i3k^{3}(n-1)^{2}R^{4}}{2}$ (18)
$\displaystyle-\frac{4k^{4}(n-1)^{3}R^{5}}{15}-\frac{ik^{5}(n-1)^{4}R^{6}}{9}+\frac{4k^{6}(n-1)^{5}R^{7}}{105}]$

where $\rho_{\scriptscriptstyle P}$ represents the distance of
$\overline{PO_{l}}$.
When a large number of microspheres exist in the medium, the incident light
will be diffracted by each microsphere. Then the total amplitude at point
$O_{l}$ is

$\displaystyle U_{O_{l}}=$ $\displaystyle\sum_{\rho_{\scriptscriptstyle
P}}\frac{AK(\theta)e^{ik\rho_{\scriptscriptstyle
P}}}{i\rho_{\scriptscriptstyle
P}}[\frac{2k^{2}(n-1)R^{3}}{3}+\frac{i3k^{3}(n-1)^{2}R^{4}}{2}$ (19)
$\displaystyle-\frac{4k^{4}(n-1)^{3}R^{5}}{15}-\frac{ik^{5}(n-1)^{4}R^{6}}{9}+\frac{4k^{6}(n-1)^{5}R^{7}}{105}]$

In Eq. (19), the particles are thought to be concentrated on the $xy$ plane
for simplicity. Point $P(r_{\scriptscriptstyle P},\varphi_{\scriptscriptstyle
P},z_{\scriptscriptstyle P})$ is equivalent to point
$P^{\prime}(r_{\scriptscriptstyle P},\varphi_{\scriptscriptstyle P},0)$, then

$\displaystyle U_{O_{l}}=$ $\displaystyle\sum_{\rho_{\scriptscriptstyle
P}}\frac{AK(\theta)e^{ik\rho_{\scriptscriptstyle
P^{\prime}}}}{i\rho_{\scriptscriptstyle
P^{\prime}}}[\frac{2k^{2}(n-1)R^{3}}{3}+\frac{i3k^{3}(n-1)^{2}R^{4}}{2}$ (20)
$\displaystyle-\frac{4k^{4}(n-1)^{3}R^{5}}{15}-\frac{ik^{5}(n-1)^{4}R^{6}}{9}+\frac{4k^{6}(n-1)^{5}R^{7}}{105}]$

where, $\rho_{\scriptscriptstyle P^{\prime}}$ represents the length of
$P^{\prime}O_{l}$. Let the density of the microspheres be $N$. Then the number
of the microspheres on per unit area of the $xy$ plane is $Nl$, and the sum in
Eq. (20) can be transformed into an integral:

$\displaystyle U_{O_{l}}=$
$\displaystyle[\int\limits_{0}^{\infty}\int\limits_{0}^{2\pi}\frac{NlAK(\theta)e^{ik\rho_{\scriptscriptstyle
P^{\prime}}}}{i\rho_{\scriptscriptstyle
P^{\prime}}}r\mathrm{d}r\mathrm{d}\varphi][\frac{2k^{2}(n-1)R^{3}}{3}+\frac{i3k^{3}(n-1)^{2}R^{4}}{2}$
(21)
$\displaystyle-\frac{4k^{4}(n-1)^{3}R^{5}}{15}-\frac{ik^{5}(n-1)^{4}R^{6}}{9}+\frac{4k^{6}(n-1)^{5}R^{7}}{105}]$

According to Fresnel wave zone method[9], we can have
$\int\limits_{0}^{\infty}\int\limits_{0}^{2\pi}\frac{AK(\theta)e^{ik\rho_{\scriptscriptstyle
P^{\prime}}}}{i\rho_{\scriptscriptstyle
P^{\prime}}}r\mathrm{d}r\mathrm{d}\varphi=i\lambda Ae^{ikl}$. Then Eq.(21) can
be rewritten as

$\displaystyle U_{O_{l}}=$ $\displaystyle\frac{i4\pi
k(n-1)R^{3}ANl}{3}-\frac{6\pi k^{2}(n-1)^{2}R^{4}ANl}{2}-\frac{i8\pi
k^{3}(n-1)^{3}R^{5}ANl}{15}$ (22) $\displaystyle+\frac{2\pi
k^{4}(n-1)^{4}R^{6}ANl}{9}+\frac{i8\pi k^{5}(n-1)^{5}R^{7}ANl}{105}$

Let

$a=\frac{4\pi k(n-1)R^{3}AN}{3}$ (23) $b=\frac{6\pi k^{2}(n-1)^{2}R^{4}AN}{2}$
(24) $c=\frac{8\pi k^{3}(n-1)^{3}R^{5}AN}{15}$ (25) $d=\frac{2\pi
k^{4}(n-1)^{4}R^{6}AN}{9}$ (26) $e=\frac{8\pi k^{5}(n-1)^{5}R^{7}AN}{105}$
(27)

Substitute equations (23)-(27) into (22), we have

$u_{O_{l}}=Ae^{ikl}(ial-bl-icl+dl+iel)$ (28)

Adding the amplitude $Ae^{ikl}$ of the incident light at point $O_{l}$ and Eq.
(28), the total amplitude at point $O_{l}$ can be obtained as

$U_{O_{l}}=Ae^{ikl}+u_{O_{l}}=Ae^{ikl}(1+ial-bl-icl+dl+iel)$ (29)

The optical medium in Fig.3 is very thin, that is, $l$ in Equation (29) is
very small, then:

$1+ial-bl-icl+dl+iel=e^{ial-bl-icl+dl+iel}=e^{i(a-c+e)l-(b-d)l}$ (30)

Substitute (30) into (29):

$U_{O_{l}}=Ae^{ikl}e^{i(a-c+e)l-(b-d)l}=Ae^{-(b-d)l}e^{i(k+a-c+e)l}$ (31)

The influence of a layer of medium with a thickness of $l$ on an incident
light can be expressed as the transmittance $T$:

$U_{O_{l}}=Ae^{-(b-d)l}e^{i(k+a-c+e)l}=AT$ (32)

where

$T=e^{-(b-d)l}e^{i(k+a-c+e)l}$ (33)

##  4 Thick medium dispersion properties

A macro medium with a length of $L$, as shown in Fig.4, can be equivalent to
$m$ layers of thin medium with a thickness of $l$. Then we have

Figure 4: Replace medium of length $L$ by $m$ layers of thin medium

$\displaystyle U_{L}$
$\displaystyle=U_{0}T^{m}=U_{O}[e^{-(b-d)l}e^{i(k+a-c+e)l}]^{m}=U_{0}e^{-(b-d)ml}e^{i(k+a-c+e)ml}$
(34) $\displaystyle=U_{0}e^{-(b-d)L}e^{i(k+a-c+e)L}=U_{0}e^{ik^{\prime}L}$

where

$k^{\prime}=i(b-d)+(k+a-c+e)$ (35)

It can be seen from Eq. (34) that when light propagates in a non-uniform
medium, the real part $k+a-c+e$ of the wave number $k^{\prime}$ determines the
wavelength $\lambda=2\pi/(k+a-c+e)$ of the light, and the imaginary part
$i(b-d)$ determines the attenuation of the light. Assume that the optical
wavelength in a uniform medium is $\lambda$, and its frequency is
$\nu=v_{0}/\lambda$, then the propagation velocity of light in a dispersive
medium can be obtained from the real part of wave number as:

$v=\nu\lambda^{\prime}=\frac{v_{0}}{\lambda}\frac{2\pi}{k+a-c+e}=v_{0}\frac{k}{k+a-c+e}$
(36)

According to Equation (36), the refractive index of the medium is:

$n(\lambda)=\frac{v_{0}}{v}=\frac{k+a-c+e}{k}=1+\frac{a}{k}-\frac{c}{k}+\frac{e}{k}$
(37)

Substitute (23), (25), and (27) into (37), it can be obtained

$\displaystyle n(\lambda)$
$\displaystyle=1+\frac{4\pi(n-1)R^{3}AN}{3}-\frac{8\pi
k^{2}(n-1)^{3}R^{5}AN}{15}+\frac{8\pi k^{4}(n-1)^{5}R^{7}AN}{105}$ (38)
$\displaystyle=1+\frac{4\pi(n-1)R^{3}AN}{3}-\frac{1}{\lambda^{2}}\frac{32\pi^{3}(n-1)^{3}R^{5}AN}{15}+\frac{1}{\lambda^{4}}\frac{128\pi
k^{4}(n-1)^{5}R^{7}AN}{105}$
$\displaystyle=n_{0}-\frac{a^{\prime}}{\lambda^{2}}+\frac{b^{\prime}}{\lambda^{4}}$

where

$\displaystyle n_{0}=1+\frac{4\pi(n-1)R^{3}AN}{3}$ (39) $\displaystyle
a^{\prime}=\frac{32\pi^{3}(n-1)^{3}R^{5}AN}{15}$ $\displaystyle
b^{\prime}=\frac{128\pi k^{4}(n-1)^{5}R^{7}AN}{105}$

It is obvious that equation (38) is the dispersion law for inhomogeneous
media, which is consistent with the Cauchy dispersion equation.

##  5 Conclusion

Using Huygens wavelet as the fundamental element of light field, the
interaction between light and particles can be described correctly, and the
dispersion caused by medium inhomogeneity can be found. The method using
Huygens’ principle to study dispersion can also be extended to the atomic
scale, as well as being used to study the relationship between optical
materials and dispersion.

## References

  * [1] Isaac Newton.  Opticks, or, a treatise of the reflections, refractions, inflections & colours of light.  Courier Corporation, 1952.
  * [2] Augustin Louis Cauchy.  Mémoire sur la dispersion de la lumière.  Calve, 1836.
  * [3] Wilhelm Sellmeier.  Ueber die durch die aetherschwingungen erregten mitschwingungen der körpertheilchen und deren rückwirkung auf die ersteren, besonders zur erklärung der dispersion und ihrer anomalien.  Annalen der Physik, 223(12):525–554, 1872.
  * [4] Christiaan Huygens.  Treatise on Light: In which are Explained the Causes of that which Occurs in Reflexion, & in Refraction. And Particularly in the Strange Refraction of Iceland Crystal.  MacMillan and Company, limited, 1912.
  * [5] Chao Zhang, Zhenming Zhao, and Mei Kong.  Study on mathematical essence of huygens’ principle.  Optik, 175:49–53, 2018.
  * [6] Chao Zhang, Zhenming Zhao, and Mei Kong.  Huygens’ principle may reveal rayleigh scattering.  Optik, 206:163120, 2020.
  * [7] Zhenming Zhao, Mei Kong, and Yameng Xu.  Phase advance of photons generated in stimulated emission relative to incident light.  Optik, 127(20):8970–8975, 2016.
  * [8] Zhenming Zhao, Jialin Li, and Mei Kong.  Huygens’ principle may reveal interaction between light and atoms.  Optik, 171:605–610, 2018.
  * [9] Craig F Bohren and Alistair B Fraser.  Colors of the sky.  The Physics Teacher, 23(5):267–272, 1985.


# Motion Planning for Triple-Axis Spectrometers

Tobias Weber<EMAIL_ADDRESS>Institut Laue-Langevin (ILL), 71 avenue des
Martyrs, CS 20156, 38042 Grenoble Cedex 9, France

###### Abstract

We present the free and open source software TAS-Paths, a novel system which
calculates optimal, collision-free paths for the movement of triple-axis
spectrometers. The software features an easy to use graphical user interface,
but can also be scripted and used as a library. It allows the user to plan and
visualise the motion of the instrument before the experiment and can be used
during measurements to circumvent obstacles. The instrument path is calculated
in angular configuration space in order to keep a maximum angular distance
from any obstacle.

††journal: arXiv

##  1 Introduction

Ever since their conception by Bertram Brockhouse, neutron triple-axis
spectrometers (TAS) have become an indispensable tool for research in solid-
state physics. They are regularly used in large-scale facilities around the
world to probe nuclear or magnetic excitations in crystals.

The three axis of a TAS instrument are the monochromator, the sample, and the
analyser axis. They are used for selecting the energy and momentum that is
transferred from the neutrons to a sample crystal. Modern instrument control
software [1, 2, 3] allows the user to drive the spectrometer using reciprocal
crystal coordinates which are internally translated by the software to
rotations of the instrument axes and the sample crystal. As the transformation
from sample crystal coordinates to instrumental angles is not trivial [4], it
is not immediately obvious to the user if a given coordinate leads to a
collision of the instrument with a shielding wall or any apparatus stationed
in the instrument space. The control software itself is usually only capable
of catching the simplest pre-defined cases of possible collisions, namely by
allowing each motor to have soft limits in addition to the hard limits imposed
by end switches. For details about the functioning of TAS please refer to the
textbook by Shirane, Shapiro, and Tranquada [5].

Since the onset of the COVID-19 pandemic, both remote and autonomous
experiments have come into focus. Remote experimentation means that the users
do not have to be at the instrument itself anymore; they instead drive it via
a remote control software. Autonomous experiments go one step further and let
the entire measurement be run by a machine learning system. While remote
control is already very common at neutron facilities, research into autonomous
systems based on Gaussian processes is currently being conducted at several
facilities [6, 7].

These new developments further disconnect the user from the instrument and
exacerbate the problem of possible collisions during scans or motor movement.
Even the machine learning software tools so far only consider the crystal
coordinate space and are oblivious to any details concerning the instrument,
they specifically do not take into account how the coordinates are translated
into instrument coordinates and axis angles.

The present software is intended to bridge this gap and provides the means to
calculate a safe path in instrumental space from one set of either
instrumental angles or crystal coordinates to another. While collision
detection and limited motion planning for triple-axis spectrometers has
already been attempted in the past [8], our algorithm goes beyond such a
direct grid search and instead is based on modern methods for analytical robot
motion planning using Voronoi diagrams.

##  2 Software Design

The TAS-Paths software is written in a modular way using modern C++20 and
comprises a core library with a scripting interface and a graphical user
interface (GUI), which are each described in the following subsections. TAS-
Paths makes heavy use of the Boost library [9] and utilises the same
mathematical library [10] that we employ in our triple-axis software suite
Takin [11].

###  2.1 Core Library and Algorithm

The basic algorithms of TAS-Paths’s core module are realised as a C++ library.
The principal functionalities of the software comprise, first, the building of
a road map, i.e. a mesh of all possible paths on which the instrument can
safely move, and, second, picking the optimal path from a start to a target
position from the mesh. The approach is based on the retraction method (see
[12], Ch. 7, pp. 163 and 304) of classical motion planning for robots
possessing full information about their surroundings. It is named so because
the robot retracts onto the road map, moves along its path mesh and detaches
in the vicinity of the goal. A simplified version of the employed algorithm is
presented in the following.

#### Path mesh calculation

For the purpose of motion planning, a triple-axis instrument can be seen as a
robotic arm possessing three angular degrees of freedom (DOF), namely the
monochromator, the sample, and the analyser axis, as depicted in Fig. 1. All
DOF are constrained to the same two-dimensional plane. Only two of the three
DOF are used during an experiment, because energy selection can be done by
moving either the monochromator or the analyser axis, leaving the other axis
at a fixed angle. These two DOF, which are usually the monochromator and the
sample axis angle for instruments operating in fixed final energy mode, span a
two-dimensional angular configuration space in which the position of the
instrument is represented as a single point. The configuration space
corresponding to the instrument in Fig. 1 is shown in Fig. 2. Please refer to
[12], Ch. 13.1, pp. 284f for more information about configuration spaces in
general.

Figure 1: Instrumental space. During typical experiments, a triple-axis
spectrometer uses two degrees of freedom of its axes, these are the sample
axis angle $2\theta_{S}$ together with either the monochromator axis angle
$2\theta_{M}$ or the analyser axis angle $2\theta_{A}$. This example shows a
simplified model of the instrument MIRA [13] and one obstacle. Figure 2:
Angular configuration space spanned by the sample axis angle $2\theta_{S}$ and
the monochromator axis angle $2\theta_{M}$. Forbidden regions leading to
collisions are shown in red, while regions where the instrument can move are
shown in blue. The calculated road map, i.e. the mesh of possible paths, is
displayed as thin white lines. One concrete path from a start position (red
circle) to a target position (green circle) is depicted as a thick yellow
line. The figure corresponds to the instrumental space shown in Fig. 1.

It is in this two-dimensional angular configuration space that the road map as
the mesh of possible collision-free paths is constructed via a multi-step
approach:

  * 1.

In the first step, the software simulates instrumental positions on a grid in
angular configuration space and marks areas where the instrument would collide
with obstacles in its path, with itself, or areas where the axis motors are
outside their angular limits. This divides the configuration space into
regions of allowed and disallowed positions, which are shaded as blue and red
areas in Fig. 2, respectively.

  * 2.

The contours of these two regions’ borders are reconstructed in the second
step and approximated by line segments $l_{i}$.

  * 3.

In the central step of the algorithm, the line segments $l_{i}$ serve as the
sites for constructing a Voronoi diagram $V$. We calculate the mesh of
possible instrument paths as the set of Voronoi bisectors
$B\left(l_{i},\,l_{j}\right)$ of $V$ with [14]:

$B\left(l_{i},\,l_{j}\right)\ =\ \left\\{\alpha\in
C\left|\right.\left\|\alpha-l_{i}\right\|=\left\|\alpha-
l_{j}\right\|\right\\},$ (1)

where $C$ names the angular configuration space and $\left\|\cdot\right\|$ the
angular norm. Since $l_{i}$ and $l_{j}$ are any two line segments separating
forbidden and allowed regions, the bisectors give the loci of equal angular
distance to the closest obstacles. They are shown as the thin white lines in
Fig. 2 and constitute the road map.

Using a Voronoi diagram ensures that the angular coordinates of each point on
the path mesh are at the farthest possible angular distance from any
disallowed position. Calculating the Voronoi diagram is done by one of two
supported back end libraries. The user can here choose between Boost’s Polygon
[15, 9] and CGAL’s Segment Delaunay Graph [16, 17] software. For efficiency,
the core library distributes the path mesh calculation onto multiple threads
of execution.

The use of a line segment Voronoi diagram results from our quantisation of the
boundaries of valid and invalid configuration space into line segments. In
general, analytical terms, this is an approximation to the topological
skeleton [18] of the configuration space. Please refer to [12], Ch. 7, pp.
147-171 for more information on Voronoi diagrams and their generalisations.

#### Path calculation

For performing calculations of paths, the Voronoi nodes and bisectors of the
generated mesh are registered as vertices and edges of a weighted graph data
structure, respectively. The angular distances between two Voronoi nodes serve
as the weights of the graph edges, where we also consider the speed of the
axis motors for the calculation of the distance function. A preliminary
version of this kind of distance function has also served as cost function for
our complementary project concerning autonomous instrument control [6]. The
shortest angular distance between a start and a target instrument angle is
calculated by employing Dijkstra’s single-source shortest path algorithm (see
[19], pp. 273-297), which finds the shortest path of a source vertex and all
other vertices of a graph using the weights associated with the edges. In our
example, the calculated shortest path is depicted as thick yellow line in Fig.
2.

So far, the algorithm chooses the shortest path on the road map. Nevertheless,
there may still be alternative, safer paths available. To calculate them, we
optionally introduce additional weight factors depending on how far a position
is located from the next obstacle using the direct angular distance between
them. These weight factors effectively serve as a potential function pushing
the optimal path away from positions that are too close to forbidden regions.
The idea is similar to the classical potential field method of robot motion
planning (see [12], p. 305), where walls generate a repulsive potential to
keep the robot at a distance, but here with the addition of keeping the
instrument on the road map.

The user can either directly supply the axis angles for the source and target
position of the instrument or alternatively specify Miller indices of the
sample’s crystal coordinate system. The transformation from one into the other
is done transparently by the software using the same $UB$ matrix formalism [4]
that is also widely used by instrument control software, e.g. NICOS [1], SICS
[2], or NOMAD [3].

#### External bindings

The core C++ library features bindings to Python [20] using the SWIG software
[21] to generate a native interface. This way calculations of instrument paths
can be scripted and – for instance – be directly used in Python-based
instrument control software like NICOS [1]. Reusable example scripts for both
the fixed final and the fixed initial energy modes of TAS are provided with
the source code distribution.

###  2.2 Graphical User Interface

The GUI is based on the Qt library and its OpenGL widgets [22]. It features a
three-dimensional editor that lets the user place obstacles, move the
instrument by dragging and dropping the mouse and change its properties on-
the-fly (Fig. 3). For modeling the instrument and the obstacles we use
geometric primitives. These can be seen as bounding geometries to the actual,
complicated instrumental details and as such cannot lead to invalid positions.

The GUI uses the core library to calculate and simulate the path mesh and the
specific path from the current instrument position to a target position, which
can also be chosen graphically. The calculation and the instrumental movement
in angular configuration space is visualised using the QCustomPlot library
[23]. The calculated path can be exported to motor commands for several
instrument control systems.

Figure 3: Main window. The GUI features a three-dimensional editor to easily
add obstacles into the instrument space and move all components using mouse
drag and drop. Instrumental motion along the calculated path is simulated and
visualised.

##  3 Use Cases

Apart from our main goal of including it into the autonomous instrument
control project, the software has multiple use cases of various degrees of
complexity. In the simplest case, it can be employed for calculating possible
collision configurations when planning an experiment. A more sophisticated
scenario is to combine the software with an existing instrument control system
to automatically drive the instrument on a calculated path. In the following
we provide examples for these two cases.

###  3.1 Collision calculation

A collision that can easily occur during an experiment is due to the
instrument’s motors typically moving at different speeds. This can lead to a
situation where a drive command issued to an instrument that is already close
to a wall can crash the instrument into the wall even if both the source and
the target positions by themselves would be safe. Such a situation is shown in
Fig. 4, it is modeled after scan positions we encountered during an experiment
at the instrument Thales [24]. At Thales, the monochromator axis moves
considerably more slowly than the sample axis. Manually driving back the
instrument from position (a) in Fig. 4, which was at the end of a scan, to its
neutral position (b) would therefore have led to collisions with the wall,
because the control software usually moves all axes at the same time.

Figure 4: Without motion planning, moving an instrument that is at a position
close to a wall (a), for example at the end of a scan, back to a neutral
position (b) can lead to a crash into the wall if the monochromator axis moves
slower than the sample axis.

In such a scenario, the TAS-Paths core library might be linked to the
instrument control software and used as a monitoring system warning of
imminent collisions when the control software issues a drive command.

###  3.2 Path tracking

Apart from mere monitoring of the positions driven by the instrument control
system, TAS-Paths can actively calculate the paths to be used by the control
software. We successfully performed first tests at the instrument MIRA [13]
using the NICOS [1] control system, where we let the software drive the
instrument around an obstacle. For our test, a trash can served as a
placeholder for the obstacle. In a real experiment, this could typically be a
helium or nitrogen can or devices dedicated to sample environment which
usually tend to be placed close to the instrument arms. A video of the
experiment is available on-line at https://youtu.be/F0SAQp00he4. Note that due
to slow instrument movement the video has been sped up multifold for easier
viewing.

The results of the test show that in order to be compatible with TAS-Paths,
the instrument control system has to be adapted for a different kind of motor
control. In normal operation, the control system would drive all motors
simultaneously, correct their positions within less than a tenth of a degree
of precision and switch off the air cushions after each point. For TAS-Paths,
the movement has to be continuous, keeping the air cushions on. A correction
after each control point within the degree range is usually sufficient.

##  4 Conclusion

We presented the novel collision detection and motion planning system TAS-
Paths. The software finds the instrumental path which has the farthest angular
distance from any obstacles that may be in the experiment space of a triple-
axis spectrometer.

As there is currently no automated safety system in place during an autonomous
experiment that would prevent the instrument from collisions, the software
will be included in our larger autonomous experimentation project for which we
have performed first tests [6] and which will be available for normal user
operation in the future. This is possible since TAS-Paths is complementary to
our current autonomous control system in every respect: TAS-Paths calculates
its positions analytically and is only concerned about the instrumental side
of an experiment, while the autonomous control software uses statistical
methods and heuristics [25] for position selection and concerns only the
physics side of the experiment.

Aside from its inclusion in autonomous experiments, the TAS-Paths software
provides a means for the user to simulate and visualise instrument movement
during experiment planning. This will help prevent dangerous situations before
commencing any measurements. The software has been successfully tested for
typical situations at instruments as well as for moving a spectrometer around
obstacles.

Future developments might include the automatic determination of obstacles in
instrument space using RGBZ cameras and the usage of external, full CAD models
of instruments instead of simplified geometries.

## Acknowledgements

First and foremost I am indebted to Dr. Lihong Ma and Prof. Dr. Christian
Icking for supervising this project as part of a thesis work [26] and for many
discussions about it and computational geometry in general. I wish to thank
Gaétan Fine for his work on integrating TAS-Paths with the NOMAD instrument
control system [3] and for beta testing. Further thanks go to Robert Georgii
for his support with the MIRA [13] commissioning test, to Martin Böhm and Paul
Steffens for discussions, and to Paolo Mutti and Stéphane Rols for supporting
the project. Thanks to Alain Filhol for his help getting the software onto the
App Store.

## Source Code

TAS-Paths’s unified release repository is located at
https://github.com/ILLGrenoble/taspaths, its development repository can be
found at https://code.ill.fr/scientific-software/takin/paths. The software’s
DOI is 10.5281/zenodo.4625649.

## References

  * [1] G. Brandl, E. Faulhaber, C. Felder, J. Krüger, A. Lenz, B. Pedersen, NICOS, the Networked Instrument Control System (2010 - 2023).
URL https://nicos-controls.org

  * [2] H. Heer, M. Könnecke, D. Maden, The SINQ instrument control software system, Physica B: Condensed Matter 241-243 (1997) 124–126, proceedings of the International Conference on Neutron Scattering.  doi:10.1016/S0921-4526(97)00528-0.
  * [3] P. Mutti, F. Cécillon, A. Elaazzouzi, Y. L. Goc, J. Locatelli, H. Ortiz, J. Ratel, NOMAD – more than a simple sequencer, in: Proceedings of ICALEPCS 2011, Grenoble, France, 2011, pp. 808 – 811.
  * [4] M. D. Lumsden, J. L. Robertson, M. Yethiraj, UB matrix implementation for inelastic neutron scattering experiments, Journal of Applied Crystallography 38 (3) (2005) 405–411.  doi:10.1107/S0021889805004875.
  * [5] G. Shirane, S. M. Shapiro, J. M. Tranquada, Neutron Scattering with a Triple-Axis Spectrometer: Basic Techniques, Cambridge University Press, Cambridge, UK, 2002.
  * [6] M. M. Noack, P. H. Zwart, D. M. Ushizima, M. Fukuto, K. G. Yager, K. C. Elbert, C. B. Murray, A. Stein, G. S. Doerk, E. H. R. Tsai, R. Li, G. Freychet, M. Zhernenkov, H.-Y. N. Holman, S. Lee, L. Chen, E. Rotenberg, T. Weber, Y. L. Goc, M. Böhm, P. Steffens, P. Mutti, J. A. Sethian, Gaussian processes for autonomous data acquisition at large-scale synchrotron and neutron facilities, Nature Review Physics 3 (2021) 685–697.  doi:10.1038/s42254-021-00345-y.
  * [7] M. T. Parente, G. Brandl, C. Franz, U. Stuhr, M. Ganeva, A. Schneidewind, AI-assisted neutron spectroscopy using active learning with log-Gaussian processes, preprint available on arXiv: 2209.00980 (2023).  arXiv:2209.00980.
URL https://arxiv.org/abs/2209.00980

  * [8] Q. Mühlbauer, K. Hradil, Monitoring and Preventing Collisions for a Triple Axis Spectrometer, in: Proceedings of the 2006 IEEE International Conference on Control Applications, Munich, Germany, October 4-6, 2006, 2006, pp. 1795–1800.  doi:10.1109/CACSD-CCA-ISIC.2006.4776913.
  * [9] Various Authors, Boost C++ Libraries (2004-2023).
URL https://www.boost.org

  * [10] T. Weber, tlibs – a physical-mathematical C++ template library (2012-2023).  doi:10.5281/zenodo.5717779.
  * [11] T. Weber, Update 2.0 to “Takin: An open-source software for experiment planning, visualisation, and data analysis”, (PII: S2352711016300152), SoftwareX 14 (2021) 100667.  doi:10.1016/j.softx.2021.100667.
  * [12] M. de Berg, O. Cheong, M. van Kreveld, M. Overmars, Computational Geometry, Algorithms and Applications, Third Edition, Springer-Verlag Berlin Heidelberg, Germany, 2008.  doi:10.1007/978-3-540-77974-2.
  * [13] R. Georgii, T. Weber, G. Brandl, M. Skoulatos, M. Janoschek, S. Mühlbauer, C. Pfleiderer, P. Böni, The multi-purpose three-axis spectrometer (TAS) MIRA at FRM II, Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment 881 (2018) 60–64.  doi:10.1016/j.nima.2017.09.063.
  * [14] C. Icking, R. Klein, L. Ma, S. Nickel, A. Weißler, On bisectors for different distance functions, Discrete Applied Mathematics 109 (1) (2001) 139–161, 14th European Workshop on Computational Geometry.  doi:10.1016/S0166-218X(00)00238-9.
  * [15] A. Sydorchuk, Boost Polygon Voronoi extensions, part of the Boost C++ library [9] (2010-2013).
URL https://www.boost.org/doc/libs/1_76_0/libs/polygon/doc/voronoi_main.htm

  * [16] M. I. Karavelas, Voronoi diagrams in CGAL [17], in: I. Z. Emiris, M. I. Karavelas, L. Palios (Eds.), Proceedings of the 22nd European Workshop on Computational Geometry (EWCG’06), Delphi, Greece, 2006, pp. 229–232.
URL http://users.math.uoc.gr/~mkaravel/files/papers/vda-ewcg06.pdf

  * [17] Various Authors, Computational Geometry Algorithms Library (CGAL) for C++ (1995-2023).
URL https://www.cgal.org

  * [18] P. Golland, W. Eric, L. Grimson, Fixed topology skeletons, in: Proceedings IEEE Conference on Computer Vision and Pattern Recognition. CVPR 2000 (Cat. No.PR00662), Vol. 1, 2000, pp. 10–17.  doi:10.1109/CVPR.2000.855792.
  * [19] J. Erickson, Algorithms, 1st edition, self-published, 2019.
URL http://jeffe.cs.illinois.edu/teaching/algorithms/

  * [20] G. van Rossum, J. Fred L. Drake, Python Language Reference Manual, Network Theory Ltd., 2011.
  * [21] The SWIG Developers, Simplified Wrapper and Interface Generator (SWIG) (1995-2023).
URL http://www.swig.org

  * [22] The Qt Company, Qt (2023).
URL https://www.qt.io

  * [23] E. Eichhammer, QCustomPlot (2011 - 2023).
URL https://www.qcustomplot.com

  * [24] M. Böhm, P. Steffens, J. Kulda, M. Klicpera, S. Roux, P. Courtois, P. Svoboda, J. Saroun, V. Sechovsky, ThALES – Three Axis Low Energy Spectroscopy for highly correlated electron systems, Neutron News 26 (3) (2015) 18–21.  doi:10.1080/10448632.2015.1057050.
  * [25] M. M. Noack, K. G. Reyes, Mathematical nuances of Gaussian process-driven autonomous experimentation, MRS Bulletin 48 (2023) 1–11.  doi:10.1557/s43577-023-00478-8.
  * [26] T. Weber, Pathfinding for Triple-Axis Spectrometers, FernUniversität in Hagen (FUH), Fakultät für Mathematik und Informatik, Lehrgebiet Kooperative Systeme, Hagen, Germany (2021).