{'fraction_non_alphanumeric': 0.028669294294294295, 'fraction_numerical': 0.009712837837837838, 'mean_word_length': 5.034258210645526, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Joint prediction of truecasing and punctuation for conversational speech in low-resource scenarios

Capitalization and punctuation are important cues for comprehending written texts and conversational transcripts. Yet, many ASR systems do not produce punctuated and case-formatted speech transcripts. We propose to use a multi-task system that can exploit the relations between casing and punctuation to improve their prediction performance. Whereas text data for predicting punctuation and truecasing is seemingly abundant, we argue that written text resources are inadequate as training data for conversational models. We quantify the mismatch between written and conversational text domains by comparing the joint distributions of punctuation and word cases, and by testing our model cross-domain. Further, we show that by training the model in the written text domain and then transfer learning to conversations, we can achieve reasonable performance with less data.


INTRODUCTION
Automatic speech recognition (ASR) systems are frequently used to transcribe meetings, calls, or dictated notes. Most ASR models are trained to predict all lowercase or all uppercase transcripts without any punctuation. Lack of text formatting makes it more difficult to read and comprehend text, even when it is free of speech recognition errors [1]. In addition to improving the legibility of speech transcripts, punctuation and capitalization restoration also facilitates other natural language processing (NLP) tasks, such as named entity recognition (NER) [2], part-of-speech tagging, syntactic parsing, and discourse segmentation. Recently, [3] have shown that the presence of punctuation and truecasing is the single largest factor affecting the accuracy of various dialog act segmentation and classification systems. Furthermore, they found that punctuation is highly correlated with the presence of dialog act classes that correspond to conversational cues, such as incomplete utterances, restarts, repairs, and backchannels.
It is clear that the presence of punctuation is important for automated transcript processing -but does there exist a single, correct way of inserting the punctuation symbols? Truecasing and punctuation are abundantly available in written text resources. In some languages (such as Polish) the use of punctuation is well-defined by a set of rules. Other languages, such as English, permit -to some extent -arbitrary use of punctuation (e.g., the insertion of commas). However, the use of truecasing and punctuation in speech transcripts is more complex due to the increased syntactic complexity of speech [4]. Annotation of speech transcripts is a difficult and time-consuming task, which requires expertise and complex annotation guidelines. We expect that the level of interannotator agreement for inserting punctuation is likely to be lower for conversational data, due to its spontaneity, disfluencies, and often unfinished sentences [4][5][6]. We hypothesize that there is a distribution mismatch between truecasing and punctuation present in written text resources, such as books, and in conversational transcripts. In addition, conversational transcripts are typically much more difficult to come by -except for abundantly-resourced languages such as English.
To investigate our hypothesis, we prepare an experimental setup with two text corpora that are representative of their respective domains -the Gutenberg project books [7] and Fisher conversational transcripts [8]. We consider a multitask approach for joint punctuation and truecasing prediction to leverage the label correlations and dependencies between these tasks. We specifically investigate the following research questions: • How mismatched are book text and conversational transcripts domains in terms of punctuation and truecasing use?
• Can this mismatch be mitigated by leveraging crossdomain transfer learning, and to what extent?
• How much conversational data is needed to effectively leverage transfer learning from books? Note that we specifically choose the Fisher corpus due to its large size to answer this question.
• How much improvement can we expect from multi-task learning and is it consistent in both the books domain and the conversational domain?
• Does seeing truecased text in pretraining improve the performance of further fine-tuning for truecasing prediction?
The rest of the paper is organized as follows: in section 2 we briefly highlight related literature; sections 3 and 4 describe our methods and experimental setup. We present our results in section 5 and conclude our findings in section 6.

RELATED WORK
The early efforts tackle truecasing and punctuation prediction using n-gram language models [2,9]. However, the performance of simple n-gram language models suffers when longrange lexical information is required to disambiguate between punctuation classes [10]. Joint modelling of truecasing and punctuation tasks is considered in [11,12] using deep learning models in a classification framework. Authors in [11] assume punctuation as an independent task and truecasing as conditionally dependent on punctuation given latent representation of the input. However, it is treated as a multi-task problem in [12] where both truecasing and punctuation are independent given the input latent representation. Recently, [13] proposed training ASR models to directly transcribe text with truecasing and punctuation, which is enabled by the release of a large speech corpus with rich-format transcriptions. Unfortunately, their data use is not permissible for commercial applications. Speech signal holds some cues such as pauses and intonation patterns to predict punctuation marks [14]. Incorporation of speech cues to the text-based models is explored in [15,16] and have shown improvements in punctuation prediction. The distribution mismatch between text and conversational domains can be mitigated by retrofitting word embeddings to the target domain [17] when GloVe [18] embeddings are used in the model.

OUR APPROACH
Recent works have shown significant improvements by finetuning pre-trained language models for NLP-related downstream tasks [19][20][21]. Inspired by this research, we choose to follow a similar method for truecasing and punctuation prediction. In this work, we fine-tune base versions of BERT [19] pre-trained models for truecasing and punctuation prediction. BERT base model consists of a sequence of 12 blocks of selfattention layer and fully-connected layer. It is trained to optimize masked language model (MLM) objective and next sentence prediction (NSP). For fine-tuning, we remove MLM and NSP heads from the model and only consider the encoder part for further modelling. Below, we explain the procedure followed in this work to adapt the BERT model for joint prediction of truecasing and punctuation.

Multi-tasking of truecasing and punctuation
In this work, we optimize truecasing and punctuation loss functions together in a multi-tasking manner to exploit relations between truecasing and punctuation. Flow chart for the multi-task model with an example is shown in Fig. 1. As shown in the figure, we process the BERT encoder output using task-specific layers to obtain model predictions for our tasks. Task-specific layers include a dropout layer and a fully connected layer. As the BERT encoder is common for both tasks, it has to encode information related to both the tasks and then task-specific layers retain relevant information depending on the task. Through optimization of the loss computed for each task, we adapt the pre-trained weights and also learn the newly introduced parameters. Loss for each task is computed by comparing fully connected layers output against the corresponding ground truth labels. We use the cross-entropy loss function to compute losses as the targets for both the tasks are categorical. For joint optimization, we minimize a weighted combination of both losses as shown in (1). We use a hyper-parameter λ to balance/control the relative learning of the tasks. We show experiments with various values of λ.
where CE c and CE p are the cross-entropy loss functions for truecasing and punctuation respectively. We use truecasing and punctuation models trained without multi-tasking as our baselines. We obtain baseline models for truecasing and punctuation by setting λ to one and zero respectively.
To achieve truecasing and punctuation, we assign labels for every word in the input document and force the model to make a prediction for every word. However, a word could be divided into several sub-word tokens as the BERT models use sub-word tokens at the input. We compute loss only for the first sub-word token and do not consider the losses of other sub-word tokens. We do not discard other sub-word tokens from training as they could be helpful to disambiguate the first sub-word token from other similar sub-word tokens. In our experiments, we found that computing loss for the first or last sub-token token did not matter. Loss for an input document is computed by taking a summation of each word loss which further used to calculate the batch loss.
The efficacy of fine-tuned models for downstream tasks could depend on the training data used for pre-training. The training data used for the BERT base model include BooksCorpus [22] and English Wikipedia. Considering one of the target tasks in this paper, truecasing, it is interesting to see how the casing during pre-training affects the target tasks performance. In this work, we compare BERT models trained with and without casing when adapted for truecasing and punctuation tasks.

Exploration of model performance on conversational text in low-resource scenarios
Given the effort required, minimizing the amount of annotated conversational data needed to achieve strong model performance is desirable in practical applications. For that reason, we investigate the performance on various subsets of the Fisher dataset, most of which can be considered low resource scenarios. Fig. 2 shows the pipeline we follow in our experiments to achieve truecasing and punctuation prediction in low-resource scenarios. We explore knowledge transfer from models trained on written text resources to conversational transcripts. For this purpose, we use truecasing and punctuation prediction on Gutenberg dataset as an intermediate task. That is, we first fine-tune the BERT-uncased model on the Gutenberg dataset to learn truecasing and punctuation patterns in the dataset then again fine-tune on small amounts of Fisher training data. We compare it with a model obtained without any intermediate task i.e., fine-tuning BERT-uncased model directly on Fisher dataset. We hypothesize that intermediate task optimization boosts performance on the Fisher dataset when only a few documents of Fisher are available. Ideally, a small number of conversations would be sufficient to bridge the gap between the two domains.  The Gutenberg corpus is a collection of over 50k fictional, multilingual books [7]. It contains copyright-free books including biographies, fantasy, art, fiction, poetry and philosophy. The dataset has rich and high-quality punctuation annotation that was double-checked by the editor's team. However, due to the license restrictions, most of the books are dated between 1800-1930 making the language possibly outdated, especially when considering truecasing prediction. In this work, we use 75%, 5% and 25% splits for model training, development and testing.

Data preparation for truecasing and punctuation
We assign one truecasing and one punctuation label for every word. For truecasing, we consider three labels, namely all upper casing (AUC), lower casing (LC) and upper casing (UC). AUC is assigned for words with all upper case characters; LC is assigned for words with all lower case characters; UC is assigned for words starting with an upper case character and also for words with mixed casing. For punctuation, we assign a punctuation label out of 8 possible labels for each word. The list of punctuation considered in this work are Blank, Full-stop (.), Comma (,), Question mark (?), Exclamation mark (!), Semicolon (;), Double-dash (-), Ellipsis (...). In cases where punctuation appears after a word, we assign that word with that punctuation otherwise we assign Blank. Note that this setup diverges from previous works on the Fisher corpus [15][16][17] -we included more punctuation classes specifically to investigate how well the models deal with less frequent punctuation marks that exist in both domains.
Class count and their percentage in the corresponding dataset are shown in Table 1. The distribution of the token count for punctuation and truecasing classes are highly skewed. As expected, LC class frequency is much higher than AUC and UC in both datasets. Truecasing classes distribution between the datasets is more similar compared to punctuation classes distribution. Blank dominates in both the datasets followed by Comma and FullStop. One noticeable difference between the datasets is the use of DoubleDash: it occurs for 6.04% of the tokens in Fisher whereas only for 0.45% of the tokens in the Gutenberg dataset. We observed that DoubleDash is majorly used at the change of turns in the Fisher conversations. Question mark usage is more frequent in Fisher compared to the Gutenberg dataset which could be expected -questions are the main tool of eliciting information from the other parties in conversations. Ellipsis, although rare, is significantly more frequent in conversations, reflecting a larger portion of unfinished utterances. Finally, semicolons are practically non-existent in conversation transcripts.

RESULTS
In this section, we present the results of our experiments on truecasing and punctuation. First, we show the impact of casing and punctuation in the input document on each other's task followed by a multi-task model to improve the performance of both tasks. Then, we explore the model performance on conversational text when only limited data is available. Fig. 3 presents the statistics of word casing for the next word after punctuation for Fisher and Gutenberg datasets. As is the case with some of the basic rules in the English language, we can observe that the most frequent casing after the full stop, question mark and exclamation is the upper casing. Similarly, lowercased words follow the majority of the time after comma, semicolon and Blank. We can observe that the most frequent casing after the double dash is different in both datasets: a lower casing (57.41%) in Fisher and an upper casing (65.38%) in Gutenberg. Calculating Macro F1 with the most frequent casing, we see 54.85% for Fisher and 52.7% for the Gutenberg dataset. In this case, we almost never predict the AUC class and miss many UC words which are likely the most important classes for applications like named entity recognition. Table 2 shows the impact of truecasing and punctuation on each other's prediction. To evaluate the effect of punctuation on truecasing prediction, we experiment with and without including punctuation in the input documents. Similarly, to quantify the effect of casing on punctuation prediction, we experiment with and without including casing in the input documents. We fine-tune the BERT-cased model for this experiment as the tokenization process removes word casing in the BERT-uncased model. We can observe that the truecasing task performance is dropped by 2.9% and 4.87% absolute on Gutenberg and Fisher respectively without punctuation in the  Fig. 3. Results of this experiment along with Fig. 3 strongly suggest that truecasing and punctuation are correlated. Hence, we expect their joint modelling improves the performance of both tasks.

Experiments with multi-tasking
Tables 3 and 4 present the results of multi-task models when fine-tuned from BERT-uncased and BERT-cased pre-trained models respectively along with corresponding baselines. The multi-task model is trained with the objective function shown in (1) where setting λ to 0 provides a baseline for truecasing and 1 for punctuation task. We show experiments with λ = 0.1, 0.25, 0.5, 0.75, 0.9 for multi-task model to find the optimum values for λ. For truecasing task, multi-tasking provides improvements with λ = 0.9, 0.75, 0.5 and sometimes even when λ is less than 0.5. We can observe improved performance for punctuation task too with λ = 0.1 in all cases except when BERT-uncased is fine-tuned for Gutenberg. It supports our hypothesis that joint modelling helps both truecasing and punctuation tasks. Comparing BERT-cased (Table 4) and BERT-uncased (Table 3) pre-trained models, the latter suited better for truecasing task. The BERT-cased model was trained on the cased text and the BERT-uncased model on uncased text. For the punctuation task, the BERT-uncased model provided better results on both Gutenberg and Fisher compared to BERTcased model except for the Fisher baseline. From these results, we can conclude that pre-training with uncased text is more suitable for both truecasing and punctuation tasks compared to training with cased text.
We can observe that punctuation task performance ranges are quite different for Fisher (around 47%) and Gutenberg dataset (around 75%). We suspect two reasons for the dif-  ference: 1) Gutenberg is a collection of books, usually well proof-read, we can expect consistent punctuation compared to the punctuation in conversations and 2) BERT models are pre-trained on written text. Note that it is a mere comparison demonstrating the difficulty of recognizing punctuation in written and conversational text but not to be taken in a strict sense as the corresponding models are trained and tested on different data.

