The success of generative AI applications across a wide range of industries has attracted the attention and interest of companies worldwide who are looking to reproduce and surpass the achievements of competitors or solve new and exciting use cases. These customers are looking into foundation models, such as TII Falcon, Stable Diffusion XL, or OpenAI’s GPT-3.5, as the engines that power the generative AI innovation.
Foundation models are a class of generative AI models that are capable of understanding and generating human-like content, thanks to the vast amounts of unstructured data they have been trained on. These models have revolutionized various computer vision (CV) and natural language processing (NLP) tasks, including image generation, translation, and question answering. They serve as the building blocks for many AI applications and have become a crucial component in the development of advanced intelligent systems.
However, the deployment of foundation models can come with significant challenges, particularly in terms of cost and resource requirements. These models are known for their size, often ranging from hundreds of millions to billions of parameters. Their large size demands extensive computational resources, including powerful hardware and significant memory capacity. In fact, deploying foundation models usually requires at least one (often more) GPUs to handle the computational load efficiently. For example, the TII Falcon-40B Instruct model requires at least an ml.g5.12xlarge instance to be loaded into memory successfully, but performs best with bigger instances. As a result, the return on investment (ROI) of deploying and maintaining these models can be too low to prove business value, especially during development cycles or for spiky workloads. This is due to the running costs of having GPU-powered instances for long sessions, potentially 24/7.
Earlier this year, we announced ایمیزون بیڈرک, a serverless API to access foundation models from Amazon and our generative AI partners. Although it’s currently in Private Preview, its serverless API allows you to use foundation models from Amazon, Anthropic, Stability AI, and AI21, without having to deploy any endpoints yourself. However, open-source models from communities such as Hugging Face have been growing a lot, and not every one of them has been made available through Amazon Bedrock.
In this post, we target these situations and solve the problem of risking high costs by deploying large foundation models to ایمیزون سیج میکر asynchronous endpoints سے ایمیزون سیج میکر جمپ اسٹارٹ. This can help cut costs of the architecture, allowing the endpoint to run only when requests are in the queue and for a short time-to-live, while scaling down to zero when no requests are waiting to be serviced. This sounds great for a lot of use cases; however, an endpoint that has scaled down to zero will introduce a cold start time before being able to serve inferences.
حل جائزہ
درج ذیل خاکہ ہمارے حل کے فن تعمیر کو واضح کرتا ہے۔
The architecture we deploy is very straightforward:
- The user interface is a notebook, which can be replaced by a web UI built on Streamlit or similar technology. In our case, the notebook is an ایمیزون سیج میکر اسٹوڈیو notebook, running on an ml.m5.large instance with the PyTorch 2.0 Python 3.10 CPU kernel.
- The notebook queries the endpoint in three ways: the SageMaker Python SDK, the AWS SDK for Python (Boto3), and LangChain.
- The endpoint is running asynchronously on SageMaker, and on the endpoint, we deploy the Falcon-40B Instruct model. It’s currently the state of the art in terms of instruct models and available in SageMaker JumpStart. A single API call allows us to deploy the model on the endpoint.
What is SageMaker asynchronous inference
SageMaker asynchronous inference is one of the four deployment options in SageMaker, together with real-time endpoints, batch inference, and serverless inference. To learn more about the different deployment options, refer to Deploy models for Inference.
SageMaker asynchronous inference queues incoming requests and processes them asynchronously, making this option ideal for requests with large payload sizes up to 1 GB, long processing times, and near-real-time latency requirements. However, the main advantage that it provides when dealing with large foundation models, especially during a proof of concept (POC) or during development, is the capability to configure asynchronous inference to scale in to an instance count of zero when there are no requests to process, thereby saving costs. For more information about SageMaker asynchronous inference, refer to غیر مطابقت پذیر تخمینہ. مندرجہ ذیل خاکہ اس فن تعمیر کو واضح کرتا ہے۔
To deploy an asynchronous inference endpoint, you need to create an AsyncInferenceConfig
object. If you create AsyncInferenceConfig
without specifying its arguments, the default S3OutputPath
ہو جائے گا s3://sagemaker-{REGION}-{ACCOUNTID}/async-endpoint-outputs/{UNIQUE-JOB-NAME}
اور S3FailurePath
ہو جائے گا s3://sagemaker-{REGION}-{ACCOUNTID}/async-endpoint-failures/{UNIQUE-JOB-NAME}
.
سیج میکر جمپ اسٹارٹ کیا ہے؟
Our model comes from SageMaker JumpStart, a feature of SageMaker that accelerates the machine learning (ML) journey by offering pre-trained models, solution templates, and example notebooks. It provides access to a wide range of pre-trained models for different problem types, allowing you to start your ML tasks with a solid foundation. SageMaker JumpStart also offers solution templates for common use cases and example notebooks for learning. With SageMaker JumpStart, you can reduce the time and effort required to start your ML projects with one-click solution launches and comprehensive resources for practical ML experience.
The following screenshot shows an example of just some of the models available on the SageMaker JumpStart UI.
ماڈل تعینات کریں۔
Our first step is to deploy the model to SageMaker. To do that, we can use the UI for SageMaker JumpStart or the SageMaker Python SDK, which provides an API that we can use to deploy the model to the asynchronous endpoint:
This call can take approximately10 minutes to complete. During this time, the endpoint is spun up, the container together with the model artifacts are downloaded to the endpoint, the model configuration is loaded from SageMaker JumpStart, then the asynchronous endpoint is exposed via a DNS endpoint. To make sure that our endpoint can scale down to zero, we need to configure auto scaling on the asynchronous endpoint using Application Auto Scaling. You need to first register your endpoint variant with Application Auto Scaling, define a scaling policy, and then apply the scaling policy. In this configuration, we use a custom metric using CustomizedMetricSpecification
، سے ملاقات کی ApproximateBacklogSizePerInstance
, as shown in the following code. For a detailed list of ایمیزون کلاؤڈ واچ metrics available with your asynchronous inference endpoint, refer to Monitoring with CloudWatch.
You can verify that this policy has been set successfully by navigating to the SageMaker console, choosing اختتامی نکات کے تحت ارادہ in the navigation pane, and looking for the endpoint we just deployed.
Invoke the asynchronous endpoint
To invoke the endpoint, you need to place the request payload in ایمیزون سادہ اسٹوریج سروس (Amazon S3) and provide a pointer to this payload as a part of the InvokeEndpointAsync
request. Upon invocation, SageMaker queues the request for processing and returns an identifier and output location as a response. Upon processing, SageMaker places the result in the Amazon S3 location. You can optionally choose to receive success or error notifications with ایمیزون سادہ نوٹیفکیشن سروس (ایمیزون ایس این ایس)۔
SageMaker Python SDK
After deployment is complete, it will return an AsyncPredictor
object. To perform asynchronous inference, you need to upload data to Amazon S3 and use the predict_async()
method with the S3 URI as the input. It will return an AsyncInferenceResponse
object, and you can check the result using the get_response()
طریقہ.
Alternatively, if you would like to check for a result periodically and return it upon generation, use the predict()
method. We use this second method in the following code:
بوٹو 3
Let’s now explore the invoke_endpoint_async
method from Boto3’s sagemaker-runtime
client. It enables developers to asynchronously invoke a SageMaker endpoint, providing a token for progress tracking and retrieval of the response later. Boto3 doesn’t offer a way to wait for the asynchronous inference to be completed like the SageMaker Python SDK’s get_result()
operation. Therefore, we take advantage of the fact that Boto3 will store the inference output in Amazon S3 in the response["OutputLocation"]
. We can use the following function to wait for the inference file to be written to Amazon S3:
With this function, we can now query the endpoint:
لینگ چین
LangChain is an open-source framework launched in October 2022 by Harrison Chase. It simplifies the development of applications using large language models (LLMs) by providing integrations with various systems and data sources. LangChain allows for document analysis, summarization, chatbot creation, code analysis, and more. It has gained popularity, with contributions from hundreds of developers and significant funding from venture firms. LangChain enables the connection of LLMs with external sources, making it possible to create dynamic, data-responsive applications. It offers libraries, APIs, and documentation to streamline the development process.
LangChain provides libraries and examples for using SageMaker endpoints with its framework, making it easier to use ML models hosted on SageMaker as the “brain” of the chain. To learn more about how LangChain integrates with SageMaker, refer to the SageMaker Endpoint in the LangChain documentation.
One of the limits of the current implementation of LangChain is that it doesn’t support asynchronous endpoints natively. To use an asynchronous endpoint to LangChain, we have to define a new class, SagemakerAsyncEndpoint
, that extends the SagemakerEndpoint
class already available in LangChain. Additionally, we provide the following information:
- The S3 bucket and prefix where asynchronous inference will store the inputs (and outputs)
- A maximum number of seconds to wait before timing out
- An
updated _call()
function to query the endpoint withinvoke_endpoint_async()
بجائےinvoke_endpoint()
- A way to wake up the asynchronous endpoint if it’s in cold start (scaled down to zero)
To review the newly created SagemakerAsyncEndpoint
، آپ چیک کر سکتے ہیں sagemaker_async_endpoint.py
سنچکا GitHub پر دستیاب.
صاف کرو
When you’re done testing the generation of inferences from the endpoint, remember to delete the endpoint to avoid incurring in extra charges:
نتیجہ
When deploying large foundation models like TII Falcon, optimizing cost is crucial. These models require powerful hardware and substantial memory capacity, leading to high infrastructure costs. SageMaker asynchronous inference, a deployment option that processes requests asynchronously, reduces expenses by scaling the instance count to zero when there are no pending requests. In this post, we demonstrated how to deploy large SageMaker JumpStart foundation models to SageMaker asynchronous endpoints. We provided code examples using the SageMaker Python SDK, Boto3, and LangChain to illustrate different methods for invoking asynchronous endpoints and retrieving results. These techniques enable developers and researchers to optimize costs while using the capabilities of foundation models for advanced language understanding systems.
To learn more about asynchronous inference and SageMaker JumpStart, check out the following posts:
مصنف کے بارے میں
ڈیوڈ گیلیٹیلی EMEA خطے میں AI/ML کے لیے ایک ماہر حل آرکیٹیکٹ ہے۔ وہ برسلز میں مقیم ہے اور پورے بینیلکس میں صارفین کے ساتھ مل کر کام کرتا ہے۔ وہ اس وقت سے ایک ڈویلپر رہا ہے جب وہ بہت چھوٹا تھا، اس نے 7 سال کی عمر میں کوڈ بنانا شروع کیا۔ اس نے یونیورسٹی میں AI/ML سیکھنا شروع کیا، اور تب سے اسے اس سے پیار ہو گیا۔
- SEO سے چلنے والا مواد اور PR کی تقسیم۔ آج ہی بڑھا دیں۔
- پلیٹو ڈیٹا ڈاٹ نیٹ ورک ورٹیکل جنریٹو اے آئی۔ اپنے آپ کو بااختیار بنائیں۔ یہاں تک رسائی حاصل کریں۔
- پلیٹوآئ اسٹریم۔ ویب 3 انٹیلی جنس۔ علم میں اضافہ۔ یہاں تک رسائی حاصل کریں۔
- پلیٹو ای ایس جی۔ آٹوموٹو / ای وی، کاربن، کلین ٹیک، توانائی ، ماحولیات، شمسی، ویسٹ مینجمنٹ یہاں تک رسائی حاصل کریں۔
- پلیٹو ہیلتھ۔ بائیوٹیک اینڈ کلینیکل ٹرائلز انٹیلی جنس۔ یہاں تک رسائی حاصل کریں۔
- چارٹ پرائم۔ ChartPrime کے ساتھ اپنے ٹریڈنگ گیم کو بلند کریں۔ یہاں تک رسائی حاصل کریں۔
- بلاک آفسیٹس۔ ماحولیاتی آفسیٹ ملکیت کو جدید بنانا۔ یہاں تک رسائی حاصل کریں۔
- ماخذ: https://aws.amazon.com/blogs/machine-learning/optimize-deployment-cost-of-amazon-sagemaker-jumpstart-foundation-models-with-amazon-sagemaker-asynchronous-endpoints/
- : ہے
- : ہے
- : نہیں
- :کہاں
- $UP
- 1
- 10
- 100
- 12
- 13
- 15٪
- 1M
- 2022
- 25
- 7
- a
- قابلیت
- ہمارے بارے میں
- تیز رفتار
- قبول کرتا ہے
- تک رسائی حاصل
- کامیابیوں
- کے پار
- سرگرمی
- اس کے علاوہ
- اعلی درجے کی
- فائدہ
- کے بعد
- عمر
- AI
- اے آئی ماڈلز
- AI / ML
- اجازت دے رہا ہے
- کی اجازت دیتا ہے
- پہلے ہی
- بھی
- اگرچہ
- ایمیزون
- ایمیزون سیج میکر
- ایمیزون سیج میکر جمپ اسٹارٹ
- ایمیزون ویب سروسز
- رقم
- مقدار
- an
- تجزیہ
- اور
- کا اعلان کیا ہے
- ایک اور
- بشری
- کوئی بھی
- اے پی آئی
- APIs
- درخواست
- ایپلی کیشنز
- کا اطلاق کریں
- فن تعمیر
- کیا
- دلائل
- فن
- AS
- At
- توجہ
- اپنی طرف متوجہ
- آٹو
- دستیاب
- اوسط
- سے اجتناب
- AWS
- کی بنیاد پر
- BE
- بن
- رہا
- اس سے پہلے
- کیا جا رہا ہے
- BEST
- بڑا
- اربوں
- بلاکس
- جسم
- توڑ
- برسلز
- عمارت
- تعمیر
- کاروبار
- لیکن
- by
- فون
- کہا جاتا ہے
- کر سکتے ہیں
- صلاحیتوں
- صلاحیت
- صلاحیت رکھتا
- اہلیت
- کیس
- مقدمات
- چین
- زنجیروں
- چیلنجوں
- بوجھ
- پیچھا
- چیٹ بٹ
- چیک کریں
- میں سے انتخاب کریں
- منتخب کریں
- طبقے
- کلائنٹ
- قریب سے
- کوڈ
- سردی
- کس طرح
- آتا ہے
- کامن
- کمیونٹی
- کمپنیاں
- حریف
- مکمل
- مکمل
- مکمل کرتا ہے
- جزو
- وسیع
- کمپیوٹر
- کمپیوٹر ویژن
- تصور
- ترتیب
- کنکشن
- کنسول
- کنٹینر
- مواد
- شراکت دار
- قیمت
- اخراجات
- تخلیق
- بنائی
- مخلوق
- اہم
- موجودہ
- اس وقت
- اپنی مرضی کے
- گاہکوں
- کٹ
- لاگتوں میں کمی
- سائیکل
- اعداد و شمار
- معاملہ
- پہلے سے طے شدہ
- وضاحت
- مطالبات
- demonstrated,en
- تعیناتی
- تعینات
- تعینات
- تعیناتی
- تفصیلی
- دیو
- ڈیولپر
- ڈویلپرز
- ترقی
- DICT
- مختلف
- براڈ کاسٹننگ
- طول و عرض
- غیر فعال کر دیا
- DNS
- do
- دستاویز
- دستاویزات
- نہیں کرتا
- کیا
- نیچے
- دو
- کے دوران
- متحرک
- e
- آسان
- مؤثر طریقے سے
- کوشش
- اور
- ای ایم ای اے
- کو چالو کرنے کے
- کے قابل بناتا ہے
- اختتام پوائنٹ
- انجن
- کافی
- خرابی
- خاص طور پر
- ہر کوئی
- مثال کے طور پر
- مثال کے طور پر
- اس کے علاوہ
- رعایت
- دلچسپ
- اخراجات
- تجربہ
- تلاش
- ظاہر
- توسیع
- وسیع
- بیرونی
- اضافی
- چہرہ
- حقیقت یہ ہے
- گر
- جھوٹی
- نمایاں کریں
- فائل
- فرم
- پہلا
- کے بعد
- کے لئے
- فاؤنڈیشن
- چار
- فریم ورک
- سے
- تقریب
- فنڈنگ
- حاصل کی
- پیدا
- پیدا کرنے والے
- نسل
- پیداواری
- پیداواری AI۔
- GitHub کے
- اچھا
- GPUs
- عظیم
- بڑھتے ہوئے
- ہینڈل
- ہارڈ ویئر
- ہے
- ہونے
- he
- مدد
- یہاں
- ہائی
- میزبانی کی
- کس طرح
- کیسے
- تاہم
- HTML
- HTTP
- HTTPS
- سینکڑوں
- لاکھوں لاکھ
- مثالی
- شناخت
- if
- وضاحت کرتا ہے
- تصویر
- نفاذ
- درآمد
- in
- سمیت
- موصولہ
- اشارہ کرتا ہے
- صنعتوں
- معلومات
- انفراسٹرکچر
- جدت طرازی
- ان پٹ
- آدانوں
- مثال کے طور پر
- کے بجائے
- انٹیگریٹٹس
- انضمام
- انٹیلجنٹ
- دلچسپی
- انٹرفیس
- میں
- متعارف کرانے
- سرمایہ کاری
- IT
- میں
- سفر
- فوٹو
- JSON
- صرف
- جانا جاتا ہے
- زبان
- بڑے
- تاخیر
- بعد
- شروع
- آغاز
- معروف
- جانیں
- سیکھنے
- کم سے کم
- لائبریریوں
- کی طرح
- حدود
- لسٹ
- لوڈ
- محل وقوع
- لانگ
- تلاش
- بہت
- محبت
- لو
- مشین
- مشین لرننگ
- بنا
- مین
- برقرار رکھنے
- بنا
- بنانا
- بہت سے
- میکس
- زیادہ سے زیادہ
- یاد داشت
- طریقہ
- طریقوں
- میٹرک۔
- پیمائش کا معیار
- لاکھوں
- منٹ
- ML
- ماڈل
- ماڈل
- زیادہ
- نام
- قدرتی
- قدرتی زبان عملیات
- تشریف لے جارہا ہے
- سمت شناسی
- ضرورت ہے
- نئی
- نیا
- اگلے
- ویزا
- نہیں
- نوٹ بک
- نوٹیفیکیشن
- اطلاعات
- اب
- تعداد
- اعتراض
- اکتوبر
- of
- پیش کرتے ہیں
- کی پیشکش
- تجویز
- اکثر
- on
- ایک
- صرف
- اوپن سورس
- آپریشن
- کی اصلاح کریں
- اصلاح
- اختیار
- آپشنز کے بھی
- or
- ہمارے
- باہر
- پیداوار
- پین
- پیرامیٹرز
- حصہ
- خاص طور پر
- شراکت داروں کے
- زیر التواء
- انجام دیں
- کارکردگی کا مظاہرہ
- تصویر
- مقام
- مقامات
- پلاٹا
- افلاطون ڈیٹا انٹیلی جنس
- پلیٹو ڈیٹا
- پی او سی
- پالیسی
- مقبولیت
- ممکن
- پوسٹ
- مراسلات
- ممکنہ طور پر
- طاقت
- طاقتور
- عملی
- کی پیشن گوئی
- پیش گو
- پیش نظارہ
- پرنٹ
- نجی
- مسئلہ
- عمل
- عمل
- پروسیسنگ
- پیش رفت
- منصوبوں
- ثبوت
- تصور کا ثبوت
- ثابت کریں
- فراہم
- فراہم
- فراہم کرتا ہے
- فراہم کرنے
- ازگر
- pytorch
- سوالات
- سوال
- بلند
- رینج
- لے کر
- پڑھیں
- تیار
- اصل وقت
- وصول
- کو کم
- کم
- خطے
- رجسٹر
- یاد
- ہٹا
- کی جگہ
- درخواست
- درخواستوں
- کی ضرورت
- ضرورت
- ضروریات
- کی ضرورت ہے
- محققین
- وسائل
- وسائل
- جواب
- نتیجہ
- نتائج کی نمائش
- واپسی
- واپسی
- کا جائزہ لینے کے
- انقلاب آگیا
- خطرہ
- ROI
- رن
- چل رہا ہے
- sagemaker
- بچت
- توسیع پذیر
- پیمانے
- سکیلنگ
- sdk
- دوسری
- سیکنڈ
- SELF
- خدمت
- بے سرور
- سروس
- سروسز
- سیشن
- مقرر
- مختصر
- دکھایا گیا
- شوز
- اہم
- اسی طرح
- سادہ
- بعد
- ایک
- حالات
- سائز
- سائز
- ٹھوس
- حل
- حل
- حل
- کچھ
- ذرائع
- ماہر
- کاتنا۔
- استحکام
- مستحکم
- شروع کریں
- شروع
- شروع
- حالت
- مرحلہ
- بند کرو
- ذخیرہ
- ذخیرہ
- براہ راست
- کارگر
- کافی
- کامیابی
- کامیابی کے ساتھ
- اس طرح
- حمایت
- کی حمایت کرتا ہے
- اس بات کا یقین
- پیچھے چھوڑ
- سسٹمز
- لے لو
- ہدف
- کاموں
- تکنیک
- ٹیکنالوجی
- سانچے
- شرائط
- ٹیسٹنگ
- شکریہ
- کہ
- ۔
- ریاست
- ان
- ان
- تو
- وہاں.
- اس طرح
- لہذا
- یہ
- وہ
- اس
- اس سال
- تین
- کے ذریعے
- بھر میں
- وقت
- اوقات
- وقت
- کرنے کے لئے
- مل کر
- ٹوکن
- بھی
- ٹریکنگ
- تربیت یافتہ
- ترجمہ
- سچ
- کوشش
- اقسام
- ui
- کے تحت
- افہام و تفہیم
- یونیورسٹی
- جب تک
- صلی اللہ علیہ وسلم
- us
- استعمال کی شرائط
- رکن کا
- صارف مواجہ
- کا استعمال کرتے ہوئے
- عام طور پر
- قیمت
- مختلف
- مختلف
- وسیع
- وینچر
- اس بات کی تصدیق
- بہت
- کی طرف سے
- نقطہ نظر
- انتظار
- انتظار کر رہا ہے
- جاگو
- اٹھو
- چاہتے ہیں
- تھا
- راستہ..
- طریقوں
- we
- ویب
- ویب خدمات
- جب
- چاہے
- جس
- جبکہ
- ڈبلیو
- وسیع
- وسیع رینج
- گے
- ساتھ
- بغیر
- وون
- کام کرتا ہے
- دنیا بھر
- گا
- لکھا
- سال
- تم
- نوجوان
- اور
- اپنے آپ کو
- زیفیرنیٹ
- صفر