How does ChatGPT work?
The Chat Interface
A Large Language Model (LLM) like GPT-4 is just a raw prediction engine. If you gave it the prompt "The sky is", it would just output "blue." It wouldn't converse with you.
ChatGPT is the product built around the LLM to make it useful for conversation. OpenAI added specific training to the model (called RLHF - Reinforcement Learning from Human Feedback) to teach it how to act like a helpful assistant rather than just an autocomplete engine.
The System Prompt
When you start a new conversation with ChatGPT, OpenAI secretly injects a massive hidden instruction before you even type your first word. This is called the System Prompt.
The system prompt tells ChatGPT things like:
- "You are ChatGPT, a helpful AI assistant trained by OpenAI."
- "Do not give medical advice."
- "Today's date is..."
- "If the user asks for code, format it in markdown."
Your prompt is then appended after this hidden system prompt, and the AI generates its response based on both.
Stateless Nature
An AI model has no permanent memory of your conversations. It is completely stateless.
When you ask a follow-up question, ChatGPT doesn't "remember" what you said 5 minutes ago. Instead, the application takes your entire chat history and sends it back to the AI model alongside your new question. The AI re-reads the entire conversation every single time you hit send.