***This article was originally published on Understanding LLM and using Chain of Thoughts on July 24, 2023 by Rick Hightower.***

https://media.licdn.com/dms/image/v2/D5612AQF7vJDJtDzpVw/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1690825545417?e=1736380800&v=beta&t=66qZTNaNKKQPKf1xV7nVH5NGpTsPt3ylcgdbf6P0pIY

Understanding LLM and using Chain of Thoughts

Author: Rick Hightower

We implement a real-world use case that most developers and tech managers should understand. We give ChatGPT a Java method and ask it to produce a Mermaid markdown format.

Chain of Thought (CoT) prompting is a technique that improves the performance of Large Language Models (LLMs) on reasoning-based tasks through few-shot learning. According to Toward Data Science, CoT enables LLMs to address complex tasks, such as common sense reasoning and arithmetic, by breaking down multi-step requests into intermediate steps. This decomposition creates a window of insight and interpretation, allowing for manageable granularity for both input and output, making it easier to tweak the system.

CoT prompting breaks down a problem into a series of intermediate reasoning steps, thus significantly improving the ability of LLMs to perform complex reasoning. There are different strategies for implementing CoT prompting, such as few-shot CoT and zero-shot CoT. In few-shot CoT, examples of Question-Answer pairs are provided where the answer is explained step by step. In zero-shot CoT, the Answer block is prefixed with "Let's think step by step" to prompt the LLM to complete the output in that format. The benefits of CoT prompting become more apparent as the model scale increases, leading to improved performance that substantially outperforms standard prompting for large model sizes. These findings are supported by experiments on three large language models, as described in Google AI Blog and arXiv.

It is the context.

ChatGPT is an AI language model that generates human-like text and engages in conversations. It's like an intelligent computer program that can understand and generate text based on context. However, it's important to remember that ChatGPT is not perfect and can sometimes forget or misunderstand the context, especially if the conversation is long or complex. To help ChatGPT better understand and remember the context, you can try the following:

  1. Keep the context clear and concise: Ensure your instructions are easy to understand and short. This will help ChatGPT focus on critical information and reduce the chances of it forgetting the context.
  2. Repeat important information: If there's a specific rule or piece of information you want ChatGPT to remember, you can remind it periodically throughout the conversation. This will help reinforce the context and make it more likely for ChatGPT to remember it.
  3. Be patient and adjust your expectations: ChatGPT is an impressive AI tool, but it's imperfect. It might only sometimes remember the context or follow the rules you set. In such cases, could you remind it of the context or rules and try again.
  4. Use Chain of Thought (CoT) to prime ChatGPT with context so the generation it does is more likely to be your desired results.

ChatGPT is like predictive text, so it's essential to prime its context to produce the desired output. By following these tips, you can help improve ChatGPT's understanding of the context and increase the chances of it generating the text you want. Let’s break down what COT is and then show an example. This article focuses on CoT.

Basics of Chain of Thoughts

Chain of Thought (CoT) prompting is a technique that improves the performance of Large Language Models (LLMs) on reasoning-based tasks through few-shot learning. According to Toward Data Science, CoT enables LLMs to address complex tasks, such as common sense reasoning and arithmetic, by breaking down multi-step requests into intermediate steps. This decomposition creates a window of insight and interpretation, allowing for manageable granularity for both input and output, making it easier to tweak the system.

CoT prompting breaks a problem down into a series of intermediate reasoning steps, thus significantly improving the ability of LLMs to perform complex reasoning. There are different strategies for implementing CoT prompting, such as few-shot CoT and zero-shot CoT. In few-shot CoT, examples of Question-Answer pairs are provided where the answer is explained step by step. In zero-shot CoT, the Answer block is prefixed with "Let's think step by step" to prompt the LLM to complete the output in that format. The benefits of CoT prompting become more apparent as the model scale increases, leading to improved performance that substantially outperforms standard prompting for large model sizes. These findings are supported by experiments on three large language models described in Google AI Blog and arXiv.

Let's break CoT down a bit.