{'fraction_non_alphanumeric': 0.033082888996606885, 'fraction_numerical': 0.006362094037809016, 'mean_word_length': 5.12430426716141, 'pattern_counts': {'":': 0, '<': 1, '<?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}}
Evaluating context-invariance in unsupervised speech representations

Unsupervised speech representations have taken off, with benchmarks (SUPERB, ZeroSpeech) demonstrating major progress on semi-supervised speech recognition, speech synthesis, and speech-only language modelling. Inspiration comes from the promise of ``discovering the phonemes'' of a language or a similar low-bitrate encoding. However, one of the critical properties of phoneme transcriptions is context-invariance: the phonetic context of a speech sound can have massive influence on the way it is pronounced, while the text remains stable. This is what allows tokens of the same word to have the same transcriptions -- key to language understanding. Current benchmarks do not measure context-invariance. We develop a new version of the ZeroSpeech ABX benchmark that measures context-invariance, and apply it to recent self-supervised representations. We demonstrate that the context-independence of representations is predictive of the stability of word-level representations. We suggest research concentrate on improving context-independence of self-supervised and unsupervised representations.


INTRODUCTION
Self-supervised and unsupervised learning of speech representations have their roots in attempts to discover phoneor phoneme-like units, or similarly linguistically relevant representations, either in the interest of working with lowerresource languages or of cognitive modelling [1]. These representations have already seen practical success. The use of recent models such as CPC [2], Wav2vec 2.0 [3], HuBERT [4], or WavLM [5] for pre-training has been shown to greatly reduce the amount of labelled speech data needed to build a recognizer. But the promise of self-supervised speech representations is much greater. In principle, if we were truly able to discover low-bitrate representations for a language similar to phonemes or letters, higher-level tasks could be done directly from speech. Currently, however, the performance of self-supervised representations on even mid-level tasks such as word segmentation lags behind that of text, to say nothing of higher-level tasks such as language modelling [6].
What makes text or phoneme representations so fundamental in language processing is their dual nature, linking signifier (form) and signified (content), which otherwise bear no meaningful relation. A language might use any string of sounds to refer to canines, but the transcription of the English word dog tells the reader both what was pronounced and (if they know English) what was meant. Text and phonemes sift through all the linguistically insignificant variations in the signal and pinpoint those necessary for understanding.
Critically, phonemes change pronunciation substantially depending on their surrounding phoneme context due to coarticulation and allophony. Yet, current evaluations of intrinsic quality for unsupervised and self-supervised representations do not directly measure whether representations remain the same when the surrounding context changes. In this paper, we propose a novel evaluation based on the ABX phone error rate which directly assesses context-invariance.
In Experiment 1, we evaluate systems submitted to the 2021 Zero Resource Speech Challenge and demonstrate that effects of context are the most significant source of instability for current models-much greater than lack of invariance to speaker or resistance to less-clean speech. In Experiment 2, we demonstrate that this result is not an artefact of the models' warping of time. Finally, in Experiment 3, we demonstrate that context-invariance predicts representations' ability to consistently encode tokens of the same word type.

BACKGROUND
In addition to benchmarking on downstream tasks (SU-PERB: [7]), a large part of self-supervised speech representation evaluation consists of measures of intrinsic quality. Linguistically-motivated measures of intrisic quality have been proposed as part of the ZeroSpeech challenge [6]. Notably, the ABX phone discriminability score [8] attempts to measure, for a model trained on a given language, how distinctly the model represents the linguistically relevant sound (phoneme) categories.
The task is inspired by human psychophysics and measures discriminability between two sound categories. ∆, the ABX-discriminability of sound category A from category B, is defined as the probability that tokens a, x ∈ A are further apart than token b ∈ B is from x, according to a dissimilarity function d.
where 1 is the indicator function and |A| (|B|) the number of tokens in category A (B). The discriminability score is symmetrized by averaging ∆(A, B) and ∆(B, A).
Evaluating a model for a language begins with the model's encoding for a test corpus. Using the gold alignment, the evaluation splits the encoding into one sequence of frames for each token of each category. To calculate d for two tokens, dynamic time warping is used to realign them, and frame-level dissimilarities are averaged along the alignment path. Submissions to the ZeroSpeech challenge specify whether to use angular dissimilarity (arccos of the normalized dot product of the frame embeddings) or KL divergence to calculate d; see [6]. Scores are calculated as error rates. Scores for all pairs of categories are averaged to obtain an overall ABX error rate.
Importantly, however, in the ZeroSpeech ABX phone evaluation, each token is a triphone: to compare two phoneme categories (for example, /l/ and /r/) we use triphones where only the middle phoneme varies in the critical phone contrastlike /flu/-/fru/. The immediate context is thus included in the token, and is constant across a, b, and x. This was originally to avoid relying on very short, one-phone sequences and to avoid demanding that the representations meet the (presumably difficult) requirement of context-independence. The strong scores on the within-context version of the new benchmark, which uses one-phone sequences, demonstrate that the first problem is not an issue with current systems.
We base our novel evaluation on the ABX-LS benchmark [6] for English, itself based on LibriSpeech [9]. This benchmark additionally measures speaker invariance by comparing a within-speaker score, in which all of the phone triplets belong to the same speaker (e.g., a = flu T1 , b = fru T1 , x = flu T1 ) to an across-speaker score, in which a and b are the same speaker and x a different one (e.g., a = flu T1 , b = fru T1 , x = flu T2 ). It also compares the clean speech part of the LibriSpeech corpus to the other part. The ABX phone discriminability measure has been demonstrated to correlate with the performance of speech representations on a number of other quality measures and downstream tasks [6].
Another intrinsic quality measure sometimes applied to speech representations is the mean average precision, or MAP on spoken word embeddings [10,11]. MAP assesses how well spoken word embeddings separate different word types using a method similar (but not equivalent) to the ABX score. All pairs of word tokens in the test corpus are compared using a dissimilarity; then, a precision-recall curve for same/different word type classification is calculated across different dissimilarity threshholds. The MAP score is the area under the precision-recall curve. A simple (albeit lossy) way of constructing spoken word embeddings from a selfsupervised representation is to simply do mean pooling (time average), which allows for an approximate assessment of the quality of the representation for encoding a spoken lexicon.
We propose an ABX-discriminability measure of how well learned speech representations track context-independent phonemes. The most closely related work is [12], which applies a closely-related ABX-discriminability score to MFCC representations to measure how much different classes of phonemes are acoustically influenced by context, rather than to evaluate learned representations. Additionally, a number of papers have used phoneme classification as an evaluation for the quality of learned speech representations [2,13]. Correct phoneme classification for segments extracted from a representation requires context-independent representations. However, unlike the present evaluation, these classification analyses do not measure context-independence by itself: doing so requires calculating a context-dependent performance baseline for the same system.

METHODS
Starting from the ABX-LS benchmark, we develop a novel variant to evaluate context-invariance. 1 Rather than extracting tokens of triphones, we extract tokens of phonemes in isolation. This permits us to construct two different conditions. In the within-context condition, the immediately preceding and following phoneme are always held constant across a, b, and x. In the without-context condition, there are no constraints on the surrounding context; in general, it varies. We evaluate all of the self-supervised speech representations submitted to the 2021 ZeroSpeech benchmark [6], which appear on the current leaderboard. HuBERT is an implementation of [4] described in [14]; CPC is an implementation of [2] as described in [15]. This model was the baseline model for the benchmark, and many submitted systems re-used these baseline features unchanged (taking different approaches to the language modelling component of the benchmark, which does not interest us here). We exclude these submissions. S-CPC [16] attempts to push CPC to learn representations of phone segments that are stable across time; P&H VG is a "visually grounded" model [17] that trains end-to-end on a masked language modelling objective using spoken picture captions; ZR VG and ZR VG-CPC [18] are also trained with picture captions, based on [19], with the first using MFCCs as input and the second using CPC representations; ResDaveNet, also visually-grounded, is an implementation of [20]; finally CPC+Seg discovers boundaries on CPC units and applies pooling.

EXPERIMENT 1
Results of applying the novel evaluation to these models are shown in Table 1 and Figure 1. The separation between the -and the -pointed lines in Figure 1 shows the gap between within-speaker and across-speaker to vary between a modest penalty and a doubling of the error rate, depending on the model and the evaluation condition. The gap between solid and dashed lines compares the clean speech and other subsets, and is of a similar magnitude. However, the gap between the darler purple within-context and the lighter orange without-context scores is much greater, tripling or even quadrupling the error rate. This lack of context-invariance disproportionately affects high-performing models such as Hu-BERT and CPC, suggesting these models' loss encourages them to perform particularly well within context.

EXPERIMENT 2
While Experiment 1 suggests the representations evaluated are not context-invariant, an alternate explanation is that their time-scales are incompatible with that of the ABX evaluation. The ABX evaluation extracts representations from timestamps based on gold-standard alignments. Not all model loss functions penalize time warping, and so some representations may preserve the order of phonemes without preserving their exact position in the sequence. If the evaluation is using the "wrong" time-alignment for the representation, this would have a disproportionate impact on the without-context condition. Because the context around the phoneme is different, small disagreements in alignment between the representation and the gold transcription will be more important.
To assess this, we change the way we deal with time in the ABX calculation. Instead of aligning a and x (b and x) using DTW and averaging dissimilarities for the aligned frames, we perform pooling to obtain a single representation for a, for b, and for x, weighted using a Hamming window, which peaks at the centre of the sequence; d is angular dissimilarity or KL divergence. This is less forgiving than DTW, which can compensate for minor errors in the alignment. If the alignment is problematic, ABX scores should worsen when the Hamming window is used. We perform the experiment on the within-speaker, clean condition. To validate the experiment, we evaluate manipulated gold phoneme transcriptions (onehot, by frame) wherein phoneme boundaries were sometimes (p = 0.5) shifted right by 4, 6, or 8 frames. We expect scores to be non-zero for the manipulated representations.
Results are shown in Table 2. Frame-shifting the gold transcription indeed makes scores worse and without-context evaluation is more impacted; pooling amplifies the effect. 2 The spectrogram does not appear to be perfectly "aligned," nor do the self-supervised representations (Hamming pooling makes the scores worse): information about phone identity is not all concentrated at the centre of the gold segment. How-  ever, unlike for the manipulated alignments, the difference (<14% of the original error rate) falls far short of explaining the penalty incurred in the without-context condition. We conclude that alignment is at most a small part of the reason for systems' issues with context-invariance.

EXPERIMENT 3
For tasks such as unsupervised discovery of a lexicon of word types [21], it is critical to accurately represent the phonemic content of word tokens without colouring by adjacent context. Following [10], we use the mean average precision (MAP) as defined above to assess the discriminability of word embeddings based on the self-supervised speech representations above. We construct embeddings for each word token in the gold annotation using mean pooling. While this method is necessarily lossy, it is sufficient to demonstrate the importance of context-invariance for speech word embeddings. For the self-supervised systems, within-and withoutcontext ABX scores are strongly correlated. Thus, to evaluate the role of context-independence by itself, we artificially dissociate the two. We do so by applying a square filter to each of the representations: we replace each frame by the surrounding time average in a window of 3, 5, or 7 frames, pulling parts of the surrounding context into the representation of a given frame. This will have an outsized impact on the without-context condition: for within-context, the surrounding phones are identical for A, B, and X, while, for without-context, filtering will introduce substantial noise. We assess whether these degraded representations have lower MAP scores. We perform the experiment on the clean subset again, this time examining the across-speaker ABX as it is more relevant to the representational coherence of words (within-speaker results are qualitatively similar).
Results are shown in Table 3. Across systems, the withincontext ABX scores worsen slightly as the filter width in-  creases (by around 0.1 percentage points in general), while the without-context ABX scores show much greater degradation (e.g., HuBERT gets about 50% worse in the withincondition at width 7, CPC around 12% worse, while in the without-context condition they degrade by 90% and 28% respectively). The exception is width 3, which has little impact. In general, we see a relation between the without-context ABX and MAP scores. Across systems, we note much unexplained variance-the MAP scores are not entirely predictable from the ABX scores-consistent with the result of [11]. Within systems, however, we see a notable degradation in the MAP scores as the (without-context) ABX scores decline. This suggests that further improving the contextindependence of these units would lead to more consistent representations of word types, thus more useful for tasks that require accurate representation of individual word tokens.

SUMMARY OF CONTRIBUTIONS
This paper introduces a new version of the ZeroSpeech ABX-LS evaluation measure for self-supervised representations in English. While the previous benchmark measures whether representations are consistent with the phonemic contrasts of the language only within specific phonetic contexts, the new benchmark measures the context-independence of representations. We demonstrate that current systems show poor context independence: the typical case is a 300-400% drop in performance on a context-independent (versus a context-specific) phoneme discrimination task, far larger than the gap seen for speaker-independence or for clean versus less-clean speech. We propose that future research address this gap.