Investigating grammatical abstraction in language models using few-shot learning of novel noun gender (2024)

Abstract: Humans can learn a new word and infer its grammatical properties from very few examples. They have an abstract notion of linguistic properties like grammatical gender and agreement rules that can be applied to novel syntactic contexts and words. Drawing inspiration from psycholinguistics, we conduct a noun learning experiment to assess whether an LSTM and a decoder-only transformer can achieve human-like abstraction of grammatical gender in French. Language models were tasked with learning the gender of a novel noun embedding from a few examples in one grammatical agreement context and predicting agreement in another, unseen context. We find that both language models effectively generalise novel noun gender from one to two learning examples and apply the learnt gender across agreement contexts, albeit with a bias for the masculine gender category. Importantly, the few-shot updates were only applied to the embedding layers, demonstrating that models encode sufficient gender information within the word-embedding space. While the generalisation behaviour of models suggests that they represent grammatical gender as an abstract category, like humans, further work is needed to explore the details of how exactly this is implemented. For a comparative perspective with human behaviour, we conducted an analogous one-shot novel noun gender learning experiment, which revealed that native French speakers, like language models, also exhibited a masculine gender bias and are not excellent one-shot learners either.

## introduction deep learning models of language have been shown to acquire non-trivial grammatical knowledge and match human levels of performance on natural language processing tasks. for example, lstm @xcite and transformer models @xcite trained on next-word prediction are able to parse complex syntactic structures that are thought to be essential to natural language @xcite . language models have been shown to perform long-distance grammatical number @xcite and gender agreement @xcite , even with intervening phrases @xcite @xcite and in grammatical but meaningless sentences @xcite . the human language ability is not limited to employing grammatical rules in familiar cases. language acquisition studies have shown that humans are able to easily generalise and apply grammatical knowledge in relation to novel words from very few examples. for example, @xcite showed that young children can learn a non-word such as 'wug sg ' and easily infer its plural form 'wugs pl ' @xcite , and similarly 'kich sg ' to 'kiches pl @xcite . numerous studies have also shown that children as young as three years old learn grammatical gender categories for new words using determinernoun pairs @xcite . older children can spontaneously infer the appropriate morpho-syntactic feminine and masculine forms for french novel nouns in previously unencountered contexts @xcite . this demonstrates that humans have the ability to form linguistic abstractions that extend beyond having specific grammatical rules for individual words. to address whether small-scale lstms and transformer language models can achieve humanlike grammatical abstractions, we design a wordlearning experiment, inspired by psycholinguistics studies of language acquisition and generalisation. we introduce a novel noun into the embedding layer of our trained language model and investigate both few-shot learning abilities and the acquisition of abstract grammatical gender in french. critically, the few-shot updates are isolated to the em-bedding layers. we assess the ability of language models to learn the gender category of a novel noun from a few examples in one grammatical agreement context, and then apply this knowledge in another agreement context during testing. this would indicate that models represent gender as an abstract category that is not tied to occurrences of specific syntactic contexts, and this information can be represented within the word-embedding space. across four experimental conditions, both models successfully acquired and generalised the gender of novel nouns after learning only one to two examples of gender agreement. models effectively predicted noun-adjective and noun-participle agreement after encountering examples of the novel nouns with gender-marked articles 'le m ' or 'la f '. however, we observed a gender bias: the gender prediction accuracy for feminine novel nouns remained consistently lower than the accuracy for masculine nouns, even after ten learning examples. the models also effectively generalised gender from noun-adjective and noun-participle agreement to a rarer context, noun-relative-pronoun agreement, exhibiting less gender bias and appropriately predicting 'lequel m ' or 'laquelle f ' agreement with nouns. our findings suggest that (1) language models appear to represent grammatical gender as an abstract property, and (2) this information is encoded in the representation layers of language models and can be changed with few-shot updates. further analysis into the patterns of weight change in the embedding layers during few-shot learning of gender revealed that both models primarily update the representation of the novel noun. only the transformer, however, also updates the embeddings of the masculine determiner 'le m ' even when it was not present in the learning examples. this suggests that models may learn gender by updating related gender-marked words rather than assigning it as a core property of nouns like humans do. finally, for a comparative perspective with human behaviour on an analogous task, we conducted a one-shot novel noun gender learning experiment with 25 first-language french speakers. we show that humans also exhibited a masculine gender bias in a sentence completion task that required inferring the gender of novel nouns. while models and humans may rely on different mechanisms to abstract grammatical gender and perform syntactic generalisations, gender bias is evident in both. this commonality suggests that the bias could either be an inherent characteristic of french noun gender distribution or an efficient strategy for language and grammatical gender acquisition. ## background our study employs a word-learning paradigm to examine how language models generalise grammatical categories to novel nouns across syntactic contexts. we question whether they truly abstract grammatical properties beyond previous occurrences and specific syntactic contexts, or if they can only employ these features in familiar, repeated patterns of lexical units. since we are interested in quantifying human-like generalisability in models, we focus on smaller models, training corpora, and vocabularies. below, we briefly outline related work and discuss our choice of language models and gender agreement tasks used in our few-shot word-learning paradigm. ## human behavioural experiment although language models are vastly different from humans with regards to inductive biases and working memory constraints, comparing their performance and mechanisms to humans is useful for exploring possible strategies for grammatical representation in each system, see @xcite for a review. in order to compare model performance on the generalisation task to human behaviour, we conducted a one-shot word learning experiment online, with 25 native french speakers. participants learnt 16 novel nouns with a gender-ambiguous endings and 8 novel nouns with typical gender endings, shown in ## discussion the primary goal of this work is to investigate whether language models develop an abstract grammatical gender category. to address this, we demonstrated that lstms and transformers are proficient in acquiring the gender of a novel noun from one to two learning examples, and apply gender agreement in a previously unencountered context. both language models seem to acquire abstract gender properties of novel nouns from fewshot learning. while our transformer exhibited marginally lower accuracies in the baseline gender agreement tasks, its few-shot learning capabilities and patterns are similar to the lstm. more specifically, few-shot updates to the embedding layers are enough for acquiring novel noun gender and generalising this to unseen agreement contexts. this aligns with how humans are believed to learn words, which only requires an incremental update to the knowledge of nouns during acquisition while maintaining an abstract understanding of grammatical gender and agreement rules. it appears that language models have a similar capacity to generalise grammatical gender to include new words and that important grammatical category information may be encoded in the word embedding space learned by models. this is consistent with @xcite , who demonstrate that noun, adjective, adverb and verb categories emerge in the model's representational space, and @xcite , who showed using principle component analysis that noun, adjective, verb and article embeddings encode gender and number properties. although models seem to succeed on tasks that require having a representation of grammatical gender that generalises across syntactic agreement contexts and extends to novel nouns, the specific implementation details are not immediately clear. we conducted additional analysis on weight changes and learning dynamics as an initial step to under-stand the underlying mechanisms of how gender is represented and generalised. for both models, fewshot learning primarily results in updates to embeddings of the novel noun and words that appear in the learning constructions. the transformer model additionally updates the representations of the gendermarked article, specifically 'le m '. this suggests that the trained language model may not represent gender as critically hosted by nouns, and gender agreement as triggered by nouns alone. it may be that the transformer has developed a representational space governed by co-occurrence patterns, consisting of the word-embeddings, that groups nouns, verbs, adjectives and determiners such as 'le m '/'la f ' by gender. on the other hand, humans typically assign gender to nouns in a deterministic manner; where agreement is determined by the noun's gender and relies less on heuristics; this does not seem to be the case for our models, especially the transformer. an interesting parallel can be drawn between this mechanism in transformers and a child's acquisition of gender. driven by their affinity to learn chunks of words, children begin to acquire noun gender through determiner-noun pairs, treating them as single units @xcite ; transformers seem to employ a similar strategy to encode word co-occurrence patterns. however, our weight change analysis alone does not provide conclusive evidence for exactly how the model represents gender within its embedding layer, and whether it is truly abstract. future work may investigate this by conducting additional fewshot learning experiments with weight updates restricted to the novel noun embeddings and other parts of the embedding space; this would reveal whether abstract grammatical gender is localised to a sub-space or to a single noun embedding in the representational space. similarly, running the experiments with the embedding layer frozen while updating the rest of the model and comparing this with updating the whole model could reveal how important the representational layers are for grammatical gender and agreement. further mechanistic explorations are required to understand the extent to which models form abstract grammatical gender. for example, @xcite used causal mediation analysis to uncover sparse mechanisms whereby individual units in the lstm tracked grammatical number and gender @xcite . @xcite used similar methods to isolate gender bias to a group of attention heads in transformers. future work could utilize similar methods to characterise how gender information from word embeddings is processed through the model to drive downstream agreement performance; this could reveal how influential and abstract the representation of grammatical properties is. language models exhibit masculine gender bias across four gender agreement contexts and during few-shot learning of novel noun gender. on the baseline gender agreement task, transformers and lstms, to a lesser extent, exhibited a masculine gender bias. the bias could not have been due to frequency as the 20 feminine and 20 masculine nouns had similar frequencies in the corpus. few-shot learning behaviour also showed this bias, where feminine gender prediction falls short of masculine prediction accuracies even after training with ten learning examples. one explanation for gender bias might be that it is an inherent property of french or the corpus. it may be because there are more masculine words @xcite . moreover, in colloquial french, past-participles and adjectives are produced in their default singular-masculine forms, omitting the plural/feminine inflections @xcite , thus not obeying the agreement rule; it is likely that the corpus reflects this pattern. the observation of gender bias in language models is consistent with studies by @xcite and @xcite demonstrating that models encode a preferential or 'default' category for grammatical properties: default singular number category and default masculine gender category. humans are not perfect one-shot learners of novel noun gender either. given the numerous studies demonstrating acquisition of grammatical gender in 3-4 year old children @xcite @xcite , it is surprising that adult french speakers did not achieve high accuracies in inferring novel noun genders in our experiment. they also exhibited a masculine gender bias, like the language models. it is important to consider the experimental constraints that make it difficult to observe people's true generalisation abilities. firstly, it is established that adult second language learners struggle to attain native-like proficiency in gender assignment @xcite . the poor performance we observe could be because children are better learners of grammatical gender than adults @xcite . secondly, it is established that children rely on morphological cues in noun endings for gender acquisition, while semantic cues play a more minor role @xcite . in our experiment, despite novel nouns having typically neutral endings, participants may still assign noun gender based on their intuitive familiarity with gender-typical endings, rather than adhering to the gender in the learning example. lastly, the feminine inflections, especially in adjectives and past-participles, only result in subtle changes in pronunciation, reinforcing the tendency to default to the masculine gender category. ## conclusion characterising the ability of models to generalise linguistic knowledge in a human-like way remains a challenge, and the potential impacts are twofold. in terms of the mechanistic interpretability of models, such studies lead to a better understanding of how specific linguistic generalisations are achieved. our work shows that grammatical gender information for nouns is sufficiently encoded in word embeddings and can be used to perform agreement across syntactic contexts; however, it is unclear whether gender information is primarily hosted by the embeddings, and the specific noun, or whether other mechanisms in the model are more critical. it may be that models may not employ a genuine abstraction of grammatical gender in order to generalise gender agreement tasks to new nouns, and may employ different mechanisms for each agreement context. further work is required to understand the mechanisms underlying our behavioural result, showing successful generalisation. from a psycholinguistic perspective, we find some parallels between model and human biases, and learning strategies. we find asymmetric model performance across gender categories and syntactic agreement contexts, which points to a default reasoning strategy in models @xcite . the same behavioural pattern was also found in our human word learning experiment, supporting the default reasoning hypothesis for gender acquisition in french @xcite . more broadly, examining how humans and models employ grammatical properties in novel contexts offers possible strategies and testable hypotheses for abstract linguistic representation and generalisation in both systems.