Ir al contenido principal

Entradas

Mostrando las entradas etiquetadas como nlp

[NLP][AI][MATHS] Mathematical foundations of Neural Language Models (NLMs)

  Let’s delve into the mathematical foundations of   Neural Language Models (NLMs) , which form the basis for modern   Large Language Models (LLMs) : Representation Learning : NLMs aim to learn meaningful  continuous representations  (also known as  embeddings ) for words or tokens. Each word is mapped to a high-dimensional vector in a continuous space. These embeddings capture semantic relationships and contextual information. Feedforward Neural Networks (FNNs) : The simplest neural model consists of a single hidden layer with nonlinear activation functions. Given an input (word embedding), the network computes a hidden representation using weights and biases. The output layer predicts the next word or token. Recurrent Neural Networks (RNNs) : RNNs handle sequential data by maintaining hidden states across time steps. Each time step processes an input (word embedding) and updates the hidden state. RNNs suffer from vanishing gradients and struggle with long...

[NLP][AI] Differences between the n-gram approach and the neural approach in Large Language Models (LLMs)

  Let’s explore the differences between the   n-gram approach   and the   neural approach   in   Large Language Models (LLMs) : N-gram Approach : Definition : N-gram models use statistical and probabilistic techniques to determine the probability of a given sequence of words occurring in a sentence. Basic Idea : An n-gram is a contiguous sequence of n items (usually words) from a given text sample. Assumption : The probability of the next word in a sequence depends only on a fixed-size window of previous words (context). Strengths : Simplicity : N-gram models are straightforward and easy to implement. Efficiency : They can handle large datasets efficiently. Limitations : Local Context : N-grams consider only local context, which may not capture long-range dependencies. Sparsity : As n increases, the number of possible n-grams grows exponentially, leading to data sparsity. Fixed Context Window : The fixed context window may not adapt well to varying sentence...

[NLP] Bigram model

 

NLP: tr and sort - Unix Commands to extract and manipulates word - corpus

  tr -sc 'A-Za-z' '\n' < ./wizard_of_oz | sort | uniq -c you should replace ./wizard_of_oz by the file you want to analyze change lower by upper case letters: tr -sc 'A-Za-z' '\n' < ./wizard_of_oz |tr a-z A-Z | sort | uniq -c order numerically the occurrences: tr -sc 'A-Za-z' '\n' < ./wizard_of_oz |tr a-z A-Z | sort | uniq -c | sort -n -r

NLP: La ley de Herdan

 La ley de Herdan es una ley empírica que describe el número de palabras distintas en un documento (o conjunto de documentos) como una función de la longitud del documento. La fórmula de la ley de Herdan es: V R ​ = K ⋅ n β donde V R ​ es el número de palabras distintas en un documento de tamaño n , y K y β son parámetros libres que se determinan empíricamente. Con un texto en inglés, típicamente K es entre 10 y 100, y β es entre 0,4 y 0,6 1 2 3 . El parámetro K se refiere a la riqueza léxica del documento, es decir, el número de palabras distintas que aparecen en el documento. El valor de K depende del idioma y del tipo de texto. Por ejemplo, un texto técnico tendrá una riqueza léxica más baja que un texto literario. El parámetro β se refiere a la tasa de crecimiento de la riqueza léxica con respecto al tamaño del documento. Un valor de β cercano a 1 indica que la riqueza léxica crece linealmente con el tamaño del documento, mientras que un valor de β menor que 1 ind...