Docsity
Trusted Seller

Complete Notes Computational Linguistics 2 - Passarotti Linguistic Computing Unicatt, Sbobinature di Linguistica

Toggle sidebar
bg1
COMPUTATIONAL LINGUISTICS 2
26.02.2024
WORD SENSE DISAMBIGUATION
The second semester is basically about dealing with semantics. In Computational linguistics we have
enemies and friends and very often they overlap. Our enemy in this case (that of Word Sense
Disambiguation) is polysemy; so I decided to start this second semester talking about one big issue in
CL that is Word Sense Disambiguation (WSD). We will see what exactly WSD is and, as you can see
from the name, it deals with disambiguating the sense of a word in a context. This is due to the fact that
words in several cases are polysemous (they have many different meanings) but, usually, in a specific
context they have a specific meaning.
While it’s very simple, or apparently simple, for all of us, to understand which the right sense of a word is
given the context, this is not an easy issue for a machine. Maybe you remember that during the first
week of CL1 I showed you a document from IBM for a conference held in Pisa in the 70s. In that
document, IBM said “oh, the next step is dealing with semantics, it’s dealing with the meaning of words”.
After almost 50 years we are finally there. Today we have tools that work very very well on word sense
disambiguation and the LLMs revolution that happened during the last two years provided us with
surprising results: if you work with ChatGPT and ask to it to disambiguate a polysemous word in context
and, of course, you provide ChatGPT with a context, most likely the result will be right. As a
computational linguist I’m really surprised that it works so well. Here we just bought the ChatGPT
advanced version which makes use of the LLMs 4 (the free version is 3.5) and it works much better
giving you the opportunity to provide ChatGPT also with a file or a number of files to process. For
instance, Passarotti provided ChatGPT with a number of scientific papers and asked ChatGPT to
provide a summary of all those papers: it was great. Passarotti also tested ChatGPT4 with a number of
polysemous words in English and in Italian and it works really well; then he tested it also on Latin and it
works so and so. If you remember the pyramid (data, information, knowledge and wisdom) the
generation of Passarotti dealt with information (à computers had only data and structured data,
therefore information: a treebank is information), our generation deals with knowledge (à today
computers have knowledge and a LLM provides knowledge). Wisdom is not yet reached by machines,
but now we have machines with knowledge and this knowledge is very very much about semantics.
Passarotti started to take this course ten years ago and semantics was just at the end, in the last month.
Today it’s completely the second part of the course: all we have done so far during Computational
Linguistics 1, basically did not really deal with semantics, it dealt with lexicon, of course semantically
reached lexical resources (à a valency lexicon is a semantically reached lexical resource, but it’s a
resource, not processing), we dealt with morphology and we dealt with syntax. All towards semantics.>
>
The first problem is that the human language is ambiguous, so that many words can be interpreted in
multiple ways depending on the context in which they occur. This seems to be very trivial but here there
are in this first sentence some words that are key words we will deal with during these first two weeks.
So “a word can be interpreted in multiple ways” means that not only a word can be polysemous, but that
you can have different levels of granularity in semantics. What are the meanings of a word? Those
provided by dictionary. But taking four dictionaries for the same word you will have different level of
granularity for the meanings of that word. So many words can be interpreted and annotated
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Anteprima parziale del testo

Scarica Complete Notes Computational Linguistics 2 - Passarotti Linguistic Computing Unicatt e più Sbobinature in PDF di Linguistica solo su Docsity!

COMPUTATIONAL LINGUISTICS 2

WORD SENSE DISAMBIGUATION

The second semester is basically about dealing with semantics. In Computational linguistics we have enemies and friends and very often they overlap. Our enemy in this case (that of Word Sense Disambiguation) is polysemy; so I decided to start this second semester talking about one big issue in CL that is Word Sense Disambiguation (WSD). We will see what exactly WSD is and, as you can see from the name, it deals with disambiguating the sense of a word in a context. This is due to the fact that words in several cases are polysemous (they have many different meanings) but, usually, in a specific context they have a specific meaning. While it’s very simple, or apparently simple, for all of us, to understand which the right sense of a word is given the context, this is not an easy issue for a machine. Maybe you remember that during the first week of CL1 I showed you a document from IBM for a conference held in Pisa in the 70s. In that document, IBM said “oh, the next step is dealing with semantics, it’s dealing with the meaning of words”. After almost 50 years we are finally there. Today we have tools that work very very well on word sense disambiguation and the LLMs revolution that happened during the last two years provided us with surprising results: if you work with ChatGPT and ask to it to disambiguate a polysemous word in context and, of course, you provide ChatGPT with a context, most likely the result will be right. As a computational linguist I’m really surprised that it works so well. Here we just bought the ChatGPT advanced version which makes use of the LLMs 4 (the free version is 3.5) and it works much better giving you the opportunity to provide ChatGPT also with a file or a number of files to process. For instance, Passarotti provided ChatGPT with a number of scientific papers and asked ChatGPT to provide a summary of all those papers: it was great. Passarotti also tested ChatGPT4 with a number of polysemous words in English and in Italian and it works really well; then he tested it also on Latin and it works so and so. If you remember the pyramid (data, information, knowledge and wisdom) the generation of Passarotti dealt with information (à computers had only data and structured data, therefore information: a treebank is information), our generation deals with knowledge (à today computers have knowledge and a LLM provides knowledge). Wisdom is not yet reached by machines, but now we have machines with knowledge and this knowledge is very very much about semantics. Passarotti started to take this course ten years ago and semantics was just at the end, in the last month. Today it’s completely the second part of the course: all we have done so far during Computational Linguistics 1, basically did not really deal with semantics, it dealt with lexicon, of course semantically reached lexical resources (à a valency lexicon is a semantically reached lexical resource, but it’s a resource, not processing), we dealt with morphology and we dealt with syntax. All towards semantics. The first problem is that the human language is ambiguous, so that many words can be interpreted in multiple ways depending on the context in which they occur. This seems to be very trivial but here there are in this first sentence some words that are key words we will deal with during these first two weeks. So “a word can be interpreted in multiple ways” means that not only a word can be polysemous, but that you can have different levels of granularity in semantics. What are the meanings of a word? Those provided by dictionary. But taking four dictionaries for the same word you will have different level of granularity for the meanings of that word. So many words can be interpreted and annotated

