Bhaskar

Experimenting with a Beverage Inventory Management System Enhanced by RAG Capabilities

· bhaskar

Managing inventory and analyzing sales trends are crucial for businesses, especially in the food and beverage industry. With advancements in AI and data querying technologies, tools like Retrieval-Augmented Generation (RAG) and language models can significantly enhance traditional inventory systems by enabling natural language interactions and intelligent data retrieval.

I conducted an experiment with a Python-based Beverage Inventory Management System that integrates RAG capabilities using LlamaIndex and Ollama LLM. While the system performed well, it is worth noting that more powerful LLMs (Large Language Models) could be utilized in the future to provide better tool support and enhanced functionality.

Source: https://github.com/bhaskaraa2/beverage-tech-innovations/tree/main/src/rag-demo


System Overview

The Beverage Inventory Manager is a Python application designed to streamline inventory operations while integrating advanced querying capabilities. It combines traditional inventory management features with RAG to allow for natural language queries and conversational interactions. The system is built using modular components such as:

  1. Pandas DataFrame Queries: For querying sales and inventory data.
  2. RAG Query System: For document indexing and natural language querying using LlamaIndex.
  3. LangChain Agents: For advanced workflows and multi-tool integrations.

The system currently uses Ollama and LlamaIndex for development, but future iterations could integrate more powerful LLMs like OpenAI GPT-4, Anthropic Claude, or Google PaLM to improve tool support and expand capabilities.


Experiment Details

Objective

The purpose of this experiment was to test the functionality of the system in various scenarios, including inventory checks, batch order processing, sales analysis, and querying capabilities.


Steps and Observations

1. Inventory Check

Case 1: Checking inventory for a specific store

I ran the following command to check the inventory for a specific store (e.g., STORE006):

python src/main.py --action inventory --store STORE006

Observation:
The system successfully retrieved inventory details for STORE006, displaying product IDs and stock levels.


Case 2: Checking inventory for all stores

I ran the following command to check inventory for all stores:

python src/main.py --action inventory

Observation:
The system displayed inventory details for all stores in the dataset, confirming its ability to handle multi-store queries.


2. Batch Order Processing

To test batch order processing, I ran the following command:

python src/main.py --action batch

Observation:
The system processed all pending batch orders and returned the status of each order, including batch IDs and their respective processing statuses. This demonstrated the system’s efficiency in handling bulk operations.


3. Sales Analysis

I analyzed sales data for a specific store (STORE006) over the last 30 days using the following command:

python src/main.py --action sales --store STORE006 --days 30

Observation:
The system provided a detailed sales analysis, including:

  • Total sales revenue for the last 30 days.
  • Total number of transactions.
  • A list of top-selling products and their quantities.

The results were accurate and aligned with the expected data trends.


4. RAG Query System

To test the RAG query capabilities, I ran the following command:

python src/main.py --action query

I then entered a natural language query, such as:

"What is the stock level of product P123 in store_001?"

Observation:
The system successfully retrieved the relevant information from the indexed documents and displayed the stock level for the specified product in the given store. This demonstrated the effectiveness of the RAG-powered querying system.


5. Chat Interaction

To test the conversational capabilities, I ran the following command:

python src/main.py --action chat

I entered a conversational query, such as:

"Can you tell me the top-selling product in store_002?"

Observation:
The system responded accurately with the top-selling product in store_002, showcasing its ability to handle conversational queries effectively.


Results

The experiment validated the functionality of the system across all tested scenarios. The system performed well in inventory checks, batch order processing, sales analysis, and natural language querying. The integration of RAG capabilities and conversational AI enhanced the system’s usability, making it a versatile tool for inventory management.


System Features

1. Inventory Management

The system allows users to check inventory levels for specific stores or all stores using the run_inventory_check method. It interacts with the backend BeverageInventorySystem to fetch real-time stock levels.

Example Commands:

  • Check inventory for a specific store:

    python src/main.py --action inventory --store STORE006
    
  • Check inventory for all stores:

    python src/main.py --action inventory
    

2. Batch Order Processing

The process_batch_orders method processes pending batch orders in bulk, ensuring that stock levels are replenished efficiently.

Example Command:

python src/main.py --action batch

3. Sales Analysis

The analyze_sales method provides insights into sales trends for a specific store over a given time period. It calculates metrics such as total sales, transaction count, and top-selling products.

Example Command:

python src/main.py --action sales --store STORE006 --days 30

4. RAG Query System

The system demonstrates document indexing and querying using LlamaIndex, enabling users to retrieve information from indexed documents with natural language queries.

Example Command:

python src/main.py --action query

5. Chat Interaction

The system supports conversational interactions using advanced language models, allowing users to interact with the system in a natural and intuitive way.

Example Command:

python src/main.py --action chat

Limitations

While the system performed well, some limitations were observed:

  1. Tool Invocation Issues:
    • The llama3-groq-tool-use integration with Ollama is not functioning as expected.
  2. Compatibility Challenges:
    • There may be compatibility issues between Ollama and LLM model recognition.
  3. Alternative Recommendations:
    • More powerful LLMs, such as OpenAI GPT-4, Anthropic Claude, or Google PaLM, could be integrated for better tool support and enhanced functionality.

Future Improvements

LangChain Enhancements

  • Multi-Agent Support: Implement support for multiple agents to handle complex workflows.
  • Multi-User Functionality: Add features to support multiple users simultaneously.
  • Model Exploration: Experiment with different models and approaches to improve performance.
  • Expanded Tool Integration: Enhance the system’s ability to integrate with additional tools and APIs.

LlamaIndex Improvements

  • Vector Database Integration: Incorporate vector databases for more efficient document retrieval.
  • Unit Testing: Expand test coverage to handle a wider variety of scenarios.
  • Enhanced Indexing: Improve document indexing capabilities for better query performance.

Conclusion

The experiment demonstrated the effectiveness of the Beverage Inventory Management System with RAG capabilities. The system successfully handled inventory checks, batch order processing, sales analysis, and natural language querying, showcasing its versatility and reliability.

While the system currently uses Ollama and LlamaIndex for development, integrating more powerful LLMs like OpenAI GPT-4 or Anthropic Claude could significantly enhance tool support and expand the system’s capabilities. With planned enhancements such as multi-agent support, vector database integration, and expanded tool capabilities, the system is well-positioned to become a comprehensive platform for inventory management and data-driven decision-making.