You can also find all 63 answers here π Devinterview.io - LLMs
Large Language Models (LLMs), such as GPT-3 or BERT, are advanced machine learning models with the ability to understand and generate human-like text.
These models have made groundbreaking achievements in language processing tasks such as translation, summarization, and question-answering.
-
Encoder-Decoder Framework: Utilized in models like GPT-3 for a single direction and BERT for bidirectional workflows.
-
Transformer Architecture: LLMs use a vast network of transformer blocks, each with multi-headed self-attention mechanisms. This enables the model to comprehend the context of a given word within a broad surrounding text.
-
Vocabulary and Tokenization: Models segment text into manageable pieces, or "tokens", and manage these through a predefined vocabulary set.
-
Embeddings: These are high-dimensional numerical representations of tokens that lend a sense of context to the model.
-
Self-Attention Mechanisms: Notable for their capacity to couple distinct tokens within the same sentence or sentence pairs.
The training of LLMs goes through several stages, starting with unsupervised training and evolving into widespread context awareness.
-
Unsupervised Pretraining: The model familiarizes itself with the structure of text using massive datasets, often comprising internet content.
-
Fine-Tuning: Algorithms adjust specific parameters according to the goals of the task at hand.
-
Prompt-Based Learning: Implements a more direct learning avenue by asking the model specific questions or issuing directives. This method is fundamental in encouraging the model to create tailored and targeted content.
-
Continual Training: Ensures the model keeps up with the latest data trends, warranty drafts, and language shifts.
The Transformer model has gained immense popularity in modern NLP thanks to its ability to capture long-range dependencies and outperform previous methods. Its foundation is based on attention mechanisms.
-
Encoder-Decoder Model: The Transformer initially featured separate encoders for processing the input sequence and decoders for generating outputs. However, variants like GPT (Generative Pre-trained Transformer) have focused on using only the encoder for tasks such as language modeling.
-
Self-Attention Mechanism: This enables the model to weigh different parts of the input sequence when processing each element. This mechanism forms the heart of both the encoder and decoder.
-
Encoder Layers:
- Comprises multiple encoder layers, each of which consists of a multi-head self-attention module followed by a fully connected feed-forward network. Residual connections are employed for stability.
-
Decoder Layers:
- Contains self-attention and an additional encoder-decoder attention mechanism. Each decoder layer also contains a feed-forward network.
-
Positional Encoding:
- Liberate from sequential network requirements
- Synthetic position-characteristics embedding shared across-data
- Frequency- and position-encoded patterns
-
Multi-Head Self-Attention Mechanism:
- Projects the original input into different subspaces.
-
Feed-Forward Neural Network:
- Consists of two linear layers separated by an activation function.
-
Embeddings:
- Transforms input tokens into a continuous vector space and incorporates relative and absolute positional information.
Teacher Forcing and Self-Learning Schedules are used in the encoder-decoder settings and exclusively with GPT's encoder, respectively.
-
Scalability: Transformer models can upscale up to word-level or subword-level tokens to fit the target application.
-
Adaptability to Modalities: The model conveniently accommodates diverse inputs, making it equally ideal for natural language and other data formats like images and audio.
While both LSTMs (and by extension, RNNs) and traditional statistical language models like N-grams are methods for language prediction, they vary vastly in terms of architecture, training efficiency, and input processing.
- LSTMs: Based on neural networks with a focus on time-series tasks. They model word sequence relationships through memory units. This design allows them to better handle long-range dependencies, which are intrinsic to the probabilistic structure of sentences.
- N-grams: Heavily based on text statistics and word co-occurrences in a fixed window or length of previous words. They are generally unsuitable for capturing complex grammatical structures.
- LSTMs: They require significant computational resources and may take longer to converge during training.
- N-grams: Training is typically faster due to the algorithm's simplicity. The primary compute requirement is for constructing the initial models of word sequences and calculating their probabilities.
- LSTMs: They accept input sequences of variable lengths. They are commonly implemented with mini-batch training to improve computational performance.
- N-grams: The input length is restricted to 'n' previous words. Models are initialized by combining adjacent words through a fixed-length sliding window mechanism; therefore, they have a limited capability to predict sequences with significantly different or longer contexts than the training data.
Here is the Python code:
from collections import defaultdict
class NGramsModel:
def __init__(self, n):
self.n = n
self.sequences = defaultdict(int)
self.contexts = defaultdict(int)
def train(self, corpus):
for sentence in corpus:
words = sentence.split()
for i in range(len(words)-self.n):
context = ' '.join(words[i:i+self.n-1])
word = words[i+self.n]
self.contexts[context] += 1
self.sequences[(context, word)] += 1
def predict(self, history):
max_prob = 0
next_word = ''
for word in set(self.sequences.keys()):
if word[0] == history and self.sequences[word]/self.contexts[history] > max_prob:
max_prob = self.sequences[word]/self.contexts[history]
next_word = word
return next_word
# Usage
corpus = ["The cat sat on the mat.", "The dog barked loudly."]
ngrams_model = NGramsModel(2)
ngrams_model.train(corpus)
print(ngrams_model.predict('The cat'))
- N-grams: Better for applications where model simplicity and fast real-time inference are essential, such as spell checking systems and speech recognition.
- LSTMs: More suitable for tasks requiring complex contextual understanding and long-range dependencies, such as machine translation and text generation.
The Attention Mechanism, a key innovation in transformer models, enables them to process entire sequences at once. Unlike RNNs or LSTMs, which proceed sequentially, transformers can parallelize operations, making them ideal for lengthy sequences.
-
- For each word or position, the transformer generates three vectors: Query, Key, and Value.
- These vectors are used in a weighted sum to focus on certain parts of the input sequence.
-
-
The Dot-Product Method of obtaining attention scores constitutes multiplying Query and Key vectors. The result is then normalized through a softmax function.
-
The Scaled Dot-Product Method involves adjusting key vectors for increased numerical stability.
-
From attention scores, the model derives attention weights that suggest the relative importance of each word in the sequence with regard to the specific word or position.
-
-
-
To give the model necessary multitude and independence in learning, attention mechanisms in modern transformer models are adapted into multiple "heads." This method also enhances the distinction in mechanisms by:
- Dividing the vector spaces into independent dimensional subspaces, affording the model more scope to learn varied and rich representations.
- Conducting attention distinctively over these subspaces, with each head supplying a weighted sum of word representations ("value" vectors), which is then merged before being input into subsequent layers.
-
The results of these multiple attention heads are blended linearly and projected, contributing to further sophistication.
-
The advantage is that each attention head can focus on unique parts of the input sequence.
-
-
- Since attention mechanisms alone do not inherently observe the sequence's order, a method is required to impart positional information.
- Positional encodings, which reveal the stride and arrangement of words in a sequence, are connected to both the input and output of the attention mechanisms.
- Encoder-Decoder Architecture: Its fundamental design comprises an encoder, responsible for analyzing the input sequence, and a decoder, which utilizes this understanding to generate the output sequence.
- Stacked Layers: The transformer structure is formed by attaching multiple repetitive layers on top of each other. Each of these layers is composed of intra- and inter-relationships amongst different attention heads. Such depth aids in the incremental refinement of representations.
Here is the Python code:
import tensorflow as tf
# Suppose we have a sequence of 10 words, each represented by a 3-dimensional vector.
# Let's create artificial data for Illustrative purposes.
sequence_length = 10
dimension = 3
batch_size = 2 # Two data instances
# Create synthetic data
input_sequence = tf.random.normal((batch_size, sequence_length, dimension))
num_attention_heads = 2 # We will use two attention heads
# Perform multi-head attention
multi_head_layer = tf.keras.layers.MultiHeadAttention(num_heads=num_attention_heads, key_dim=dimension)
# Process the input sequence through the multi-head layer
# Here, we are simulating the self-attention mechanism often used in transformers where the query, key, and value matrices are derived from the same input sequence
output_sequence = multi_head_layer(query=input_sequence, value=input_sequence, key=input_sequence)
print(output_sequence.shape) # Expected Output: (2, 10, 3) since the sequence length and dimensionality remain the same.
In the context of Language Models, Positional Encodings aim to capture the sequence information that is not intrinsically accounted for in transformer models.
Transformers use self-attention to process all tokens simultaneously, which makes them position-independent. Positional encodings are introduced to inject position information, using a combination of fixed patterns and learned representations.
-
Additive Approach: The original input word embeddings and the positional encodings are summed, effectively combining the static, learned word representations with positional information.
-
Frequency Method: Some models, like the GPT (Generative Pre-trained Transformer) series, use a trigonometric function to create the positional encodings, which are then added to the input embeddings.
The general formulation of Positional Encoding is:
Here,
The usage of a sine function for even indices and a cosine function for odd indices allows the model to capture different phase relationships between sequences of different frequencies.
This approach offers a "hackish" way to prioritize positional information of varying scales. As the formula demonstrates, higher-frequency components influence words that are further along in the sentence, while lower-frequency components emphasize closer proximity.
The specific constant
Here is the Python code:
import numpy as np
def positional_encoding(sentence_length, model_dim):
pos_enc_matrix = np.zeros((sentence_length, model_dim))
for pos in range(sentence_length):
for i in range(0, model_dim, 2):
pos_enc_matrix[pos, i] = np.sin(pos / (10000 ** (i / model_dim)))
pos_enc_matrix[pos, i + 1] = np.cos(pos / (10000 ** (i / model_dim)))
return pos_enc_matrix
Linear Language Models (LLMs) are a type of statistical language model that aims to generate coherent and task-relevant language sequences based on the given input. LLMs have brought about a paradigm shift in the era of Natural Language Processing (NLP) and have led to significant improvements in various NLP-centric tasks.
One of the essential aspects of LLMs is pre-training and fine-tuning, which provides substantial benefits and practical advantages, especially when working with small datasets.
- Capturing General Language Patterns: LLMs are pre-trained on vast amounts of text data, enabling them to understand general language structures, contexts, and nuances.
- Learning Contextual Representations: They capture contextual word representations based on surrounding words in sentences and paragraphs.
- Domain Agnostic Learning: LLMs trained on diverse datasets can be used as a starting point for various tasks and domains.
- Universal Embeddings: They produce word and sentence embeddings that are contextually rich and universally applicable to a wide range of tasks.
- Task-Specific Adaptation: By fine-tuning LLMs on task-specific data, you can leverage the general knowledge captured during pre-training to address specific requirements of the given task or domain.
- Accommodating Data Imbalance: Fine-tuning allows you to rectify skewed class distributions and dataset imbalances that are common in real-world applications.
- Context Refinement: When fine-tuned on domain-specific data, LLMs can improve their contextual understanding and textual generation accuracy within that particular domain or task.
Another advanced strategy involves knowledge distillation, where a large pre-trained LLM is used to train a smaller, task-specific LLM. This approach benefits from both the broad linguistic knowledge of the large model and the precision and efficiency of the smaller model, making it useful in scenarios with limited computational resources.
Here is the Python code:
# Load pre-trained BERT model
bert_model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
# Prepare training data and optimizer
# Fine-tune BERT on your specific text classification task
bert_model.train()
for input_ids, attention_mask, labels in training_data:
optimizer.zero_grad()
outputs = bert_model(input_ids, attention_mask=attention_mask, labels=labels)
loss = outputs.loss
loss.backward()
optimizer.step()
# After fine-tuning, you can utilize the tuned BERT model for text classification
Large Language Models (LLMs) have revolutionized natural language processing, leveraging advanced techniques to handle context and long-term dependencies in text.
Recurrent Neural Networks (RNNs) were one of the earliest models to incorporate word sequences and handle context. A hidden state vector from the previous time step is used to incorporate historical context, but owing to its simpler mechanism, RNNs often face vanishing/exploding gradient problems, limiting their ability to capture long-range dependencies.
Long Short-Term Memory Networks (LSTMs) and Gated Recurrent Units (GRUs) were designed to overcome the limitations of simple RNNs in capturing long-range dependencies.
-
LSTM: Employs a memory cell and three gates - input, forget, and output.
- The input and forget gates regulate the flow of information into the cell.
- The output gate controls what information from the cell state is passed on to the next time step.
-
GRU: Simplified architecture with two gates - a reset gate and an update gate.
- The reset gate decides the proportion of previous state to forget.
- The update gate balances between new and previous states.
By selectively retaining or updating information, both LSTMs and GRUs effectively manage context.
The Transformer moved away from RNN-based designs entirely, relying on self-attention mechanisms. It optimally processes word sequences in parallel, effectively capturing context and long-range dependencies. Each word's embedding attends to all words in the sequence, producing a weighted sum that encapsulates context.
-
Self-Attention: Words in a sentence interact with one another, with the attention mechanism highlighting relevant words for each word in the sequence.
-
Positional Encoding: To imbue words with their location in the sequence, a positional encoding is added to word embeddings.
-
Layer Normalization: Reduces the harmful effects of degradation in deeper networks.
-
Multi-head Attention: Enables the model to focus on different parts of the sequence, enhancing its interpretability.
While the original Transformer was introduced for sequence-to-sequence tasks, it also outperforms traditional RNN-based models like LSTMs and GRUs in language modeling.
- Encoder: Captures dependencies within a sentence.
- Decoder: Uses the encoded information to generate translations in machine translation tasks.
Models such as BERT and GPT-3 leverage the Transformer's architecture and have been fine-tuned for various natural language tasks.
-
BERT (Bidirectional Encoder Representations from Transformers): Unlike traditional LSTMs, BERT employs a bidirectional architecture that utilizes both preceding and succeeding words together.
-
GPT (Generative Pre-trained Transformer): A unidirectional model that's been trained on an extensive corpus, demonstrating excellent capabilities in tasks that require generating coherent text, such as story completion or question answering.
Transformers are a crucial tool in achieving parallelization for both inference and training in Large Language Models.
A Transformer architecture is based on input Embeddings, Self-Attention Mechanism, and Feed-Forward Neural Networks.
- The self-attention mechanism allows each word in a sequence to attend to all other words, enabling parallel processing.
- Two steps in the self-attention processβQKV (query, key, value) and weighted sumβare computational bottlenecks without parallelization.
To speed up QKV computation, matrix operations are relied upon, allowing for parallelization across head, sequence length, and model's depth dimensions.
- Several operations can be expressed in matrix notation for concurrent execution.
- High-performance libraries like cuBLAS, cuDNN, and TensorRT are optimized for neural networks, providing maximum parallelism.
While parallelism is advantageous, it also introduces complications, especially with learning dependencies and resource allocation. Techniques such as bucketing, attention masking, and layer normalization are deployed to address these concerns.
- Bucketing breaks down the input into sets (or "buckets") with similar sizes for efficiency, and the buckets can then be processed in parallel.
- Attention masking ensures that not all tokens are attended to, enabling control over parallel processing.
- Layer normalization bridges the gap between computational steps, lessening the impact of parallelism on learned representations.
Language Model Pipelines (LLMs) are versatile tools that find applications in a wide range of industries. Let's take a look at some of the prominent use-cases.
-
Text Generation: LLMs can auto-complete sentences or generate entire paragraphs. They are frequently used for email recommendations, chatbots, and content auto-generation.
-
Text Summarization: These models are proficient at condensing long documents into shorter, more focused summaries. This is useful in news articles, document management, and note-taking applications.
-
Machine Translation: LLMs can swiftly translate text from one language to another, enabling global communication.
-
Question-Answering Systems (QA): Applications such as search engines or virtual assistants benefit from LLMs that can comprehend user queries and return accurate answers.
-
Named Entity Recognition (NER): LLMs identify and classify entities in text, such as names of persons, organizations, or locations. This is essential in tasks like information retrieval, sentiment analysis, and data extraction.
-
Speech Recognition: While not a direct LLM application, combined use with LLMs allows for text generation from voice inputs, enabling virtual assistants and voice-to-text features in devices.
-
Language Model Composition: By combining LLMs with task-oriented modules, complex applications in document completion, grammatical error correction, or machine comprehension can be achieved.
-
Adaptive Learning: LLMs can refine themselves over time by learning from user interactions and feedback, leading to more targeted, personalized results. This forms the backbone of various personalized recommendation systems for e-commerce or content streaming.
-
Text Classification: LLMs play a pivotal role in classifying incoming text into distinct categories, such as sorting emails into folders.
-
Anomaly Detection: By comparing incoming text with what the LLM has learned, it can identify divergent or unusual patterns, crucial in fraud detection or security protocols.
-
Human-Robot Interaction: In applications employing a linguistic interface between humans and robots, LLMs facilitate natural, context-aware conversations, enhancing the user experience.
10. How is GPT-3 different from its predecessors like GPT-2 in terms of capabilities and applications?
Generative Pre-trained Transformer 2 (GPT-2) and Generative Pre-trained Transformer 3 (GPT-3) are both cutting-edge language models, but they differ significantly in scale, training methods, and practical applications.
-
GPT-2: Released in 2019, it had 1.5 billion parameters, setting the standard for advanced language models at the time.
-
GPT-3: Its 175 billion parameters dwarf GPT-2, making it almost 100 times more powerful. It's the largest language model developed as of 2021.
-
GPT-2: Trained mainly through unsupervised learning, using a diverse array of internet data.
-
GPT-3: It incorporates a hybrid of supervised and unsupervised learning, culled from a more controlled dataset, a feature that sets it apart from its predecessor.
-
GPT-2: Demonstrated a striking capacity for coherent, context-aware text generation, albeit with occasional issues of consistency and fact checking.
-
GPT-3: With its enhanced scale and refined training, it has substantially improved text coherence, consistency, and factual accuracy.
-
GPT-2: Its common applications include text completion, summarization, language translation, and more exploratory uses such as creative story generation.
-
GPT-3: Thanks to its augmented capabilities, it's employed in chatbots, virtual assistants, code generation, automated content writing, and other advanced language tasks while still under certain regulatory constraints.
The fields of Natural Language Processing (NLP) and Machine Learning have seen a rapid evolution with the advent of Large Language Models (LLMs). Their adaptable nature is evident through domain-specific models tailored to solve task-specific challenges.
-
Domain-specific Search Engines: These engines are proficient at filtering and retrieving information related to specific industries or interests.
-
Sentence Correction and Predictive Text: Integrating specialized models significantly enhances accuracy and relevance in grammar checks and text suggestions.
-
Legal Research and Documentation: Tools customized for the legal domain offer precise insights and document automation.
-
Medical Domain: Custom solutions cater to tasks like diagnosis, report generation, and making sense of complex medical texts.
-
Customer Service and Sentiment Analysis: Sentiment models are finessed to discern nuances in language, particularly within the context of customer interactions.
-
Finance: Models are fine-tuned to recognize financial jargon, analyze market trends, and for risk assessment.
-
Entertainment: Tailored engines can anticipate user preferences and deliver personalized content recommendations.
-
E-commerce: The process of product recommendation is enriched by ML algorithms trained to understand purchasing behaviors and product features in an e-commerce context.
-
Gaming: LLMs contribute to realistic conversation with in-game characters and drive dynamic game narratives.
-
Automotive: They help in the refinement of voice-enabled controls.
Language Model is a trailblazing technique in machine learning and natural language processing.
For sentiment analysis, LLMs have proven especially effective due to fine-tuning and transfer learning, making them a top choice in many applications today.
LMs are models that predict the likelihood of a word given the preceding words in a sequence.
LLMs extend this and allow for bi-directional context, considering words both before and after the current word.
This helps them better understand vocabulary, grammar, and contextual semantics.
LLMs show pronounced effectiveness in three key areas of sentiment analysis:
-
Nuanced Responses: By considering context from both preceding and following words, LLMS are able to more accurately comprehend complex nuances, idioms, and figures of speech.
-
Disambiguation and Negation: Through pre-trained knowledge and contextual insight, LLMs effectively tackle issues like negation and ambiguity, which are common challenges in sentiment analysis.
-
Contextual Relevance: They notably excel in determining sentiment based on linguistic context, which often requires looking beyond a single sentence.
Here is the Python code:
from transformers import BertTokenizer, BertForSequenceClassification
import torch
# Load pre-trained model and tokenizer
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
# Prepare text and convert to token IDs
text = "Movie was not good, very disappointing"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
# Obtain predicted sentiment using the model
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits)
print("Predicted Sentiment Class:", predicted_class)
In this example, the code uses BERT, a popular LLM, to predict the sentiment class of the given text.
Language Model-based Methods (LLMs) are widely used for generating coherent, context-aware text. Their applications range from chatbots and virtual assistants to email auto-response systems.
LLMs, particularly the modern Transformer-based models, have pioneered the development of advanced text generation techniques, allowing for dynamic text synthesis with high fidelity and context-awareness.
- Method: Selects the most likely word at each step, keeping a pool of top-scoring sequences.
- Advantages: Simplicity, robustness against local optima.
- Drawbacks: May lead to repetitive or generic text.
- Method: Extends beam search by adding diversity metrics that bias towards unique words.
- Advantages: Reduces repetitive sentences.
- Drawbacks: Complexity and potential for longer runtimes.
- Method: Randomly samples from the top k or the nucleus (cummulative probability) words.
- Advantages: Improves novelty and allows for more diverse text generation.
- Drawbacks: Sometimes results in incoherent text.
- Method: Incorporates randomness in beam search at each step.
- Advantages: Adds randomness while preserving structure.
- Drawbacks: Potential for less coherent text.
- Method: Employs a score-based approach to regulate text length.
- Advantages: Useful for tasks requiring specific text sizes.
- Drawbacks: May not always provide the expected length.
- Method: Introduces noise in input sequences and uses model's language context to predict the original sequence without the noise.
- Advantages: Provides privacy for input sequences without affecting output quality.
- Drawbacks: Requires an extensive clean dataset for training.
Large Language Models (LLMs) exhibit versatility beyond traditional translation approaches. Their self-supervised learning mechanisms, context comprehension, and multilingual capabilities have made them an excellent choice for multi-faceted language tasks.
Most LLMs are proficient in multiple languages, streamlining the translation of texts across language pairs.
Instead of word-to-word mappings, LLMs consider sentence and document contexts for better translation fidelity.
LLMs are equipped to handle sentence structure, vocabulary, and grammar across source and target languages, providing robust translations.
LLMs accommodate the morphological complexities of different languages, enhancing the precision of translations.
With data from a multitude of sources, LLMs can offer translations for less common languages, often outperforming traditional methods.
-
Direct Inference: Request the LLM for translation with encode-decode mechanisms.
-
Iterative Refinement: Implement a loop where the model fine-tunes the translation with each step.
-
Hybrid Systems: Combine LLM-generated translations with rule-based approaches for enhanced accuracy.
Large Language Models have revolutionized the field of conversation AI, making chatbots more sophisticated and responsive. These models incorporate context, intent recognition, and semantic understanding, leading to more engaging and accurate interactions.
-
Intent Recognition: LLMs analyze user queries and identify the intent or purpose behind them. This helps chatbots provide more relevant and accurate responses. LLMs like BERT can be fine-tuned for intent classification tasks.
-
Named Entity Recognition (NER): Determining specific entities mentioned in user input, like names, locations, or dates, assists in tailoring the bot's responses. Custom models trained on top of LLMs may prove beneficial for domain-specific tasks.
-
Coreference Resolution: Recognizing and resolving pronouns' antecedents enhances the chatbot's ability to understand and maintain consistent context. For example, if the user says, "I want a pizza," followed by "It should be vegetarian," the bot should correctly link "It" to "pizza."
-
Natural Language Generation (NLG): LLMs generate human-like text, allowing chatbots to provide more coherent and contextually appropriate responses. This makes the interaction feel more natural to users.
To optimize LLMs for specific tasks, they can undergo transfer learning followed by fine-tuning:
- A pretrained LLM, like GPT-3, serves as a base model. It's pretrained on vast amounts of general textual data, making it a valuable starting point for specialized tasks.
- The LLM is then fine-tuned using a more focused dataset related to the specific chatbot function or industry, like customer support or healthcare.
Here's the Python code:
# Install the required libraries
!pip install transformers
from transformers import BertForSequenceClassification, BertTokenizer
# Load the pre-trained model and tokenizer
model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2)
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
# Classify the intent
def classify_intent(user_input):
# Tokenize the input
input_ids = tokenizer.encode(user_input, truncation=True, padding=True)
# Predict the intent
logits = model(torch.tensor(input_ids).unsqueeze(0))[0]
intent_id = logits.argmax().item()
# Map the intent ID to a human-readable label
intent_label = ['Positive', 'Negative'][intent_id]
return intent_label
# Test the function
user_input = "I love this product!"
print(classify_intent(user_input)) # Output: "Positive"
In this example, BERT is used for intent classification, which can be the foundation of chatbot interactions, guiding the responses based on user input.