A Study on Accessing Linguistic Information in Pre-Trained Language Models by Using Prompts (2023)

Abstract: We study whether linguistic information in pre-trained multilingual language models can be accessed by human language: So far, there is no easy method to directly obtain linguistic information and gain insights into the linguistic principles encoded in such models. We use the technique of prompting and formulate linguistic tasks to test the LM’s access to explicit grammatical principles and study how effective this method is at providing access to linguistic features. Our experiments on German, Icelandic and Spanish show that some linguistic properties can in fact be accessed through prompting, whereas others are harder to capture.

## introduction with pre-trained language models becoming ever larger and continuously better at solving a variety of tasks, there is a growing interest in understanding how they represent knowledge, particularly linguistic information. while pre-trained language models carry out impressive feats of linguistic generalization, there is no simple way to directly access the linguistic knowledge encoded in them. easy access to linguistic information, and -in a more long-term vision -the ability to modify parts of the linguistic representation, would be a powerful instrument. for instance, a linguist without expert knowledge in machine learning could use linguistic querying to gain insights into a model's linguistic properties and to pinpoint problems with its linguistic representation. similarly, for a language learner, interacting with a language model in the form of textual instructions could provide interesting new learning opportunities. in this work, we focus on accessing linguistic information through natural language queries. we propose using prompting as a simple way to test the lm's access to explicit grammar principles. we study on german, icelandic and spanish how effective prompting is for querying linguistic informa-tion, and what type of information can be obtained, versus what is out of reach for the method. there has been limited work on prompting english models for english linguistic information, while our focus is on other languages. we are also interested in prompting in one language and obtaining linguistic information in another, such as a language learner or linguist might do. this will be also of interest for working with linguistic information in low-resource languages, both when looking only at a low-resource language individually, or in combination with another (high-resource) language, such as the pair of spanish and mayan languages. in our experiments, we formulate question prompts for different linguistic tasks, for example to "ask" for the grammatical case of a word in a given context sentence. the tasks are designed as classification tasks, where the labels correspond to linguistic properties (e.g., singular, plural for the feature number). our experiments address standard morphological features, such as tense, case, number, gender, but also syntactic information, such as the distinction between subject and object, and the distinction between active and passive voice. our findings indicate that features corresponding to concrete and locally defined properties like number of nouns are easier to obtain than more abstract features like the grammatical case of nouns. they also support the hypothesis that abstract grammatical terms (e.g., dative case) are not always wellsuited for formulating prompts or answers as they are not necessarily well-covered in the grammatical sense in general-language data. we present this analysis as some first steps in evaluating how relevant linguistic properties of a language can be made accessible through human language queries. possible next steps can be to focus on low-resource languages, as well as identifying problems in representing linguistic information and strategies to solve such problems. ## related work there is strong interest in how linguistic information is represented in pre-trained lms: @xcite is a well-known probing study transferring linear probing techniques to contextual models. @xcite study multilabel probing to assess the morphosyntactic representations of multilingual word embeddings. @xcite investigate whether the same subsets of neurons encode universal morpho-syntactic information and therefore enable cross-lingual generalization. @xcite study how bert encodes grammatical number in a number-agreement task. @xcite by contrast focus on structural probes to find out whether bert and similar models encode parse trees according to their theory. @xcite provide a challenge set using acceptability contrasts to evaluate the morphosyntactic and semantic knowledge of lms, testing for a range of phenomena. @xcite is a probing study of english roberta across time. the authors test a range of probes and downstream tasks at dozens of checkpoints. @xcite argue that prompting acts as a model-free probe, thus eliminating the distinction between what the model knows and what the probe learns. they compare prompting to linear regression and mlp probing. @xcite also probe gpt-3 using prompts, specifically on tense and number features. @xcite prompt gpt models to append pos tags to each word in a given sentence. however, most of the above works focus on english-only settings. we work with multilingual models and for the presented experiments, use mixed-language prompts, where the question is formulated in english to obtain information about a another language, in which the target word and the context sentence are given. ## methodology: pet we apply pattern-exploiting training (pet: schick and schütze (2021a), schick and schütze (2021b), @xcite ). 1 pet is a semisupervised training procedure which combines textual instructions with fine-tuning based on labeled examples. its key idea is providing textual instructions for the task (prompts) as cloze-style phrases for a masked language model @xcite , where the mask token is then substituted by one of 1 we use the implementation in https://github.com/ timoschick/pet sentence given as context: label: die regelung ist stark umstritten. sg the regulation is highly controversial. gloss sentence. " regelung " is _mask_ . sentence. the number of " regelung " is _mask_ . sentence. number of " regelung " : _mask_ . verbalizer mapping: @xmath0, @xmath1 a set of possible output tokens. a verbalizer maps the class labels to natural-language outputs, and completions are sampled exclusively from this set of output options. one example from the original paper is predicting restaurant ratings given reviews, where the verbalizer maps "terrible" to a 1-starrating and "great" to 5 stars. in our experiments, the output classes typically correspond to the values of grammatical features to be predicted, for example plural, singular for the feature number. typically, the training of pet relies on several patterns, namely variations of the prompts. in a first step, individual models are fine-tuned on a small training set for each pattern. the resulting models are then used to label a larger set of unlabeled examples with soft labels as training data for a final classifier with a regular sequence classification head, similar to knowledge distillation. pet has two advantages for our experiments: it is designed to work well with small sets of training data, which might be useful for tasks with only few annotated data available; and it combines several prompt formulations for the same task, which alleviates the problem of finding the "right" prompt. ## prompt design and data to train pet, we need linguistically annotated data to derive prompts and the respective labels which are then mapped to natural-language words as candidates for the mask position in the lm. prompts and labels for the formulation of prompts, we first present a sentence as context, and then variations of statements like "the feature of w is _mask_", with w being a word in the sentence. we mix the language of the prompt (english) and the languages of the queried feature (german, icelandic, spanish). even though multilingual language models are robust to mixed-language input, there are some considerations: the terminology used in the prompts, namely grammatical features and their values, might be insufficiently covered in the underlying training data of the language model in general, and potentially even more so for english labels referring to another language's grammar. for some terms, there might be a domain shift (grammatical gender vs. gender in the societal sense). with the success of the method hinging on the coverage of the relevant terminology (in english or otherwise), we also experiment with substituting grammatical terms with general-language discriminative context of the respective target languages (cf. "variants" in section 5.1). data our datasets foot_0 stem from the universal dependency treebank @xcite , which contains high-quality data for many languages. our main focus is on german, which has a complex nominal morphology with many syncretic forms making it often impossible to derive a word's features without context. in addition, we choose icelandic, which has a similar feature distribution (three gender values, four case values), but is a lower-resource language compared to german. on the other hand, spanish has a comparatively simple nominal morphology (two gender values, no noun cases), but a more complex verbal morphology, largely without syncretic forms. for the experiments on morphological features, we select the target words (nouns and finite verbs) such that that each combination of lemma and features occurs only once, and that there is no overlap between test and training data. the target word can only occur once in the sentence, and we restrict sentence length to 50 words. the different feature values do not always oc ## experiments for the experiments on morphological features, we use finite verbs and nouns as words w. while the nominal features number, gender and case are also present for adjectives and determiners, we chose to only look at the phrase head for the sake of simplicity, assuming that if the feature of the head is known, it is also known for the rest of the phrase. in our tables, we give the accuracy of the final distilled model for bert-base-multilingual-cased, and xlm-roberta-large @xcite , conneau et al. ( 2020 )). we report the average over two runs with different seeds, 3 using the default parameters of pet. for each set of experiments in this section, we use 100 training examples, 1000 (de/es) or 500 (is) examples to be labeled for the final model (cf. ## conclusion we presented a study on using prompting to access linguistic information in pre-trained lms for german, icelandic and spanish. we evaluated predicting a set of morphological features, as well as a broader variety of linguistic tasks. our results indicate that some features are indeed accessible, whereas the approach fails for features such as the complex and abstract grammatical case. using natural language to obtain linguistic information is potentially useful in many scenarios; querying for a variety of non-standard linguistic tasks might be an especially interesting use case, in particular for low-resource languages.