Introduction to Neural Networks
Biological Inspiration
Artificial Neural Networks (ANNs) represent one of the most fascinating intersections between biology and computation. Inspired by the human brain, which contains approximately 100 billion neurons, these networks attempt to mimic the way biological neurons send electrical pulses to activate other neurons, creating the complex interconnected systems that enable cognition through intricate interactions between individual units.
When we examine ANNs from different perspectives, we discover that they serve as statistical models providing mathematical frameworks for pattern recognition, computational models offering parallel processing capabilities, and biologically-inspired models that attempt to capture the essence of neural behavior. This multi-faceted nature makes them particularly powerful tools for understanding and processing complex data patterns.
The biological inspiration runs deeper than mere analogy. Just as neurons in the visual cortex activate in response to specific stimuli (a discovery that earned Hubel and Wiesel the 1981 Nobel Prize), artificial neurons learn to respond to particular patterns in data. Hubel and Wiesel's groundbreaking research demonstrated that specific neurons in the visual cortex would fire when presented with edges at particular orientations, effectively serving as feature detectors. Similarly, artificial neural networks develop specialized "neurons" that activate in response to specific patterns in the input data. This biological foundation provides the conceptual framework for understanding how artificial networks can process information in ways that traditional programming approaches cannot easily achieve.
Basic Architecture of Feedforward ANNs
Network Architecture
The architecture of feedforward neural networks follows a deceptively simple yet powerful structure. At its foundation lies the input layer, which receives raw data whether that consists of pixel values from images or encoded representations of words from text. Each input represents a numerical value that the network can process mathematically. For images, this might mean flattening a 64×64 pixel image into a single vector of 4,096 values, while for text, it involves converting words into their corresponding vector representations.
Between the input and output lies the heart of the network's computational power: the hidden layers. These layers transform information as it flows through the network, with each layer building upon the representations created by the previous layer. Deep networks distinguish themselves by having multiple hidden layers, allowing for increasingly sophisticated transformations of the input data. Each individual neuron within these layers performs a fundamental operation: it computes an output by applying a function to the weighted sum of its inputs plus a bias term.
Neuron Computation
The mathematical foundation underlying each neuron's operation can be expressed as h = f(W·x + b), where h represents the neuron's output, f is an activation function such as ReLU or sigmoid, W is the weight matrix, x is the input vector, and b is the bias term. This simple mathematical operation, when replicated across thousands or millions of neurons, creates the network's ability to learn and recognize complex patterns.
In more concrete terms, each neuron computes a weighted sum of its inputs, adds a bias value, and then applies an activation function to determine its output. For example, in an image recognition task, the input vector x might represent pixel values of a flattened image (e.g., a 64×64 pixel image becomes a 4,096-dimensional vector). The weights in W essentially encode what patterns the neuron is looking for. Early layers might detect simple features like edges or textures, while deeper layers combine these to recognize more complex patterns. The learning process involves adjusting these weights to minimize prediction errors on training examples.
The output layer completes the architecture by producing the network's final predictions. For classification tasks, this layer typically contains one output for each category the network needs to distinguish between. In language applications, the output layer generates a probability distribution over the entire vocabulary, allowing the network to express its confidence in each possible word as the next prediction.
How Feedforward Networks Process Information
Information Flow
Information flows through feedforward networks in a carefully orchestrated manner that distinguishes them from other neural architectures. The forward pass represents the core mechanism by which data moves from input through hidden layers to output, with no loops or backward connections (hence the term "feedforward"). This unidirectional flow creates a clear computational pipeline where each layer transforms the representation it receives from the previous layer.
The learning process within feedforward networks follows a hierarchical feature extraction pattern that mirrors many natural information processing systems. Early layers typically learn to recognize simple patterns such as edges and basic shapes when processing images, or fundamental linguistic patterns when processing text. Middle layers combine these simple patterns into more complex features, building increasingly sophisticated representations. Finally, the later layers use these complex features to make final decisions about classification or prediction.
Feature Learning Hierarchy: Face Recognition Pipeline
Consider the face recognition pipeline as an illustrative example: raw image data progresses through edge detection in early layers, then face part recognition in middle layers, followed by complete face assembly, and finally identity classification in the output layer. This hierarchical processing allows the network to build understanding progressively, from simple visual elements to complex semantic concepts.
From Images to Language: The Transition
Data Type Comparison
The transition from processing images to handling language represents a crucial conceptual leap that demonstrates the versatility of neural network architectures. While images consist of high-dimensional pixel arrays that can be directly fed into networks as numerical values, language presents unique challenges because words are inherently symbolic rather than numerical.
The key insight enabling this transition lies in recognizing that both images and text can be represented as high-dimensional data suitable for neural network processing. Images naturally exist as arrays of pixel values, while text requires conversion into numerical representations through various encoding schemes. Once this conversion is accomplished, the same fundamental neural network principles that excel at image recognition can be applied to language understanding and generation.
Word Vectors: Representing Language Numerically
Word Vector Space
The challenge of converting symbolic words into numerical representations that neural networks can process has been solved through the development of word vectors, also known as word embeddings. These vectors transform the discrete, symbolic nature of language into continuous, high-dimensional numerical spaces where mathematical operations become meaningful and computationally tractable.
Word vectors solve the fundamental problem of representing language by converting each word in a vocabulary to a fixed-size numerical vector. These vectors capture semantic relationships between words in ways that enable mathematical operations to reflect linguistic relationships. The remarkable property of well-trained word vectors is that similar words occupy nearby positions in the vector space, allowing the network to generalize knowledge about one word to similar words.
Word Relationships: Vector Arithmetic Captures Relationships
The mathematical relationships captured by word vectors often mirror human understanding of language in surprising ways. The famous example of "king - man + woman ≈ queen" demonstrates how vector arithmetic can capture analogical relationships. Similarly, geographic relationships like "Paris - France + Italy ≈ Rome" show how vectors encode factual knowledge about the world. This property extends to many semantic domains, including colors, where relationships like "blue + sunset hints" might lead to vectors close to "pink" or "purple" in the vector space. These mathematical operations on word vectors allow neural networks to make sophisticated predictions about word relationships without explicitly being programmed with rules about language.
Language Modeling with Feedforward Networks
Language Model Architecture
Language modeling with feedforward networks centers on the fundamental task of predicting the next word in a sequence, a deceptively simple objective that requires sophisticated understanding of linguistic patterns, context, and meaning. The basic approach involves training networks to predict what word should come next given a sequence of preceding words, thereby learning to model the statistical structure of language.
Training data creation for language modeling involves converting continuous text into structured input-output pairs. From a sentence like "The sky was quite nice today," the system creates multiple training examples: given the input sequence ["The", "sky", "was"], the target is "quite"; given ["sky", "was", "quite"], the target is "nice"; and given ["was", "quite", "nice"], the target is "today." This process transforms natural language into the structured format required for supervised learning. By creating millions of such examples from large text corpora, the network learns to recognize patterns in language that enable it to make increasingly accurate predictions about which words are likely to follow a given context.
Practical Example: Filling Missing Words
Word Prediction Process
To understand how feedforward neural networks can fill missing words in sentences, consider the practical example: "The sky was quite nice today, it was blue with hints of ___ due to the sunset." The expected output is "pink," and examining how the network arrives at this prediction reveals the sophisticated processing that occurs beneath the surface of apparently simple language understanding.
The process begins with data preprocessing, where the network analyzes the context words ["The", "sky", "was", "quite", "nice", "today", "it", "was", "blue", "with", "hints", "of"] along with the following context ["due", "to", "the", "sunset"]. The missing word position is marked as a special token that the network learns to recognize as requiring prediction.
Word vector conversion transforms each word into its corresponding numerical representation. "The" might become a 300-dimensional vector like [0.1, -0.3, 0.8, 0.2, ...], while "sky" becomes [0.4, 0.1, -0.2, 0.9, ...], and so forth. These vectors encode semantic information learned during training, positioning similar words near each other in the high-dimensional space.
The prediction generation process might result in probabilities such as "pink": 0.45, "orange": 0.23, "yellow": 0.15, "red": 0.12, "purple": 0.05, and so forth. The network's choice of "pink" as the highest probability word reflects its learned associations between sunset contexts and warm colors, its understanding that "blue" combined with "hints of" suggests color mixing, its recognition of temporal context indicating evening or sunset scenarios, and its knowledge of linguistic patterns common in similar descriptive contexts.
This prediction process demonstrates how the network has learned not just statistical patterns in language, but also semantic relationships between concepts. When predicting "pink," the network isn't simply matching patterns it has seen before. It's performing complex operations in vector space that capture the relationship between time of day (sunset), existing colors (blue), and the likely resulting colors that would appear in that context. The network effectively learns a mathematical representation of how colors interact in natural language descriptions.
Training Process
Training Loop
The training process that enables feedforward networks to learn language patterns involves sophisticated optimization techniques that gradually adjust millions of parameters to minimize prediction errors. The foundation of this process rests on the cross-entropy loss function, expressed mathematically as -log(P(correct_word | context)), which encourages the network to assign high probabilities to correct words while penalizing incorrect predictions.
Training proceeds through a carefully orchestrated sequence of steps repeated across enormous datasets. The forward pass computes predictions for training examples, producing probability distributions over the vocabulary for each context. Loss calculation compares these predictions to the actual next words in the training data, quantifying how far the network's predictions deviate from the correct answers. The backward pass, implemented through backpropagation, calculates gradients that indicate how each parameter should be adjusted to reduce the loss. Weight updates then modify the network's parameters in directions that should improve performance.
This backward step was one of the most crucial things UofT professor Geoffrey Hinton did in his career. It was a game changer for the field of AI. It allowed for the training of much larger networks, and it allowed for the training of networks that were able to learn much more complex patterns. It was a major breakthrough that led to the development of the modern AI we see today. This is part of the reason why he is considered the "Godfather" of AI and in-part why he won the Nobel Prize recently.
Hinton's work on backpropagation in the 1980s provided an efficient algorithm for calculating how each weight in a neural network should be adjusted to reduce the overall error. While the mathematics of backpropagation existed earlier, Hinton and his colleagues demonstrated that this approach could be used to train multi-layer neural networks effectively. This insight was revolutionary because it solved the "credit assignment problem" (determining which weights in a complex network were responsible for errors and needed adjustment). Without backpropagation, the deep neural networks that power today's language models would be impossible to train, as there would be no practical way to tune their millions or billions of parameters.
Loss Function Visualization
Limitations and Considerations
Context Window Limitation
Despite their remarkable capabilities, feedforward neural networks for language processing face several fundamental limitations that constrain their effectiveness and highlight the need for more advanced architectures. Computational constraints represent one significant category of limitations, particularly the fixed-size context windows that characterize feedforward approaches. These windows miss long-range dependencies that are crucial for understanding complex linguistic phenomena, limiting the network's ability to maintain coherence over extended passages or capture relationships between distant words.
The context window limitation is particularly significant for language understanding. A typical feedforward network might only consider the previous 3-5 words when predicting the next word, meaning that information from earlier in a text is completely lost. For example, in a long document discussing "Abraham Lincoln," if the text later refers to "the president" after several paragraphs, the network with a small context window would have no way to know which president is being referenced. This limitation forces these networks to make predictions based on local patterns rather than global document understanding.
Semantic understanding limitations highlight deeper philosophical questions about what these networks actually learn. The "Octopus Problem," as described in the academic literature, suggests that language models might predict patterns in text without developing true understanding of the concepts they manipulate. This raises concerns about whether networks can capture real-world knowledge or merely reproduce statistical patterns present in their training data.
The Octopus Problem is illustrated by an analogy: imagine an octopus reading correspondence between two astronomers discussing their observations. The octopus might become extremely good at predicting what words the astronomers will use next, but this doesn't mean it understands astronomy. Similarly, language models can predict "The Earth orbits around the ___" with "sun" without truly understanding planetary motion or physics. This distinction between statistical pattern recognition and genuine understanding represents one of the fundamental philosophical questions in artificial intelligence research.
Current solutions to these limitations have led to the development of more sophisticated architectures. Transformer architectures replace basic feedforward processing with attention mechanisms that can capture long-range dependencies more effectively. Pre-training approaches involve training networks on massive, general-purpose corpora before fine-tuning them for specific tasks, allowing for better generalization and more efficient use of task-specific data.