Imagine transforming your retail store’s performance with just a smartphone and the power of artificial intelligence (AI). This isn’t a far-off future scenario; it’s a reality that small and mid-size retail stores can implement today! In this tutorial, we’ll explore an exciting real-world use case where store owners and managers can use AI to optimize their shelf arrangements, boost sales and enhance the customer experience. We will leverage both the latest IBM Granite model in this project as well as Meta's Llama 3.2 vision model.
With the advent of agent-based generative AI, small and mid-size retail stores now have access to expert-level analysis and recommendations that were once the domain of large corporations with dedicated data science teams. This democratization of AI technology can be groundbreaking for your local grocery store, boutique shop or regional chain.
Here’s what makes this approach so revolutionary:
Let’s dive into the technical details and see how this AI-powered retail optimization works, step by step. By the end of this tutorial, you’ll have a clear understanding of how to implement this system in your own store, potentially revolutionizing your retail space with the power of AI.
Sarah is a local grocery store owner who was struggling to compete with larger chains. Despite her best efforts, she noticed that certain products weren't selling as well as they should, while others were constantly out of stock. One day, while reorganizing her fresh produce aisle for the third time that month, she wondered if there was a better way.
That's where our AI-powered solution comes in. Using just her smartphone and our intelligent system, Sarah was able to transform her store's performance. Let's dive into how to build such a system.
We can use crewAI, an open-source agent framework that orchestrates agent interactions in crews. The term "crew" refers to multi-agent systems. Our crew is a team of agents role-playing retail experts that are available 24 x 7, each with their own specialty. Tasks can either be directly assigned to an agent or handled through crewAI’s hierarchical process that assesses specific roles and availability.
For crewAI beginners, check out the crewAI explainer along with the official docs. On the official crewAI GitHub repository, you can also find examples of crews performing stock analysis, data analysis, RAG, LangGraph integration and much more.
Let's have a look at the team of agentic retail experts we will use in this tutorial.
The task workflow is as follows.
You can find this project on Github.
We first need to set up our environment. You can find these steps in the Markdown file on GitHub or by following along here.
The project structure of the
src/my_retail_advisor/ ├── config/ │ ├── agents.yaml # Agent configurations │ └── tasks.yaml # Task definitions ├── tool/ │ ├── custom_tool.py # Custom crewAI tool implementations │ └── tool_helper.py # Vision helper functions ├── crew.py # Crew orchestration └── main.py # Application entry point
Generate and take note of your free Serper API key. Serper is a Google Search API that we will be using in this project.
We need to install the crewAI framework for this tutorial and set our watsonx.ai credentials that we generated in step 2.
To install crewAI, run the following command in your terminal.
In a seperate
crewAI can be configured to use any open source large language model (LLM). LLMs can be connected through Ollama and several other APIs such as IBM watsonx™ and OpenAI. Users can also leverage pre-built tools available through the crewAI Toolkit as well as LangChain Tools.
Our custom visual search tool is powered by the
There are many ways you can customize your crew:
Ensure you are in the proper working directory of this project. You can change directories by running the following command in your terminal.
To kickoff your crew of AI agents and begin task execution, run this command from the root folder of your project. Note, the crew may run for several minutes before returning a final result.
This command initializes themy-retail-advisor Crew, assembling the agents and assigning them tasks as defined in your configuration. This example, unmodified, will use Granite on watsonx.ai to create a report.md file with the output. crewAI can return JSON, Pydantic models and raw strings as output. Here is an example of the output produced by the crew.
Action Plan for Rearranging and Improving the Vegetable Shelf
Objective:
To create a visually appealing and organized produce section that showcases the most popular vegetables, increases sales, and enhances customer satisfaction.
Recommendations from the Market Analyst:
Action Plan for Store Manager and Store Buyer:
...
Step 1: Focal Point Display
...
Step 4: Themed Displays and Additional Features
As seen in the sample output, the multi-agent system is able to execute the sequential process of processing input, tool calling and formulating findings.
Remember Sarah's fresh produce aisle problem? Here's how the system helped her:
In summary, the
With AI-powered tools like this, small and medium-sized retailers can streamline their decision-making process. Just like Sarah, you can transform your store's performance with technology that's accessible, affordable and effective. This architecture also unlocks other AI opportunities across various domains, such as product design and enhanced customer experience. Its flexibility makes it valuable beyond retail, empowering businesses to innovate and excel in industry-specific tasks.
Easily design scalable AI assistants and agents, automate repetitive tasks and simplify complex processes with IBM® watsonx Orchestrate™.
Create breakthrough productivity with one of the industry's most comprehensive set of capabilities for helping businesses build, customize and manage AI agents and assistants.
Achieve over 90% cost savings with Granite's smaller and open models, designed for developer efficiency. These enterprise-ready models deliver exceptional performance against safety benchmarks and across a wide range of enterprise tasks from cybersecurity to RAG.