<?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 Jessica López Espejel on Medium]]></title>
        <description><![CDATA[Stories by Jessica López Espejel on Medium]]></description>
        <link>https://medium.com/@jessica_lopez?source=rss-e70682b5a78f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b0u8mNH3KdjGb66kJVwoPA.jpeg</url>
            <title>Stories by Jessica López Espejel on Medium</title>
            <link>https://medium.com/@jessica_lopez?source=rss-e70682b5a78f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:56:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jessica_lopez/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[Time series and MLLMs]]></title>
            <link>https://medium.com/@jessica_lopez/time-series-and-mllms-9970a9c336c7?source=rss-e70682b5a78f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9970a9c336c7</guid>
            <dc:creator><![CDATA[Jessica López Espejel]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 18:25:16 GMT</pubDate>
            <atom:updated>2025-08-20T18:25:16.911Z</atom:updated>
            <content:encoded><![CDATA[<p>The present blog is inspired by the paper entitled “<strong>Position: Empowering Time Series Reasoning with Multimodal LLMs</strong>” [<a href="https://arxiv.org/pdf/2502.01477">Kong et al., 2025</a>].</p><h4>Background of reasoning techniques in Large Language Models (LLMs)</h4><p>The ability to reason is a key part of human thinking. It helps us solve problems, make decisions, and think carefully. People still debate how well Large Language Models (LLMs) can really reason. Many researchers show that we can <strong>encourage</strong> LLMs to behave more like reasoning systems by using certain techniques. Below are the main ones:</p><ol><li><strong><em>Chain-of-Thought (CoT)</em> [</strong><a href="https://arxiv.org/pdf/2201.11903"><em>Wei et al., 2023</em></a><strong>]</strong></li></ol><ul><li><strong>What it is </strong>: Ask the model to show its internal steps before giving the final answer.</li><li><strong>Why it helps </strong>: <em>Breaking the problem into steps </em>helps the model reach a correct answer more often.</li><li><strong>How to prompt </strong>: Give an instruction like “<em>Show your reasoning step by step</em>.” or <strong>include example</strong> step-by-step solutions (<em>few-shot</em>).</li><li><strong>Example using few-shot:</strong></li></ul><p>Q: Ana and Pedro’s ages add up to 30. Ana is 6 years older than Pedro. How old is Ana? <br>S: <em>Let Pedro= x. Then Ana = x + 6. So x + (x + 6) = 30 → 2x + 6 = 30 → 2x = 24 → x = 12. Ana = 12 + 6 = 18</em>. Final answer: 18.</p><p>Q: Jessica bought 2 kg of apples. Each kilogram contains 5 apples. If she ate 2 apples, how many apples are left?</p><p>S: <em>Let total apples = 2 × 5 = 10. She ate 2 apples, so apples left = 10 − 2 = 8</em>. Final answer: 8.</p><p>2. <strong><em>“Let’s think step by step”</em> [</strong><a href="https://arxiv.org/pdf/2205.11916"><em>Kojima-style prompt</em></a><strong>]</strong></p><ul><li><strong>What it is </strong>: A short prompt nudge that tells the model to reason out loud.</li><li><strong>Why it helps</strong>: Triggers a chain-of-thought even with zero examples.</li><li>Note: It is a simple version of CoT. It can help a lot but is sensitive to wording.</li></ul><p>3. <strong>Few-shot CoT / Example-based prompting [</strong><a href="https://arxiv.org/pdf/2201.11903"><em>Wei et al., 2023</em></a><strong>]</strong></p><ul><li><strong>What it is</strong>: Give one or more worked examples that show step-by-step thinking, then ask a new question.</li><li><strong>Why it helps</strong>: The model imitates the example style and gives step-by-step answers for new problems.</li></ul><p>4.<strong> <em>Self-consistency</em> [</strong><a href="https://arxiv.org/pdf/2203.11171">Wang et al., 2023</a><strong>]</strong></p><ul><li><strong>What it is</strong>: Ask the model to produce many CoT answers (sample several times), then pick the most common final answer.</li><li><strong>Why it helps</strong>: It reduces errors from one strange chain of thought.</li><li><strong>Short idea</strong>: If 5 runs give answers [18, 18, 17, 18, 19], choose 18.</li></ul><p>5. <strong><em>Tree of Thoughts (simple idea)</em> [</strong><a href="https://arxiv.org/pdf/2305.10601">Yao et al., 2023</a><strong>]</strong></p><ul><li><strong>What it is </strong>: Explore several reasoning paths in parallel, keep the best ones, continue expanding them.</li><li><strong>Why it helps </strong>: It avoids getting stuck on one bad line of thinking. Good for harder puzzles or planning.</li><li><strong>Note :</strong> This is more expensive (it needs many model calls) but can find better solutions.</li></ul><p>6.<strong> <em>ReAct (Reason + Action) </em>[</strong><a href="https://arxiv.org/pdf/2210.03629">Ya et al., 2023</a><strong>]</strong></p><ul><li><strong>What it is</strong>: Let the model alternate between reasoning and actions (like searching, calling tools, or reading data). Use it in the agents.</li><li><strong>Why it helps</strong>: The model can gather facts or run small tools while it reasons. This makes answers more accurate for tasks that need external info.</li></ul><p>7.<strong> Program-Aided methods (PAL) [</strong><a href="https://arxiv.org/pdf/2211.10435">Gao et al., 2023</a><strong>]</strong></p><ul><li><strong>What it is</strong>: Ask the model to write short code (for example, Python) to compute exact results, then run that code.</li><li><strong>Why it helps</strong>: The model offloads precise calculation to code, avoiding numeric mistakes.</li><li><strong>Example prompt</strong>: “Write a short Python program that computes the correct sum and return only the number.”</li></ul><h4>From Reasoning in LLMs to Reasoning in MLLMs (Multimodal Large Language Models)</h4><p>These techniques <strong>were first developed and tested in LLMs</strong> to improve their ability to solve complex tasks. These methods help models break down problems, reduce errors, and produce more consistent answers. As Multimodal Large Language Models (MLLMs) emerged — capable of processing not only text but also images, audio, and numerical data — researchers began <strong>adapting these reasoning strategies to them</strong>.</p><p>The motivation is clear: MLLMs often need to combine insights from different data types, align information over time, and handle tasks that require both interpretation and precise calculation. <em>By bringing established reasoning approaches from LLMs into MLLMs</em>, <strong>models can better analyze and explain complex multimodal patterns, such as those found in time series data</strong>.</p><p>However, it is not an easy task because MLLMs face unique challenges. Some of them are mentioned in the following list.</p><h4>Challenges of Applying Reasoning Techniques to MLLMs for Time Series</h4><ul><li><strong>Multimodal alignment</strong> — Combining and synchronizing information from text, images, and numerical sequences is complex, especially when temporal order matters.</li><li><strong>Long sequences</strong> — Context windows are limited, so very long time series or reasoning chains can be truncated.</li><li><strong>Exact numbers</strong> — Models often make mistakes in precise arithmetic or when handling many-digit numbers.</li><li><strong>Prompt sensitivity</strong> — Small wording changes in prompts can lead to very different answers.</li><li><strong>No true memory</strong> — MLLMs cannot persistently store and recall information like a traditional program; earlier details may be forgotten in long reasoning steps.</li><li><strong>Noise and concept drift</strong> — Changing patterns or noisy data can confuse models, especially without specialized time-series architectures.</li><li><strong>Compute cost</strong> — Methods like self-consistency or Tree of Thoughts require multiple model calls, increasing processing time and cost.</li><li><strong>Hallucination</strong> — Models may invent facts or reasoning steps that sound plausible but are incorrect.</li><li><strong>Reproducibility</strong> — Stochastic generation can produce different results each run unless sampling is tightly controlled.</li></ul><p>Based on the previous information, let’s explore what a time series is, where they are commonly found, and how the authors of the paper “<strong><em>Position: Empowering Time Series Reasoning with Multimodal LLMs</em></strong>” addressed this challenging task.</p><h4>Definition and use cases of time series</h4><p>Time series are data points or measurements collected over time, usually at regular intervals. They are useful to understand <strong>how something changes</strong>. Each point has two parts: the time when the it was measured and the value recorded</p><p>We can find time series anywhere we measure something more than once and care about how it changes over time, for example: <strong>Weather records</strong> (daily temperature, rainfall), <strong>stock market data</strong> (price every minute or day), <strong>health monitoring</strong> (heart rate over the day), <strong>sales data</strong> (items sold each month), and <strong>traffic counts</strong> (cars passing each hour). Image 1 shows an example of the time series charecteristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oYiF0hNpwbymkPXRHLZ_cQ.png" /><figcaption>Image . Time series characteristics</figcaption></figure><p>The authors proposed 4 key components for achieving time series reasoning:</p><ol><li><strong>Understanding Time Series Characteristics</strong> — This is an key stage in time series analysis. We must understand the characteristics of a time series to identify patterns such as <strong>seasonality, trend, cycles, sudden changes (shocks),</strong> and <strong>noise</strong>.<br>Knowing these features we can do a more accurate analysis and make better decisions.</li><li><strong>Contextual Guidance </strong>— The authors highlight that time series rarely occur in isolation: context matters. For example, financial data must be read alongside news or economic indicators; sensor readings may need environmental or operational logs. They stress using multimodal context to guide interpretation — but note that external context can be sparse, unstructured, or incomplete, so models must carefully integrate it to avoid misleading conclusions.</li><li><strong>Reasoning Process</strong> — The authors propose that reasoning over time series should be structured and flexible, multi-step reasoning, combining forward inference (e.g., detecting seasonal patterns) with backward reasoning (e.g., diagnosing anomalies) within a unified framework. Maintaining logical consistency across steps, avoiding spurious connections, and clearly articulating each inference are key challenges.</li><li><strong>Iterative Feedback</strong> — Given that reasoning over multiple steps can introduce errors or inconsistencies, the authors argue that models need mechanisms for iterative feedback: detecting and correcting mistakes, reassessing intermediate conclusions, and revising logic when new context arrives. Options include self-evaluation, external agents checking reasoning, or architectural feedback loops.</li></ol><h4>What the Authors Did, Their Position, and Datasets Used</h4><p><strong>What they propose:</strong><br>The authors position that <strong>multimodal LLMs (MLLMs)</strong> can enable more powerful and flexible reasoning for time series analysis. They advocate embedding the four key components — <em>understanding, context guidance, structured reasoning, and iterative feedback</em> — into MLLM frameworks to enhance decision-making and interpretability across real-world domains.</p><p>They outline and categorize model architectures that support these components, including:</p><ul><li><strong>Zero-Shot Inference</strong>, using reasoning-aware prompts.</li><li><strong>One-Stage Tuning-Based</strong> models, fine-tuned on time-series instruction-response pairs.</li><li><strong>Two-Stage Tuning-Based</strong> models, which first align modalities and then fine-tune for reasoning tasks.</li><li><strong>Multimodal Time Series</strong> models, combining modality encoders, alignment interfaces, and a shared reasoning backbone.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*KQOFU_TonqSnUhr-ANjGcw.png" /><figcaption>Image 2. Classifications of complex temporal data reasoning tasks and their framework designs (<strong>took it from the paper</strong> “Position: Empowering Time Series Reasoning with Multimodal LLMs”)</figcaption></figure><p><strong>Datasets and Benchmarks:</strong><br>As a <strong>position paper</strong>, this work does <em>not introduce new datasets or experiments</em>. Instead, the authors survey existing datasets that pair time series with textual (and sometimes image) context and reasoning tasks. Some of the notable benchmarks include:</p><ul><li><strong>Jolt</strong> (healthcare, representation tasks)</li><li><strong>TS-Insights</strong> (general, trend classification)</li><li><strong>Time-series-reasoning</strong> (general, Q&amp;A)</li><li><strong>ChatTS</strong> (weather &amp; AIOps, Q&amp;A; MLLM-based)</li><li><strong>TimeMMD</strong>, <strong>Finst</strong>, <strong>CiK</strong>, <strong>ChatTime</strong>, <strong>TabPFN</strong>, <strong>TimeQA</strong> — each targeting tasks like forecasting or QA across domains like finance, traffic, etc.</li></ul><p><strong><em>The authors point out that many datasets are limited</em></strong>: some are synthetic, many lack fully multimodal inputs, and most focus on forward reasoning (e.g., chain-of-thought) rather than richer reasoning patterns. <strong><em>They underscore the need for more diverse, realistic multimodal, high-quality datasets, as well as new evaluation metrics that assess both accuracy and reasoning quality.</em></strong></p><p>Finally, <strong>which are the opportunities of MLLMs to achieve</strong> more accurate, explainable, and context-aware analysis in time series tasks?</p><h4>Opportunities for Reasoning in MLLMs for Time Series</h4><ol><li><strong>Richer context understanding</strong> — Combining numeric data with related text, images, or metadata can produce more informed and human-like explanations.</li><li><strong>Cross-modal reasoning</strong> — MLLMs can connect visual patterns in plots with numerical anomalies or textual event descriptions.</li><li><strong>Improved decision support</strong> — Reasoning chains can help explain why certain predictions or detections were made, increasing trust.</li><li><strong>Better anomaly diagnosis</strong> — Multimodal reasoning can link unusual time-series events to external causes, such as weather or market news.</li><li><strong>Adaptive forecasting</strong> — Reasoning can guide the choice of forecasting strategies based on detected patterns.</li><li><strong>Human-in-the-loop collaboration</strong> — MLLMs can present reasoning steps for expert review, making analysis more transparent and adjustable.</li><li><strong>Scenario simulation</strong> — Reasoning can be used to explore “what-if” cases, combining time-series projections with contextual changes in other modalities.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9970a9c336c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vicuna chatbot: the promising open-source model]]></title>
            <link>https://medium.com/@jessica_lopez/vicuna-chatbot-the-promising-open-source-model-282152619815?source=rss-e70682b5a78f------2</link>
            <guid isPermaLink="false">https://medium.com/p/282152619815</guid>
            <dc:creator><![CDATA[Jessica López Espejel]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 13:37:12 GMT</pubDate>
            <atom:updated>2023-07-11T13:37:12.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E3i1v2USzb455eUfkyXnLA.png" /><figcaption>Image 1. Image generated with DALL·E</figcaption></figure><p>Since the introduction of Chat-GPT-4, numerous Chatbots have emerged to address similar tasks as ChatGPT-4. These attempts have been developed with various purposes in mind. For instance, some focus on optimizing resource usage by utilizing GPUs with 6 or 8GB VRAM, or even CPUs. Additionally, these models boast reduced parameter counts or are offered as open-source solutions. The objective behind these efforts is to match or even overcome the performance of GPT-4. One of these chatbots is <a href="https://lmsys.org/blog/2023-03-30-vicuna/"><strong>Vicuna</strong></a>.</p><h3><strong>Vicuna details</strong></h3><p>Vicuna is an <strong>open-source </strong>chatbot developed by LMSYS (Large Model Systems Organization) team. It combines the strengths of two models: <strong>LLaMA </strong>from META and <strong>Alpaca </strong>from Stanford. One aspect of Vicuna’s design involves fine-tuning LLaMA using a dataset of approximately 125K user-shared conversations sourced from ShareGPT after cleaning. This fine-tuning process enhances Vicuna’s ability to understand and respond to user inputs effectively. Vicuna builds upon the foundation of Stanford’s Alpaca model, incorporating various enhancements in its recipe. These improvements serve to refine Vicuna’s performance, ensuring an even more satisfying user experience.</p><p>According to the authors, Vicuna achieves a remarkable 90% capability of Bard/ChatGPT. This leads us to conclude that Vicuna can be considered akin to a “<em>GPT-3.25</em>”<em> in terms of performance</em>. While it may not overcome the capabilities of GPT-3.5, it certainly outperforms GPT-3 in power and effectiveness. This deduction is also supported by the fact that LLaMA, which outperforms GPT-3 (175 billion parameters) in various benchmarks (Touvron et al., 2023), serves as the basis for fine-tuning Vicuna. Therefore, it is reasonable to expect Vicuna-13B to deliver even better performance than LLaMA-13B.</p><p>Vicuna is trained using Reinforcement Learning from Human Feedback (RHLF). While LLaMa model uses 512 as context length, length input vicuna is 2048.</p><p>Here is the list of hyperparameters that the authors used to train both Vincuna 7B and 13B.</p><ul><li>global batch size=128</li><li>learning=2e-5</li><li>epochs=3</li><li>seq length=2048</li></ul><p>During the training process, the authors employed 8x A100 GPUs. Additionally, they incorporated SkyPilot (Yang, Zongheng et al., 2023) and FlashAttention (Dao, Tri et al., 2022) for memory optimizations.</p><h3>Experiments with Vicuna</h3><p>In the paper “<a href="https://arxiv.org/pdf/2306.05685.pdf"><em>Judging LLM-as-a-judge with MT-Bench and Chatbot Arena</em></a>,” the authors investigated the performance of Vicuna using the “LLM-as-a-judge” approach in zero-shot tasks. Those tasks includes writing, math, coding, knowledge, etc.To evaluate Vicuna’s performance, the authors employed two benchmarking methods: 1) MT-bench, which consisted of 80 high-quality multi-turn questions designed to assess the model’s capability in common use cases and challenging questions, and 2) Chatbot Arena, a chatbot platform where users can interact simultaneously with two anonymous models. In Chatbot Arena, users vote for the model that provided the best answer, and the identities of both models are revealed at the end. Both evaluation methods incorporate human ratings to ensure accuracy.</p><p>The findings indicated that Vicuna did not perform well in some of these tasks, leading the authors to decide on <strong>fine-tuning the model using human votes obtained from Chatbot Arena</strong>. One of the main limitations observed in Vicuna during <strong>zero-shot tasks</strong> is its inability to adhere to a pre-defined template. Moreover, they investigated the use of <strong>CoT (Chain-of-Thought), </strong>a technique proposed by Wei, Jason et al., in their 2023 paper titled “<a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a>.” However, none of these techniques proved effective in specific tasks, particularly those involving mathematics and reasoning, where Vicuna faced greater challenges.</p><h3><strong>What is ShareGPT?</strong></h3><p><a href="https://sharegpt.com/">ShareGPT </a>is a specialized platform created for the purpose of sharing ChatGPT conversations. Its primary objective is to curate and compile a diverse range of discussions that can be leveraged to refine and enhance our own models using authentic conversations. The repository encompasses a wide array of topics, including mathematics, programming challenges, and everyday life conversations. As of the time of writing this blog, the repository contains a collection of 331,480 conversations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5KrmdjVRhP7zjBp8ZVqUQ.png" /><figcaption>Image 2. Example of <a href="https://sharegpt.com/">ShareGPT</a> conversations (take it from the website)</figcaption></figure><h3>Conclusion</h3><p>This blog has compiled valuable information about the Vicuna model. I consider, Vicuna is a commendable effort towards achieving a performance level akin to ChatGPT-4 and other state-of-the-art models. Despite being smaller in scale, it demonstrates competitive performance. However, it is worth noting that there is room for improvement in its mathematical and reasoning capabilities, offering promising avenues for further research.</p><p>Finally, one of the key findings of this model highlights is the importance of presenting a comprehensive conversation to facilitate better contextual understanding by the LLM judge. This holds true not only for GPT-4 but also to a certain degree in the current models. It implies that for optimal results, it is advantageous to thoroughly explain our intentions and provide examples (such as in CoT), mirroring the way humans learn.</p><h3><strong>References</strong></h3><p>Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M. A., Lacroix, T., … &amp; Lample, G. (2023). <em>Llama: Open and efficient foundation language models</em>. arXiv preprint arXiv:2302.13971.</p><p>Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. <em>Flashattention: Fast and memory-efficient exact attention with io-awareness. </em>Advances in Neural Information Processing Systems, 35:16344–16359, 2022.</p><p>Wei, J., Wang, X., Schuurmans, D., Bosma, M., Xia, F., Chi, E., … &amp; Zhou, D. (2022). <em>Chain-of-thought prompting elicits reasoning in large language models</em>. Advances in Neural Information Processing Systems, <em>35</em>, 24824–24837.</p><p>Zheng, L., Chiang, W. L., Sheng, Y., Zhuang, S., Wu, Z., Zhuang, Y., … &amp; Stoica, I. (2023). J<em>udging LLM-as-a-judge with MT-Bench and Chatbot Arena</em>. arXiv preprint arXiv:2306.05685.</p><p>Zongheng Yang, Zhanghao Wu, Michael Luo, Wei-Lin Chiang, Romil Bhardwaj, Woosuk Kwon, Siyuan Zhuang, Frank Sifei Luan, Gautam Mittal, Scott Shenker, and Ion Stoica. <em>SkyPilot: An intercloud broker for sky computing</em>. In 20th USENIX Symposium on Networked Systems Design and Implementation (NSDI 23), pages 437–455, Boston, MA, April 2023. USENIX Association.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=282152619815" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT and the tools developed to detect AI-generated text]]></title>
            <link>https://medium.com/@jessica_lopez/chatgpt-and-the-tools-develop-to-detect-ai-generated-text-8d983def4f92?source=rss-e70682b5a78f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d983def4f92</guid>
            <category><![CDATA[limitations]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gpt-3]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Jessica López Espejel]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 22:57:02 GMT</pubDate>
            <atom:updated>2023-01-31T12:30:36.921Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, ChatGPT has been a popular topic on social media and various websites, as well as in local newspapers, and other sources. Almost a month after its launch, this article breaks down what ChatGPT is, its technical aspects, limitations, and why it has gained widespread popularity. Additionally, it includes personal perspectives, and at the end, the systems for determining if a written text was created by a human or AI. Have a great read!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*wRaBjBHOX4RYkydVOfH3rg.jpeg" /><figcaption>Image taken from internet</figcaption></figure><h3><strong>What is ChatGPT?</strong></h3><p><a href="https://chat.openai.com/">ChatGPT</a> is a AI text-generator released on January 2nd, 2023 by <a href="https://openai.com/">OpenA</a>I. It answers questions, and it’s able to work in a variety of languages such as Spanish, English, French, German, Arabic, and so on.</p><h3><strong>On which model is ChatGPT built? Other technical details</strong></h3><p>ChatGPT is based on one of the GPT-3.5 (Generative Pre-Trained Transformer 3.5) models, and trained on Microsoft Azure AI. Three models from OpenAI are derived from GPT-3.5:</p><ul><li><strong>code-davinci-002</strong> — It is one of the <a href="https://openai.com/blog/openai-codex/">Codex</a> models, that are trained on natural language and programming language. It is capable of translating natural language into a dozen of programming languages, such as Python, JavaScript, Go, Perl, PHP, Shell, etc. The model’s training data reaches June 2021, and the max length tokens in the sequence is 8,000.</li><li><strong>text-davinci-002 </strong>— It is an InstructGPT model based on code-davinci-002.</li><li><strong>text-davinci-003</strong> — It is the most powerful GPT-3 model compare with based-gpt previous models. It can perform better in quality language generation, instruction-following, etc. The model’s training data reaches June 2021, and the max length tokens in the sequence is 4,000.</li></ul><p>Consistent with <a href="https://beta.openai.com/docs/models/gpt-3">OpenA</a>I, the davinci family of models have shown high proficiency in understanding tasks. But, <strong>how ChatGPT generates the answers?</strong></p><p>According to <a href="https://www.blogdumoderateur.com/tout-savoir-sur-chatgpt/">BDM </a>ChatGPT generates the answers based on 5 parameters:</p><ol><li><strong>prompt </strong>— It is the input provided by the user.</li><li><strong>temperature </strong>— It is a hyperparameter used to control the randomness of the output. If temperature = 0, then the decoding algorithm becomes equal to greedy decoding. The higher is the temperature, more uniform or random distribution.</li><li><strong>max_length </strong>— It is the maximum length of tokens in the sequence accepted by the model.</li><li><strong>top_k </strong>— It keeps the <em>k </em>tokens with the highest probability.</li><li><strong>top_p </strong>— It keeps the tokens with the highest cumulative probability.</li></ol><p>ChatGPT saves the answers and the questions in its memory. Since it&#39;s trained using <em>RLHF (Reinforcement Learning from Human Feedback),</em> its responses are natural and human-like.</p><h3><strong>Limitations</strong></h3><p>As ChatGPT is currently in its testing period, it has certain limitations that are highlighted by ChatGPT itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*vmBlLAaHnKoTxj5MCOHxJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*WFevEuIvzAdCkHwSkH4h2Q.png" /><figcaption>Some limitations of ChatGPT</figcaption></figure><p>I will add two more limitations:</p><ul><li>ChatGPT is unable to provide you links of some websites.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*JpfVwutwo6gSnUIQBB_k4g.png" /></figure><ul><li>Since the answers are derived from existing content, they are not 100% original.</li></ul><h3>The boom of ChatGPT!</h3><p>Since OpenAI release ChaGPT, it has been a popular topic on social media. Actually, more than one million people used it within a week of its upon release. As well, much controversy has been caused around this chat. For example, Yann Lecun clarify that chatGPT is not so incredible new, innovative and unique as many people think about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*-6vrmyIMJNt7jSPqTICI1Q.png" /><figcaption>Image taken from twitter</figcaption></figure><p>Hence, he is right? I think yes. OpenAI has done a great job! No one says the inverse, but it is true, it is not a breakthrough. OpenAI have many versions of gpt models, they have been adding data, adding time of training, modifying hyper-parameters, adding techniques to tackle difficult tasks, but the heart and main principle is still the gpt model, which is based on transformer neural networks.</p><p>ChatGPT has gained popularity due to its capability to generate coherent text, paraphrase text, detect errors in the text , get the automatic summary given a text, write an email, create stories, generate code through specific constraints, resolve programming challenges, etc. Nonetheless, other models such as BART, T5, CodeBERT, among others, were already doing some of these tasks. So what is different about ChatGPT?</p><p>Two key points to consider are:</p><p>1. Other models were not accessible to everyone in the form of a chatbot application.</p><p>2. Additionally, this model has the capability to handle multiple tasks simultaneously.</p><p>Another debate is that ChatGPT can generate reports for students on their assignments, create full paragraphs for theses, write full scientific articles, presenting a challenge for teachers. If they can’t determine if the text was created by students or by an AI, they cannot determine fairly their students’ progress.</p><h3>Tools to detect a text is done by an AI</h3><p>While some researchers focus on developing AI models for tasks such as language generation, others are working on developing methods for detecting AI-generated text. The following lines show some tools developed to detect AI-generated text.</p><ul><li><strong>Giant Language model Test Room (</strong><a href="http://gltr.io/dist/index.html"><strong>GTL</strong></a><strong>)</strong>, 2019 — It is a result from the research made by MIT-IBM Watson AI lab and Harvard Natural Language Processing (NLP) group. The website uses GPT-2 to determine whether a text is human-written or generate by a machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*mHIQcIO1p2Z60mGDPq8CtQ.png" /></figure><ul><li><a href="https://openai-openai-detector.hf.space/"><strong>GPT-2 Output Detector Demo</strong></a><strong>, <em>2022</em></strong>— It is a technology releases by OpenIA. It is based on <a href="https://openai.com/blog/gpt-2-1-5b-release/">GPT-2 model</a> (1.5B parameters).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*zwedYnUT8Vh05vuJAXozHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28VtuG7p2LfQs6qhg2gRcQ.png" /></figure><ul><li><a href="https://etedward-gptzero-main-zqgfwb.streamlit.app/"><strong>GPTZero </strong></a>— Edward Tian, a computer science student from Princeton, created GPTZero. This tool can identify if text was written by a human or an AI. The current version is in beta. It is based on the perplexity, and the burstiness of the text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rgTpQv6A12tOvn4MjLl9Bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*5kI6kx8yv3dJEm-lQJhhHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*LrxfxcSnCsHxAdEKaLWKRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*5YEWoUFi-9BOR-vwor9IAg.png" /></figure><ul><li><a href="https://copyleaks.com/features/ai-content-detector"><strong>Copyleaks</strong></a><strong> , 2011— </strong>It is a software company that provides plagiarism detection and content comparison tools for businesses and individuals.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*SJaEEckrDmzP3TE92Mar9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ih705NPrH8TRAO5Sn3wFTw.png" /></figure><ul><li><strong>Watermaking</strong>— It is a proposition by OpenIA. It consists into adding watermarking in all ChatGPT text. The tool would have “cryptographic pseudorandom function”, but only OpenIA will have the key.</li><li><a href="https://writer.com/ai-content-detector/"><strong>Writer.com</strong></a><strong> </strong>— It gives an score from 0–100. 100% means is a text totally written by humans. If the scores is less than 80% indicates the authour use some AI tools to paraphrase the original text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vbC85N-9oYc5hT0_Tpu9Q.png" /><figcaption>Text taken from <a href="https://openai.com/blog/chatgpt/">ChatGPT blog</a></figcaption></figure><p>Determining if a text was written by a human or an AI is a challenging task. Some tools have been developed to tackle this arduous task, but they are still far to have an acceptable precision and accuracy.</p><p>The availability of tools that can determine if a text was created by a human or not is more extensive, however, only some of them are cited in this article.</p><h3>Conclusion</h3><p>ChatGPT has been a hot topic of discussion, and will do so for the next few months. It won’t be until the release of GPT-4 that comparisons will start. According to speculations, GPT-4 will have much better performance on all tasks. Until then, ChatGPT will keep fixing errors, enhancing its responses, and learning from new information.</p><p>Can the use of ChatGPT really be bad for students? No, I believe that like any other technology, if utilized properly, it can bring many benefits. ChatGPT and more advanced technology in the future won’t be exceptions to this. It is up to each person to use these tools in a responsible and productive way.</p><h3>References</h3><p>[1] <a href="https://www.blogdumoderateur.com/tout-savoir-sur-chatgpt/">Tout savoir sur ChatGPT : accès, cas d’usages, limites, paramètres, SEO, détection, alternatives… (blogdumoderateur.com)</a></p><p>[2] <a href="https://www.blogdumoderateur.com/gpt-3-gpt-4-tout-savoir/">https://www.blogdumoderateur.com/gpt-3-gpt-4-tout-savoir/</a></p><p>[3] <a href="https://beta.openai.com/docs/models/overview">https://beta.openai.com/docs/models/overview</a></p><p>[4] <a href="https://www.fastcompany.com/90830518/tools-to-detect-ai-generated-text-chatgpt">Was this written by a robot? These tools help detect AI-generated text (fastcompany.com)</a></p><p>[5] <a href="https://goldpenguin.org/blog/check-for-ai-content/">How To Check If Something Was Written with AI | Gold Penguin</a></p><p>[6] <a href="https://www.vice.com/en/article/3admg8/a-compsci-student-built-an-app-that-can-detect-chatgpt-generated-text">A CompSci Student Built an App That Can Detect ChatGPT-Generated Text (vice.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d983def4f92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic understanding of Abstract Syntax Tree (AST)]]></title>
            <link>https://medium.com/@jessica_lopez/basic-understanding-of-abstract-syntax-tree-ast-d40ff911c3bf?source=rss-e70682b5a78f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d40ff911c3bf</guid>
            <dc:creator><![CDATA[Jessica López Espejel]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 23:52:36 GMT</pubDate>
            <atom:updated>2023-01-01T23:58:40.487Z</atom:updated>
            <content:encoded><![CDATA[<p>Abstract Syntax Tree (AST) is a tree representation of the source code. Since the tree describes the hierarchy of each node, it makes simple to understand the relation between each node. For example, we have two mathematical expressions: 1) <em>10 — [(5 / 4 ) + 1]</em> and 2) <em>[10 — (5 / 4)] + 1</em>. Both expressions have the same numbers, but the way of using parentheses and brackets are different. Therefore, figure 1 shows the syntax trees generated by both expressions (left side — expression 1, and right side — expression 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZ6PQlHmNtUvjuQEH-Y6ZQ.png" /><figcaption>Figure 1. Syntax tree of expression 1 and expression 2, respectively.</figcaption></figure><p>The syntax tree is composed by nodes and edges, formally we can denote it as <em>T=&lt;N, E&gt;</em>, where <em>N</em> is the list of nodes, and <em>E</em> is the list of edges. The nodes contain the data, and the edges indicate the hierarchy among the nodes. In the nodes of a tree we can identify the root node (red node in figure 1), and the leaf nodes (orange outline nodes). The root node has the highest hierarchy in the tree, and the leaf nodes are the last nodes in the tree.</p><p>We can traverse the abstract syntax tree recursively. However, there are already some libraries that make our work easier, for example, <a href="https://tree-sitter.github.io/tree-sitter/">tree sitter</a>.</p><h3><strong>Nodes AST using tree_sitter</strong></h3><p><a href="https://tree-sitter.github.io/tree-sitter/">Tree sitter</a> is a powerful parser able to generate syntax trees from more than 40 programming languages. For this example, we will use tree_sitter to get the list of nodes from the 10 - [(5 / 4 ) + 1] (expression 1).</p><pre>from tree_sitter import Language, Parser<br><br># We instanciate the parser, and we indicate the programming language. <br>parser = Parser()<br>LANGUAGE = Language(&#39;parser/my-languages.so&#39;, &#39;java&#39;)<br>parser.set_language(LANGUAGE)<br><br>def tree_to_token_nodes(root_node):<br>  &quot;&quot;&quot;<br>    It returns a list of nodes<br>  &quot;&quot;&quot;<br>  if (len(root_node.children)==0 or root_node.type==&#39;string&#39;) and root_node.type!=&#39;comment&#39;:<br>    return [root_node]<br>  else:<br>    code_tokens=[]<br>    for child in root_node.children:<br>        code_tokens+=tree_to_token_nodes(child)<br>    return code_tokens<br><br>if __name__ == &quot;__main__&quot;:<br>  tree = parser.parse(bytes(code,&#39;utf8&#39;))<br>  root_node = tree.root_node <br>  ast_token_nodes = tree_to_token_nodes(root_node)<br>  print(ast_token_nodes)</pre><p>The generate list of nodes is the following:</p><pre>[<br> &lt;Node type=decimal_integer_literal, start_point=(0, 0), end_point=(0, 2)&gt;, <br> &lt;Node type=&quot;-&quot;, start_point=(0, 3), end_point=(0, 4)&gt;, <br> &lt;Node type=identifier, start_point=(0, 4), end_point=(0, 4)&gt;, <br> &lt;Node type=&quot;[&quot;, start_point=(0, 5), end_point=(0, 6)&gt;, <br> &lt;Node type=&quot;(&quot;, start_point=(0, 6), end_point=(0, 7)&gt;, <br> &lt;Node type=decimal_integer_literal, start_point=(0, 7), end_point=(0, 8)&gt;, <br> &lt;Node type=&quot;/&quot;, start_point=(0, 9), end_point=(0, 10)&gt;, <br> &lt;Node type=decimal_integer_literal, start_point=(0, 11), end_point=(0, 12)&gt;, <br> &lt;Node type=&quot;)&quot;, start_point=(0, 13), end_point=(0, 14)&gt;, <br> &lt;Node type=&quot;+&quot;, start_point=(0, 15), end_point=(0, 16)&gt;, <br> &lt;Node type=decimal_integer_literal, start_point=(0, 17), end_point=(0, 18)&gt;, <br> &lt;Node type=&quot;]&quot;, start_point=(0, 18), end_point=(0, 19)&gt;, <br> &lt;Node type=&quot;;&quot;, start_point=(0, 19), end_point=(0, 19)&gt;<br>]</pre><p>It can be seen that expression 1 generated 13 nodes, i.e., the abstract syntax tree of expression 1 contains 13 nodes. Attention: these are only the nodes that compose the tree, it is not the tree yet. Each of these node has the type of the node, the start_point and the end_point. The type node can be <em>decimal_integer_literal, identifier, character_literal, keyword, etc.</em></p><ul><li><em>decimal_integer_literal — </em>numbers (either integers or decimals)</li><li><em>identifier — </em>name assigned by the programmer</li><li><em>character_literal —</em>are the strings. For example in <em>System.out.printl(‘helllo’), </em>the character_literal is ‘hello’</li><li><em>keyword — </em>own words of the programming language such as <em>public, private, Integer,</em> and so on.</li></ul><p><strong>Attention: </strong>Each programming language and each tool we use defines differently the properties of each node.</p><h3>Generating Abstract Syntax Tree using AST explorer</h3><p><a href="https://astexplorer.net/">AST explorer</a> is a website so useful to generate AST in a large number of programming languages, such as, Java, JavaScript, Python, etc. Moreover, there are a large number of parser like acorn, @babel/parser, seafox, shift, and so on. Continuing with expression 1 of the previous example, the figure 2 shows the AST generated by the JavaScript programming language and the @babel/parser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*W28HUNpumRBho_aJ5w6KJg.png" /><figcaption>Figure 2. AST generated by AST explorer website</figcaption></figure><p>Figure 2 shows the abstract syntax tree. The tree indicates that this is a file that has multiple attributes, e.g., a type, an start, and an end. In turn, there is a program, and within the program is the body of the tree. It is precisely the body of the tree that contains the data we are going to analyze in Figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*kWtot_ERoFy48T_ZOCLNMA.png" /><figcaption>Figure 3. Tree body details</figcaption></figure><p>Figure 3 shows the formal structure of the tree (Figure 1 — left). The <em>BinaryExpression (-)</em> is highlighted in red (root node). This node is divided into <em>left</em> (blue color) and <em>right</em> (green color). On the left side you can see the value 10 of the node, however, the right side has more data ‘<em>(5/4) +1’</em>, so only a small part is shown.</p><h3>AST applications</h3><ul><li>Compiler — for a better explanation <a href="https://www.twilio.com/blog/abstract-syntax-trees">here</a></li><li>Code maintenance</li><li>Code refactor</li><li>Clone detection</li><li>In the last years, abstract syntax trees have been used for artificial intelligence. For example, <a href="https://arxiv.org/pdf/2206.05239.pdf">StructCoder</a> used AST to make the model understand and recognize the syntax of java programming language in the task generation task.</li></ul><h3>Conclusion</h3><p>Abstract syntax trees have been used mostly for building compilers, however, they are also useful to see the differences from one version to another in a script. Nowadays, there are many tools to obtain the ASTs of different programming languages, and with different parsers. Recently, they have been used for code generation in artificial intelligence. Much work remains to be done to exploit their properties and apply them in understanding syntax for AI models.</p><p>This short blog only presents the introduction of ASTs, and some of their applications. In future blogs I will explain step by step how to traverse an AST, and other practical examples using the tree sitter tool.</p><h3>References</h3><p>[1] <a href="https://www.newline.co/courses/practical-abstract-syntax-trees/what-is-an-ast">https://www.newline.co/courses/practical-abstract-syntax-trees/what-is-an-ast</a></p><p>[2] <a href="https://www.twilio.com/blog/abstract-syntax-trees">https://www.twilio.com/blog/abstract-syntax-trees</a></p><p>[3] Tipirneni, Sindhu and Chandan, Ming and K. Reddy, Zhu. <em>StructCoder: Structure-Aware Transformer for Code Generation</em>. Proceedings of the 39th International Conference on Machine Learning, 2022.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d40ff911c3bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding greedy search and beam search]]></title>
            <link>https://medium.com/@jessica_lopez/understanding-greedy-search-and-beam-search-98c1e3cd821d?source=rss-e70682b5a78f------2</link>
            <guid isPermaLink="false">https://medium.com/p/98c1e3cd821d</guid>
            <category><![CDATA[language-generation]]></category>
            <category><![CDATA[beam-search]]></category>
            <category><![CDATA[sequence-to-sequence]]></category>
            <category><![CDATA[decoder]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Jessica López Espejel]]></dc:creator>
            <pubDate>Sun, 20 Feb 2022 01:12:19 GMT</pubDate>
            <atom:updated>2022-03-08T23:05:30.140Z</atom:updated>
            <content:encoded><![CDATA[<p>Greedy search and beam search are well known algorithms in the language generation tasks of NLP (Natural Language Processing). Neural machine translation (NLM), and automatic summarization (AS) are some of the most popular tasks in the automatic language generation.</p><p>Greedy search and beam search aim to generate the sequence outputs of tokens from a neural network model. Both approaches are focused in sequence-to-sequence models. The model maps an input sequence to a target sequence (Figure 1) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*0KQjaDIwTbk-uq7QRr_uMw.png" /><figcaption>Figure 1. : Sequence-to-sequence model [<a href="https://tel.archives-ouvertes.fr/tel-03376172/">3</a>]</figcaption></figure><p>The encoder accepts the input sequence of tokens (1), where <em>N</em> is the number of tokens in the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/159/1*vNOaZ6j8eQQ3Dz-oJEIlOg.png" /><figcaption>1. Input sequence</figcaption></figure><p>The decoder generates the output sequence (2) at each time step <em>t, </em>where<em> </em><strong><em>T </em>is the maximum number of tokens in the sequence.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/149/1*Mpo_YQxUiAJ0xiS_XlPsfg.png" /><figcaption>2. Output sequence</figcaption></figure><p>The probability of each decoder output <em>y_(t)</em> is conditional of the previous token outputs. Mathematically, we represent it as it follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*ebIkpe2LAgUQXTRL_qrI-A.png" /></figure><p>At each time step <em>y_(t)</em>, the decoder computes the probability of each token in the vocabulary. In consequence, the more tokens there are in the vocabulary, the more the computational cost increases.</p><h3>Greedy Search</h3><p>Greedy search consists of<strong> taking the token with the highest conditional probability from the vocabulary <em>V</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*Nh_Q0_s1KiiFitZVafqb3g.png" /></figure><p>For example, we consider 16 words in our vocabulary <em>V</em>: <em>&lt;EOS&gt;, &lt;UNK&gt;, the, war, is, to, from, as, was, last, second, global, abbreviated, WWII, 1939, 1945. </em>Moreover, the maximum number of tokens in the sequence, <em>T = 8</em>.</p><p>According to the figure 2, the squares highlighted in red correspond to the words that have the highest conditional probability at each time step <em>t</em>. In the first time step the word with the highest conditional probability is <strong><em>the</em></strong>,<strong> </strong>in the second time step is<strong> <em>last</em></strong>, etc. Therefore, the sequence output predicted by the decoder is: <strong><em>the last global war is abbreviated as WWII</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*1cpVadniWjs2qWpddhCaCg.png" /><figcaption>Figure 2. Greedy search algorithm</figcaption></figure><p><strong>Main drawback:</strong></p><ul><li>Greedy search algorithm hides high probabilities that can be found in posterior tokens. Therefore, it does not always generate optimal output sequences.</li></ul><h3>Beam Search</h3><p>Beam search algorithm is the improved version of greedy search. Beam search has a parameter called <em>beam_size. </em>The<em> beam_size</em> is the number of tokens with the highest conditional probabilities at each time step <em>t</em>. In the Figure 2, the <em>beam_size=3.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*SNO2jyh7brFe_Ugz1iC4xg.png" /><figcaption>Figure 3. Beam search algorithm</figcaption></figure><p><strong>Sequence 1 </strong>— the last global war — <em>(0.35 * </em><strong><em>0.4</em></strong><em> * 0.1 * 0.21) = 0.0029</em></p><p><strong>Sequence 2 </strong>— the second war was —<em> (0.35 * </em><strong><em>0.2</em></strong><em> * 0.25 * 0.2)</em> <em>=</em><strong><em>0.0034</em></strong></p><p><strong>Sequence 3 </strong>— the war was the — (0.35 * <strong>0.1 </strong>* 0.15 * 0.17) = 0.00089</p><p>Following the greedy search algorithm we selected the <strong>sequence 1</strong>, because the highest probability the greedy search found was in the second token (<strong>last = 0.4</strong>), and it continues the token generation from this only branch. However, if we use beam search algorithm, the sequence with the highest probability is the <strong>sequence 2. </strong>This is a clear example of greedy search algorithm discarding sequences of tokens with higher probability.</p><p><strong>Drawbacks:</strong></p><ul><li>Increasing the <em>beam_size</em>, the quality of the output sequence improves significantly, but it reduces the decoder speed.</li><li>There is a saturation point, where even if we increase the number of <em>beam_size, </em>the quality of the decoding does not improve anymore <a href="https://aclanthology.org/W17-3207.pdf">[1]</a>.</li><li>It does not guarantee of finding the output sequence with the highest score [<a href="https://arxiv.org/pdf/2007.03909.pdf">2</a>]</li></ul><h4>From products to addition</h4><p>Imagine, we have an output sequence of length=100. To have the final conditional probability we multiply <em>P(y_1) * P(y_2) * P(y_3) * … * P(y_100),</em> and the result will be a tiny number. The computers can be limited to represent it, and the consequence is that we loss precision. To tackle this issue, we use the product property of logarithms to turn multiplication into an addition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*3OGxzIEN48ptsoTB26-MNA.png" /></figure><p>Therefore, we compute the probability of the output sequences:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*OlfZmlpF7GgT_zzqr5A0ZA.png" /></figure><p>However, the longer an output sequence is, the more logarithmic terms it has. Therefore, one way to penalize long sequences is through the following mathematical expression. The most common value for alpha in the literature varies from 0.6 to 0.8 [<a href="https://arxiv.org/pdf/1912.08777.pdf">5</a>, <a href="https://arxiv.org/pdf/1910.10683.pdf">6</a>].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*NOycIDyudgBZUNcKy_jspw.png" /></figure><h4>Criteria to stop the generation of tokens</h4><ul><li>When the sequence of tokens exceeds the <strong>maximum number of tokens T</strong></li><li>When the full generation of tokens exceeds some <strong>amount of time</strong></li><li>The token predict in the output sequence is <em>&lt;eos&gt;, </em>or the token we are using to indicate <em>end of sequence.</em></li></ul><h3>Conclusion</h3><p>Greedy search and beam search have extensively used in NLP tasks. Meanwhile, various improvements have surged to prune the search graphs. Those propositions achieve to speed up the decoding process and/or improve the quality of the output sequences. Moreover, algorithms such as PICARD [<a href="https://arxiv.org/pdf/2109.05093.pdf">4</a>] via slight modifications to beam search, it helps to find valid output sequences of SQL code.</p><h3>References</h3><p>[1]Cohen, Eldan and Beck, J. Christopher. <em>Empirical Analysis of Beam Search Performance Degradation in Neural Sequence Models.</em> In<em> </em>Proceedings of the First Workshop on Neural Machine Translation, ACL 2017, Vancouver, Canada, August 4, 2017, pages 56–60</p><p>[2] Meister, Clara and Vieira, Tim and Cotterell, Ryan. <em>Best-First Beam Search. </em>In<em> </em>Transactions of the Association for Computational Linguistics, 2020, Cambridge, MA, vol. 8, pages 795–809</p><p>[3] Lopez Espejel, Jessica. A<em>utomatic abstractive summarization of long medical texts with multi-encoders Transformer and general-domain summary evaluation with wikiSERA.</em> Computers and Society [cs.CY]. Université Paris-Nord — Paris XIII, 2021. English. ffNNT : 2021PA131010ff. fftel-03376172</p><p>[4] Scholak, Torsten and Schucher, Nathan and Bahdanau, Dzmitry. <em>PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Models</em>. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, 2021, pages 9895–9901</p><p>[5] Zhang, Jingqing and Zhao, Yao and Saleh, Mohammad and Liu, Peter J. <em>PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive Summarization. </em>Proceedings of the 37 th International Conference on Machine Learning, Vienna, Austria, PMLR 119, 2020</p><p>[6] Raffel, Colin et al. <em>Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. </em>Journal of Machine Learning Research, 2020, vol. 21, pages 1–67</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98c1e3cd821d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>