Unit 2
Unit 2
Embeddings
Embeddings are a way to represent words or
phrases as numerical vectors, making them
understandable for machine learning models,
especially neural networks.
Example
• Suppose a language model predicts the following
sequence: "The cat sat on the mat.
• "If the model predicts each word with high
probability, the perplexity will be low, suggesting the
model understands the text well.
• If the model predicts each word with low probability,
the perplexity will be high, suggesting the model is
less effective.
network to the next, enabling the network to maintain
a memory of previous inputs.
Architecture of an RNN:
Recurrent Neural network Input Layer: Accepts sequential input data (e.g., words
in a sentence, stock prices).
RNN(Recurrent Neural Network): Recurrent Neural
Hidden Layer: Contains a recurrent connection that
Networks (RNNs) are a class of neural networks
allows the network to remember past states.
specifically designed to handle sequential data, making
them particularly well-suited for tasks in Natural Output Layer: Generates the output at each time step
Language Processing (NLP). Unlike traditional or after processing the entire sequence.
feedforward neural networks, RNNs have loops that
allow information to be passed from one step of the
Challenges with RNNs: In RNNs: This typically happens when there are large
weight values or when trying to model very complex
Vanishing Gradient Problem: Gradients diminish over
sequences, where the error gradients multiply and
long sequences, making it difficult for the network to
grow rapidly as they propagate backward through time.
learn long-term dependencies.
Impact: The training process becomes unstable, with
Exploding Gradient Problem:Gradients can grow
the model's loss function often resulting in "NaN" (Not
excessively large during backpropagation, causing
a Number) values, and the model's performance
instability.
deteriorates.
Limited Memory: Difficulty in handling very long
sequences due to reliance on hidden states.
Exploding Gradients