Experiments on Fisher in low-resource scenarios
We evaluate the re-usability of truecasing and punctuation models trained on written text (Gutenberg) for conversational text (Fisher). For this purpose, we fine-tune the BERTuncased model on the Gutenberg dataset with λ equal to 0.5 as an intermediate task (refer Fig. 2). Then, we finetune again on a limited number of transcriptions from Fisher and compare it with the BERT-uncased model fine-tuned on Fisher directly. Table 5 shows the results on the Fisher dataset when only a limited number of annotated conversational documents are available. Each row, for example 2 nd row can be interpreted as -we achieve 72.76% truecasing performance  Table 6 shows class-wise f1-scores for punctuation corresponding to the Macro F1 scores presented in Table 5. We can observe 91.81%, 46.93% and 27.21% for Blank, Comma and Question mark when the intermediate task model (trained with Gutenberg ) is evaluated on Fisher documents. Significant improvements to the punctuation marks FullStop, Question and DoubleDash have come at lower training data sizes (50-250 documents) and then a steady improvement with more training documents. We can observe that fine-tuning the Gutenberg dataset model provided better results compared to fine-tuning the BERT-uncased model in most cases. For Question mark, fine-tuning from the BERT-uncased model yielded only 12.12% f1-score even with 250 Fisher documents whereas fine-tuning a written text model provided 30.79% with just 50 documents suggesting that the usage of the Question mark is similar in both Gutenberg and Fisher datasets. A recall of 45.32% for FullStop (f1-score of 42.93% in Table 6) implies that reasonable sentence segmentation can be achieved with 50 spoken documents for training.
The most frequently used punctuation marks Blank, Comma, FullStop and Question are recognized decently with just 50 Fisher documents when the Gutenberg dataset model is fine-tuned. From a practical point of view, it implies that most of the spoken documents can be enriched with punctuation even with very little annotated conversational data. Other punctuation marks, Ellipsis, Exclamation and Semi-Colon are not recognized even with the larger set of training documents. We suspect their inconsistent usage and less frequency in training data could have contributed to their poor performance.

CONCLUSIONS AND FUTURE WORK
In this paper, we presented a multi-tasking model for truecasing and punctuation to take advantage of the correlations between them. Our experiments have shown that multi-task modelling improves the performance of both tasks. Experiments with fine-tuning BERT-based pre-trained models revealed that pre-training with casing provides inferior results compared to pre-training with uncased text on truecasing and punctuation prediction. Through knowledge transfer from written text to conversational text models, we found that as little as 50 annotated spoken documents can provide decent performance for most frequently used punctuation marks such as Comma, FullStop, and Question mark. And, adding more data provided larger improvements up until training set size 500 documents and smaller improvements after that.
In future work, we plan to investigate the transfer of knowledge from other datasets that are similar to conversational text to improve truecasing and punctuation task performance on conversational text. We also look to explore crosslingual knowledge transfer to minimize annotation costs in low-resource languages.