Artificial Intelligence

How We Made AI Time-Aware

May 17, 2024
6
MIN READ

In a world where artificial intelligence (AI) is increasingly integrated into our daily lives, enhancing its capabilities to understand and process time-related information is not just an interesting experiment—it’s a necessary evolution. Picture this: You’re organizing your schedule. and you tell your digital assistant, “Let’s meet next Tuesday.” Without context for the current date, the AI is helpless. Making AI “time-aware” enables it to interpret such vague temporal references into actual, actionable date ranges.

This leap forward isn’t just about utility in our professional and personal lives; it’s also about deepening our understanding of AI’s capabilities and limitations. Through experiments aimed at teaching AI to comprehend time, we not only refine a useful tool but also engage in a fun and enlightening challenge that reveals much about how AI thinks and operates.

The Goal

Our main objective was to enable AI to convert semantic time references like “how about next week,” “sometime next month,” or “let’s meet next Tuesday” into precise date-ranges. This capability is crucial for programming a variety of applications, from scheduling software to reminder apps, to enhance how they interact with users in everyday scenarios.

The Problem

The core challenge lies in the fact that AI, inherently, does not know today’s date. It lacks the ability to automatically determine what “next week” or “next month” specifically refers to, creating a gap between human communication and machine interpretation.

Experimentation and Discovery

How We Solved It: Attempt #1 (Didn’t Work) ❌

Approach
We started by feeding the current date into the model as a prompt prefix, hoping this would ground the AI’s understanding of time.

Example
Prompt: “Today is Monday, 1st of March, 2024. Let’s meet next Tuesday.”

Response: The AI struggled, often misinterpreting the exact future dates.

Outcome
The model edged closer to accuracy but still failed to consistently predict correct date ranges for the given examples. It appeared that knowing the current date was not enough for the AI to fully grasp future or relative date references.

How We Solved It: Attempt #2 (Didn’t Work) ❌

Approach
Next, we combined the current date with a directive for the AI to process the information step-by-step. We asked it to detail its thought process in bullet points before delivering the final date range.

Example
Prompt: “Today is Monday, 1st of March, 2024. Next week.”

Steps Articulated by AI

- Today is Monday 1st of March, 2024

- Sunday is 6 days from today

- This means Sunday is March 7th, 2024

- This means next week starts on March 8th, 2024

- Next week ends on 6th day after it starts on Monday, March 8th, 2024

- This means next week ends with Sunday, March 14th, 2024

Outcome
While the step-by-step reasoning process improved the AI’s accuracy in some cases, it still stumbled over edge cases and unusual requests. The structured thinking helped, but the AI lacked consistency in its conclusions.

How We Solved It: Attempt #3 (Success) ✅

Approach
Realizing that prompt engineering had its limits, we shifted our strategy towards leveraging the AI’s classification strength. We prepared a list of potential time ranges and asked the AI to classify the user’s request accordingly.

Setup and categories included

- TODAY

- TOMORROW

- NEXT_WEEK

- NEXT_MON, NEXT_TUE, NEXT_WED, etc.

- IN_{n}WEEKS, IN{n}_WEEKS_BEGINNING_OF_WEEK, IN_{n}_WEEKS_END_OF_WEEK

- IN_{n}_MONTHS, etc.

Example
Prompt: “I need to schedule something for next week.”

AI Classification: NEXT_WEEK

Programmatic Action: Calculate the date range starting from the current timestamp.

Outcome
This method provided the best results, comprehensively covering all necessary cases for our use case. By focusing on classification and leveraging the timestamp of the user’s message, we were able to achieve precise and reliable date-range interpretations.

How We Improved It: Attempt #4 (Success) ✅

As we were developing the app in the beginning of the year, of course, we ran into test cases that targeted this year’s leap date, February 29th.

We quickly realized that AI does understand the concept of leap years, but since it is not time-aware, it failed to recognize that 2024 is in fact a leap year. The solution for this was to explicitly tell the AI that 2024 was a leap year (and to be on the safe side, we included 2028 into the prompt as well).

Once we’ve programatically calculated possible date ranges and sent them to parties, we need to decide if the parties have accepted any of the proposed time slots or declined all of them. If they accept any of them, good job, our work here is done! But if not, we needed to repeat the process once again, with the key difference being that we needed to supply these declined time slots so that AI knew which ones should not be taken into account. We also discovered that AI works best if we don’t supply the proposed time slots in the UTC timezone but rather normalize into the requestors timezone (for example, EST). This is related to AI not being time-aware.

Our journey through these experiments has not only enhanced AI’s practical utility but also deepened our understanding of its operational framework. Making AI time-aware is a significant step towards bridging the gap between human linguistic habits and machine interpretation. Each failed attempt brought us closer to a solution, underscoring the importance of perseverance and innovative thinking in technology development. As we continue to explore AI’s vast capabilities, experiments like these are crucial for turning theoretical potential into everyday functionality, ensuring that AI can truly serve our needs in a dynamic, ever-changing world.

Table of Contents
    AUTHOR:
    Povio Team
    Read more posts by this author.
    Back to Blog

    RELATED ARTICLES