In Natural Language Processing (NLP), intent refers to a user's expression of some purpose, want or desire. By analyzing the messages sent by the user and recognizing the intention behind them, we can reply with relevant content. For example, "order food", "check the weather", "I want to go to Paris", etc. are valid intents.
In order for the chatbot to accurately recognize a user's intent, we need to define a name and a set of examples for each intent. The name is a unique label used to identify the intent and the examples are sample utterances used to train the chatbot to recognize the intent. The name should be concise, clear, and consistent, and the examples should be varied, typical, and covering. For example, we can define the following for the intent "order food":
Name: order_food
Example:
- I'd like to order a pizza.
- A bowl of beef noodles, please.
- What are your specialties?
By defining different intents, we can enable chatbots to handle multiple types of user requests and provide appropriate responses or actions based on different scenarios. For example, if a user types "I want to go to Paris", the chatbot can recognize this as a "travel" intent and provide information and suggestions for Paris based on the user's preferences and budget. In this way, we can create a smarter, more flexible, and more humanized chatbot.
Introducing Intentions
Zep 's intent extractor identifies the intent of a message and persists it in the message metadata. 💡 With intent data, developers can build richer, more personalized smart body interactions. 🔥
In the field of Natural Language Processing (NLP), extracting meaning from the chaos of human communication can seem daunting. Today, we are excited to introduce an important feature, Intent Extraction, which provides deeper value for real-time understanding.
Understanding user intent is the cornerstone of designing meaningful and personalized interactions in any conversational AI system. Extracting intent is not just about recognizing words or phrases, it's about understanding what the user means in a given context. Personalization of Large Language Model (LLM) applications requires understanding intent throughout the conversation.
Our newly launched feature:Intent Extraction, is a valuable tool for organizations to leverage AI-driven customer interactions.
What is Intent Extraction?
At the heart of intent extraction is an NLP task that involves recognizing the user's goal or purpose - what they want to do - from their input. For example, a user might say, "Play some upbeat music". The intent here is not just to "play music", but to specify the type of music - "upbeat".
Intent to use
By default, Zep automatically extracts the intent of each message, you can toggle enabling or disabling this feature by editing config.yaml:
...
extractors:
summarizer:
enabled: true
entities:
enabled: true
intent:
enabled: true
embeddings:
enabled: true
dimensions: 1536
model: "AdaEmbeddingV2"
...
By default, all conversations will contain a "system" metadata with an "intent" for each message stored in Zep.
Intent Driving Personalization
The following example illustrates how Intent can be combined with customer preferences to help drive personalized interactions with users in an e-commerce environment:
Human: I'm looking for a new skincare product.
ZepMemory:
{
"uuid": "6026b3b7-3755-4d00-89d8-243ecfc45931",
"created_at": "2023-06-21T02:19:45.577522Z",
"role": "human",
"content": "I'm looking for a new skincare product.",
"metadata": {
"system": {
"intent": "The subject is expressing a need or want for a new skincare product."
}
"customer_firstname": "Alice",
"customer_id": "KDSJFJDSF",
"member_since": "03-01-2009",
"product_pref_tags": "eco-friendly, vegan"
},
"token_count": 11
}
AI: Of course, Alice. Based on your preference for eco-friendly and vegan products, I can recommend a few options. Are you looking for a specific type of skincare product like a cleanser, moisturizer, or serum?
ZepMemory:
{
"uuid": "30eb918d-4b3a-42a9-a64b-c79e01f87ec4",
"created_at": "2023-06-21T02:19:45.577522Z",
"role": "ai",
"content": "Of course, Alice. Based on your preference for eco-friendly and vegan products, I can recommend a few options. Are you looking for a specific type of skincare product like a cleanser, moisturizer, or serum?",
"metadata": {
"system": {
"intent": "The subject is offering recommendations for eco-friendly and vegan skincare options and inquiring about the specific type of product the person is looking for."
}
},
"token_count": 46
}
Human: I'm looking for a good face moisturizer.
ZepMemory:
{
"uuid": "f8ec855b-fd59-4084-a3d1-2b81857d5dcd",
"created_at": "2023-06-21T02:19:45.577522Z",
"role": "human",
"content": "I'm looking for a good face moisturizer.",
"metadata": {
"system": {
"intent": "The subject is searching for a specific type of facial skincare product."
}
},
"token_count": 12
}
AI: I recommend the 'Green Goddess' vegan moisturizer. It's a highly rated, eco-friendly product and is particularly effective for dry skin. Would you like to add this to your cart?
ZepMemory:
{
"uuid": "4e3d0fe8-5242-4c9c-8891-34636af1e576",
"created_at": "2023-06-21T02:19:45.577522Z",
"role": "ai",
"content": "I recommend the 'Green Goddess' vegan moisturizer. It's a highly rated, eco-friendly product and is particularly effective for dry skin. Would you like to add this to your cart?",
"metadata": {
"system": {
"intent": "The subject is making a product recommendation and asking if the listener would like to add it to their cart."
}
},
"token_count": 40
}
Human: Great, that should work!
ZepMemory:
{
"uuid": "5ec6a546-eec9-4b9d-b03d-11b142600a0a",
"created_at": "2023-06-21T02:19:45.577522Z",
"role": "human",
"content": "Great, that should work!",
"metadata": {
"system": {
"intent": "None."
}
},
"token_count": 8
}
]
}
Why is intent extraction so important?
As the use of AI chatbots continues to grow across all domains, the need for these systems to understand and respond appropriately to user intent has become more important than ever. Intent extraction helps:
- Enhanced user experience: By understanding the user's intent, AI systems can provide relevant and personalized responses that increase user satisfaction.
- Simplified interaction: It helps streamline conversations by identifying the user's goals early in the exchange.
- Increased efficiency: By accurately recognizing a user's intent, AI systems can begin to perform actions on the user's behalf (e.g., calling APIs, updating the system, etc.), which can improve the overall efficiency of these systems.
practical application
Today's big language models are very powerful in terms of understanding, reasoning and inference. So how can you harness the power of intent in your applications?
Let's see how the above example can actually be used in a real production environment:
Human intents that we captured in this conversation:
1: "The subject is expressing a need or want for a new skincare product."
2: "The subject is searching for a specific type of facial skincare product."
Now that we know the intent, we can analyze how customers have had these conversations in the past and use it to model several possible ways to interact with them in the future:
- Customers looking for skin care products in the last 7 days
- Customers searching for facial skin care products in the past month
- Customers looking for specific types of products in the skin care category
So if we want to bring together all the clients who have been looking for skincare products in the last seven days, we can now create a client group that includes all the clients who intend to meet these criteria.
# Use Zep SDK
search_results = await client.asearch_memory(
session_id=session_id,
search_payload=MemorySearchPayload(
metadata={
"start_date": "2023-06-02",
"end_date": "2023-06-09",
"where": {"jsonpath": "$[*]['metadata']['system']['intent'] == 'customers looking for skincare'"},
},
),
)
# You can also use Langchain
search_results = retriever.get_relevant_documents(
metadata={
"start_date": "2023-06-02",
"end_date": "2023-06-09",
"where": {"jsonpath": "$[*]['metadata']['system']['intent'] == 'customers looking for skincare'"},
},
)
Additionally, you can continue this analysis to assess how many customers with the intent to purchase a skin care moisturizer end up purchasing it instead of a different but related product (perhaps a sunscreen). This could end up being an improvement on the existing customer base, or perhaps an additional customer base.
Each of these customer segments can then be mapped to a Prompt journey, which can then be optimized for user personalization, brand loyalty, response consistency, or other business outcomes.
from langchain.prompts import PromptTemplate, StringPromptTemplate
from langchain.chains import LLMChain
...
prompt = """you are a helpful shopping assistant. Use the User preferences and Recommendations to write back responses based on the following rules:
1. If the user has preference for {user_pref} then suggest {recommend_sku} products.
2. Make a helpful {prompt_journey_append} suggestion.
"""
prompt_journey.prompt = prompt
...
#
# an example of how a prompt_journey may be used
# prompt_journey may be implemented as a structure that
# contains different prompts that can be used and chained together
# for different customer segments
#
if customer_segment.tag == "ecofriendly":
prompt_journey.type = customer_segment.type
prompt_journey.append("eco-friendly face cream")
prompt_journey.suggest_top(eco_sku)
elif customer_segment.tag == "newcustomer":
prompt_journey.append("face cream with built in sun-protection?)
prompt_journey.suggest_top(spf_facecream)
# Now you can use the chosen prompt
prompt = PromptTemplate.from_template(prompt_journey.prompt)
chain = LLMChain(llm=ChatOpenAI(), prompt=prompt)
chain.run(input=input)
A relevant automated system might continually A/B test different Prompt paths based on learned intent and how you might want to position the product.
Now we can begin to see the power of intent in categorizing how customers interact with a product and building Prompt journeys, which can provide deeper personalization in these interactions.
future of intelligence
What's interesting about Intent is its potential for autonomous AI intelligences. We are excited to combine deep personalization with workflows that may trigger APIs or call external systems based on actions identified in a conversation. Intentions can also be used for debugging steps, pruning unnecessary intelligence execution loops, and optimizing fast intelligence execution.
Understanding intent is at the heart of human interpretability, accuracy and repeatability in these systems. This is still an emerging field and we are seeing teams experimenting and innovating rapidly. We hope that this feature will be useful for a variety of use cases.
With the launch of Intent Extraction, we aim to make conversational AI more personalized, meaningful, and efficient. Try it out now and let us know what you think.