semantically in different ways, using different tag sets, using different levels of granularity of semantic disambiguation depending on the context in which they occur. So we are working on tokens and not on types (à because of the context. Types don’t occur in context, tokens do). This word, “context”, is a very very hot word because everything will deal with context. Everything will deal with words that surround the word you must disambiguate. The different possible uses that you can make of the context where words occur make the different models (the different methods) to perform word sense disambiguation. Context is everything. Maybe you have heard that a large language model like ChatGPT is a generative- predictive model. This means that generates words one after the other and it predicts them. What are the basis for the prediction? The context! Given a sequence of words ChatGPT, LLMs (Bert, Gemini etc.), predicts what is the most probable word that comes after; so you need a context, otherwise you cannot predict nothing. This is the reason why the accuracy rate of LLMs is important. We will talk about LLMs so often because out there, when you go in companies today, everybody wants to use LLMs. In most cases people know nothing about LLMs (it’s our job!) But everybody wants to use them because they seem to provide great results and, indeed, they provide great results. This wants to be the added value that we want to give you. We want to give the expertise, the knowledge, the competence about something that everybody out there is starting to work on. So, what is surprising of LLMs, generative- predictive LLMs, is that all that they do is to predict what is the most probable word after a given context. That’s it. It’s incredible and it works very well. So, if in this class I say “oh, I don’t remember when Robert Plant (the singer of Led Zeppelin) was born, I will search on…” you’ll complete the sentence with the word “Google” automatically. The generation of Passarotti would say “encyclopedia” (taking a lot of time!). Today “Google”! Okay, you are predictive, we are predictive. Of course, we are cognitively very very more powerful machines in terms of wisdom than computers, but we do not have the computational power to process billions of words. They have it. So, it’s the collaboration, the synergy between your cognitive power and the computational power of machines that hopefully will make the world wiser. So WSD is the ability to identify the meaning of words in context in a computational manner. Computers perform automatically the disambiguation of the senses of a word in a context and in other words it’s the ability to computationally determine which sense of a word is activated by its use in a particular context. WSD has been a fundamental task of Machine Translation (MT) already in the late 1940s. If you remember, computational linguistics basically started as a sub-field of something, as Computer science of linguistics, with a very specific aim which was the MT. Then the ALPAC report came (1966) and it says “no, you cannot deal with nothing, you’re not able to do MT”. Why? Because we were not able to perform WSD. Every time you perform MT you don’t only have to translate the syntactic structure of a sentence in a language to that sentence in another language, you must understand the meaning. This is the reason why translating poetry is so difficult, and maybe it’s not really a task. So the acknowledged hardness of WSD was one of the main obstacles to the development of MT in 1960s. Basically the ALPAC report said “go back and try to understand what is a word, what are the morphological features of a word, what is the syntax of a sentence and then come to semantics” and now we are there. When Passarotti started to study CL they were not there yet. It’s not really a different world but we are one step forward. In one sense this is a very good news; at least for us who performs everyday CL because this means that throughout these decades, we did something. We moved from just processing one single word to processing senses of words.

you deal with domain-specific text the range of variability of the meanings of a word tend to restrict (à imagine that you are dealing with the terminological domain of transportations, and you have the word “coach”. It is more probable that in the specific context it is used to indicate a part of a train). LLMs can deal with text of unrestricted nature, you can ask basically everything to ChatGPT. You can fine-tune a LLM. What does it mean? It means to specify the competence of the LLM. LLM comes with some core knowledge that is a shared knowledge and a generic knowledge. If you want to have a LLM specific for the medical area you fine-tune the LLM with data from the medical area (à like us with common knowledge of primary and secondary schools, fine-tuned then with a domain specific academic course). They are fine-tuned in order to perform domain-specific tasks. This is where we will discover that linguistic resources come to place: because if you want to build a specific LLM able to perform the syntactic analysis of Italian what do you use to fine-tune a LLM? Treebanks, UDs. The set of target words to disambiguate. This is big, macroscopic, distinction in WSD. On one side you have one target word and on the other side “all-words” settings. This means that WSD can be applied either to all the words of a text or just to some specific targeted words. WSD heavily relies on knowledge. The skeletal procedure of any WSD system can be summarized as follows: given a set of words, basically a sentence, a sequence of words, some technique is applied which makes use of one or more sources of knowledge to associate the most appropriate senses with words in context. You must know something in order to disambiguate words, the senses of words. It is much different from the chomskian approach (e.g. “syntax is one thing and semantic is another thing à “colorless green ideas sleep furiously”. This sentence is perfectly formed under a syntactic point of view but all the semantic associations among these words are wrong. If you state that syntax is strongly separated by semantics, you say that you can even not have the semantic knowledge and you don’t need it to say if a sentence is well-formed or not. This sentence is okay from a syntactic point of view but if we talk about semantics, like in this case, you need some knowledge). The point is making use of one or more sources of knowledge: whenever you perform WSD, you make use of sources, which is your experience. A machine is not a human being, so where does the knowledge to perform WSD come from? Knowledge sources can vary considerably: we can range from corpora to more structured resources such as machine-readable dictionaries and semantic networks (à like WordNet which is a very good source of knowledge. Why? Because words are associated by synonymy, antonymy, hypernymy and so on. It’s very powerful). The manual creation of knowledge resources is an expensive and time-consuming effort. Building a Wordnet is a big work and this issue of cost expensive and time- consuming effort is an issue because we realized that building resources takes time and needs money and you will never build so big resources that you can train a machine in supervised method. This the reason why today LLMs were built just on raw data (à texts not enhanced with any linguistic annotations. So you can wonder why we spent six months talking about annotation and the answer is that it’s still useful). We realized that this knowledge can be acquired both from resources (e.g. a wordnet, a dictionary) and/or from just raw text. Consider that a ten-year-old child is exposed to around, on average, one hundred million words, while ChatGPT was trained, as for English, on thirty billion words. Nobody here will never be exposed to all that training data and out of there a LLMs is able to build knowledge. So, we have some knowledge that is stored in resources and is made by us together with NLP tools and raw data. It’s the sum of the two that makes the knowledge. This is a fundamental problem which pervades overall CL and particularly the field of WSD and is called knowledge acquisition bottleneck. We must make the machine able to acquire knowledge. You must give knowledge to the machine in order to perform WSD. This knowledge is stored both on linguistic resources and in raw data. Impact. Text disambiguation can potentially provide a major breakthrough in the treatment of large- scale amounts of data, thus constituting a fundamental contribution to the realization of the so-called Semantic Web, “an extension of the current Web in which information is given well-defined meaning, better enabling computers and people to work in cooperation” [Berners-Lee et al. 2001]. In semantic web words, resources, objects : things that are published there, are related to each other by some semantic property. See the Linguistic Linked Open Data that we will see at the end of the course and

