Model Window Secrets

3 min read

I've been experimenting with LLMs (Large Language Models) for a while now, and one thing that's always puzzled me is what exactly goes into the model window on each turn. I've read a lot of articles about LLMs, but most of them gloss over this important detail.

Let's take a closer look at what's happening behind the scenes. When you interact with an LLM, you're essentially having a conversation with it. You ask a question, and the model responds. But what's really happening is that the model is taking in your input text, breaking it down into smaller parts, and then using these parts to generate a response.

The input text can be broken down into several components. The prompt is the initial text that you provide to the model. It can be a question, a statement, or even a prompt for the model to generate text. The context is the text that the model has seen previously in the conversation. It can include previous questions, responses, and even the conversation history. The state refers to the internal state of the model, which can include things like the model's memory, attention, and other internal variables.

The model uses these components to generate a response, which is then displayed in the model window. But here's the thing: the model window only shows a portion of the input text. It's like looking at a snapshot of the conversation, but it's not the whole picture.

For example, let's say you're having a conversation with an LLM about a specific topic. You ask a question, and the model responds with a relevant answer. But what's actually happening is that the model is taking in the entire conversation history, including previous questions and responses, to generate a more accurate answer.

python
import torch

# Create a sample input text
input_text = "What is the capital of France?"

# Print the first 10 characters of the input text
print(input_text[:10])

In this example, the model window only shows the first 10 characters of the input text, but the model is actually taking in the entire conversation history to generate a response.

Model Window Input
Prompt20%Context40%State40%
Data from the sources listed below.

In this chart, we can see that the prompt accounts for 20% of the input text, while the context and state account for 40% and 40%, respectively.

Understanding the model window is crucial to working with LLMs effectively. By taking into account the entire conversation history, the model can generate more accurate and relevant responses.

Try this

  • Try interacting with an LLM and observe the model window to see how it changes over time.
  • Experiment with different input texts and see how the model responds.
  • Use a tool like torch to create a simple text generator and observe the output.

Sources