Algorithm library

Algorithm Library

45 NLP algorithms and techniques, each with a definition, how it works, steps, pros and cons, and references. The classification distinguishes traditional, resource-based, machine learning, deep learning and large language model methods.

Text tokenization

Traditional algorithm Implemented in the lab Regex word tokenization Rule-based (Regex) Word Tokenization Splitting text into words, numbers and punctuation marks using regular expressions that describe the shape of each kind of unit. Traditional algorithm Implemented in the lab Sentence splitting Sentence Boundary Detection Finding sentence boundaries in a text from punctuation marks, with rules that prevent wrong splits at abbreviations and decimal numbers. Traditional algorithm Implemented in the lab Byte Pair Encoding Byte-Pair Encoding (BPE) A subword tokenization algorithm that learns its vocabulary from a corpus by repeatedly merging the most frequent adjacent pair of symbols, producing units between a character and a word. Traditional algorithm Implemented in the lab WordPiece tokenization WordPiece A subword tokenization method used by BERT models: the vocabulary is built by choosing the merges that raise the likelihood of the training data, and a word is encoded by longest match from the left. Traditional algorithmFor explanation and comparison Unigram language model tokenization Unigram Language Model Tokenization A subword tokenization method that starts with a large vocabulary and gradually removes the least useful units based on a unigram probabilistic model (Unigram), choosing the best segmentation with the Viterbi algorithm. Resource-based Implemented in the lab Arabic clitic segmentation Arabic Clitic Segmentation Splitting an Arabic word into prefixes (conjunctions, prepositions and the definite article), a stem and suffixes (attached pronouns), such as «وبكتابهم» → و + ب + كتاب + هم.

Text preprocessing

Morphological analysis

Part-of-speech tagging

Named entity recognition

Sentiment analysis

Arabic dialect identification

Syntactic parsing

Semantic embeddings

Machine learningFor explanation and comparison Word2Vec Word2Vec (CBOW / Skip-gram) A method for learning dense word vectors with a shallow network that predicts a word from its context (CBOW) or the context from the word (Skip-gram). Machine learningFor explanation and comparison FastText FastText Subword Embeddings An extension of Word2Vec that represents a word as the sum of its character n-gram vectors, so it gives vectors for unseen words and suits morphologically rich languages such as Arabic. Machine learningFor explanation and comparison GloVe GloVe (Global Vectors) A method that learns word vectors from the global co-occurrence matrix by approximating the logarithm of the co-occurrence counts with the dot product of the vectors. Traditional algorithm Implemented in the lab Cosine similarity Cosine Similarity A measure of how similar the directions of two vectors are, equal to their dot product divided by the product of their lengths, ranging from −1 to 1. Traditional algorithm Implemented in the lab Principal component analysis Principal Component Analysis (PCA) A dimensionality-reduction method that projects data onto the directions with the largest variance, used to plot high-dimensional vectors in two dimensions. Deep learningFor explanation and comparison Contextual embeddings Contextual Embeddings (BERT-style) Representations that give a word a different vector depending on its sentence, produced by the Transformer layers of models such as BERT, AraBERT and CAMeLBERT.

Semantic similarity

Machine translation

Text summarization