Reasons and Effects of Rapidly Growing AI Spending in Business
Reasons for the increase in AI spending and a step-by-step guide to optimizing token consumption. Practical solutions for businesses.
Contents
- Introduction
- Problem Analysis: Key Reasons for the Increase in AI Spending
- 1. The Rise of Complex Workflows
- 2. Increasing Trend in Token Consumption
- 3. The Rise of Agent-Based AI
- Solution Steps: Controlling AI Spending
- 1. Optimizing Token Consumption
- 2. Managing the Costs of Agent-Based AI
- 3. Modernizing AI Infrastructure
- Application Example: AI Cost Optimization for an E-Commerce Site
- Conclusion
Introduction
Businesses today are rapidly adopting artificial intelligence (AI) technology to solve more complex and resource-intensive problems. This is leading to a significant increase in AI spending. According to data from Big Technology's AI Summit, while individual token costs are decreasing, the volume of tokens consumed for each task is increasing exponentially. This trend shows that efficiency gains are lagging behind the demand for complex agent-based workflows.
Problem Analysis: Key Reasons for the Increase in AI Spending
1. The Rise of Complex Workflows
Businesses have started to use AI not only for simple data analysis but also in multi-step and highly dependent workflows. For example:
- Automatic response systems and problem solving bots in customer service
- Forecasting models and risk analysis in supply chain management
- Candidate evaluation and recruitment processes in human resources
Such workflows cause the consumption of a large number of tokens at each step. For example, the number of tokens required to resolve a customer request can be 10-100 times more than a simple query.
2. Increasing Trend in Token Consumption
AI models generally work through text-based inputs (prompts) and outputs (tokens). The number of tokens represents the amount of data the model processes. Current trends are:
- Decline in Token Costs: AI model providers are reducing costs per token due to competition. For example, the token cost of the
gpt-4model has decreased by up to 80% over the years. - Explosion in Token Volume: In contrast, the number of tokens consumed for each task is increasing exponentially. For example, as the steps involved in a workflow increase, token consumption grows exponentially rather than linearly.
3. The Rise of Agent-Based AI
Agent-based AI (agentic AI) are systems that can make decisions on their own and automate complex tasks. These systems manage workflows that often consist of multiple steps and interact with the AI model at each step. Examples:
- Order processing process on an e-commerce site
- Automatic evaluation of a loan application at a bank
- Automatic updating of patient records in a hospital
In such systems, the number of tokens consumed at each step is much higher than in a simple query. For example, the number of tokens required to process an order can be up to 10,000.
Solution Steps: Controlling AI Spending
1. Optimizing Token Consumption
One of the most effective ways to reduce AI spending is to optimize token consumption. The following steps can be followed for this:
Prompt Engineering: Optimizing the query text (prompt) sent to the AI model. A well-designed prompt prevents the model from consuming unnecessary tokens.
# An example of a good prompt (for example, to summarize a text)
prompt = """
Convert the following text into a 5-sentence summary:
[Text goes here]
"""
Tip: Avoid unnecessary details in the prompt. Adding information that the model does not need increases token consumption.
Model Selection and Configuration: Different AI models perform differently in terms of token consumption. For example, the gpt-3.5-turbo model consumes fewer tokens than the gpt-4 model, but is less capable.
# Example of Python code for model selection (using OpenAI API)
import openai
# Choose a model that consumes less tokens
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello, how can I help you?"}]
)
print(response)
Warning: When choosing a model, strike a good balance between skill and token consumption. Using an unnecessarily powerful model can increase costs.
Monitoring and Reporting Token Count: Monitor token consumption to keep your AI spending in check. Most AI model providers offer tools that report token consumption.
# Using OpenAI API response to track token consumption
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello"}]
)
# Print the number of tokens to the screen
print(f"Total number of tokens: {response['usage']['total_tokens']}")
2. Managing the Costs of Agent-Based AI
Agent-based AI systems typically consume large numbers of tokens. The following strategies can be applied to manage the costs of these systems:
Reducing the Number and Complexity of Agents: Avoid adding unnecessary agents. Each agent increases token consumption.
Tip: Make sure each of your agents has a specific role. Unnecessary complexity increases costs.
Using Caching: Reduce token consumption by caching the results of frequently used queries.
# Python example for caching (e.g. using Redis)
import redis
# Create Redis connection
r = redis.Redis(host='localhost', port=6379, db=0)
# Cache the query
query = "Hello, how can I help you?"
response = r.get(query)
if response is None:
# If the query is not in the cache, send it to the AI model
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": query}]
)
# Cache the response
r.set(query, response.choices[0].message.content)
print(response.choices[0].message.content)
Monitoring Agents' Token Consumption: Monitor token consumption for each agent separately. Restructure agents that cause unnecessary token consumption.
3. Modernizing AI Infrastructure
Modernize your infrastructure to control AI spending. The following steps can be followed for this:
Optimizing Cloud Services: Optimize costs in cloud services used to host AI models. For example, avoid using unnecessarily powerful servers.
# AWS EC2 instance selection (for example, to host the AI model)
# Avoid using an unnecessarily powerful server
instance_type = "t3.medium" # Medium CPU and memory
Hosting AI Models Locally: By hosting some AI models locally, you can reduce dependency on cloud services. While this may not directly affect token costs, it may reduce overall costs.
Warning: Local hosting requires technical knowledge and infrastructure. Only choose this option if you have the necessary expertise.
Specifically Training AI Models: You can reduce token consumption by using specially trained models instead of general-purpose AI models. For example, using a model optimized for a specific industry or task can reduce token consumption by up to 30%.
Application Example: AI Cost Optimization for an E-Commerce Site
Below are the steps to optimize AI costs on an e-commerce site:
Simplifying the Order Processing Process: Reduce token consumption by reducing the steps involved in the order processing process. For example, instead of automatically filling in customer information, ask the customer for only the necessary information.
Applying Prompt Engineering: Optimize the prompts used in the order processing process. For example, express customer requests more concisely and clearly.
# A good prompt example (for order processing)
prompt = """
Verify and confirm the following order information:
Customer Name: [Name]
Product: [Product Name]
Quantity: [Quantity]
Total Price: [Price]
Type 'Yes' to confirm.
"""
Using Caching: Reduce token consumption by caching responses to frequently used customer queries.
Monitoring Token Consumption: Monitor the number of tokens consumed during the order processing process and reconstruct steps that cause unnecessary token consumption.
As a result of implementing these steps, a reduction of up to 40% was achieved in the AI costs of the e-commerce site.
Conclusion
As AI technology becomes widespread in businesses, expenses are also increasing rapidly. Key reasons for this increase include complex workflows, the explosion in token consumption, and the rise of agent-based AI. To control AI spending, strategies such as optimizing token consumption, managing the costs of agent-based AI, and modernizing AI infrastructure can be implemented.
Following the steps presented in this article can help businesses reduce their AI spend by 30-50%. While taking advantage of the opportunities offered by AI technology, it is important to keep costs under control.