Close Menu
    Main Menu
    • Home
    • News
    • Tech
    • Robotics
    • ML & Research
    • AI
    • Digital Transformation
    • AI Ethics & Regulation
    • Thought Leadership in AI

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Pores and skin Deep – Evolving InMoov’s Facial Expressions With AI

    July 28, 2025

    Chinese language ‘Fireplace Ant’ spies begin to chew unpatched VMware situations

    July 28, 2025

    Do falling delivery charges matter in an AI future?

    July 28, 2025
    Facebook X (Twitter) Instagram
    UK Tech InsiderUK Tech Insider
    Facebook X (Twitter) Instagram
    UK Tech InsiderUK Tech Insider
    Home»Machine Learning & Research»Democratize information for well timed choices with text-to-SQL at Parcel Carry out
    Machine Learning & Research

    Democratize information for well timed choices with text-to-SQL at Parcel Carry out

    Oliver ChambersBy Oliver ChambersJuly 9, 2025No Comments17 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Democratize information for well timed choices with text-to-SQL at Parcel Carry out
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    This publish was co-written with Le Vy from Parcel Carry out.

    Entry to correct information is commonly the true differentiator of wonderful and well timed choices. That is much more essential for customer-facing choices and actions. A accurately applied state-of-the-art AI might help your group simplify entry to information for correct and well timed decision-making for the customer-facing enterprise staff, whereas decreasing the undifferentiated heavy lifting performed by your information staff. On this publish, we share how Parcel Carry out, a number one AI Supply Expertise Platform for e-commerce companies worldwide, applied such an answer.

    Correct post-purchase deliveries monitoring will be essential for a lot of ecommerce retailers. Parcel Carry out supplies an AI-driven, clever end-to-end information and supply expertise and software program as a service (SaaS) system for ecommerce retailers. The system makes use of AWS companies and state-of-the-art AI to course of lots of of hundreds of thousands of day by day parcel supply motion information and supply a unified monitoring functionality throughout couriers for the retailers, with emphasis on accuracy and ease.

    The enterprise staff in Parcel Carry out typically wants entry to information to reply questions associated to retailers’ parcel deliveries, equivalent to “Did we see a spike in supply delays final week? In that case, during which transit services had been this noticed, and what was the first reason behind the difficulty?” Beforehand, the information staff needed to manually type the question and run it to fetch the information. With the brand new generative AI-powered text-to-SQL functionality in Parcel Carry out, the enterprise staff can self-serve their information wants through the use of an AI assistant interface. On this publish, we talk about how Parcel Carry out integrated generative AI, information storage, and information entry by AWS companies to make well timed choices.

    Knowledge analytics structure

    The answer begins with information ingestion, storage, and entry. Parcel Carry out adopted the information analytics structure proven within the following diagram.

    One key information sort within the Parcel Carry out parcel monitoring utility is the parcel occasion information, which may attain billions of rows. This consists of the parcel’s cargo standing change, location change, and way more. Today-to-day information from a number of enterprise items lands in relational databases hosted on Amazon Relational Database Service (Amazon RDS).

    Though relational databases are appropriate for fast information ingestion and consumption from the appliance, a separate analytics stack is required to deal with analytics in a scalable and performant means with out disrupting the primary utility. These analytics wants embody answering aggregation queries from questions like “What number of parcels had been delayed final week?”

    Parcel Carry out makes use of Amazon Easy Storage Service (Amazon S3) with a question engine offered by Amazon Athena to satisfy their analytics wants. With this strategy, Parcel Carry out advantages from cost-effective storage whereas nonetheless having the ability to run SQL queries as wanted on the information by Athena, which is priced on utilization.

    Knowledge in Amazon S3 is saved in Apache Iceberg information format that permits information updates, which is helpful on this case as a result of the parcel occasions typically get up to date. It additionally helps partitioning for higher efficiency. Amazon S3 Tables, launched in late 2024, is a managed Iceberg tables characteristic that can be an possibility for you.

    Parcel Carry out makes use of an Apache Kafka cluster managed by Amazon Managed Streaming for Apache Kafka (Amazon MSK) because the stream to maneuver the information from the supply to the S3 bucket. Amazon MSK Join with a Debezium connector streams information with change information seize (CDC) from Amazon RDS to Amazon MSK.

    Apache Flink, operating on Amazon Elastic Kubernetes Service (Amazon EKS), processes information streams from Amazon MSK. It writes this information to an S3 bucket in response to the Iceberg format, and updates the information schema within the AWS Glue Knowledge Catalog. The info schema permits Athena to accurately question the information within the S3 bucket.

    Now that you just perceive how the information is ingested and saved, let’s present how the information is consumed utilizing the generative AI-powered information serving assistant for the enterprise groups in Parcel Carry out.

    AI agent that may question information

    The customers of the information serving AI agent in Parcel Carry out are customer-facing enterprise staff members who typically question the parcel occasion information to reply questions from ecommerce retailers concerning the parcel deliveries and to proactively help them. The next screenshot reveals the UI expertise for the AI agent assistant, powered by text-to-SQL with generative AI.

    A screenshot of the AI assistant

    This performance helped the Parcel Carry out staff and their clients save time, which we talk about later on this publish. Within the following part, we current the structure that powers this characteristic.

    Textual content-to-SQL AI agent structure

    The info serving AI assistant structure in Parcel Carry out is proven within the following diagram.

    Architecture diagram of the AI assistantThe AI assistant UI is powered by an utility constructed with the Quick API framework hosted on Amazon EKS. Additionally it is fronted by an Software Load Balancer to permit for potential horizontal scalability.

    The applying makes use of LangGraph to orchestrate the workflow of huge language mannequin (LLM) invocations, using instruments, and the reminiscence checkpointing. The graph makes use of a number of instruments, together with these from SQLDatabase Toolkit, to robotically fetch the information schema by Athena. The graph additionally makes use of an Amazon Bedrock Information Bases retriever to retrieve enterprise data from a information base. Parcel Carry out makes use of Anthropic’s Claude fashions in Amazon Bedrock to generate SQL.

    Though the perform of Athena as a question engine to question the parcel occasion information on Amazon S3 is evident, Parcel Carry out nonetheless wants a information base. On this use case, the SQL technology performs higher when the LLM has extra enterprise contextual data to assist interpret database fields and translate logistics terminology into information representations. That is higher illustrated with the next two examples:

    • Parcel Carry out’s information lake operations use particular codes: c for create and u for replace. When analyzing information, Parcel Carry out typically must focus solely on preliminary creation data, the place operation code is the same as c. As a result of this enterprise logic won’t be inherent within the coaching of LLMs normally, Parcel Carry out explicitly defines this of their enterprise context.
    • In logistics terminology, transit time has particular trade conventions. It’s measured in days, and same-day deliveries are recorded as transit_time = 0. Though that is intuitive for logistics professionals, an LLM would possibly incorrectly interpret a request like “Get me all shipments with same-day supply” through the use of WHERE transit_time = 1 as an alternative of WHERE transit_time = 0 within the generated SQL assertion.

    Due to this fact, every incoming query goes to a Retrieval Augmented Technology (RAG) workflow to seek out doubtlessly related saved enterprise data, to counterpoint the context. This mechanism helps present the precise guidelines and interpretations that even superior LLMs won’t have the ability to derive from common coaching information.

    Parcel Carry out makes use of Amazon Bedrock Information Bases as a managed resolution for the RAG workflow. They ingest enterprise contextual data by importing recordsdata to Amazon S3. Amazon Bedrock Information Bases processes the recordsdata, converts them to chunks, makes use of embedding fashions to generate vectors, and shops the vectors in a vector database to make them searchable. The steps are totally managed by Amazon Bedrock Information Bases. Parcel Carry out shops the vectors in Amazon OpenSearch Serverless because the vector database of option to simplify infrastructure administration.

    Amazon Bedrock Information Bases supplies the Retrieve API, which takes in an enter (equivalent to a query from the AI assistant), converts it right into a vector embedding, searches for related chunks of enterprise context data within the vector database, and returns the highest related doc chunks. It’s built-in with the LangChain Amazon Bedrock Information Bases retriever by calling the invoke technique.

    The subsequent step includes invoking an AI agent with the provided enterprise contextual data and the SQL technology immediate. The immediate was impressed by a immediate in LangChain Hub. The next is a code snippet of the immediate:

    You're an agent designed to work together with a SQL database.
    Given an enter query, create a syntactically appropriate {dialect} question to run, then have a look at the outcomes of the question and return the reply.
    Until the person specifies a particular variety of examples they want to get hold of, all the time restrict your question to at most {top_k} outcomes.
    Related context:
    {rag_context}
    You'll be able to order the outcomes by a related column to return probably the most attention-grabbing examples within the database.
    By no means question for all of the columns from a particular desk, solely ask for the related columns given the query.
    You could have entry to instruments for interacting with the database.
    - Solely use the beneath instruments. Solely use the knowledge returned by the beneath instruments to assemble your remaining reply.
    - DO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP and so on.) to the database.
    - To start out querying for remaining reply it is best to ALWAYS have a look at the tables within the database to see what you possibly can question. Do NOT skip this step.
    - Then it is best to question the schema of probably the most related tables

    The immediate pattern is a part of the preliminary instruction for the agent. The info schema is robotically inserted by the instruments from the SQLDatabase Toolkit at a later step of this agentic workflow. The next steps happen after a person enters a query within the AI assistant UI:

    1. The query triggers a run of the LangGraph graph.
    2. The next processes occur in parallel:
      1. The graph fetches the database schema from Athena by SQLDatabase Toolkit.
      2. The graph passes the query to the Amazon Bedrock Information Bases retriever and will get an inventory of related enterprise data concerning the query.
    3. The graph invokes an LLM utilizing Amazon Bedrock by passing the query, the dialog context, information schema, and enterprise context data. The result’s the generated SQL.
    4. The graph makes use of SQLDatabase Toolkit once more to run the SQL by Athena and fetch the information output.
    5. The info output is handed into an LLM to generate the ultimate response based mostly on the preliminary query requested. Amazon Bedrock Guardrails is used as a safeguard to keep away from inappropriate inputs and responses.
    6. The ultimate response is returned to the person by the AI assistant UI.

    The next diagram illustrates these steps.

    Architecture diagram of the AI assistant with numbered steps

    This implementation demonstrates how Parcel Carry out transforms uncooked inquiries into actionable information for well timed decision-making. Safety can also be applied in a number of parts. From a community perspective, the EKS pods are positioned in personal subnets in Amazon Digital Personal Cloud (Amazon VPC) to enhance community safety of the AI assistant utility. This AI agent is positioned behind a backend layer that requires authentication. For information safety, delicate information is masked at relaxation within the S3 bucket. Parcel Carry out additionally limits the permissions of the AWS Identification and Entry Administration (IAM) position used to entry the S3 bucket so it may solely entry sure tables.

    Within the following sections, we talk about Parcel Carry out’s strategy to constructing this information transformation resolution.

    From thought to manufacturing

    Parcel Carry out began with the concept of releasing their information staff from manually serving the request from the enterprise staff, whereas additionally bettering the timeliness of the information availability to assist the enterprise staff’s decision-making.

    With the assistance of the AWS Options Architect staff, Parcel Carry out accomplished a proof of idea utilizing AWS companies and a Jupyter pocket book in Amazon SageMaker Studio. After an preliminary success, Parcel Carry out built-in the answer with their orchestration instrument of selection, LangGraph.

    Earlier than going into manufacturing, Parcel Carry out performed in depth testing to confirm the outcomes had been constant. They added LangSmith Tracing to log the AI agent’s steps and outcomes to guage its efficiency.

    The Parcel Carry out staff found challenges throughout their journey, which we talk about within the following part. They carried out immediate engineering to handle these challenges. Ultimately, the AI agent was built-in into manufacturing for use by the enterprise staff. Afterward, Parcel Carry out collected person suggestions internally and monitored logs from LangSmith Tracing to confirm efficiency was maintained.

    The challenges

    This journey isn’t free from challenges. Firstly, some ecommerce retailers may need a number of data within the information lake beneath varied names. For instance, a service provider with the title “ABC” may need a number of data such, as “ABC Singapore Holdings Pte. Ltd.,” “ABC Demo Account,” “ABC Check Group,” and so forth. For a query like “Was there any parcel cargo delay by ABC final week?”, the generated SQL has the ingredient of WHERE merchant_name LIKE '%ABC%', which could lead to ambiguity. Through the proof of idea stage, this downside brought on incorrect matching of the outcome.

    For this problem, Parcel Carry out depends on cautious immediate engineering to instruct the LLM to establish when the title was doubtlessly ambiguous. The AI agent then calls Athena once more to search for matching names. The LLM decides which service provider title to make use of based mostly on a number of elements, together with the importance in information quantity contribution and the account standing within the information lake. Sooner or later, Parcel Carry out intends to implement a extra refined approach by prompting the person to resolve the paradox.

    The second problem is about unrestricted questions that may yield costly queries operating throughout giant quantities of knowledge and leading to longer question ready time. A few of these questions won’t have a LIMIT clause imposed within the question. To resolve this, Parcel Carry out instructs the LLM so as to add a LIMIT clause with a sure variety of most outcomes if the person doesn’t specify the meant variety of outcomes. Sooner or later, Parcel Carry out plans to make use of the question EXPLAIN outcomes to establish heavy queries.

    The third problem is said to monitoring utilization and incurred price of this explicit resolution. Having began a number of generative AI initiatives utilizing Amazon Bedrock and typically with the identical LLM ID, Parcel Carry out should distinguish utilization incurred by initiatives. Parcel Carry out creates an inference profile for every venture, associates the profile with tags, and consists of that profile in every LLM name for that venture. With this setup, Parcel Carry out is ready to segregate prices based mostly on initiatives to enhance price visibility and monitoring.

    The influence

    To extract information, the enterprise staff clarifies particulars with the information staff, makes a request, checks feasibility, and waits for bandwidth. This course of lengthens when necessities come from clients or groups in several time zones, with every clarification including 12–24 hours because of asynchronous communication. Easier requests made early within the workday would possibly full inside 24 hours, whereas extra advanced requests or these throughout busy durations can take 3–5 enterprise days.

    With the text-to-SQL AI agent, this course of is dramatically streamlined—minimizing the back-and-forth communication for requirement clarification, eradicating the dependency on information staff bandwidth, and automating outcome interpretation.

    Parcel Carry out’s measurements present that the text-to-SQL AI agent reduces the typical time-to-insight by 99%, from 2.3 days to a median of 10 minutes, saving roughly 3,850 whole hours of wait time monthly throughout requesters whereas sustaining information accuracy.

    Customers can immediately question the information with out intermediaries, receiving leads to minutes slightly than days. Groups throughout time zones can now entry insights any time of day, assuaging the irritating “wait till Asia wakes up” or “catch EMEA earlier than they go away” delays, resulting in happier clients and sooner problem-solving.

    This transformation has profoundly impacted the information analytics staff’s capability and focus, releasing the information staff for extra strategic work and serving to everybody make sooner, extra knowledgeable choices. Earlier than, the analysts spent roughly 25% of their working hours dealing with routine information extraction requests—equal to over 260 hours month-to-month throughout the staff. Now, with fundamental and intermediate queries automated, this quantity has dropped to simply 10%, releasing up practically 160 hours every month for high-impact work. Analysts now give attention to advanced information evaluation slightly than spending time on fundamental information retrieval duties.

    Conclusion

    Parcel Carry out’s resolution demonstrates how you need to use generative AI to reinforce productiveness and buyer expertise. Parcel Carry out has constructed a text-to-SQL AI agent that transforms a enterprise staff’s query into SQL that may fetch the precise information. This improves the timeliness of knowledge availability for decision-making that includes clients. Moreover, the information staff can keep away from the undifferentiated heavy lifting to give attention to advanced information evaluation duties.

    This resolution makes use of a number of AWS companies like Amazon Bedrock and instruments like LangGraph. You can begin with a proof of idea and seek the advice of your AWS Options Architect or have interaction with AWS Companions. When you’ve got questions, publish them on AWS re:Put up. You too can make the event extra simple with the assistance of Amazon Q Developer. Whenever you face challenges, you possibly can iterate to seek out the answer, which could embody immediate engineering or including further steps to your workflow.

    Safety is a prime precedence. Make sure that your AI assistant has correct guardrails in place to guard towards immediate threats, inappropriate matters, profanity, leaked information, and different safety points. You’ll be able to combine Amazon Bedrock Guardrails along with your generative AI utility by an API.To study extra, discuss with the next assets:


    Concerning the authors

    Yudho Ahmad Diponegoro profile pictureYudho Ahmad Diponegoro is a Senior Options Architect at AWS. Having been a part of Amazon for 10+ years, he has had varied roles from software program growth to options structure. He helps startups in Singapore relating to architecting within the cloud. Whereas he retains his breadth of data throughout applied sciences and industries, he focuses in AI and machine studying the place he has been guiding varied startups in ASEAN to undertake machine studying and generative AI at AWS.

    Le Vy is the AI Staff Lead at Parcel Carry out, the place she drives the event of AI functions and explores rising AI analysis. She began her profession in information evaluation and deepened her give attention to AI by a Grasp’s in Synthetic Intelligence. Keen about making use of information and AI to unravel actual enterprise issues, she additionally dedicates time to mentoring aspiring technologists and constructing a supportive neighborhood for youth in tech. By way of her work, Vy actively challenges gender norms within the trade and champions lifelong studying as a key to innovation.

    Loke Jun Kai is a GenAI/ML Specialist Options Architect in AWS, protecting strategic clients throughout the ASEAN area. He works with clients starting from Begin-up to Enterprise to construct cutting-edge use instances and scalable GenAI Platforms. His ardour within the AI house, fixed analysis and studying, have led to many progressive options constructed with concrete enterprise outcomes. Outdoors of labor, he enjoys an excellent sport of tennis and chess.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Oliver Chambers
    • Website

    Related Posts

    mRAKL: Multilingual Retrieval-Augmented Information Graph Building for Low-Resourced Languages

    July 28, 2025

    How Uber Makes use of ML for Demand Prediction?

    July 28, 2025

    Benchmarking Amazon Nova: A complete evaluation by way of MT-Bench and Enviornment-Exhausting-Auto

    July 28, 2025
    Top Posts

    Pores and skin Deep – Evolving InMoov’s Facial Expressions With AI

    July 28, 2025

    Evaluating the Finest AI Video Mills for Social Media

    April 18, 2025

    Utilizing AI To Repair The Innovation Drawback: The Three Step Resolution

    April 18, 2025

    Midjourney V7: Quicker, smarter, extra reasonable

    April 18, 2025
    Don't Miss

    Pores and skin Deep – Evolving InMoov’s Facial Expressions With AI

    By Arjun PatelJuly 28, 2025

    This text appeared in Make: Vol 93. Subscribe for extra nice initiatives. In the summertime…

    Chinese language ‘Fireplace Ant’ spies begin to chew unpatched VMware situations

    July 28, 2025

    Do falling delivery charges matter in an AI future?

    July 28, 2025

    mRAKL: Multilingual Retrieval-Augmented Information Graph Building for Low-Resourced Languages

    July 28, 2025
    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    UK Tech Insider
    Facebook X (Twitter) Instagram
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms Of Service
    • Our Authors
    © 2025 UK Tech Insider. All rights reserved by UK Tech Insider.

    Type above and press Enter to search. Press Esc to cancel.