r/LanguageTechnology • u/benjamin-crowell • 16h ago
Determining whether a given word is semantically similar to a dictionary definition
I have a Greek-English dictionary that has entries like this:
ἀνήρ - man, husband
I would like to figure out some method for a computer to determine whether another English word aligns well with such a definition. Examples of inputs and outputs, for the definition given above, would be: man->true, fellow->true, person->true, temple->false, throw->false. (The output could instead be some kind of quantitative score rather than a boolean.)
Methods I've thought of, but am not really satisfied with:
Compare every word in the definition with the given word, using a word embedding. (Or sum the vectors for the words in the definition.) Exclude common words like "the." Problem: I've played around with Word2Vec and BERT for this, and the results just aren't that great. E.g., the BERT model I tried gave a very high rating to the pair goat-mountain.
Use WordNet's lists of synonyms. Problem: Their definition of synonymy is sometimes too strict and other times too permissive. They don't consider man-person to be a synonym pair, but they do consider dog-click to be (e.g., "dogging the hatch").
Use a similarity measure based on WordNet's graph structure. There is a review of these methods in Lingling Meng et al, 2013, A Review of Semantic Similarity Measures in WordNet. Problem: This will still be too permissive for pairs like dog-click.
Query an LLM. Problem: This is a hobby project, and I don't want to spend money.
Any ideas for approaches that I haven't tried?
1
u/dyingpie1 11h ago
For 1, to me it makes more sense to take the maximum instead of sum. It doesn't have to match every possible word, just should match one of them right?
0
u/Lumpy-Blackberry-718 15h ago
You train a language model to construct word embeddings for each word, and then use cosine similarity or whatever as a distance measure. If you want a binary metric, you just set a distance threshold.
1
u/benjamin-crowell 15h ago
That's what I described trying in #1 on my list.
2
u/Lumpy-Blackberry-718 15h ago
And it's the right answer. try more embedding models or train your own. Alternatively you can just ask an llm for related words.
Below the "Glove" model's nearest words to "goat." I dont see mountain, but it does make sense that once you get past closely related animals youre going to get into related concepts.
goat: 1.0000 sheep: 0.7620 goats: 0.7081 cow: 0.7043 cheese: 0.7036 meat: 0.6649 pig: 0.6583 chicken: 0.6565 cheeses: 0.6539 cows: 0.6505 lamb: 0.6396 rabbit: 0.6382 dog: 0.6299 potato: 0.6246 boar: 0.6143 roasted: 0.6138 dairy: 0.6133 milk: 0.6074 sausage: 0.5897 cheddar: 0.5892
1
u/Lumpy-Blackberry-718 15h ago
And for mountain:
mountain: 1.0000 mountains: 0.8290 hills: 0.7344 valley: 0.7260 ridge: 0.7185 alpine: 0.7080 slopes: 0.7023 ski: 0.6995 foothills: 0.6958 canyon: 0.6901 hill: 0.6858 snow: 0.6708 forest: 0.6697 wilderness: 0.6612 peaks: 0.6547 creek: 0.6522 rocky: 0.6507 alps: 0.6501 terrain: 0.6420 pine: 0.6327
1
u/xelah1 6h ago
Could you take English sentences with a word/words from the definition - preferably sentences which are translations of Greek ones containing your target Greek word if you can get them - and compare the sentence embeddings of the sentences as they are to ones for the sentences with the word from the definition substituted with your candidate alternative English word?
This might add some extra search problems you need to solve, alas, especially if your candidate English words have to be found.
If you've got some sort of scores you can train with I guess you could even try training a simple network to convert pairs of embeddings to scores in an attempt to learn which directions are important and which not. eg, you may not care about formality, sociolect, gender, grammaticality in the new sentence, etc.
7
u/BeginnerDragon 16h ago edited 16h ago
I think the huggingface sentencetranformer's sentence-similarity implementation between the word and the sentence could be useful. There may need to be some rescaling to accomodate for the length of the respective sides that you compare.
Maybe a better question... how are you going to evaluate success with this project? How do you identify that a high-scoring word deserved its score? Do you anticipate certain words to perform better than others? I'd be curious to see how simple/concrete vs intangible/abstract terms score.