that is the skeleton of the linguistics semantic web (there is also a course about it in the second year). Together with LLMs it is one of the mainstreams of CL today. In the semantic web, what is needed to know now, words are related with some semantics predicate. For instance, imagine that Marco Passarotti is a word on the web and you are all single objects on the web: there is a relation! For instance the relation is “professor of” that goes from Passarotti to us and not viceversa and it’s semantically defined. What is important to know is that processing semantics helps to treat automatically large-scale amount of data (textual data, linguistic data affected by polysemy) with the big aim of machine translation but not only. WSD can be viewed as a classification task. PoS tagging is a classification task (à given a word you must classify it under a specific label, like “noun” for example. Basically, it’s a multi-value classification task, which means that given a word in input there are many values that you can classify the word accordingly. What are the values? The labels like noun, verb, preposition, conjunction and so on). Classification tasks are divided in two big classes: multi-value classification task and dual-classification task. The first is the task when you have to assign a class to an object according to more than two values (and the PoS are more than two), while a dual or binary classification task is the task of assigning a class to an object among two possible classes, which usually is “true”/“false” (à imagine that you have an input text and you have to assign to that text a label that tell if that text is about linguistics or not). So a classification task is a task that assigns a class to an input object. The classes can be two or more than two. Here word senses are the classes that we have to deal with. Obviously it’s much more difficult. Try to think about to all word senses that you have in mind: you cannot do it! Instead, if I ask you what the value for the morphological features of number in Italian are you immedialy say “singular and plural”: they are a finite number! So words sense are our classes and they are so many. An automatic classification method (you can use different methods) is used to assign each occurrence of a word (each token) to one or more classes. It can be possible that more classes are assigned for those contexts where an ambiguous word is used ambiguously (remember the example “la vecchia porta la sbarra”: more classes!). So, an automatic classification method is used to assign each occurrence of a word to one or more classes, that is to say to one or more senses. Based from the evidence from the context and from external knowledge sources. Okay, now we have the task in our hands: we know that the task is to classify a word according to his word sense using two things (that are two allies): the context and the knowledge. In order to allow the other person talking with you to disambiguate the meaning of word you are using you must provide him or her with some context and you must assume that he or she has some knowledge (don’t be sadistic like Passarotti with her girlfriend: don’t remove the context from a message just to see what will happen next). How does it work here? We must provide machines with the capability to perform what we perform but in a computational manner and on a very large amounts of words. The knowledge is in resources and in training data. Also, PoS and NER, name entity resolution (à the classification of target textual items into predefined categories. Like for instance proper name of countries. Name entity are basically proper names with different categories: people, countries, institutions, rock band etc.) are classification task,

