La Ghigliottina: Building an AI for Italian Word Connections

How Natural Language Processing and Large Language Models can help solve one of Italy's most popular word puzzles

AI

white and black letter t-letter blocks
white and black letter t-letter blocks

The Challenge of Word Connections

Imagine you're given five seemingly unrelated words:

  • Mountain

  • Paper

  • Break

  • Heart

  • Operation

What single word connects all of them? Take a moment to think about it.

The answer is "open" (open mountain, open paper, open break, open heart, open operation).

This kind of linguistic puzzle forms the basis of "La Ghigliottina" (The Guillotine), a popular segment on the Italian TV show "L'Eredità." In this game, contestants face five words and must find the one word that can be combined with or related to all of them to form common phrases, compound words, or idioms.

What makes this game fascinating is that it requires a deep understanding of language, cultural references, and semantic relationships that even native speakers find challenging. But could a machine learn to solve these puzzles? This is precisely what our "La Ghigliottina" project explores.

Beyond Simple Word Associations

Traditional approaches to word association rely on statistical co-occurrence: words that frequently appear together in text are likely related. However, "La Ghigliottina" demands a more nuanced understanding. The connection between words might be:

  • Semantic: based on meaning (e.g., "dog" connects to "loyal")

  • Syntactic: based on how words combine grammatically

  • Cultural: based on shared cultural knowledge

  • Idiomatic: based on common expressions

  • Metaphorical: based on figurative relationships

Building an AI system capable of navigating these complex linguistic relationships requires several layers of natural language processing techniques.

The Architecture Behind La Ghigliottina

Diving into the intricate machinery of La Ghigliottina's solution requires understanding both the theoretical foundations and practical implementations that make this linguistic puzzle-solver work. Let's explore the deep architecture that powers this system, component by component.

1. Data Foundation: Building a Semantic Universe

Creating a solution for La Ghigliottina first required assembling a rich semantic landscape. The data acquisition pipeline pulled from diverse sources to capture the multidimensional nature of word relationships:

  • CNN News Data: Extracted titles (as Target words) and descriptions (as Clues), capturing real-world contextual relationships and current language usage

  • IMDb Movies Data: Leveraged film titles and descriptions to incorporate cultural references and entertainment-related semantic connections

  • Taboo Game Data: Directly modeled after the word association mechanism needed for La Ghigliottina, providing explicit keyword-to-related-words mappings

  • Wiki Dictionary Data: Supplied formal definitions where Target words (dictionary entries) linked to their meanings and examples (Clues)

  • Wiki Sentences Data: Offered natural language usage examples showing how words behave in realistic contexts

This raw data underwent a multi-stage preprocessing pipeline:

  1. Decontraction transformation: Expanded contractions like "don't" to "do not" to standardize text representation

  2. Special character filtration: Removed punctuation, symbols, and non-alphanumeric characters that could introduce noise

  3. Case normalization: Converted all text to lowercase to eliminate case-sensitivity issues

  4. Lemmatization processing: Reduced words to their base forms using linguistic rules rather than simple stemming

  5. Tokenization segmentation: Split text into individual tokens while preserving meaningful units

A critical enhancement to this dataset came through the WordNet lexical database integration. For every noun in the English dictionary, we systematically extracted:

  • Hypernyms: More general categorical terms (e.g., "furniture" is a hypernym of "chair")

  • Hyponyms: More specific instances (e.g., "oak" is a hyponym of "tree")

  • Meronyms (part and whole): Component relationships (e.g., "wheel" is a meronym of "car")

  • Holonyms (part and whole): Composite relationships (e.g., "car" is a holonym of "wheel")

  • Polysemy variations: Different meanings of the same word

  • Troponymy relationships: Manner variations for verbs

  • Entailment connections: Logical implications between concepts

This semantic enrichment created a final dataset of 277,614 relationship entries, forming a comprehensive semantic network that captured the subtle connections needed to solve La Ghigliottina's challenging word association puzzles.

2. Baseline Model: Skip-Gram Classification with Enhanced Vector Representation

The foundation of our solution architecture employed a Skip-Gram Classifier within the Word2Vec framework, but with significant customizations to address the unique challenges of La Ghigliottina.

Traditional Word2Vec implementations generate similarity scores for individual inputs, but La Ghigliottina requires finding connections across multiple words simultaneously. Our enhanced approach:

  • Generated dense vector embeddings for all words in the dataset using a distributed representation approach

  • Set the Skip-Gram parameter to 1 to optimize for predicting context words from target words

  • Defined a context window size of 5 to capture relevant semantic relationships without excessive noise

  • Deployed 4 parallel workers for efficient processing of the large dataset

  • Created 100-dimension vector representations for each word, balancing expressiveness with computational efficiency

