<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Milton Leal on Medium]]></title>
        <description><![CDATA[Stories by Milton Leal on Medium]]></description>
        <link>https://medium.com/@miltonleal?source=rss-91ee35ce981b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8BCrnas-_g-AqdqABXg4-w.jpeg</url>
            <title>Stories by Milton Leal on Medium</title>
            <link>https://medium.com/@miltonleal?source=rss-91ee35ce981b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:06:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@miltonleal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ChatGPT: How Did We Get Here? A Brief History of Language Modelling]]></title>
            <link>https://pub.aimind.so/chatgpt-how-did-we-get-here-a-brief-history-of-language-modelling-e5d1e3f7e05c?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5d1e3f7e05c</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[language-model]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Tue, 05 Sep 2023 21:58:04 GMT</pubDate>
            <atom:updated>2023-09-07T18:49:21.218Z</atom:updated>
            <content:encoded><![CDATA[<p>In the historical context of GPT models, which are essentially machines that predict the next word, it is notable to observe that as far back as 1950, the “father of Information Theory,” mathematician Claude Shannon, was already investigating and proposing experiments involving predicting the next letter of a text given the preceding context. In his work [1], based on statistical measures of Entropy and Redundancy, Shannon established the average amount of information produced by each letter in a text of a language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*00smpiOtp0FwJcBc5EZGLg.png" /><figcaption>Relative frequency with respect to the order of words in English. From Shannon [1]</figcaption></figure><p>During the 1950s, other approaches were fundamentally based on symbolic methods. In this paradigm, linguists and computer scientists manually created sets of grammatical and lexical rules to model language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*eaCY_Ue2w-pCP_O-NlBeEg.png" /><figcaption>Artisanal representation of sentences in a language, from Chomsky [2]</figcaption></figure><p>Another significant example of this era is the chatbot ELIZA, developed between 1964 and 1966 by Joseph Weizenbaum [3]. ELIZA acted as a therapist, employing simple pattern matching techniques to identify keywords in user input and generate appropriate responses. For instance, if a user said, “I feel sad,” ELIZA would identify the word “sad” and generate a response like, “Why do you feel sad?”</p><p>ELIZA was one of the first programs to undergo the Turing Test, initially proposed by Alan Turing in 1950. In the Turing Test, a human and a machine communicate in natural language through an intermediary. If the intermediary cannot distinguish which is the machine, the machine is considered to have passed the test, demonstrating advanced artificial intelligence characteristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*JCSlJnIF-TJClkBXW4HxAQ.png" /><figcaption>Interaction with Eliza. Author unknown (Wikimedia Commons)</figcaption></figure><p>The combination of linguistics and descriptive statistics, which had been popular in research during the 1950s and 1960s, was replaced from the mid-1970s by a more purely statistical focus, with models capable of making probabilistic decisions. During this period, IBM played a significant role in advancing the field of speech recognition. The company pioneered the application of optimal decoding algorithms for linear codes [4] and approaches involving likelihood function maximization [5].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*FaoIHWi_T1n8rqD-o5PqnA.png" /><figcaption>The acoustic processor is designed to act as a phonetician, transcribing speech waveform into a sequence of phonetic symbols. Meanwhile, the linguistic decoder translates the possibly distorted phonetic sequence into a sequence of words, from Bahl [5]</figcaption></figure><p>In 1997, a notable advancement in sequence modeling was achieved with the introduction of Recurrent Neural Networks (RNNs) with Long Short-Term Memory (LSTM) [6]. LSTMs were designed to overcome the limitations of conventional RNNs, particularly the vanishing gradient problem. The LSTM architecture introduced a memory cell mechanism and activation gates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-wTFh9aBa3B8iGNRmvfnA.png" /><figcaption>Example of a network with 8 input units, 4 output units, and 2 blocks of memory cells with size 2. From Hochreiter [6]</figcaption></figure><p>In the year 2003, the field of NLP began to enter the era of deep learning. In this context, Bengio et al. [7] employed feed-forward neural networks for language modeling, demonstrating that these architectures could learn semantic word representations and capture long-term dependencies between words. The authors introduced the idea of simultaneously learning word embeddings and the joint probability function of word sequences, using model simplifications to mitigate the curse of dimensionality problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*152Uwt4zjUu5oH5ePIhUBg.png" /><figcaption>The Naueral Language Model. From Bengio [7]</figcaption></figure><p>In 2008, Collobert and Weston [8] introduced a unique convolutional neural network architecture that processed various NLP tasks jointly. This architecture provided multiple linguistic predictions for a given sentence, including part-of-speech tags, text chunks, named entity tags, semantic roles, semantically similar words, and the probability of sentence grammaticality and semantic correctness. The network was trained jointly for all tasks using weight sharing. The model also employed an innovative form of semi-supervised learning, where all tasks used labeled data except for the language model, which was trained on unlabeled text.</p><p>In 2013, the Word2Vec technique [9] solidified itself as a high-quality embedding learning method. This technique captured complex semantic and syntactic relationships between words and became an integral component in many subsequent NLP architectures. We will discuss this algorithm in more detail in the dedicated chapter.</p><p>In 2014, the seed for the revolution that would follow in the coming years was planted: the attention mechanism was introduced by Bahdanau et al. [10], in the context of an automatic English-to-French translation application. The authors named the network RNNsearch-50. Later, the attention layer became a fundamental component in the development of Transformer-like architectures. This mechanism allowed the model to focus on different segments of the input sequence while generating the output sequence, enhancing the model’s ability to capture long-range dependencies and complex contexts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*qvwziPABNK73sBBXk9oh8A.png" /><figcaption>Illustrative example of word alignment obtained by RNNsearch-50 between the source sentence in English and the generated translation in French. Each pixel in the graph indicates the weight <em>αij</em>​, which represents the degree of attention from the <em>i</em>-th word in the target sentence (French) to the <em>j</em>-th word in the source sentence (English). The color scale ranges from black (0) to white (1), indicating the weight of the corresponding annotation. From Bahdanau [10].</figcaption></figure><p>In 2017, Vaswani et al. [11] introduced the Transformer architecture in their paper “Attention is All You Need.” The Transformer utilized self-attention mechanisms and achieved state-of-the-art results in various natural language processing tasks, especially machine translation. Its efficiency and scalability surpassed RNN and CNN-based approaches, establishing attention as a fundamental component in many subsequent architectures and relegating RNNs, LSTMs, and CNNs to a secondary role in current research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*Dj2av1NonD_2hxy5ZKzxHg.png" /><figcaption>The original Transformer. From Vaswani [11].</figcaption></figure><p>Inspired by [12], GPT-1 was released in 2018 by OpenAI [13], utilizing the Transformer architecture. It was designed for unsupervised learning (pre-training) and subsequent refinement (fine-tuning) in various natural language processing tasks. GPT-1 had 117 million parameters and was trained on a combination of two datasets: Common Crawl, a massive web page dataset with billions of words, and BookCorpus, a collection of over 11,000 books from various genres. GPT-1 was capable of generating fluent and coherent language when given a prompt or context. However, it had limitations, such as generating repetitive text, especially when provided with prompts outside the scope of its training data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X3igQ9KGDGg9Og0FMYZUQA.png" /><figcaption>Left: Transformer architecture and training objectives used. Right: Input transformations for fine-tuning in different tasks. Note that GPT-1 has 12 attention blocks. From Radford [12]</figcaption></figure><p>In 2019, GPT-2 [14] was introduced as a significant evolution of the previous model, utilizing the same architecture as the earlier version. The main difference was the model size. GPT-2 was trained with 1.5 billion parameters and used the WebText training dataset, containing 40 GB of text extracted from 8 million documents and 45 million web pages that received upvotes on the Reddit social network. Training the model took several weeks using specialized hardware.</p><p>In 2020, OpenAI released GPT-3 [15], redefining the state of the art for various tasks. This model was even larger and more advanced, with 175 billion parameters. It was trained on a dataset of 570 GB of plain text, containing 300 billion tokens from various sources like CommonCrawl, WebText, English Wikipedia, and two book corpora (Books1 and Books2). Training GPT-3 also required significant time and computational resources. GPT-3 not only set new standards in various NLP tasks but was also made available through an API, enabling a range of practical applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKqaQKB33TzmPmCj01vmVA.png" /><figcaption>GPT-3 model hyperparameters. From Brown [15]</figcaption></figure><p>In 2022, OpenAI once again disrupted the field by releasing ChatGPT, a language model specifically trained for conversational interactions [16]. This model underwent fine-tuning and employed Reinforcement Learning from Human Feedback (RLHF) to improve performance and alignment with user intentions. Fine-tuning allowed the model to be more effective in specific tasks, while RLHF helped minimize undesirable responses and maximize model utility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*Xr3rZYsX3ycSUFfoVb6Xfw.png" /><figcaption>ChatGPT prompts. From Ouyang [16].</figcaption></figure><p>Society has expressed growing concerns about the alignment of these AI models with ethical and moral values [16]. Questions about AI responsibility in contexts like misinformation and polarization have become widely discussed after the global emergence and popularization of ChatGPT.</p><p>In March 2023, OpenAI launched an even larger and more powerful version: GPT-4. The OpenAI technical report on GPT-4 indicates substantial improvements in performance and capabilities compared to GPT-3.5. The model was pretrained using publicly available data and licensed third-party data. GPT-4 showed a 19% increase in factual accuracy over GPT-3.5 in an internal OpenAI assessment. Additionally, GPT-4 outperformed GPT-3.5 on publicly available benchmarks like TruthfulQA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*C5y9Qk0c_MEXPamsmXIiRQ.png" /><figcaption>Performance of GPT on academic and professional exams. The simulation follows the conditions and evaluation criteria of real exams, ordered based on GPT-3.5 performance. GPT-4 outperforms GPT-3.5 in most tested exams. From OpenAI [17].</figcaption></figure><p>GPT-4 also possesses the capability to process both images and text as inputs to the model, a feature not present in previous GPT versions. During a live demonstration for developers in March 2023, OpenAI showcased how GPT-4 can process images into code.</p><p>For GPT-4 fine-tuning, OpenAI employed Reinforcement Learning from Human Feedback (RLHF) and Rule-Based Reward Models (RBRMs) to reduce the likelihood of generating harmful content.</p><p>In terms of safety, GPT-4 demonstrated an 82% reduction in responding to requests for prohibited content compared to GPT-3.5. The model also responded to sensitive requests, such as medical advice or self-harm concerns, 29% more often in compliance with OpenAI policies than GPT-3.5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*KiKVfvFjPmD1M15Fzvbynw.png" /><figcaption>Example of prompt and responses for improvements in the rejection of prohibited categories. The example shows the evolution of the GPT-4 model’s response, from an initial explanation that could be dangerous to an updated refusal that follows safety and legality guidelines. From OpenAI [17].</figcaption></figure><p>GPT-4 still experiences many of the same limitations present in previous GPT models, including producing unreliable output and limitations in its ability to “learn” from experience. The model also lacks information about events occurring after September 2021, the cutoff date for most of its pretraining data.</p><p>In 2023, open-source language models have gained prominence, such as Meta’s LLaMA and LLaMA 2 [18], along with a dozen other models from smaller companies with open-source licenses, fostering a landscape of intense development and competition among models. This variety of open-source models contributes to a robust and growing NLP ecosystem, offering alternatives to proprietary models and fostering innovation and research in the field.</p><h3>References</h3><p>[1] Shannon, C. E. (1951). Prediction and entropy of printed English.</p><p>[2] Chomsky, N. (1957). Syntactic structures.</p><p>[3] Weizenbaum, J. (1966). ELIZA — a computer program for the study of natural language communication between man and machine.</p><p>[4] Bahl, L. R., Baker, J. K., &amp; Jelinek, F. (1974). Optimal decoding of linear codes for minimizing symbol error rate.</p><p>[5] Bahl, L. R., Jelinek, F., &amp; Mercer, R. L. (1983). A maximum likelihood approach to continuous speech recognition.</p><p>[6] Hochreiter, S., &amp; Schmidhuber, J. (1997). Long short-term memory.</p><p>[7] Bengio, Y., Ducharme, R., Vincent, P., &amp; Jauvin, C. (2003). A neural probabilistic language model.</p><p>[8] Collobert, R., &amp; Weston, J. (2008). A unified architecture for natural language processing: Deep neural networks with multitask learning.</p><p>[9] Mikolov, T., Chen, K., Corrado, G., &amp; Dean, J. (2013). Efficient estimation of word representations in vector space.</p><p>[10] Bahdanau, D., Cho, K., &amp; Bengio, Y. (2014). Neural machine translation by jointly learning to align and translate.</p><p>[11] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., … &amp; Polosukhin, I. (2017). Attention is all you need.</p><p>[12] Radford, A., Narasimhan, K., Salimans, T., &amp; Sutskever, I. (2018). Improving language understanding by generative pretraining.</p><p>[13] Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., &amp; Sutskever, I. (2019). Language models are unsupervised multitask learners.</p><p>[14] Brown, T. B. et al (2020). Language models are few-shot learners.</p><p>[15] Ouyang, T., &amp; Kwok, J. T. (2022). Training language models with human feedback.</p><p>[16] Zhuo, Z., Galhotra, S., Wijaya, A. S., Xia, R., &amp; Xie, T. (2023). Red toxicity: Societal implications of large-scale AI language models.</p><p>[17] OpenAI (2023). OpenAI GPT-4 Technical Report.</p><p>[18] Touvron, H. et al (2023). Llama 2: Open Foundation and Fine-Tuned Chat Models.</p><h4>A Message from AI Mind</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*5Wm7sOfTpe5DEbhg.gif" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://pub.aimind.so/">AI Mind Publication</a></li><li>🧠 Improve your <a href="https://www.aimind.so/prompt-generator?utm_source=pub&amp;utm_medium=message">AI prompts effortlessly and FREE</a></li><li><strong>🧰 Discover </strong><a href="https://www.aimind.so/?utm_source=pub&amp;utm_medium=message"><strong>Intuitive AI Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5d1e3f7e05c" width="1" height="1" alt=""><hr><p><a href="https://pub.aimind.so/chatgpt-how-did-we-get-here-a-brief-history-of-language-modelling-e5d1e3f7e05c">ChatGPT: How Did We Get Here? A Brief History of Language Modelling</a> was originally published in <a href="https://pub.aimind.so/">AI Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Words to Vectors: Understanding Word Embeddings via Neural Networks]]></title>
            <link>https://pub.aimind.so/from-words-to-vectors-understanding-word-embeddings-via-neural-networks-475470516a36?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/475470516a36</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[skip-gram]]></category>
            <category><![CDATA[word2vec]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 11:19:35 GMT</pubDate>
            <atom:updated>2023-09-07T18:47:40.945Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*ou8QkIhg7G4szxUjNFt0VQ.png" /><figcaption>Representing words in vector spaces. Image from <a href="https://www.baeldung.com/cs/dimensionality-word-embeddings">here</a>.</figcaption></figure><p>This article will present a concrete and simple implementation of how word embedding representations can be computed in a neural network. While there are many advanced and complex algorithms available, this example employs a straightforward approach for intuitive understanding. We will be using a simple two-layer neural network to create word embeddings.</p><p>First, we import the NumPy library and request the user for the sentence they want to embed and the dimension of the embedding. Here, the “corpus” is just a single sentence, but in real-world applications, it would be a large collection of texts.</p><pre>import numpy as np<br># Request user input for the sentence and embedding dimension<br>corpus = [input(&quot;Enter the sentence you want to embed: &quot;)]<br>embedding_dim = int(input(&quot;Enter the dimension of the embedding: &quot;))<br>print(&#39;&#39;)</pre><p>Next, we construct the vocabulary, which is simply the set of unique words in the corpus. These words are converted to lowercase and split to form a list.</p><pre># Constructing the vocabulary<br>words = &quot; &quot;.join(corpus).lower().split()<br>vocab = set(words)<br>vocab_size = len(vocab)<br><br>print(f&quot;Vocabulary size: {vocab_size}&quot;)<br>print(&#39;&#39;)</pre><p>We map each word to a unique index and vice versa. This step is essential for representing words as one-hot vectors and for retrieving words from their corresponding indices. One-hot vectors are vectors that have all their components equal to zero, except for one, which is equal to one.</p><pre># Mapping words to indices and vice versa<br>word_to_index = {w: i for i, w in enumerate(vocab)}<br>index_to_word = {i: w for i, w in enumerate(vocab)}</pre><p>Here, we define a function that converts a word into a one-hot vector.</p><pre># Function to convert a word to a one-hot vector<br>def word_to_one_hot(word):<br>    word_vec = np.zeros(vocab_size)<br>    word_vec[word_to_index[word]] = 1<br>    return word_vec</pre><p>Next, we initialize the weights of the neural network. The weight matrices W1 and W2 have dimensions that correspond to the size of the vocabulary and the chosen embedding dimension.</p><pre># Initializing the weights of the network<br>W1 = np.random.rand(vocab_size, embedding_dim)<br>W2 = np.random.rand(embedding_dim, vocab_size)<br><br>print(f&quot;Dimension of W1: {W1.shape}&quot;)<br>print(f&quot;Dimension of W2: {W2.shape}&quot;)<br>print(&#39;&#39;)</pre><p>The softmax function is used to transform the logits into probabilities.</p><pre># Softmax function<br>def softmax(x):<br>    e_x = np.exp(x - np.max(x))  # for numerical stability<br>    return e_x / e_x.sum(axis=0)</pre><p>The train function outlines the learning process of the network. In it, a forward pass and a backward pass are performed for each word in the corpus, considering the context of the word.</p><p>The weights of the network are updated according to the learning rate and the gradient of the error. The function returns the updated weight matrices after the specified number of epochs.</p><pre># Training function<br>def train(word_to_index, index_to_word, corpus, W1, W2, <br>          epochs=100, learning_rate=0.01):<br>    for epoch in range(epochs):<br>        loss = 0<br>        for sentence in corpus:<br>            sentence = sentence.lower().split()<br>            for i in range(len(sentence)):<br>                target = word_to_one_hot(sentence[i])<br>                context = [<br>                    word_to_index[sentence[j]] for j in range(<br>                        max(0, i - 2), min(i + 2, len(sentence) - 1) + 1) <br>                    if j != i<br>                    ]<br><br>                # Forward pass<br>                h = np.dot(W1.T, target)  # Hidden layer vector<br>                u = np.dot(W2.T, h)  # Logits<br>                y_hat = softmax(u)  # Probabilities<br><br>                # Calculating error<br>                e = np.copy(y_hat)<br>                e[context] -= 1<br><br>                # Backward pass<br>                dW2 = np.outer(h, e)<br>                dW1 = np.outer(target, np.dot(W2, e))<br><br>                # Updating the weights<br>                W1 -= learning_rate * dW1<br>                W2 -= learning_rate * dW2<br><br>                # Updating the loss<br>                loss += -np.sum([u[word] for word in context]) + \<br>                        len(context) * np.log(np.sum(np.exp(u)))<br><br>        print(f&#39;Epoch: {epoch+1}/{epochs}, Loss: {loss}&#39;)<br><br>    return W1, W2</pre><p>Finally, we train the network and, after training, the weight matrix W1 forms the embedding matrix we were seeking.</p><pre># Training the network<br>W1, W2 = train(word_to_index, index_to_word, corpus, W1, W2, <br>               epochs=15, learning_rate=0.01)<br><br># The embedding matrix is the W1 weight matrix<br>embeddings = W1<br>print(&#39;&#39;)<br>print(f&quot;Embedding Matrix: {embeddings.shape}&quot;)</pre><p>Here, we map each word in the sentence to its corresponding embedding. Each word from the corpus is now represented as a vector of the specified dimension that captures some of the semantic context of the word in the corpus.</p><pre># Mapping each word in the sentence to its corresponding embedding<br>for word in words:<br>    print(&#39;&#39;)<br>    print(f&quot;Word: {word}&quot;)<br>    print(f&quot;Embedding: {embeddings[word_to_index[word]]}\n&quot;)</pre><p>Now that we have walked through this example, we have a clearer and more concrete understanding of how word embedding representations are computed in a neural network. With these foundational concepts, we can explore more advanced and complex algorithms, like Word2Vec, GloVe, and transformer language models like GPT-3, which use the idea of word embeddings in more sophisticated ways.</p><p>You can access the Google Colab with the full implementation <a href="https://colab.research.google.com/drive/1iS8H9-WFrdE9kOWlaQYcBOdY6VemyJXW?usp=sharing">here</a>.</p><h4>A Message from AI Mind</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*5Wm7sOfTpe5DEbhg.gif" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://pub.aimind.so/">AI Mind Publication</a></li><li>🧠 Improve your <a href="https://www.aimind.so/prompt-generator?utm_source=pub&amp;utm_medium=message">AI prompts effortlessly and FREE</a></li><li><strong>🧰 Discover </strong><a href="https://www.aimind.so/?utm_source=pub&amp;utm_medium=message"><strong>Intuitive AI Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=475470516a36" width="1" height="1" alt=""><hr><p><a href="https://pub.aimind.so/from-words-to-vectors-understanding-word-embeddings-via-neural-networks-475470516a36">From Words to Vectors: Understanding Word Embeddings via Neural Networks</a> was originally published in <a href="https://pub.aimind.so/">AI Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[50 Best ChatGPT Plugins to Boost Your Life]]></title>
            <link>https://medium.com/@miltonleal/50-best-chatgpt-plugins-to-boost-your-interactions-b9a48930db36?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a48930db36</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Tue, 30 May 2023 18:00:05 GMT</pubDate>
            <atom:updated>2023-05-30T18:00:20.137Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DWV_lDFEp57-o4hLjOQp1g.png" /></figure><p>ChatGPT, powered by OpenAI’s advanced language model, offers users a versatile platform that can be enhanced with a variety of plugins. These plugins expand the capabilities of ChatGPT, allowing users to access a wide range of functionalities and services. From real-time cryptocurrency information to personalized book recommendations and even financial analysis, these plugins enhance the conversational experience and provide valuable tools. In this article, we will explore the 50 best ChatGPT plugins available, highlighting their unique features and how they can elevate your conversations to new heights.</p><ol><li>CoinCap: Get real-time cryptocurrency prices, market data, and insights from CoinCap.</li><li>Ai Tool Hunt: Explore a comprehensive global database of AI tools to find the ideal solution for your use case.</li><li>KalendarAI: Generate revenue by connecting with potential customers from over 200 million companies globally using KalendarAI sales agents.</li><li>Penrose Analyst: Stay up to date with the latest news by searching global news and research papers, and summarize Arxiv.org links.</li><li>ThemeParkHipster: Find waiting times for theme parks around the world, making your visits more efficient and enjoyable.</li><li>DEV Community: Discover recommended articles or users from the DEV Community platform tailored to your interests.</li><li>WordCloud: Create visually appealing word cloud images from text inputs, helping you visualize the most frequent terms.</li><li>Open Lecture: Access targeted learning by discovering and accessing specific moments in open course lectures.</li><li>Access Link: Quickly gather relevant data from any links on the web.</li><li>HaffPrice: Shop for various products at the lowest prices available in the market.</li><li>Keyword Explorer: Amplify your content optimization by exploring popular related keywords suggested by Keyword Explorer.</li><li>Tic Tac Toe: Challenge the AI to a game of Tic Tac Toe with varying board sizes.</li><li>edX: Expand your knowledge at any level by finding courses and content from leading universities.</li><li>ChatWithPDF: Interact with PDF books or Google Drive documents by providing a link to access and discuss their content.</li><li>Local by GoodCall: Discover and support nearby restaurants, shops, and services using Local by GoodCall.</li><li>Options Pro: Receive personalized options trading assistance to navigate market conditions.</li><li>Creature Generator: Generate random creatures and images for use in role-playing games.</li><li>Lexi Shopper: Receive product recommendations from your local Amazon store tailored to your preferences.</li><li>Podcast search: Explore podcasts from PodcastIndex.org, a decentralized platform for audio content discovery.</li><li>Abridged Due Diligence: Search recent SEC filings and access deeper analysis for due diligence purposes.</li><li>Uniket: Elevate your shopping experience with personalized recommendations and features from Uniket.</li><li>Kraftful: Consult with industry experts at Kraftful to gain insights on best practices and product development.</li><li>GoFynd: Find the best products that suit your needs and elevate your shopping experience with GoFynd.</li><li>ABCmouse: Engage children aged 2–8 years with fun and educational learning activities through ABCmouse.</li><li>World News: Stay informed by summarizing news headlines and accessing the latest news from various sources worldwide.</li><li>Giftwrap: Get gift ideas for any occasion and recipient, and have them wrapped and delivered hassle-free.</li><li>Turo: Search for the perfect Turo vehicle for your next trip.</li><li>Video Insights: Interact with online video platforms like YouTube or Daily Motion.</li><li>CT Criteria Parser: Analyze eligibility criteria in ClinicalTrials.gov for clinical research purposes.</li><li>Yabble: Obtain instant insights from any audience by asking questions and leveraging Yabble’s AI capabilities.</li><li>Tutory: Access affordable, on-demand tutoring and education services.</li><li>CreditYelp: Access essential financial calculators for detailed repayment schedules and payoff terms.</li><li>Zumper Rental Search: Find rental homes in the US and Canada.</li><li>Crafty Clues: Enjoy a word-guessing game with crafty clues generated by AI.</li><li>LawyerPR: Find your ideal lawyer in Japan by starting with a preliminary review.</li><li>AutoInfra1: Interact with your servers using AutoInfra1, which works with AWS, GCP, Azure, and more.</li><li>Paxi AI: Speed up your tasks with AI tools that help you find the right tool for the job.</li><li>Wolfram: Access computation, math, curated knowledge, and real-time data through Wolfram|Alpha and Wolfram Language.</li><li>KeyMate.AI Search: Browse the web and search using Google Search results with KeyMate.AI, an AI-powered web crawler.</li><li>VoxScript: Search YouTube transcripts, financial data sources, and Google Search results with VoxScript.</li><li>Bookworm: Receive personalized book recommendations from Bookworm’s AI-powered system.</li><li>ChatSpot: Access marketing and sales data, domain information, company research, and search keyword research.</li><li>B12 AI Websites: Create professional and engaging websites for your business in seconds using AI.</li><li>PlaylistAI: Create Spotify playlists for any prompt or mood.</li><li>Redfin: Get answers to questions about the housing market and gain insights to succeed in today’s market.</li><li>GameBase: Chat and get game information based on the latest gaming information in 2023, supporting multiple platforms.</li><li>Ambition: Search millions of jobs near you and find the perfect career opportunity.</li><li>Outschool: Discover top-quality online classes and teachers on Outschool.</li><li>Decision Journal: Become a better decision-maker by tracking and reviewing your past decisions.</li><li>Agones: Access soccer (football) results from matches played worldwide in the past 15 years.</li></ol><p>With these 50 best ChatGPT plugins, users can unlock a plethora of functionalities and services to enhance their conversational experience. From accessing real-time cryptocurrency information to personalized book recommendations, financial analysis tools, and even insights into clinical trials, these plugins showcase the diverse capabilities of ChatGPT. As the ChatGPT ecosystem continues to evolve, we can expect more exciting plugins in the future. So, dive into the possibilities and elevate your conversations with these incredible plugins for ChatGPT!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a48930db36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LangChain vs. Bitcoin: A Tale of Technological Ascendancy]]></title>
            <link>https://medium.com/@miltonleal/langchain-vs-bitcoin-a-tale-of-technological-ascendancy-cf82c81abebf?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf82c81abebf</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Fri, 19 May 2023 12:08:30 GMT</pubDate>
            <atom:updated>2023-05-19T12:12:13.483Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*yGQGKKZfUXbXx_KYhzaeLQ.png" /><figcaption>LangChain’s exponential popularity growth</figcaption></figure><p>In a world where the technological landscape is reshaped every few months, LangChain is a fresh wind of innovation that’s rewriting the rules of GitHub popularity. LangChain is a library designed to facilitate building large language model applications (using ChatGPT, for example), and its emergence on the scene has been nothing short of explosive.</p><p>In merely six months since its birth, the LangChain repository on GitHub has garnered over 40,000 stars — a number that took Bitcoin, the granddaddy of cryptocurrencies, almost a decade to achieve. To offer some perspective, Bitcoin, one of the most groundbreaking technological innovations of the 21st century, currently rests at around 70,000 stars after more than 14 years of evolution.</p><p>It’s true — comparing the number of stars on these two vastly different projects is somewhat akin to comparing apples and oranges. Yet, it’s a comparison that underscores the speed and degree of LangChain’s ascendancy and hints at the shifts in the technological zeitgeist.</p><p>*** This post has been written with the help of GPT-4.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf82c81abebf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[20 Practical Use Cases for ChatGPT in Business]]></title>
            <link>https://medium.com/@miltonleal/20-practical-use-cases-for-chatgpt-in-business-2f5402f35dab?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f5402f35dab</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[use-cases]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Sat, 13 May 2023 19:33:37 GMT</pubDate>
            <atom:updated>2023-05-13T19:34:26.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*wGx2cm4_Feldfoif-CmmJg.png" /></figure><p>The powerful language model developed by OpenAI, ChatGPT, has been put to use in a multitude of ways. It has shown incredible versatility, finding its place in diverse fields and tasks. With a model trained on a vast corpus of text, it has the ability to generate human-like text that can be leveraged to increase efficiency and effectiveness in businesses. Let’s dive into 20 practical use cases of ChatGPT, based on the experiences shared by companies on a Hacker News thread.</p><h3>1. Coding Assistant</h3><p>ChatGPT, with plugins like Code Genie for Visual Studio Code, can act as a coding assistant. It can aid in code refactoring, bug checks, and answering contextual coding questions, reducing the need to search for solutions on Google or StackOverflow.</p><h3>2. Translation</h3><p>Translating emails and documents for international customers can be easily managed using ChatGPT. This facilitates smoother communication with a global client base.</p><h3>3. Documentation</h3><p>ChatGPT can help generate markdown or formatted spec documents, providing verbose context for feature sprint kickoffs or public-facing help center documentation.</p><h3>4. Learning and Research</h3><p>ChatGPT is a great tool for learning and research. It can be used to ask questions about SQL queries, React patterns, SVG properties, or other technical topics, saving time compared to searching on Google.</p><h3>5. Policy and Procedures Documentation</h3><p>When it comes to compliance, ChatGPT can help generate templates for policy and procedures documents.</p><h3>6. Idea Generation</h3><p>During those times when creativity seems to elude us, ChatGPT can be used to generate ideas for various tasks.</p><h3>7. Learning New Technology</h3><p>ChatGPT can be a helpful tool in learning new languages, frameworks, libraries, or other technical areas, especially for beginners or generalists.</p><h3>8. Boilerplate Code Generation</h3><p>ChatGPT can generate boilerplate code for specific frameworks or libraries, especially when the exact syntax or best practices are not readily remembered.</p><h3>9. Shell Scripting</h3><p>ChatGPT can be used for generating shell scripts or providing starting points for specific operations.</p><h3>10. Automating Repetitive Tasks</h3><p>For tasks such as building pipelines or modifying configurations, ChatGPT can generate code or scripts to automate these repetitive tasks.</p><h3>11. Writing Assistance</h3><p>ChatGPT can generate content like emails, reports, and document templates. It can assist in rewording sentences, clarifying unclear sections, and providing ideas for related concepts.</p><h3>12. Job Descriptions</h3><p>ChatGPT can generate initial drafts for job descriptions or similar HR-related documents, making the task easier for HR teams.</p><h3>13. Design Tools</h3><p>ChatGPT can be used to create design tools, such as with P5.js, to solve specific problems or find balanced arrangements.</p><h3>14. Answering Questions and Providing Information</h3><p>ChatGPT can help in finding answers, explanations, or suggestions for various topics, such as movies, films, or electronic equipment.</p><h3>15. Privacy and Redaction</h3><p>ChatGPT can be used to scrub sensitive or private information before it is inputted into the model, ensuring privacy and mitigating risks.</p><h3>16. Content Creation</h3><p>For tasks like generating creative SEO titles, checking grammar, and assisting in writing articles, emails, and landing page copy, ChatGPT can be a great tool.</p><h3>17. Support and Chatbot Interactions</h3><p>GPT-based support can interact with users more effectively, thereby improving customer service experiences.</p><h3>18. Text Summarization</h3><p>ChatGPT can summarize papers, articles, or user feedback, saving time and aiding in gaining quick insights.</p><h3>19. Generating Insights</h3><p>ChatGPT can be used to extract insights and valuable information from user feedback, customer surveys, or other text data. This can help businesses understand their customers better and make informed decisions.</p><h3>20. Development Planning</h3><p>ChatGPT can be a valuable collaborator in development builds. It can aid in discussing architecture, tech stack, and even provide feedback to streamline the process.</p><p>The versatility of ChatGPT in various domains, including content creation, support, debugging, summarization, knowledge extraction, and development processes, is truly remarkable. These use cases only scratch the surface of what’s possible with this innovative technology. As ChatGPT continues to evolve and improve, we can expect even more exciting and impactful applications in the future.</p><p>*** This text has been generated by GPT-4. We summarized <a href="https://news.ycombinator.com/item?id=35846386">this discussion</a> on Hacker News.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f5402f35dab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Source LLMs vs. Paid APIs (ChatGPT): The Race for Large Language Model Supremacy]]></title>
            <link>https://medium.com/@miltonleal/open-source-llms-vs-paid-apis-chatgpt-the-race-for-large-language-model-supremacy-6da506018aa3?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6da506018aa3</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Mon, 08 May 2023 11:46:14 GMT</pubDate>
            <atom:updated>2023-05-08T11:47:49.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*VZtGeNRNGwfh3T3T8V5yyw.png" /></figure><p>Chip Huyen, a well-known figure in the AI community, recently started a thought-provoking debate on LinkedIn about the potential competition between large tech giants such as Google and OpenAI, and the open source community in producing more powerful large language models (LLMs). <a href="https://www.linkedin.com/posts/chiphuyen_llm-chatgpt-datascience-activity-7059964150499704832-0rf0/?utm_source=share&amp;utm_medium=member_android">The poll Huyen created</a> to gather opinions showed that 58% of participants believe open source will produce a stronger LLM within two years, while 42% think paid APIs like OpenAI and Google will continue to dominate.</p><p>Alan Ho questioned the capabilities of open source, citing the example of search engines, where Google’s dominance has remained unchallenged. Eric Kristoff responded by pointing out that the primary obstacle for open-source search engines is the cost of infrastructure, not the quality of the models themselves.</p><p>Chris Hoge suggested that open source could pull ahead, thanks to the diverse viewpoints and contributions from its community. He also noted the irony of large private efforts, such as those by Google, forming the foundation for open-source advancements.</p><p>Reem Al-Halimi acknowledged the pros and cons of both open source and paid APIs, stating that while paid APIs have the resources to ensure model safety and address security concerns, open source benefits from a community-driven approach to problem-solving. However, open-source models may face greater risks due to potential data poisoning and security vulnerabilities.</p><p>Ian Yu voted for open source but acknowledged the difficulty in quantifying what makes a model stronger. He cited the importance of techniques, funding, and volunteer work as factors that contribute to open source’s potential success.</p><p>Carlos Mercado expressed that although he believes paid APIs will produce stronger LLMs within the given timeline, open source will have a broader impact in terms of use and application.</p><p>Chandana Puthane highlighted the importance of considering potential risks, such as accountability and security vulnerabilities, as more people contribute to open-source projects. Aditya Ambadipudi argued that academia might be the key player in producing better quality LLMs, rather than individual open-source contributors.</p><p>Various users commented on the need for a clearer definition of “stronger LLM” and raised concerns over data quality and the importance of computational resources in the race for more powerful models.</p><p>In conclusion, the debate sparked by Chip Huyen’s LinkedIn post reflects the diverse opinions within the AI community on the future of LLMs. While some believe open source will ultimately triumph thanks to its collaborative nature, others think the resources and data advantages of large tech companies will keep them ahead in the race. Regardless of the outcome, the competition between these two camps will undoubtedly drive innovation and advancements in the field of AI.</p><blockquote><em>*** This text has been generated by GPT-4. We first extracted the LinkedIn comments and then asked the large language model to write a tech journalistic piece about the discussion. Minor corrections to the text have been made.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6da506018aa3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Expanding Universe of Language Models and ChatGPT: Exploring 60 Innovative Use Cases]]></title>
            <link>https://medium.com/@miltonleal/the-expanding-universe-of-language-models-and-chatgpt-exploring-60-innovative-use-cases-a47abd953d01?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a47abd953d01</guid>
            <category><![CDATA[language-model]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[generative-ai]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Fri, 05 May 2023 11:17:45 GMT</pubDate>
            <atom:updated>2023-05-05T11:40:19.440Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*TilCi0g_gNOkI26_kE3Qfw.png" /></figure><p>Language models have taken the world by storm, with their applications spanning diverse domains and sparking innovation at an unprecedented pace. In this article, we have a list of 60 intriguing use cases and projects that demonstrate the versatility and power of these models.</p><p>Our inspiration comes from the LangChain Share Your Work Discord channel, a thriving community of developers, researchers, and enthusiasts who are passionate about language models and their associated technologies.</p><p>As you browse through these projects, you’ll gain valuable insights into how these cutting-edge tools are reshaping the way we interact with data, communicate, and learn. Please note that this summary was generated using GPT-3 technology and may contain inaccuracies.</p><p>We encourage you to explore the provided links and descriptions and conduct your own research to fully appreciate the potential of these use cases. So, without further ado, let’s delve into the fascinating realm of language models and their remarkable applications!</p><ul><li><strong>Notion QA Chain</strong></li></ul><p>Description: Create a chain/tool to enable question-answering using Notion databases</p><p>Link: <a href="https://github.com/hwchase17/notion-qa">https://github.com/hwchase17/notion-qa</a></p><ul><li><strong>AI Code Debugger Chatbot</strong></li></ul><p>Description: Create a Chrome extension for a chatbot that helps with coding errors</p><p>Link: <a href="https://twitter.com/krrish_dh/status/1597655648946167808?s=20&amp;t=RSY76hfccdqz1xuc53XV7g">https://twitter.com/krrish_dh/status/1597655648946167808?s=20&amp;t=RSY76hfccdqz1xuc53XV7g</a></p><ul><li><strong>chatGPT with langchain on CNext</strong></li></ul><p>Description: Use chatGPT to generate data on the fly using AI knowledge</p><p>Link: <a href="https://youtu.be/UxL-WyAfq9E">https://youtu.be/UxL-WyAfq9E</a></p><ul><li><strong>Rick and Mortify: An AI Playground for Rick and Morty Storyboards</strong></li></ul><p>Description: Generate storyboards using generative AI</p><p>Link: <a href="https://medium.com/@turc.raluca/introducing-rick-and-mortify-a14e56a8cb67">https://medium.com/@turc.raluca/introducing-rick-and-mortify-a14e56a8cb67</a></p><ul><li><strong>SMS-based Interface for Chat GPT</strong></li></ul><p>Description: Create an executive assistant through text</p><p>Link: <a href="https://github.com/HighTopTito/langchain">https://github.com/HighTopTito/langchain</a></p><ul><li><strong>Clipboard Summary</strong></li></ul><p>Description: Read clipboard and show Messagebox with summary</p><p>Link: <a href="https://github.com/thepok/Clipsum">https://github.com/thepok/Clipsum</a></p><ul><li><strong>User Authentication &amp; Authorization System</strong></li></ul><p>Description: Create user authentication and authorization system with quota management</p><p>Link: <a href="https://django-plans.readthedocs.io/en/latest/">https://django-plans.readthedocs.io/en/latest/</a></p><ul><li><strong>GPT-J6b OpenAI API</strong></li></ul><p>Description: Hack transformers with FastAPI to accept OpenAI/completion POSTs</p><p>Link: <a href="https://github.com/fullstack/langchain">https://github.com/fullstack/langchain</a></p><ul><li><strong>Zero-Shot Corporate Lobbyist</strong></li></ul><p>Description: Generate data on the fly using AI knowledge</p><p>Link: <a href="https://github.com/JohnNay/gpt-lawyer/blob/main/notebooks/gpt_corporate_lobbying_zero_shot.ipynb">https://github.com/JohnNay/gpt-lawyer/blob/main/notebooks/gpt_corporate_lobbying_zero_shot.ipynb</a></p><ul><li><strong>Open Source Agent/Chatbot</strong></li></ul><p>Description: Use LLMs and Python/LangChain to build an open source example of what you can do with LangChain</p><p>Link: <a href="https://github.com/bborn/howdoi.ai">https://github.com/bborn/howdoi.ai</a></p><ul><li><strong>GPT 3.5 Express Inator</strong></li></ul><p>Description: Generate simple explanation of highlighted text using GPT-3</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/GPT-3.5-Express-inator">https://huggingface.co/spaces/JavaFXpert/GPT-3.5-Express-inator</a></p><ul><li><strong>Eliv - Explain Like I&#39;m Five</strong></li></ul><p>Description: Generate simple explanation of highlighted text using AI (GPT-3)</p><p>Link: <a href="https://www.producthunt.com/posts/eliv-explain-like-i-m-five">https://www.producthunt.com/posts/eliv-explain-like-i-m-five</a></p><ul><li><strong>PyTorch Implementation of T5</strong></li></ul><p>Description: Peer review of a PyTorch implementation of T5</p><p>Link: <a href="https://github.com/conceptofmind/t5-pytorch/blob/main/t5_pytorch.py">https://github.com/conceptofmind/t5-pytorch/blob/main/t5_pytorch.py</a></p><ul><li><strong>QQbot</strong></li></ul><p>Description: Generate data on the fly using AI knowledge</p><p>Link: <a href="https://twitter.com/danlovesproofs/status/1610073694222848007?s=46&amp;t=IVI0Ormv617pCJMRkR47xw">https://twitter.com/danlovesproofs/status/1610073694222848007?s=46&amp;t=IVI0Ormv617pCJMRkR47xw</a></p><ul><li><strong>Nim Game</strong></li></ul><p>Description: Human plays a GPT-3.5 powered AI</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/NimGPT-3.5">https://huggingface.co/spaces/JavaFXpert/NimGPT-3.5</a></p><ul><li><strong>GPT Corporate Lobbyist</strong></li></ul><p>Description: Determines if proposed Congressional bills are relevant to specific companies + provide explanations + confidence levels</p><p>Link: <a href="https://twitter.com/johnjnay/status/1610458033422729217">https://twitter.com/johnjnay/status/1610458033422729217</a></p><ul><li><strong>GPTDuck</strong></li></ul><p>Description: Question-answering against any Github repository</p><p>Link: <a href="https://twitter.com/garywupx/status/1611029873749000192?s=20&amp;t=JWzJTGNmxHL9A4CwvjRfDQ">https://twitter.com/garywupx/status/1611029873749000192?s=20&amp;t=JWzJTGNmxHL9A4CwvjRfDQ</a></p><ul><li><strong>Question/Answering Over a Github Repo</strong></li></ul><p>Description: Tap into the power of OpenAI to answer technical questions</p><p>Link: <a href="https://dagster.io/blog/chatgpt-langchain">https://dagster.io/blog/chatgpt-langchain</a></p><ul><li><strong>Conversational Agent Functionality</strong></li></ul><p>Description: Leverage multiple tools such as &#39;serpapi&#39;, &#39;pal-math&#39;, &#39;pal-colored-objects&#39;, &#39;news-api&#39;, &#39;tmdb-api&#39;, &#39;open-meteo-api&#39;</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain">https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain</a></p><ul><li><strong>Synthetic Data Generation</strong></li></ul><p>Description: Generate data on the fly using AI knowledge</p><p>Link: <a href="https://dagster.io/blog/chatgpt-langchain">https://dagster.io/blog/chatgpt-langchain</a></p><ul><li><strong>GitHub Support Bot</strong></li></ul><p>Description: Tap into the power of OpenAI to answer technical questions</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain">https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain</a></p><ul><li><strong>Conversational Agent Demo</strong></li></ul><p>Description: Build a conversational agent with GPT3, LangChain, and Python</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain">https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain</a></p><ul><li><strong>Enhanced Version of ChatGPT</strong></li></ul><p>Description: Connected to the internet, SlackHQ and NotionHQ, powered by LangChainAI</p><p>Link: <a href="https://twitter.com/nickscamara_/status/1614119034194100224">https://twitter.com/nickscamara_/status/1614119034194100224</a></p><ul><li><strong>Updated Chat-GPT-LangChain</strong></li></ul><p>Description: Leverage Whisper for STT and all of the AWS Polly voices for TTS</p><p>Link: <a href="https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain">https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain</a></p><ul><li><strong>Jackrabbit Ops</strong></li></ul><p>Description: AI general manager for businesses</p><p>Link: <a href="https://youtu.be/O3jmaLQ13HE">https://youtu.be/O3jmaLQ13HE</a></p><ul><li><strong>MyScale Vector Store</strong></li></ul><p>Description: High-performance SQL + Vector OLAP database built on ClickHouse</p><p>Link: <a href="https://myscale.com/">https://myscale.com/</a></p><ul><li><strong>BabyAGI and AutoGPT Agent</strong></li></ul><p>Description: AI agent with memory structure that closely mimics that of humans</p><p>Link: <a href="https://twitter.com/dory111111/status/1649352520790327300">https://twitter.com/dory111111/status/1649352520790327300</a></p><ul><li><strong>Enhancedocs</strong></li></ul><p>Description: AI-powered search engine for documentation as a service</p><p>Link: <a href="https://twitter.com/Alw3ys/status/1649430814852108292">https://twitter.com/Alw3ys/status/1649430814852108292</a></p><ul><li><strong>Autonomous AI-Agent Marketplace</strong></li></ul><p>Description: Marketplace of specialized autonomous AI-agent with each unique tools and skillset</p><p>Link: <a href="https://twitter.com/achammah1/status/1649482899253501958?s=46">https://twitter.com/achammah1/status/1649482899253501958?s=46</a></p><ul><li><strong>CAMEL with an Adversarial Twist</strong></li></ul><p>Description: Browser based version of CAMEL with an adversarial twist</p><p>Link: https://twitter.com/honeyimholm/status/1648813969837096963</p><ul><li><strong>Altermind</strong></li></ul><p>Description: Create personalized AI Entities with your data to help with specific tasks</p><p>Link: <a href="https://www.producthunt.com/posts/altermind">https://www.producthunt.com/posts/altermind</a></p><ul><li><strong>LetsAsk.AI</strong></li></ul><p>Description: ChatGPT with data on websites, Discord and more</p><p>Link: <a href="https://www.producthunt.com/posts/letsask-ai">https://www.producthunt.com/posts/letsask-ai</a></p><ul><li><strong>Zillion</strong></li></ul><p>Description: Python data modeling and analytics library with experimental natural language features</p><p>Link: <a href="https://github.com/totalhack/zillion">https://github.com/totalhack/zillion</a></p><ul><li><strong>Altermind.xyz</strong></li></ul><p>Description: AI-based customer service chatbot</p><p>Link: <a href="https://www.altermind.xyz/">https://www.altermind.xyz/</a></p><ul><li><strong>Netomi</strong></li></ul><p>Description: Customer support chatbot that can understand and retrieve data through private APIs</p><p>Link: <a href="https://www.netomi.com/">https://www.netomi.com/</a></p><ul><li><strong>Chat with documents</strong></li></ul><p>Description: Demo tool showcasing how to chat with any document (pdf, docx, txt) using langchain and weaviate as vector store</p><p>Link: <a href="https://github.com/ciocan/langchain-chat-with-documents">https://github.com/ciocan/langchain-chat-with-documents</a></p><ul><li><strong>AutoGPT on the Cloud</strong></li></ul><p>Description: Host AutoGPT on the cloud and use a frontend to interact with it</p><p>Link: <a href="https://www.agenthub.dev/?run_id=faa32b38-e4d0-4c0b-b8e6-3e3721b77a3c">https://www.agenthub.dev/?run_id=faa32b38-e4d0-4c0b-b8e6-3e3721b77a3c</a></p><ul><li><strong>Telegram Chat-Bot</strong></li></ul><p>Description: Create a custom Telegram chatbot based on a document or website using LangChain, GPT-3.5, and FAISS</p><p>Link: <a href="https://github.com/shamspias/langchain-telegram-gpt-chatbot">https://github.com/shamspias/langchain-telegram-gpt-chatbot</a></p><ul><li><strong>Django Backend</strong></li></ul><p>Description: Create a chatbot based on any PDF with LangChain, GPT3.5, and Pinecone</p><p>Link: <a href="https://github.com/shamspias/customizable-gpt-chatbot">https://github.com/shamspias/customizable-gpt-chatbot</a></p><ul><li><strong>Exemplary AI Platform</strong></li></ul><p>Description: Accurate transcription and AI-Assisted Editing &amp; Analysis platform</p><p>Link: <a href="https://exemplary.ai/">https://exemplary.ai/</a></p><ul><li><strong>Accurate Transcription and AI-Assisted Enhancements</strong></li></ul><p>Description: Transcribe audio and provide AI-assisted enhancements</p><p>Link: <a href="https://thimbleai.com/">https://thimbleai.com/</a></p><ul><li><strong>AI-Powered arXiv Paper Summarization</strong></li></ul><p>Description: Provide fast, accurate, and easy-to-read summaries of scientific papers</p><p>Link: <a href="https://www.summarizepaper.com/">https://www.summarizepaper.com/</a></p><ul><li><strong>GPT4-ExpertManager</strong></li></ul><p>Description: Language model prompt manager and library</p><p>Link: <a href="https://github.com/Bradybry/GPT4-ExpertManager">https://github.com/Bradybry/GPT4-ExpertManager</a></p><ul><li><strong>Contextual Compression</strong></li></ul><p>Description: Scrape web content and return document chunks most relevant to the search query</p><p>Link: <a href="https://github.com/prof-frink-lab/slangchain">https://github.com/prof-frink-lab/slangchain</a></p><ul><li><strong>Log10.io</strong></li></ul><p>Description: Tooling to help with logging, debugging and improving prompts in an LLM chaining context</p><p>Link: <a href="https://log10.io/">https://log10.io/</a></p><ul><li><strong>BacklinkGPT</strong></li></ul><p>Description: AI-powered platform that helps you generate personalized outreach messages for link-building campaigns</p><p>Link: <a href="https://backlinkgpt.com/">https://backlinkgpt.com/</a></p><ul><li><strong>Super Translator</strong></li></ul><p>Description: JSON translator for web app and chrome extensions</p><p>Link: <a href="https://super-translator.vercel.app/">https://super-translator.vercel.app/</a></p><ul><li><strong>ChatGPT Automation Code (Selenium)</strong></li></ul><p>Description: Tool to create interactive scripts automatically with ChatGPT on a web browser</p><p>Link: <a href="https://github.com/nguyenbinh0807/chatgpt_selenium">https://github.com/nguyenbinh0807/chatgpt_selenium</a></p><ul><li><strong>T3 + Plasmo + Clerk with Turborepo</strong></li></ul><p>Description: Monorepo for AI app development</p><p>Link: <a href="https://github.com/ibrahimyaacob/turborepo">https://github.com/ibrahimyaacob/turborepo</a></p><ul><li><strong>LLM Bootcamp Workshop</strong></li></ul><p>Description: One-day hands on workshop for LLM strategies and design patterns</p><p>Link: <a href="https://kono.io/bootcamp/">https://kono.io/bootcamp/</a></p><ul><li><strong>AgentLLM</strong></li></ul><p>Description: PoC for using browser-native LLMs in autonomous agents</p><p>Link: <a href="https://twitter.com/idosal1/status/1651577682302312449">https://twitter.com/idosal1/status/1651577682302312449</a></p><ul><li><strong>LangChain Chatbot</strong></li></ul><p>Description: Chatbot for talking to data with fast ingestion, chat history and no context lost</p><p>Link: <a href="https://github.com/Haste171/langchain-chatbot">https://github.com/Haste171/langchain-chatbot</a></p><ul><li><strong>PyCodeAGI</strong></li></ul><p>Description: Generate data on the fly using AI knowledge</p><p>Link: <a href="https://github.com/chakkaradeep/pyCodeAGI/">https://github.com/chakkaradeep/pyCodeAGI/</a></p><ul><li><strong>Livepeer</strong></li></ul><p>Description: Primary online resource for participants and users of the Livepeer network</p><p>Link: <a href="https://livepeer.org/">https://livepeer.org/</a></p><ul><li><strong>Self-Planning Code Generation with Large Language Model</strong></li></ul><p>Description: Generate code given an objective</p><p>Link: <a href="https://arxiv.org/abs/2303.06689">https://arxiv.org/abs/2303.06689</a></p><ul><li><strong>Langchain Chat</strong></li></ul><p>Description: Chatbot for talking to your data</p><p>Link: <a href="https://github.com/Haste171/langchain-chatbot">https://github.com/Haste171/langchain-chatbot</a></p><ul><li><strong>Preprocessing and QnA Bot</strong></li></ul><p>Description: Generate markdown summaries of python code and create a QnA bot to make it more capable of answering questions</p><p>Link: <a href="https://github.com/MarkEdmondson1234/langchain-github">https://github.com/MarkEdmondson1234/langchain-github</a></p><ul><li><strong>Accelerator to Chat and Ask</strong></li></ul><p>Description: Upload enterprise data and use Azure OpenAI services to chat to the data and ask questions</p><p>Link: <a href="https://github.com/akshata29/chatpdf">https://github.com/akshata29/chatpdf</a></p><ul><li><strong>Prompt Compression Algorithm</strong></li></ul><p>Description: Plug and play module to allow LLMs to deal with 2x more context without any finetuning/training</p><p>Link: <a href="https://github.com/liyucheng09/Selective_Context">https://github.com/liyucheng09/Selective_Context</a></p><ul><li><strong>HR AI Companion</strong></li></ul><p>Description: Feature-rich Slackbot + LangChain agent and a few tools</p><p>Link: <a href="https://github.com/trancethehuman/hr-gpt">https://github.com/trancethehuman/hr-gpt</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a47abd953d01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Probabilistic Inference: the Junction Tree Algorithm and the Chest-Clinic Problem]]></title>
            <link>https://medium.com/@miltonleal/probabilistic-inference-the-junction-tree-algorithm-and-the-chest-clinic-problem-66241417addc?source=rss-91ee35ce981b------2</link>
            <guid isPermaLink="false">https://medium.com/p/66241417addc</guid>
            <category><![CDATA[belif-propagation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bayesian-networks]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Milton Leal]]></dc:creator>
            <pubDate>Sun, 18 Dec 2022 22:12:04 GMT</pubDate>
            <atom:updated>2022-12-18T22:12:04.229Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This piece is an assignment of the course </em><a href="https://uspdigital.usp.br/jupiterweb/obterDisciplina?sgldis=MAP2314&amp;codcur=45070&amp;codhab=4"><em>MAP2314</em></a><em> (Information Systems Theory, Bayesian Inference and Machine Learning) lectured by Professor </em><a href="https://www.ime.usp.br/~rvicente/"><em>Renato Vicente</em></a><em> at the</em><a href="https://www.ime.usp.br/en/home/"><em> Institute of Mathematics and Statistics of the University of São Paulo</em></a><em> in 2022. All mistakes are my own.</em></p><h3>1. Arrival</h3><p>In this article, we will delve into the Junction Tree algorithm and its role in making inferences on probabilistic graphical models. Probabilistic graphical models are a powerful tool for representing and reasoning about uncertain relationships between variables, and the Junction Tree algorithm is a key technique for efficiently making inferences on these models.</p><p>We will begin by reviewing the concept of Belief Networks and introducing the Chest-Clinic problem, a classic example first proposed by S. Lauritzen and D. Spiegelhalter in 1988 [1]. This problem will serve as a case study throughout the article, allowing us to demonstrate the different techniques and algorithms we will discuss.</p><p>Next, we will introduce the Variable Elimination technique, a general but inefficient method for an inference that can be used to compute probabilities. We will then introduce the concept of a factor graph and how it can be used in conjunction with the Belief Propagation algorithm to make efficient computations on tree-structured graphs. However, we will also discuss the limitations of directly applying the Belief Propagation algorithm to graphs that contain cycles.</p><p>Finally, we will explain how to construct a Junction Tree and show a computational implementation in R that can be used to query the Chest-Clinic network efficiently.</p><h3>2. Belief Networks</h3><p>A Belief Network, also known as a Bayesian Network, is a probabilistic model that uses a graph to represent the relationships between different variables.</p><p>The nodes in the graph represent variables, and the edges represent dependencies between these variables. Nodes that are connected are conditionally dependent on each other, while nodes that are not connected are assumed to be conditionally independent of each other. This allows the model to capture complex relationships between variables and make predictions based on this structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Lf8RBAMHBv-zFca6FRs4qA.png" /><figcaption>A simple Bayesian Network with conditional probability tables. Image from Wikipedia.</figcaption></figure><p>As defined by D. Barber [2], a Belief Network is represented as a directed acyclic graph (DAG) with nodes corresponding to the conditional probability of a variable given its parental variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*NNBoRRMR8t5DYp9DLbWWQg.png" /></figure><p>This allows probability operations such as marginalizing and conditioning to be represented as operations on the graph, and details about the model can be “read” from the graph.</p><p>It’s important to note that Belief Networks cannot capture all possible relationships between variables. However, they are well-suited for representing “causal” relations [2] and are useful for representing probabilistic relationships between diseases and symptoms. Given a set of symptoms, the network can be used to compute the probabilities of various diseases.</p><p>In terms of computational efficiency, Belief Networks are beneficial as the possible ways in which variables can interact are extremely large. Independently specifying all entries of a joint probability distribution over binary or multi-state variables would take exponential space, making it intractable. By leveraging known independence relations, we can drastically reduce the number of computations required for inference tasks.</p><p>In this article, we will be limited to discussing discrete variables with finite state spaces. However, these ideas can be generalized to continuous random variables, though the complexity increases significantly.</p><h3>3. Chest-Clinic Problem</h3><p>The chest clinic problem, as presented in [1], is a small fictitious example of medical knowledge that is rich enough to explore several aspects of inference on graphs. The scenario is as follows:</p><blockquote>Shortness-of-breath (dyspnoea) may be due to tuberculosis, lung cancer or bronchitis, or none of them, or more than one of them. A recent visit to Asia increases the chances of tuberculosis, while smoking is known to be a risk factor for both lung cancer and bronchitis. The results of a single chest X-ray do not discriminate between lung cancer and tuberculosis, as neither does the presence or absence of dyspnoea.</blockquote><p>Graphically, we are representing variables by nodes and using arrows to formalize a relationship expressed in the narrative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*sF6Q7D_LTjgNlM0WqW2Qkw.png" /><figcaption>The Chest-Clinic Belief Network. Image from [3]</figcaption></figure><p>Based on the Belief Network definition, we can write the following factorization of the joint probability distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*FiNeYh-OBWh8dynZGsjn8A.png" /></figure><p>where a = Asia, t = Turbeculosis, x = X-ray, e = either, d = Dyspnoea, l = Lung cancer, b = Bronchitis, s = Smoking.</p><p>For every term in the factorization, one must specify an initial conditional probability table (CPT), which relates in this case to the previous knowledge that doctors have about the scenario. Below we have the CPT given in [1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*HNxxPN-2xQFXbW-qa-TNBg.png" /></figure><h4>3.1 Querying The Network</h4><p>The chest clinic problem is a scenario in which a doctor would like to determine the likelihood of different diseases given certain observations. In this case, the patient has visited Asia recently and is experiencing dyspnoea.</p><p>The doctor would like to know the probability of each disease but does not yet have information about the patient’s smoking history or the results of a chest X-ray. The doctor also wants to know how the probabilities would change if tuberculosis were ruled out by another test, and which piece of information (smoking history or X-ray) would provide the most information about cancer, given that smoking may “explain away” the dyspnoea due to the possibility of bronchitis. Finally, the doctor wants to know which factors were most influential in forming a judgement once all the information is available.</p><h3>4. Variable Elimination</h3><p>Variable Elimination (VE) is a simple and general exact inference algorithm used in probabilistic graphical models, such as Belief Networks and Markov Random Fields.</p><p>VE can be used for a variety of tasks, including the inference of the maximum a posteriori (MAP) state or the estimation of conditional or marginal distributions over a subset of variables. The algorithm has exponential time complexity but can be efficient in practice for low-treewidth graphs if the proper elimination order is used.</p><p>Below is an example of using VE to compute the marginal distribution p(d) by pushing summations inwards and computing CPTs. VE takes advantage of the <a href="https://en.wikipedia.org/wiki/Generalized_distributive_law">Generalized Distributive Law</a> in order to perform these calculations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*z0yeUiIqR0KzSoR3RHgvyg.png" /><figcaption>Kudos to <a href="https://rpubs.com/tomasu/math8670_hw3">Thomas Flaherty</a> for showing the calculations</figcaption></figure><p>Although VE is a simple and intuitive technique, it is not feasible to use in practice when dealing with a large number of variables. That is because if we want to ask the model for another query, we need to restart the algorithm from scratch.</p><p>Depending on the graph&#39;s structure, alternative algorithms such as Belief Propagation (BP) may be more effective. We will discuss this algorithm briefly later but first, we will explore how to convert a directed graph into an undirected graph of factors.</p><h3>5. Factor Graphs</h3><p>It is important to note that the DAG is only used to provide a simple and transparent way of specifying a probability model, while the simplification in computations is based on exploiting conditional independencies in an undirected graph. This means that methods for building undirected graphical models can be used to construct probabilistic inference machines [4].</p><p>Factor graphs are a useful representation of probabilistic graphical models that allow us to apply the Belief Propagation algorithm to compute marginal and conditional marginal distributions of the variables in the graph.</p><p>A factor graph is a bipartite graph that represents the dependencies and independencies between the variables in a graphical model, with one set of nodes representing the variables and the other set of nodes representing the factors or potential functions that define the conditional dependencies between the variables. In the context of the Chest-Clinic belief network, a factor graph can be constructed by representing each variable as a node and each conditional probability table (CPT) as a factor.</p><h4>5.1 Building a Factor Graph</h4><p>To build a factor graph out of a belief network, you can follow these steps:</p><ol><li>Identify the variables and their dependencies in the belief network.</li><li>For each variable, create a node in the factor graph.</li><li>For each dependency between variables, create a factor in the graph that depends on both variables. The factor should be a function of the variables, representing the conditional probability of one variable given the other(s).</li><li>Connect the nodes and factors in the factor graph according to the dependencies between the variables. Each factor should be connected to the variables it depends on, and each variable should be connected to the factors that depend on it.</li></ol><p>Below we show the factor graph for the Chest-Clinic problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*BhaAKauiUImQ4EgDeI0njQ.png" /><figcaption>Note that this factor graph has a cycle</figcaption></figure><h3>6. Belief Propagation</h3><p>The Belief Propagation algorithm, also known as sum-product message passing, is an algorithm for performing inference on graphs. It calculates the marginal distribution for each unobserved node, conditional on any observed nodes (or variables). This algorithm is commonly used in artificial intelligence and information theory and has demonstrated success in numerous applications, including low-density parity-check codes, turbo codes, free energy approximation, and satisfiability [1].</p><p>BP was first proposed by Judea Pearl in 1982, who initially formulated it as an exact inference algorithm on trees. It was later extended to polytrees. While the algorithm is not exact on general graphs (i.e. graphs that are not trees), it has been shown to be a useful approximate algorithm.</p><p>If the factor graph has no cycles, which means that the graph is a tree (which is not the case in our problem), then the Belief Propagation algorithm can be applied to make exact inferences in a computationally tractable manner.</p><p>If, on the other hand, the factor has a cycle, Belief Propagation can still be applied, but it can sometimes produce inaccurate results, due to the presence of so-called “loopy” beliefs. Loopy beliefs refer to the fact that messages can pass through a cycle multiple times, which can lead to over-counting or under-counting of certain paths and ultimately result in inaccurate marginal probabilities.</p><p>BP works by passing messages between nodes in the graph, with each node representing a variable and each edge representing a dependency between the two connected variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*-g_X6jrF4fQffLKJcMecEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*S04_akE_3m17E-WlwOE_uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*jyRA_ET0lvZUj10yggAX_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*SsPL5QpGlXZms0DtuQRMoA.png" /></figure><p>The algorithm iteratively updates the messages that each node sends to its neighbours based on the messages that it has received from its other neighbours. The messages sent by a node represent the beliefs of that node about the values of its neighbouring nodes. These messages are updated using the sum-product rule, which takes into account the dependencies between the variables as represented by the edges in the graph.</p><p>Once all of the messages have been updated, the algorithm uses the final messages to compute the marginal distribution for each unobserved node, which represents the probability of that node taking on a particular value given the observed values of the other nodes in the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*ZfTUNrKjqcMqi57RmErduA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*ZW_wnalzGEt7_Tdw3wLMTQ.png" /></figure><h3>7. Junction Tree</h3><p>Because our Chest Clinic example has a cycle in its factor graph, we can take our original Belief Network and turn it into a Junction Tree, which is a type of graph that encodes the structure of a probabilistic graphical model in a way that makes it amenable to exact inference using the sum-product algorithm.</p><p>This algorithm will first execute two runs of the VE algorithm to initialize a particular data structure holding a set of pre-computed factors. Once the structure is initialized, it can answer marginal queries in O(1) time [6].</p><p>Junction trees are tree-structured graphs in which the nodes represent subsets of the random variables in the original graphical model, and the edges represent the conditional dependencies between these subsets of variables. The process of transforming a graphical model into a junction tree typically involves two steps: moralization and triangulation.</p><p>The key to making efficient computations with networks is:</p><ol><li>to utilize the modular structure of the model so that computations can be made locally and;</li><li>to use the graph for identifying this modular structure. By making local computations we mean that multiplications/summations are carried out locally in an order such that the distributive law can be employed. [5]</li></ol><p>To understand how to proceed with computations, let’s adopt the notation from [1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*Hs90OqixS-R30KQlKMLLcw.png" /><figcaption>In our case, V is the set of all 8 variables and pa(v) is the parent of node v.</figcaption></figure><p><em>Equation 1:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*S7FWbdhav5CRStx1ALL6EQ.png" /><figcaption>Our factorized joint probability distribution</figcaption></figure><h4>7.1 The Moral Graph</h4><p>One way of keeping track of the sets of variables in the CPTs is through the moral graph. The moral graph of a DAG is obtained by adding edges between all parents of each node and then dropping the directions of the edges. The name “moral graph” comes from the fact that two nodes that have a common child are connected by an edge as if they are “married” in some sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*N7P664KY94Jm0AcUozgsaQ.png" /><figcaption>The Chest Clinic Moral Graph</figcaption></figure><p>The terms p(v|pa(v)) may be seen as functions of v ∪ pa(v). It then follows that the factorized version of p(V ) has interactions only among neighbours in the moral graph. We shall exploit this for the chest clinic example by writing</p><p><em>Equation 2:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*brvB9Phu1G5KKiz-C5vIsA.png" /></figure><p>where ψ(τ, α) = p(α)p(τ |α), ψ(λ, σ) = p(σ)p(λ|σ), ψ(β, σ) = p(β|σ), ψ(e, τ, λ) = p(e|τ, λ), ψ(δ, e, β) = p(δ|e, β) and ψ(ξ,e) = p(ξ|e). The ψ functions are called by [1] as evidence potentials.</p><p>To find the marginal p(d, a), for example, we need to sum over all other variables. We are interested in making these summations locally so that we do not create new potentials defined over variables which are not neighbours in the moral graph. In order to do that, we need to triangularize the graph.</p><h4><strong>7.2 Triangulation</strong></h4><p>The summations in a moral graph can be carried out in such a way that no new functions are created if and only if the moral graph is triangulated. A graph is triangulated if it has no cycles of length 4 or greater without a chord. If a graph is not triangulated, it can be made so by adding additional edges, known as fill-ins. When a moral graph is triangulated, it is possible to find an ordering in which the summations can be performed without creating any new functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*TEfFFfgFtHh0pQW15KXJWw.png" /><figcaption>An edge between bronchitis and lung cancer was added</figcaption></figure><p>We may now write:</p><p><em>Equation 3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*i49iSEiGCp8SK-y9FeBGFg.png" /></figure><p>where ψ(λ, β, σ) = p(σ)p(λ|σ)p(β|σ), ψ(e, β, λ) = 1 and all other potentials are as defined in connection with <em>Equation 2</em>.</p><p>The representation in <em>Equation 3</em> is called a clique potential representation</p><h4><strong>7.3 Different Representations of the Joint Distribution</strong></h4><p>To make calculations efficient, it is helpful to convert the representation of a clique’s potential into a representation of the clique’s marginal. To understand this process, we will introduce some graph theory concepts from [5].</p><p>In an undirected graph, the neighbours of a vertex v_i are referred to as bd(v_i).</p><p>A set of variables in an undirected graph is considered complete if there is an edge between every pair of variables in the set.</p><p>A numbering of the vertices v_1, v_2, …, v_k is considered perfect if, for each i, the set {v_1, …, v_{i-1}} intersected with bd(v_i) is complete.</p><p>An undirected graph is considered triangulated if its vertices can be given a perfect numbering, which can be found using the Maximum Cardinality Search algorithm.</p><p>This algorithm assigns the number 1 to any node and then iteratively assigns the next number to the node with the most previously numbered neighbours. If the resulting numbering is perfect, the graph is triangulated. If the graph is not triangulated, it can be made so by adding extra edges, called fill-ins.</p><p>An ordering of the cliques C_1, C_2, …, C_T in an undirected graph has the Running Intersection Property (RIP) if S_j, which is defined as the intersection of (C_1 ∪ … ∪ C_{j-1}) and C_j, is contained within one or more of the cliques C_1, …, C_{j-1}.</p><p>In a RIP ordering, one clique (e.g. C_k) is chosen as the parent clique of C_j, while C_j is the child of C_k. S_j is called the separator, and R_j, which is defined as C_j minus S_j, is called the residual. S_1 is defined as an empty set. It can be proven that the cliques of a graph have a RIP ordering if and only if the graph is triangulated.</p><p>A RIP ordering can be found by ordering the cliques based on the highest number assigned to the vertices in each clique using the Maximum Cardinality Search algorithm.</p><p>The table below shows the RIP ordering of the cliques of the triangulated moral graph for the chest clinic example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*8PpoxadzovFKZdiYbesoPA.png" /></figure><h4><strong>7.4 The Junction Tree</strong></h4><p>The RIP ordering of the cliques can be represented as a DAG which we call a junction tree with C_1 as the root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*Zz-mULuMawHOOJv3P7V3yg.png" /></figure><p>More generally we may (following the steps illustrated above) obtain a clique potential representation of p(V ) as</p><p><em>Equation 4</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*14B0NaNhWuUrXgQ_BHbGgw.png" /></figure><p>where C_1, C_2, . . . , C_T are the cliques of the triangulated moral graph.</p><p>Notice that <em>Equation 1</em> can be seen as a way of specifying a complex joint distribution through simpler terms, a collection of CPTs. However, these CPTs are only used for establishing the clique potential representation in <em>Equation 4</em>. Once this representation is established, the CPTs are of no further use.</p><h4><strong>7.5 Obtaining Set Chain Marginals and Clique Marginals</strong></h4><p>In order to easily obtain the Clique Marginals, we need an intermediate step, which is to obtain the Set Chain Marginals as [1] calls.</p><p>It can be shown, using the concept of absorption, that we may write:</p><p><em>Equation 5</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*VdI9Zp4bOp2LG1v3VS_U4A.png" /></figure><p>We call the equation above as the set chain representation.</p><p>Next, it can be shown that the clique marginal representation will be the following</p><p><em>Equation 6</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*5e2PBbH1HL50oIfCYyO6Bw.png" /></figure><p>Based on the clique marginal representation, the marginal probabilities of each node can be found by summing out the other variables.</p><p>In [1] we have all calculations for the different representations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HT-gjnE8wfoahprvZ1C3kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*06VvzIcBIynxUtdjGEgH0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZONA5GzwWwAZa0B_6LVLHA.png" /></figure><h4><strong>7.6 Propagating Evidence</strong></h4><p>In the junction tree algorithm, evidence is absorbed into the junction tree by modifying the potentials (probabilities) associated with the cliques in the tree. Specifically, this process is known as “propagating evidence”.</p><p>The process of propagating evidence through a junction tree involves the following steps:</p><ol><li>Identify the cliques in the junction tree that contain the variables for which evidence is available.</li><li>For each of these cliques, modify the clique potentials to reflect the evidence. This is typically done by setting the probabilities of the variables for which evidence is available to 1, and the probabilities of the other variables to 0.</li><li>Propagate the modified clique potentials through the junction tree using the rules of probability. This involves multiplying the modified clique potentials by the separator potentials associated with the edges between the cliques, and summing over the variables that are not in the clique.</li><li>Repeat the process for each clique in the junction tree until the evidence has been propagated throughout the entire tree.</li></ol><h4><strong>7.7 Answering Queries</strong></h4><p>After the evidence has been propagated through a junction tree, the modified clique potentials can be used to answer queries about the variables in the graphical model.</p><p>There are several approaches to answering queries using a junction tree, such as Variable Elimination and the Sum-Product Message Passing algorithm.</p><p>These approaches allow us to use the modified clique potentials, which have been computed after propagating the evidence through the junction tree, to answer queries about the variables in the graphical model.</p><p>The process of propagating evidence through the junction tree incorporates the available evidence into the probabilities associated with the cliques in the tree, enabling more accurate inferences about the variables in the graphical model.</p><h3>8. Computational Implementation</h3><p>As shown by [4], a simple way of specifying the network for the chest clinic is by using the gRain package in the R language. It is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*TDPNXLTgkfuiJO2MTZyurQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*atymWCpjqGWNyDkngsxcVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*5wMM7nbGcw6oFxpURHnF9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*A5zfvNFpHjH0sKxtHw3vlw.png" /><figcaption>These are marginal probabilities for Lung Cancer and Bronchitis variables</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*2v2lp9nm-jz_nRPr8iNg6A.png" /><figcaption>Telling the network that a patient who has been to Asia is facing Dyspnoea</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*BObTN6cA7oazfrVwwKK6uA.png" /><figcaption>Updated probabilities for Lung Cancer and Bronchitis after incorporating evidence</figcaption></figure><h3>9. Final Thoughts</h3><p>In this article, we explored the Junction Tree algorithm and its role in making inferences on probabilistic graphical models. We began by reviewing the concept of Belief Networks and introducing the Chest-Clinic problem, a classic example used to demonstrate different techniques and algorithms. We then introduced the Variable Elimination technique and the concept of a factor graph and discussed the limitations of directly applying the Belief Propagation algorithm to graphs that contain cycles.</p><p>Finally, we explained how to construct a Junction Tree and showed a computational implementation in R that can be used to solve the Chest-Clinic problem efficiently, even for graphs that contain cycles. We also demonstrated how to use the Sum-Product technique to answer queries about the variables in the graphical model using the modified clique potentials computed after propagating the evidence through the junction tree.</p><p>Overall, the Junction Tree algorithm is a powerful tool for making inferences on probabilistic graphical models, and understanding its principles and techniques can help us make more accurate predictions and decisions in a variety of contexts.</p><h3>9. References</h3><p>[1] S. Lauritzen &amp; D. Spiegelhalter (1988). Local Computations with Probabilities on Graphical Structures and Applications to Expert Systems.</p><p>[2] D. Barber (2007). Bayesian Reasoning and Machine Learning.</p><p>[3] Denis D. Mauá (2016). <a href="https://www.ime.usp.br/~ddm/courses/mac6916/">MAC6916 Probabilistic Graphical Models</a></p><p>[4] S. Højsgaard, D. Edward &amp; S. Lauritzen (2012). Graphical Models with R.</p><p>[5] S. Højsgaard. Graphical Independence Networks with the gRain package for R</p><p>[6] <a href="https://ermongroup.github.io/cs228-notes/inference/jt/">https://ermongroup.github.io/cs228-notes/inference/jt/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66241417addc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>