class words) of a text. This task usually is not performed in a supervised manner because you have to deal with all words. This task required a large-coverage system (LLMs are a wide coverage systems, the wider ones). Consequently, purely supervised systems can potentially suffer from the problem of data sparseness, as it is unlikely that a training set of adequately sizes is available which covers full lexicon of the language of interest. While in the targeted WSD task we deal with a small and limited set of words to disambiguate and we can build an annotated corpus where all the occurrences of these words are labeled with their specific sense in that specific context, we cannot do the same when we perform an all-words WSD task, because you never know what is there. This is the reason why to perform the all-words WSD task, usually you perform an unsupervised approach (ChatGPT is a very huge unsupervised model). LLMs are not supervised, they can be supervised later in fine-tuning but in itself they are models typically built by unsupervised approach (don’t confuse them!). We will see now the four pillars of WSD. The question is about having or not an inventory of senses and to select the senses. What is a sense? Imagine, we do not agree on the set of PoS; imagine about senses (so big, so subjective)! 1) Selection of Word Senses. A word sense is a commonly accepted meaning of a word. What does it mean to be commonly accepted? It’s vague. Determining the sense inventory of a word is a key problem in WSD. A sense inventory partitions the range of meaning of a word into its senses and what senses cannot easily discretized, that is, reduced to a finite discrete set of entries each encoding one distinct meaning: language is inherently subject to change and interpretation. This is one problem. Our aim is to build a sense inventory. A sense inventory is nothing but a set of senses assigned to the words of the lexicon of a language (it’s very difficult). What is “discretized”? It means that can be strongly divided one from the other. On the other sense you’ve continuous which means that we can have overlaps. Also in PoS we have overlaps but PoS in itself are discrete: at the end you assign a PoS, only one, but originally it is not discrete. Senses, at the same time, are not clearly separated one from the other. Very often you have a grey area. And this is the reason why this is so difficult. On the other hands we continuously have new senses while a lot of existing ones die. This is different from PoS where subjects, nouns etc. never die (ex. “consistente” in Italian means “solid” but from a few years it acquired the sense of “coerente/coherent” from the English word “consistent”. The English meaning is attached to the corresponding word in Italian, even if it usually means another thing. Another example is “le classi di ginnastica”. In Italian “classi” doesn’t mean “lessons”, also this meaning comes from English). Language is something that is dynamic, that changes. So it’s very difficult to define a sense inventory because in five years it would be different. There is nothing immutable. In order to enable an objective evaluation and comparison of WSD systems, senses must be enumerated in a sense inventory (maybe this is too strong: it’s bettere to use “usually”). That is the so- called enumerative approach (it is one of the possible approaches to the problem of selection of word senses). All traditional paper-based and machine-readable dictionaries adopt the enumerative approach (because if you open a dictionary you find the senses in ordered and enumerated using some criteria). So the typical and traditional approach to the managing of senses is the enumerative approach. Another different approach is the generative approach by Pustejovsky (a Passarotti friend of

dance) in which related senses are generated from rules which capture regularities in the creation of senses. The justification is that it’s not possible to constrain the ever-changing expressivity of a word (of a language) within a predetermined set of senses. So you don’t have an inventory of senses but you have a scomposition of the meaning into components and it’s the sum of these components that give raise to the meaning. The meaning is generated according to the components (it’s like Lego). On one side you have the enumerative approach with sense inventory and on the other side you have generative approach with components that make the sense. James Pustejovsky is a pupil of Chomsky and this is why the approach take the name “generative”. He was able to build this system to scan the meaning of a sentence in its semantic component and to make it all work together using rules (it’s very nice but like many generative approaches it doesn’t work really well. It’s very difficult to make it real in a computational environment). In the generative approach senses are expressed in terms of qualia roles that is semantic features which structured the basic knowledge about an entity. The features stem from Aristotle’s basic elements for describing the meaning of lexical items. 28.02. Recap of previous lecture So, yesterday we were here. So, where we are now processed to talking about word sense disambiguation, the task to assign the correct sense of words in their context. Yesterday we mentioned the really important, relevant, core role played by context. Together with context another important role is played by knowledge. These are the two kind of information that you and the machine make you of whenever you have, or the machine has, to disambiguate the word sense in context. Yesterday we have mentioned my friend James Pustejovsky, a pupil of Chomsky, who is still alive, 96/ years old. He has just written this article on large language model, on Chat GPT on the New York Times, some weeks ago. If you search in Google “Chomsky, large language model” you will find it and I strongly disagree with that paper, because it is strongly generativist, but I’m not totally against generatism at all, I wrote a volume about “generativism” ( joking ), these mistakes that you do when you are young. Well, read it, it will be an interesting reading! Starting the real lecture In the generative approach, senses are expressed in terms of qualia roles, that is, semantic features which structure the basic knowledge about an entity. It’s like that you divide the meaning of something into two components. The features stem from Aristotle’s basic elements for describing the meaning of lexical items. Ok, now we will go on the figure of the next slide, which is about the word “knife” (coltello) and there we will see that there are 4 (+1) qualia roles are provided.  The first kind of qualia role is formal (a superordinate of knife), so what kind of thing is a knife? It is an instrument. We will see that this kind of information resemble, more or less, that information that you can find in a lexical resource. What is the lexical resource where you can find the superordinate of knife, its hyperonym? It’s WordNet!  Second, constitutive (parts of a knife)  Third, telic (the purpose of a knife)  Fourth, agentive (who uses a knife)  And the instantiation of a combination of roles allows for the creation of a sense. So the full sense of the word “knife” in the generative lexicon is generated by the instantiation of the combination of these roles, by combining by joining these roles. So formally this is represented like this:

The most fortunate case is when a word is monosemous. A word is monosemous when it can convey only one meaning. There are several words in the lexicon that convey only one meaning. Many of these words are terminological words. Example about his work at Gemelli’s Hospital I was at Gemelli’s hospital, last week, reading the reports about patients and I go through a lot of monosemeous words like “biopsia” or “emocromo”. So, you see that terminological words, very often are monosemeous. We have a course here about Terminological Resources because they are an important component in NLP. I was at Gemelli because they want to perform NLP tasks on their reports of patients, and they provided us with more than 350.000 reports of the last 3 years (imagine how many million of reports they have) and reports are written using words and language. So, doctors asked us to cluster together all the report for those patients that show some common proprieties among these 350.000. You can read them one by one and say “this is here, and this is here” or you perform some NLP process that reads the text of the reports and cluster reports in different areas, in order to provide doctors with that empirical evidence, information, knowledge, that is stored in many reports that simply doctors cannot manually handle. And the experience, I’ve learnt, is so much important in medical world. Experience is there, is stored in those reports that are written and are a manifestation of language. This just to tells you how different the application of computational linguistics can be today. When I was there and I’ve studied classics, I have never thought that I would have gone to Rome, to Gemelli hospital, talking about the processing of data of the reports of doctors. That’s great! Computational Linguistics is everywhere. Back to lecture On the other side we have our enemy, polysemous words. A word is polysemous if it can convey more meanings. For instance, race (NOUN) as a competition, as a contest of speed, as a taxonomic group, etc. (Example: la gara, la razza, in English is “race”, a polysemous word). Senses of a word which can convey (usually etymologically) unrelated meanings are homonymous. For instance, race (NOUN) as a contest vs. race (NOUN) as a taxonomic group. It looks like the same word but it’s not etymologically related. But they end up being homonyms: they are written “r-a-c-e” but they come from different etymology. We have a perfect example in Italian, which is the word “accettare”, which means “to accept” and “to cut with an ax”. They end up completely homonymous, they inflect in the same way, but they are two homonymous words unrelated etymologically. It’s difficult for a machine to disambiguate which of the two “accettare” or the two “race” is the right one. But if I tell you “Ho accettato il voto all’esame” (I’ve accepted the mark at the exam) you immediately understand that is the “accettare” with the meaning “to accept” and indeed I translate “I accepted”. I did not say “I cut the exam”. So, what do you need? You need the context. Second element in WSD are external knowledge sources. First of all, we need to know an inventory of senses. So, we need to know our enemy, how big the polysemous word are in this text and how many are or can be the polysemous words. This gives you the size of the problem you have to deal with. Imagine to have a text made of one hundreds millions words and you know that just one of this polysemous and it has only two senses. So, the size of your problem is small, just performing manually. But, now you have a text of one hundred millions words and 90 thousand words are polysemous and they have a range of senses from 2 to 22. It’s much more difficult. So, first of all, know about your senses: polysemy, monosemy or homonymy. We need knowledge. You can collect knowledge from different resources. Knowledge sources (sense inventories) provide data essential to associate senses with words. We have to kinds of knowledge sources: structured and unstructured resources. Let’s have a look on structured resources:

  1. First of all, Thesauri, which provide information about relationships between words, like synonymy and antonymy. The most widely used thesaurus in the field of WSD is Roget’s International Thesaurus [1911]. The latest edition of the thesaurus contains 250,000-word entries. So basically, Thesaurus by Roget is a kind of WordNet ante litteram, where words are related to each other by this kind of relations like synonym or antonym.
  2. Then machine-readable dictionaries. Of course, when you have to find a sense you open the dictionary, it’s trivial. Well, machine readable dictionaries have become a popular source of knowledge for natural language processing since the 1980s, when the first dictionaries were made available in electronic format: e.g., the Longman Dictionary of Contemporary English. Since the ’80 it’s true, I perfectly remember, when I was a student, I have the CD-ROM that for you are prehistorical object, and we have to go to the “Sala di consultazione” and we have to ask for a CD-ROM, waiting in a long queue and there was just one computer with CD-ROM and look inside the CD-ROM look a lot of time but it seems to us to be at the NASA. Great, look: it’s in digital form. There were the first years of digitalisation phase, everything that was digital seems to be wonderful. That’s the reason why these years were named “Digital Humanities” that you know, I totally hate, because the real advance is “Computational Humanities”, not digital because digital is just the format. As a student, I used to use that CD-ROM in the same way I used to use the paper dictionary, there was no added method with methodology. It was just faster or cooler but not a methodological advance. So, machine readable dictionaries were very important for the community because for the first time you have some digital resource that you could use for the computational process of data. A resource that was collecting the senses of a word. So, if you open a dictionary and if you open a lexical entity in a dictionary, you find there the name of the entity (house) some morphological information (like, in Italian for instance, the gender or if you open the Latin dictionary the genitive), some etymological information and then the senses come. Very often the senses are organised in senses and sub-senses and the senses are numerated (1,2,1.2,2.1) and senses are usually reported as translation, if it is a bilingual dictionary, definition, if it is a monolingual dictionary and then you have quotation, so example of use of the word. I remember when I was at secondary school and I did my ancient Greek translation I was always look for the sentence in ancient Greek dictionaries (Fatemi cercare la frase fatta, with translation). You see how much different a lexicography entry is. What do you need here for a lexicography entry? You need the definition; you need the senses. If a lexicography entry in a machine readable dictionary are not structured it is very difficult for you to pick up the sense of a word, this is the reason why we are talking about structured resources, because if you just read the lexicographic entries you will find everything morphological, etymological information, examples and then the senses, so you need some structure. During the last decades digital dictionaries were structured, usually using a mark-up language like XML, there is a particular language of the mark-up language which is vocabulary of the mark-up language that is called TEI (Text Encoding Initiative) that encodes, for instance, the part of the dictionary, that explicitly mark up (mark-up is like annotation) that this is the name of the lemma, this is the morphological information, this is an etymology, this is an example… and this is the sense. So, if you have a digital dictionary and in its XML version the information of the different parts of the definition are marked-up you are very lucky, because you can focus on the values of the elements of TIE XML that are about senses. These elements (à we have seen some elements when we talked about in-line-annotation vs distributed/stand-off-annotation) are those names of containers between the angle brackets (<>). Those are called elements and in TIE XML there are some elements called senses and inside that there are the senses. So, if you go on the purses digital library, that is a big digital library of classic digital texts, or if you search for any other digital dictionary and you can download the XML behind that look at that, you will see that each lexicographic elements is organised like that. That’s because we are talking about structured resources, because the dictionary in itself, just the PDF OCR of a dictionary is not so much helpful, because there is too much information, and you have to select only the sense. If you open a dictionary, you immediately understand what is the sense and what is the quotation but it’s not clear for the stupid machines.
  3. Ontologies, which are specifications of conceptualizations of specific domains of interest, usually including a taxonomy and a set of semantic relations. In this respect, WordNet can be considered an ontology. A specification of conceptualisation of specific domain of interests. Do

