What is a Prompt and How Does AI Understand It?
The sentences we write when asking AI a question or requesting a specific task are called prompts.
A prompt is a command or question structured so that AI can understand and respond to it.
In this lesson, we will explore how AI understands and processes these prompts.
What is a Prompt?
A prompt is a sentence that requests AI to perform a specific task or information.
For example, the question "What's the weather like tomorrow?" is a prompt asking AI for weather information.
AI will receive this question and generate a suitable response.
Understanding and generating an appropriate response to this sentence involves a complex process for AI.
How AI Understands Prompts
Let's look at the main steps AI goes through to understand a prompt and generate a response.
1. Tokenization
First, AI breaks down the sentence into smaller units. This process is called tokenization.
For example, the sentence "What's the weather like tomorrow?" would be broken down into ['What's', 'the', 'weather', 'like', 'tomorrow', '?'].
These smaller units are called tokens.
Tokenization is the first step for AI to understand the sentence, allowing it to process each word individually.
2. Embedding
The next step is the embedding process, which converts each token into numerical form.
Since AI cannot directly understand text, it needs to convert it into numbers.
Embedding transforms each word into a unique vector (an array of numbers) so that a computer can compute it.
For example, the word 'tomorrow' might be converted into a vector like [0.1, 0.3, -0.2].
This vector is generated according to specific rules to represent the relationships between words.
3. Context Understanding through the Attention Mechanism
The attention mechanism is a key technology that helps AI understand context.
Sentences are not just a simple sequence of words, so AI needs to grasp the meaning of each word within the sentence.
The attention mechanism helps AI focus on specific words while also considering other parts of the sentence simultaneously.
For example, the attention mechanism helps AI understand that the word 'weather' is closely related to 'like' in the sentence "What's the weather like tomorrow?" to generate a more accurate response.
4. Response Generation
Finally, AI generates a response based on the understood context.
After going through the previously mentioned steps, AI derives the most appropriate answer to the given prompt.
Summary
AI uses tokenization, embedding, the attention mechanism, and other techniques to understand the prompts written by users.
Through these processes, AI can comprehend complex contexts and provide suitable responses.
In the next session, we will explore how to write more effective prompts for interaction with AI.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.