Slide 1

Slide 1 text

Not only Claude 3 and Amazon Forecast! Get the Future by Chronos of Amazon's Timeseries FM Kohei MATSUSHITA An AWS Hero (Community) @Max

Slide 2

Slide 2 text

2 Technology Evangelist at Soracom, Inc. Soracom is an IoT platform provider to the world Kohei “Max” MATSUSHITA A bit of understanding of IoT #IoT #AWSHero #TheCodeOverTheory #reInvent2024 (GoGo!!) #Maxデテル WiJG?, Public domain, via Wikimedia Commons NEW!!

Slide 3

Slide 3 text

Hi! Have a time? Why is Generative AI Trending? A: Ready-to-Use Based on Foundation Models (FMs). LLMs are the Most Famous in FMs A: Yes, but there are Other FMs in the world. Then, I’ll be showing How to Run FMs Serverless-ly!! 3

Slide 4

Slide 4 text

Time-Series dataset is All around US, But… We can see the Past and Present. What we really wanted is … the Future! 4 • Temperature(Weather) records • Electricity consumption • Water/Oil level • Equipment outputs • Website traffic • Passenger numbers • Exchange rates …

Slide 5

Slide 5 text

Get the Future … !? Forecasting for Timeseries dataset 5

Slide 6

Slide 6 text

What are the Methods for Forecasting using a TS dataset? Claude? Generative AI?? • LLMs could Generate the Future. However, It’s still in the Research Stage. • e.g.) Large Language Models for Time Series: A Survey ([Submitted on 2 Feb 2024 (v1), last revised 6 May 2024 (this version, v3)]) Amazon SageMaker??? • True, but we must build Learning Model. It’s a bit hard (for me). 6

Slide 7

Slide 7 text

Amazon Forecast …? 7 https://x.com/jeffbarr/status/1818461689920344321 Oh, Amazon Forecast… https://x.com/jeffbarr/status/1818488419347317217

Slide 8

Slide 8 text

“Chronos” a FM for timeseries forecast!! 8 https://www.amazon.science/code-and-datasets/chronos-learning-the-language-of-time-series Sunshine Hours in Fuji City(JP) Over the Past 5 Years (Blue) and Forecast using Amazon Chronos for the Next 12 Months (Red) ― Based on Data from the Japan Meteorological Agency

Slide 9

Slide 9 text

The Code over Theory (Live Demo): Interactive Python(REPL) 9 A Very simple TS dataset (Sequential number, 1 to 29) Amazon Chronos Historical Forecast w/ Range

Slide 10

Slide 10 text

Key points of essential 10 csv = pd.read_csv('seq.csv') pl = ChronosPipeline.from_pretrained("amazon/chronos-t5-tiny") fc = pl.predict(torch.tensor(csv[0]), prediction_length=1) low, mid, high = np.quantile(fc[0].numpy(), [0.2, 0.5, 0.8]) #=> (29.47214127, 30.24193573, 30.83577614) Remark: Some contents is omitted 1: 2: 3: 4:

Slide 11

Slide 11 text

FastAPI NEXT: WebAPI-ized with FastAPI • FastAPI: a framework of Python for Web API 11 '{"historical":[1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23 ,24,25,26,27,28,29]}' Amazon Chronos {"forecast":{"min":[29.97800559 9975585],"median":[30.0219936 3708496],"max":[30.285923767 089844]} http://.../forecast.json http://.../forecast.png

Slide 12

Slide 12 text

Large ? Tiny, Small ?? • Need high accuracy, Large is better. • Higher accuracy means longer inference time and memory. • For near-future predictions, Tiny/Small are good. 12

Slide 13

Slide 13 text

Opps…No Mention of AWS? Don't Worry! 13

Slide 14

Slide 14 text

LAST: Lambda Web Adapter • Lambda Web Adapter: Run Container Web Apps on Lambda with a bit Changes. 14 Container (Dockerfile) AWS Lambda Serverless Deploy Various FMs Easily!! Especially FMs on Huggingface! Lambda Web Adapter (Layer) AWS Cloud Amazon Elastic Container Registry (Amazon ECR) FastAPI Amazon Chronos Exposing as a Web API / APP docker push

Slide 15

Slide 15 text

Notes for working FM on AWS Lambda 15 • Predicted number of cases is proportional to processing time. • Tiny or Small if running in Lambda, considering Async implementation. • Amazon Chronos can derive the objective variable from the explanatory variables. Model size Image size (on ECR) Tmp space (for FM files) Memory Timeout RTT (cold, warm) Tiny 3.2GB 0.5GB 1.0GB 60s 20s, 10s Small 3.4GB 1.0GB 2.0GB 60s 25s, 15s Base 4.0GB 2.0GB 2.5GB 90s 50s, 25s Large 5.8GB 4.0GB 6.0GB 360s 200s, 120s

Slide 16

Slide 16 text

Conclusion ― Get the Future by Chronos Choose the Right FM Based on I/O • Similar open-source libraries and AWS. From “Make” to “BUILD”. Consider Time-Series FM • Wide variety of usage and fine-tuning is possible. • Research on time-series analysis using LLMs is advancing. Any FMs, can be Easily Web-Appified with Lambda Web Adapter • Of course, Web apps using Amazon Bedrock are also easy to create. Easier than AWS Fargate and so on. Get the “Our” Future! 16 https://github.com/awslabs/aws-lambda-web-adapter/releases

Slide 17

Slide 17 text

Thank you ! Kohei “Max” MATSUSHITA X: @ma2shita I will be at AWS re:Invent this year! Looking forward to see in LAS!! 17 https://github.com/ma2shita/amazon-chronos-with-lambda-web-adapter Examples is available!!