and Wikipedia, among others. BabelNet is structured as a semantic network where nodes are multilingual synsets, i.e., groups of synonyms lexicalized in several languages, and edges are semantic relations between them. Again, the overall structure of BabelNet is very similar to the one in Word§Net: we have synsets and relations between synsets. The added value of BabelNet is that is highly multilingual and very much fine grade. There is a lot of information there, about valency, images that are able to disambiguate for visual computational automatic analysis the content of an image (we are talking about NLP but there is a lot of work in automatic processing and clustering of images. Today you can show the image of a cat to the computer and the computer will assign the annotation tag “cat”) Enjoy BabelNet, is very big and vety powerful. So, here you have knowledge, and the knowledge is stored here and it is structured. On the other side you will have sources of knowledge that are unstructured.

  1. First of all Corpora. I don’t have to define what a corpus is, you know about it. Both:  Raw corpora (unlabelled, made just of raw data, that is to say the words tokenised) e.g., WSJ corpus, Brown.  Sense-Annotated Corpora: the most important is SemCor [Miller et al. 1993], a subset of the Brown whose content words have been manually annotated with part-of-speech tags, lemmas, and word senses from the WordNet inventor. It is the largest and most used sense-tagged corpus, which includes 352 texts tagged with around 234,000 sense annotations. MultiSemCor [Pianta et al. 2002] is an English-Italian parallel corpus annotated with senses from the English and Italian versions of WordNet, it is SemCore about many other languages and it is the same as parallele corpus annotated with senses from the English and Italian versions of WordNet. What’s the problem here? The problem with sense annotated corpora is that they are very tome consuming it takes a lot to build a sense annotated corpus. Look here “manually annotated with senses”, which means that every time you get through a word which is assigned more than one synset in WordNet, you have to choose what is the right sysnset of this specific word in that context. This is the work of sense tagging. It is very difficult even fo a human being, because sometimes the semantic differences between the colosses of the synsets of WordNet are very very fine grade and you do not always understand which is the right sysnet to assign to that word in that specific context. Try this at home, use the multi-WordNet: take a piece of a text, a paper in a journal, an article in a newspaper… try to assign what is the right sense of the word using the word synsets. Sometimes is exciting because when you have to deal with poetry, it raises a lot of questions and you must really understand poetry, but if you deal with poetry it means that you have a lot of time to stay just on that text. Building such sense annotated corpora takes a lot of time and at the end you come out with SemCor, which is very big, but it’s not so big anymore: SemCor was started to build in 1993, today it’s some million words big but today we deal with billion words. So, you can use SemCor in supervised approach (you know what supervised approach is, it means that you train some statistical model using a corpus annotated with tags that you want that a machine assign to another corpus, I hope that the difference supervised and unsupervised approach is clear in that classroom). On the other side you can use SemCor as a Gold standard, so you have the output of a machine and you want to evaluate the quality of that machine, of that model and you compare the output of some computational train model with the senses in SemCor.
  2. Another evaluating system are Collocation resources, which register the tendency for words to occur regularly with others: examples include the Word Sketch Engine and the British National Corpus collocations. So, you can try Sketch Engine and you will see that there are these collocations. Basically, they say that two words tend to co-occur, one with the other. Collocations are very important and interesting resources in our words. Have you ever seen the paper collocations? You know what I’m talking about? I’m talking about collocation. Collocation are key words in context, nothing but data. For instance, if you

