Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Not only Claude 3 and Amazon Forecast! Get the ...

Not only Claude 3 and Amazon Forecast! Get the Future by Chronos of Amazon's Time series FM/get-the-future-by-chronos-of-amazons-time series-fm

This is a document presented by Kohei "Max" MATSUSHITA at JAWS PANKRATION 2024 on 8/24.

Kohei "Max" MATSUSHITA

August 25, 2024
Tweet

More Decks by Kohei "Max" MATSUSHITA

Other Decks in Technology

Transcript

  1. Not only Claude 3 and Amazon Forecast! Get the Future

    by Chronos of Amazon's Timeseries FM Kohei MATSUSHITA An AWS Hero (Community) @Max
  2. 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!!
  3. 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
  4. 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 …
  5. 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
  6. “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
  7. 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
  8. 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:
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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!!