The core innovation in our Skip-Gram implementation was the multi-input processing algorithm:

"For each input word in the set of five: Generate n most similar words with cosine similarity scores Store these word-score pairs Identify recurring words across all five input sets Calculate the average similarity score for each recurring word Rank recurring words by their average similarity Return the top-ranked word as the solution"

This approach encountered several technical challenges:

  1. Embedding generation limitation: Word2Vec couldn't process multiple words simultaneously, requiring string format presentation

  2. Score extraction complexity: The system couldn't extract both word and similarity score concurrently, necessitating a two-stage process

  3. Data structure conversion: The tuple format of word-score pairs required conversion to DataFrames for effective manipulation

Despite successfully identifying basic semantic relationships, this model struggled with semantically hyponymous words and more nuanced linguistic connections that characterize the most challenging La Ghigliottina puzzles.

3. Intermediate Solution: Sequence-to-Sequence with LSTM Memory Enhancement

To capture more sophisticated linguistic patterns, we implemented a Sequence-to-Sequence (Seq2Seq) model enhanced with Long Short-Term Memory (LSTM) neural networks. This approach allowed the system to recognize temporal dependencies and contextual patterns across multiple words.

The data processing pipeline for this model involved:

  1. Processing input through Word2Vec to generate 100-dimension embeddings

  2. Concatenating individual words into a single sequential list for each entry

  3. Tokenizing unique targets and representing clues as sequences of numerical indices

  4. Applying end-padding to ensure consistent sequence length

  5. Splitting data with a 0.2 test ratio for proper evaluation

The neural architecture consisted of multiple specialized layers:

  • Embedding layer: Initialized with pre-trained embeddings to leverage transfer learning

  • LSTM layer with 64 hidden units: Capable of learning long-range dependencies in sequences

  • L2 regularization (coefficient 0.01): Applied to weights to prevent overfitting by penalizing large values

  • Dropout layer (0.5 probability): Randomly disabled neurons during training to increase robustness

  • Dense output layer: Used softmax activation for multi-class classification across the vocabulary

  • Adam optimizer: Employed adaptive learning rate optimization

  • Sparse categorical cross-entropy loss function: Optimized for classification tasks with numerous classes

This architecture achieved two critical capabilities beyond our baseline model:

  1. Utilized a comprehensive vocabulary obtained from the entire dataset, enabling the model to search across the whole corpus rather than restricting selection to specific entries.

  2. Recognized patterns beyond immediate inputs through LSTM temporal memory, allowing the model to leverage what it learned during training when faced with new inputs.

The model's performance revealed interesting patterns:

  • It accurately predicted direct relationships but struggled with more ambiguous connections

  • Despite implementing regularization and dropout, it still exhibited overfitting tendencies

  • We discovered redundant word relationships in the data, requiring dataset pruning to eliminate overlaps

  • Without LSTM, the model could only predict words from the immediate input set, ignoring training data patterns

4. Advanced Solution: Bidirectional Auto-Regressive Transformer (BART)

Our most sophisticated approach leveraged the BART generative model, designed to both understand input context and generate appropriate responses based on learned semantic relationships.

The implementation focused on two key objectives:

  1. Utilizing a pre-trained model capable of generating words following specific linguistic patterns

  2. Fine-tuning this model on our dataset to ensure outputs adhered to the format required by La Ghigliottina

The BART model's operational mechanism centered on introducing masked tokens both within and at the end of data entries. This dual-masking strategy forced the model to:

  • Predict semantic relationships inherent in the existing data

  • Generate outputs based on established semantic patterns

  • Learn contextual connections between input words and potential solutions

Technical implementation details included:

  • Selecting BART-base as the foundation model based on computational resource constraints

  • Additional preprocessing to eliminate lingering special characters and whitespace

  • Utilizing a Hugging Face tokenizer to process "Clues" and "Target" columns

  • Creating input IDs, attention masks, and labels for each word in both dataset and vocabulary

  • Setting a learning rate of 2e-5, batch size of 10, and training for 3 epochs

  • Implementing a self-attention module to maintain contextual awareness throughout computations

The BART approach encountered several technical challenges:

  1. Integration complexity: Merging our dataset with the Hugging Face tokenizer required reformatting data into a specific dictionary structure

  2. Token recognition issues: Despite successful tokenization, the model sometimes struggled to recognize the tokens

  3. Individual feeding requirement: To overcome recognition problems, tokens had to be fed individually with a batch size of 10

  4. Character-level generation: Even after careful integration, the model sometimes produced character representations instead of complete words

5. Supplementary Approach: T5 Architecture Implementation

We also explored the T5 (Text-to-Text Transfer Transformer) architecture, focusing on masked word prediction to improve overall generative capabilities.