go in the Sala di Consultazione here, and you search for the collocations of the poem of Guido Gozzano and you search for the word “giovinezza”, you will see that all the occurrences of giovinezza preceded and followed buy the context. Five words before, five words after, that’s collocations. Already Thomas Aquinas asked to write for him collocations of Aristotels text. So, they are very important tools that are used in order to understand the language of a text. Second generation of collocations was anymore based on papers, but it was on CD-ROMs, online services, and you can decide the window size: (example) give me all the collocations of the word “table” preceded and followed by 10 words/5 words/50 words. That’s it. Collocations resources are the result of the abstraction of the data of collocations and they say “on tendency, the word “table” collocates with…”, single occurrences of “table” and its collocations on the left and on the right you can extract some information, some knowledge actually. The knowledge is that “table” tends to collocate with some words. I want that this is crystal clear because this is important to understand the next point, which is sense embeddings. Collocations are co-occurrence of a word with other words in context. I’m pretty sure that the word “professor” tends to collocate more frequently with the word “university” that with the word “racket”, or with the word “concert”. It’s clear, you know about it, knowledge, you have this knowledge, the machine doesn’t have this knowledge, but it can acquire this knowledge out of data, out of text. Why did you know that “professor” occurs more often with “university” than with “rackets”? Because you have experience and your experience is an experience of linguistic life: you know the words of your language, or maybe of other languages too. The machine does not have this knowledge but we can show to the machine a huge amount of text and out of it the machine learns that more often, more frequently “professor” co-occurs” with -2university than with “rackets”. This is the very base of embeddings. I will dedicate quite a lot of time to embeddings, because embeddings are the fundamental resources for generative pretrained transformers that you know about it GPTs and of artificial intelligence.

  1. Sense embeddings are spaced vectors (imagine a piece of space made of vectors). Each word is assigned a vector, two words are assigned closer vectors if they show similar behaviour in the training corpus. So that means that “university” and “professor” are very close because they seem to behave similarly in the training corpus, that is to say “they tend to share the same company”: you know the word by the company it keeps. Sense embeddings forces where words are assigned as many vectors in a vector space as are its senses. So “race” will be assigned 3 vectors (one for competition, one for contest and one for “razza”, because they have different companies) Race will be closer to words like “white”, “human being”, woman, country if we talk about the race “razza”. If we talk about competition, they will be similar to “cars” or “monza”… all this stuff. You, see? Different companies, different senses. Today artificial intelligence is based on this, that’s based on the act that words are similar to each other according to the fact that they show similar behaviour in the training corpus. You see the reason why today the richest man or woman in the word is not anymore, the one who own oil but the owners of data. We are living the war of data and data is the new oil, that’s it. You cannot build Chat GPT without this oil, without data. In order to build Chat GPT you need two things: data, for training, and computational power. Even in if in this university I have data, I could not build Chat GPT because I don’t have computational power. Chat GPT can build 2 thousand cloud computing settings one together, at the same time, with my computer, which is a pretty good computer, it would have taken 300 years to train the model behind Chat GPT. I don’t have money for them. At the research centre we are buying new more powerful machines and Chat GPT doesn’t work there, and Chat GPT doesn’t work there, I can only use it, like you, as a user. I’m just using LLaMa or Mistral (LLaMa and Mistral are two others large language models that are free to use but it is a very powerful computer the one that we build with structured LLaMa and here the

these levels tokenization, lemmatizazion, PoS tagging, chunking and syntactic parsing, one mode-one task. Two years ago, LLM were published, and we suddenly moved to one mode – several tasks approach. This means that we just have a LLM that can perform basically everything: you can perform tokenization, lemmatizazion, PoS tagging, chunking and syntactic parsing, named entity resolution, sentiment analysis, emotion analysis, text summarisation, machine translation… just by prompting. Prompting is telling the machine to do something. You tell the machine “Translate into English this Italian sentence”, today I was writing to a PhD student of mine, a paper, and I said “Your scientific writing is not so good. Ok let’s take your piece of paper and prompt Chat GPT to take this English text and translate it into another register, that is scientific writing. It was a wonderful scientific writing. The same model, one model, can be used for many tasks. From one model – one task to one mode- several tasks. It was a huge revolution. As a result, WSD (is performed) using discrete levels, while LLM are continuous models. They are not discrete; they do not separate lemmatisation to syntactic parsing. Is it cognitive plausible? Do we work like this? Do we separate syntax, lemmatisation and PoS while processing language? Probably not, we put it all together but please ask to a psycho linguist, not to a computational linguist. As a result of the pre-processing phase of the portion of a text, for instance, a sentence, paragraph, or a full document… every word can be represented as a vector of features, so you assign to a word a number of features. For instance, its lemma, its part of speech, its morphological features... this is vector of features. This is a result of features. Each word can be represented as a vector of features of different kinds or in more structured ways, for example, as a tree or a graph of the relations between words. For instance, in a treebank. The representation of a word in context is the main support, together with additional knowledge resources, for allowing automatic methods to choose the appropriate sense from a reference inventory. So now we have the inventory of senses, we have some knowledge based on some structured and unstructured resources and we have some features, some proprieties assigned to a word. Each word come with information about its context, knowledge about its context and features like its lemma, its PoS, its syntax. Why do we do this? We must provide these stupid machines with information so that machines can automatically perform Word disambiguation of senses. For each word we have to give to the machine information about its lemma, its PoS, its morphological features and all these stuffs… because we are still thinking about the discrete NLP approach. Every time you disambiguate a sense you do not think about a vector of features of all the words of the sentence, I hope you don’t do it! Sometimes I do it but I’m totally perverted by computational linguistics, I hope that you do not become like this. But, anyway, you do not do it, you put it all together in a continuous manner. But with a discrete approach to NLP, you have to provide machines with information about each word, context, knowledge and vector of features. So, what are these features? There are different set of features to represent the context:

  • local features, which represent the local context of a word usage, that is, features of a small number of words surrounding the target word, including part-of-speech tags, word forms, positions with respect to the target word, etc. I have a target words, it is surrounded by some words and for each word I have information about its PoS, the fact that is on the left or on the right of the target word, that is a t distance 0/1/2/3/4 and the word form. I provide local features, the local context of a word. Why in the previous slide I said that sometimes some pre-processed is performed? Because without these pre-processed (tokenisation, lemmatisation, PoS…) you cannot assign the PoS here, you need to know the PoS, otherwise how can you assign this? Do you think that local features are more helpful for fixed word order or free word order languages? For fixed ones!
  • topical features, which—in contrast to local features—define the general topic of a text or discourse, thus representing more general contexts (e.g., a window of words, a sentence, a phrase, a paragraph, etc.), usually as bags of words; Bags of words are nothing else but a big collection of words without of order. I put in this bag of words all the words of the chapter and I have an idea of the topic of the chapter.
  • syntactic features, representing syntactic cues and argument-head relations between the target word and other words within the same sentence. So, if I say “I love Mary”, Mary is not only after love, but it is the object of love. So, now we are understanding hopefully why Computational Linguistics 1 was so important, because you need syntax, treebank, syntactic parser and PoS, tokens and lemmatisatiom. There is a consistency in CL1 and CL2: you need to know what is tokenisation and what are the problems of tokenisation, even when you have to perform WSD
  • semantic features, representing semantic information, such as previously established senses of words in context. Based on this set of features, each word occurrence (usually within a sentence) can be converted to a feature vector. So, for instance, if a sense tagged corpus like Sem Core you know that the target word is preceded by some words that have some meaning, disambiguated in order to train some model. Based on such set of features, each word occurrence, usually within a sentence, can be converted in a feature vector. A feature vector is the collection of some features that are assign to some token. 29.02. Yesterday we were talking about one of the main components of Word Sense Disambiguation, which is the context. We saw the different kind of features related to the context and we were talking about the idea of features of vectors or vectors of features, so the set of features assigned to a component (In this case, usually words). Next element of Word Sense Disambiguation is the choice of a classification method. It’s an essential point, because depending on the classification method you can achieve very different results.

trained in supervised fashion in output assigns the labels that are learnt during the learning phase. I mean if during learning phase I use tags like noun, verb, adjective, the train model will assign tags like noun, verb, adjective, without inventing any other label, but applying the labels that it learnt during the training phase. This is the point: labelled training set. Output: the assignment of the labels learnt during the training set to new instances. This approach is linked to the knowledge based approach that relies on the use of external lexical resources Unsupervised Word Sense Disambiguation Unsupervised Word Sense Disambiguation and more generally speaking unsupervised NLP are, instead, methods based on unlabelled corpora. This is the big difference. In supervised methods you have a labelled training set or corpus. In unsupervised methods you have unlabelled corpora. I think you know what we mean with unlabelled corpus : a corpus not enhanced with any label, with any linguistic annotation layer. No lemmatization, no PoS Tags, no morphological feature no syntax. Just raw text. This methods, which are based on unlabelled data, don’t exploit any manually sense tagged corpus to provide a sense choice for a word in context. So the output here is not the assignment of the labels learnt during the training phase, but is clusters of instances considered similar to each other. Let’s spend some minutes on this. So we’re talking about the different kind of outputs of supervised NLP methods and unsupervised NLP methods. I think it’s clear what the output of supervised NLP methods is: a corpus where words are assigned labels that are learnt during the training phase based on a labelled corpus. In unsupervised methods, instead you don’t deal with any label. You just have unlabelled data, you can’t exploit any manually sensed tagged corpus you can’t exploit the labels for senses assigned for corpus, because they’re not there. You cannot use these labels to provide the sense choice for the words in contexts. A sense choice are the possible choices of sense per each word that are found in a labelled corpus. If in a labelled corpus, where senses are assigned, you have the word coach , there will be some instances of the word coach where it is related to the sense train and when it is related to the sense mental coach. So in the label data you have the sense choices and the machine learns to assign the correct sense choice among the possible ones assigned by the training data to the new instances. In instead unsupervised approaches the output is not the assignment of these labels that are learnt during the training phase, because the labels are not there, but are clusters : groups, sets, of objects that share something objects that are similar in some way. Yesterday I told you about the work with the Gemelli hospital. We built clusters of patients, because starting from the reports (cartelle cliniche) some patients are more similar to each others than to others. It’s clear. So, clusters are sets of objects that share something. Clusters of instances (words) that are considered similar to eachother. The output of unsupervised Word Sense Disambiguation methods are just sets of words that are considered similar to each other. This approach is linked to the corpus based approach that doesn’t use external resources (knowledge is not provided to the machine), but it uses large quantity of data How is this similarity computed? What do we have? We have the data, corpus, and corpus is made of words and sequences of words. It’s not a bag of words in which you just put all the words of a corpus without caring about the order of the words. Instead in a corpus you have the words and the word order , which is the context. A word is preceded and followed by other words. It seems trivial but I must say it. This is all we have. Just having this information, we can build this cluster because words are considered similar to each other if they behave similarly in the training data: when they share collocations, they share the company (you should know a word by the company keeps). You build clusters of words that behave similarly in the unlabelled training data, based on the assumption that words that share similar company in the training data have something semantic similar. That’s how embeddings work, it’s how GPTs work and linguistic component of Artificial Intelligence works. Just based on huge amount of unlabelled data, machines can learn clusters of words. This is very important. Imagine a search engine like google .. I remember the 1st^ version of Google years ago. It was based on the 1.0 version of the Web. It just searched the string of characters you ware looking for: if you looked for table , tables didn’t come out. Just the string of characters, then tables started to come out thanks to lemmatization. Now if you search table, Ikea and other pieces of

furniture come out. How does it work?. Is it based on Wordnet? Maybe, but mostly they make use of embeddings , because in embeddings, in this output (which are clusters of things considered similar to each other) you will find chair, table and other pieces of furniture all together, because they behave similarly in a corpus. When I used wordvect ( It’s the original tool for building embeddings ) for the first time (don’t take notes we’ll go back to this), I was pretty surprised because suddenly I had all the prepositions for Latin all together. And then I had all the subordinate conjunctions all together and I didn’t tell the machine anything about prepositions and conjunctions. Just using the distribution of words in the unlabelled training data, the machine learnt that these words behaved similarly and that prepositions behave similarly to other prepositions. So I had all the preposition together and I said… “Oh PoS is solved!”, because if I have a machine that is able to put together all the words that share the same PoS, PoS is solved. And that’s really a revolution in the world of Computational Linguistics. We’re realizing that raw data are sufficient. Maybe. Because annotated linguistic resources still play a role. We’ll see it when we talk about fine tuning. So we firstly talked about knowledge-based approaches and Corpus- based approaches. As you know knowledge-based approaches are knowledge rich or dictionary based approaches. I already mentioned the sources of knowledge (dictionary, BabelNet, WordNet, lexicon and ontology) that are the ones relying on some external lexical resources. One or more. Such as machine-readable dictionaries, thesaurus, ontologies. Instead Corpus-based or knowledge-poor approaches don’t make use of any of the resources mentioned above for disambiguation. So knowledge based approach is usually performed in supervised Word Sense Disambiguation approaches, while the Corpus-based is u sually linked to the unsupervised approaches. So knowledge poor … usually at the exam for Computational Linguistics 1 I don’t ask about the maximum entropy approach because they find it hard, but it’s not hard. It’s the fact that there is no principle (immagino intenda dire precedente ) information. We try to build a train model with no information provided before, it’s the opposite of rule-based approach, where there is a lot of information: if there is a noun preceded by adjective, the probability that it’s a noun is so and so. Knowledge poor means that we don’t provide the machine with any previous knowledge. We let the machine learn by example like children. (When I was a child nobody told me which were nouns or adjectives. They probably told us about the subjunctive, but most of our linguistic knowledge comes just from ostension, from the daily linguistic behaviour that we have. Even if we don’t teach grammar to children, they’ll probably be able to communicate and understand. Maybe not so well, because grammar is important, but anyways that’s it). Same with machines: we don’t provide machines with knowledge, but machines are able to provide information just out of data. This is how LLMs today work. GPT is built on huge amount of unlabelled data. Today Artificial Intelligence, GPT, LLM, embeddings, are all built in unsupervised fashion using a corpus-based approach. So what is the added value of using unsupervised approaches and corpus-based approaches? The fact that you don’t need large annotated resources. You just need large data, and you know that building an annotated resource needs time and money. And the size that you reach will always be smaller than the huge amount of raw data found on the web. The problem of having limited in size annotated resourced is solved by using unsupervised approach. This was an important bottleneck in NLP. Many times in the Research Center for Latin we would have needed sense annotated corpora for Latin to perform Word Sense Disambiguation for Latin. Ok, to do so we have to start from scratch by annotating data. The same holds for other levels like sentiment analysis, you need sentiment analysis tagged corpora in order to perform sentiment analysis, but it takes time, effort. So unsupervised approaches, corpus- based approach solved the problem of having limited amount of annotated labelled data, using unlabelled training data.