The T5 approach:

  • Predicted masked words within sentences to strengthen contextual understanding

  • Applied this methodology to improve prediction capability for La Ghigliottina's word connections

  • Processed data through the same tokenization pipeline as BART

  • Maintained information consistency through self-attentive layers in both encoder and decoder components

  • Set identical hyperparameters to BART for comparative evaluation

The T5 model revealed an interesting limitation: it tended to prioritize first occurrences of words in the dataset. While our data structure ensured unique words per entry, repeated words across entries with alternative contexts weren't always effectively utilized by the algorithm.

6. The Core Integration Mechanism: From Words to Connections

The heart of our system is the integration mechanism that processes five input words to find the single connecting word. This mechanism implements a series of algorithmic steps:

  1. Vector Embedding Generation:

    for each input_word in input_words:

        embedding = embedding_model.get_vector(input_word)

        embeddings.append(embedding)

  2. Association Mining:

    for embedding in embeddings:

       related_words = []

       for vocab_word in vocabulary:

           similarity = cosine_similarity(embedding, vocab_word_embedding)

           if similarity > threshold:

               related_words.append((vocab_word, similarity))

        related_words_per_input.append(related_words)

  3. Intersection Analysis:

    candidate_words = {}

    for word, score in related_words_per_input[0]:

        if all(word in [w for w, s in words] for words in related_words_per_input[1:]):

            combined_score = score

            for i in range(1, len(related_words_per_input)):

                for w, s in related_words_per_input[i]:

                    if w == word:

                        combined_score += s

        candidate_words[word] = combined_score

  4. Ranking Algorithm:

    ranked_candidates = sorted(candidate_words.items(), key=lambda x: x[1], reverse=True)

  5. Contextual Validation:

    for word, score in ranked_candidates[:top_n]:

        validation_score = validate_against_corpus(word, input_words)

        final_score = alpha * score + (1 - alpha) * validation_score

        validated_candidates.append((word, final_score))

    return sorted(validated_candidates, key=lambda x: x[1], reverse=True)[0][0]

7. Implementation Challenges and Technical Limitations

Throughout the development process, we encountered several technical hurdles that shaped our architectural decisions:

  • Data acquisition barriers: Pre-existing datasets for this specific task were scarce, forcing us to compile data from disparate sources

  • Semantic relationship extraction: While WordNet provided nouns for entries, it didn't explicitly delineate semantic relationships between them

  • Model selection uncertainty: The uniqueness of La Ghigliottina required exploring multiple architectural approaches, from classification to prediction to generation

  • Parameter optimization complexity: The BART model struggled with text generation, producing character tokens instead of coherent text despite explicit configuration

  • LSTM regularization requirements: Preventing overfitting demanded careful tuning of dropout and L2 regularization parameters

  • Embedding space limitations: Representing complex cultural and contextual relationships in vector space proved challenging

  • Tokenizer integration difficulties: Hugging Face tokenizers required specific dictionary formats, necessitating data restructuring

  • Computational resource constraints: More sophisticated models like full-scale BART or T5 variants were computationally prohibitive

8. Evaluation Metrics and Performance Analysis

To evaluate our models, we employed multiple scoring mechanisms:

  • Cosine similarity for measuring vector space relationships in the Skip-Gram model

  • Validation accuracy and loss curves for the Seq2Seq LSTM model

  • Training and validation loss for the BART model

  • ROUGE scores (ROUGE-1, ROUGE-2, ROUGE-L) for evaluating generation quality in transformer models

Cross-model performance comparison revealed that:

  • The Skip-Gram model performed well on inputs with direct semantic relationships but struggled with more abstract connections

  • The Seq2Seq LSTM model showed higher accuracy but exhibited signs of overfitting despite regularization

  • The BART model achieved lower loss values but struggled with generating the intended outputs

  • The T5 model showed promise in understanding context but had limitations in comprehensive vocabulary utilization

This multi-layered architectural approach demonstrates the potential and challenges of applying advanced NLP techniques to the complex linguistic task represented by La Ghigliottina, paving the way for future enhancements that could further bridge the gap between computational language processing and human-like word association capabilities.

Training and Optimization

The training process for La Ghigliottina's solution involved carefully calibrating each model to balance performance with computational efficiency. This multi-stage optimization journey revealed crucial insights about natural language understanding.

Skip-Gram Model Training

The Word2Vec embeddings formed our foundation, trained on the entire 277,614-entry dataset with specific parameters:

  • Vector dimensionality of 100: Balancing expressiveness with computational efficiency

  • Negative sampling of 5: Improving training quality by contrasting with negative examples

  • Minimum word count threshold of 1: Ensuring comprehensive vocabulary coverage

  • Context window size of 5: Capturing meaningful word associations without excessive noise

  • 4 training threads: Utilizing parallel processing for efficiency

The model's training revealed an interesting limitation: while cosine similarity effectively identified related words, it struggled to prioritize connections when dealing with hyponymous relationships (subtypes and supertypes). Training experiments showed that adjusting the similarity threshold could improve precision but reduced recall, requiring careful calibration.

Sequence-to-Sequence with LSTM Optimization

The LSTM model underwent more complex training with multiple optimization strategies:

  • Embedding initialization with pre-trained vectors: Leveraging transfer learning

  • Gradient clipping at 1.0: Preventing exploding gradients during backpropagation

  • Batch size of 64: Balancing training stability and computational efficiency

  • Early stopping with patience of 3 epochs: Preventing overfitting while ensuring convergence

  • Learning rate scheduling: Starting at 0.001 with reduction on plateau

Despite these optimizations, the model still exhibited overfitting tendencies, evidenced by training accuracy reaching 99.17% while validation accuracy plateaued at 99.16%. The loss curves showed a similar pattern, with training loss decreasing more rapidly than validation loss before stabilizing.

Statistical analysis revealed that redundant relationships in the dataset contributed to this overfitting. Data augmentation and k-fold cross-validation were implemented to address these issues, resulting in more stable performance metrics.

BART Model Fine-Tuning

The BART model required specialized fine-tuning approaches:

  • Two-stage training process: First running the pre-trained model to establish a baseline, then fine-tuning on our dataset

  • Learning rate warmup: Gradually increasing from 1e-6 to 2e-5 over the first 10% of training steps

  • Weight decay of 0.01: Controlling model complexity through L2 regularization

  • Gradient accumulation over 4 steps: Effectively increasing batch size without additional memory requirements

  • Mixed precision training: Using 16-bit floating-point where appropriate to improve efficiency

The loss curve showed promising convergence, decreasing from 4.3 to 3.9 for training and 3.95 to 3.75 for validation over three epochs. However, ROUGE scores revealed limitations in generation quality, with ROUGE-1 at 0.402, ROUGE-2 at 0.277, and ROUGE-L at 0.378.

Beyond Simple Word Associations: Challenges and Insights

Developing an AI system for La Ghigliottina revealed several fundamental challenges in computational linguistics and semantic understanding:

The Polysemy Problem

Words in La Ghigliottina often connect through different senses of the same word. For example, "open" connects to "heart" (open heart surgery), "mountain" (open mountain), and "paper" (open paper) through entirely different meanings of "open."

Our models struggled with this polysemous nature of language. While word embeddings capture some sense distinctions through context, they often conflate multiple meanings into a single vector. This limitation became particularly evident in cases where the connecting word linked to the five clues through different semantic relationships.

Cultural Knowledge Integration

Many La Ghigliottina puzzles rely on culturally-specific knowledge and idiomatic expressions. For instance, Italian phrases like "brutto tempo" (bad weather) or cultural references specific to Italian society created challenges for our models.

Even with extensive training data, capturing these cultural nuances proved difficult. The models performed noticeably better on connections based on logical or semantic relationships than on those requiring cultural knowledge.

Contextual Ambiguity Resolution

La Ghigliottina often presents words that could connect to multiple potential solutions, requiring disambiguation through context. Our approaches struggled with this contextual resolution, particularly when multiple candidates scored similarly on semantic similarity metrics.

This challenge highlighted the gap between statistical pattern recognition and human-like contextual reasoning. While humans naturally consider the five words as a cohesive set, our models initially treated them as independent inputs, losing valuable contextual information.

Conclusion: The Future of Linguistic AI

La Ghigliottina represents a fascinating intersection of entertainment, linguistics, and artificial intelligence. Our attempt to build a system capable of solving these puzzles has revealed both the impressive progress in NLP and the substantial challenges that remain.

The gap between current AI capabilities and human linguistic intuition highlights the complex nature of language understanding. Words aren't merely labels or statistical patterns—they're flexible tools expressing meaning through intricate webs of relationships, connotations, and cultural knowledge.

Future Directions

Looking ahead, several promising approaches could advance this work:

  • Multimodal integration combining visual and linguistic information

  • Neuro-symbolic methods blending neural networks with symbolic reasoning

  • Enhanced contextual models better capturing the polysemous nature of language

  • Cultural knowledge graphs explicitly modeling idiomatic expressions

Whether you're a language enthusiast, AI researcher, or just a fan of word puzzles, La Ghigliottina demonstrates how even seemingly simple word games can reveal the remarkable complexity of human language and the growing sophistication of AI systems.

Want to try your hand at solving "La Ghigliottina" puzzles or test our AI system? Check out the project repository at github.com/deadven7/la_ghigliottina for the code and documentation.