ããã«ã¡ã¯ãã¨ã³ã¸ãã¢ã®å±±ä¸ã§ãã
ä»å㯠Salesforce Data Cloud 㨠Amazon SageMaker ã®é£æºæ©è½ã«ã¤ãã¦æ¸ãããã¨æãã¾ãã
ãããã¨
ä»å㯠Data Cloud 㨠SageMaker ã®é£æºæ©è½ãæ¤è¨¼ããããã§ãããå®ã¯ãã®æ¤è¨¼ã« SageMaker ã¯ä½¿ç¨ãã¾ãããæ¬è¨äºã®ã¿ã¤ãã«ã«ã SageMaker ã®ã¢ãã«ãå¼ã³åºãã¨ã¯ä¸è¨ãæ¸ãã¦ããªãã£ãããã¾ãã
è¦ããã«ãããããã¨ã§ããä»å㯠SageMaker ã®ã¨ã³ããã¤ã³ããè£ ã£ãããã¼ã®ãµã¼ãã¹ãç«ã¡ä¸ã㦠Data Cloud ã«æ¥ç¶ãã¾ããããã¦ããã¼ã®ãµã¼ãã¹ããé©å½ãªçµæãè¿ã㦠Data Cloud ãã¡ããã¨ãããå¦çãã¦ããããã¨ã確èªãã¾ããã¤ã¾ã SageMaker ã®ã¨ã³ããã¤ã³ããã¹ã¿ãåããã¨ãããã¨ã§ããã
ãã®ãããªæ¤è¨¼æ¹æ³ãåãã®ã«ã¯ãããªãã®çç±ãããã®ã§ããããã®çç±ã«ã¤ãã¦ã¯å¾ã»ã©èª¬æãããã¨æãã¾ãã
Data Cloud ã®è¨å®
ãããã SageMaker ã¨ã®é£æºã®ããã«ä½ãå¿ è¦ãªã®ããããããªããã°å§ã¾ããªãã®ã§ãã¾ã㯠Data Cloud ã®è¨å®ç»é¢ããè¦ã¦ããã¾ãã
Data Cloud 㧠SageMaker ã®ã¢ãã«ãå¼ã³åºãã«ã¯ãEinstein Studio 㧠Predictive Model ã¨ãã¦ã¢ãã«ãç»é²ããå¿ è¦ãããã¾ãã以ä¸ããã®ç»é¢ã§ãã
SageMaker ã¨æ¥ç¶ããããã®å°ç¨ã®é ç®ãããã¾ããããã¡ããé¸æããã¨ä»¥ä¸ã®ç»é¢ã«é·ç§»ãã¾ãã
Data Cloud 㨠SageMaker 㯠API çµç±ã§é£æºããã®ã§ãããã§ã¯ãã® API ã¨ã³ããã¤ã³ããè¨å®ããå¿ è¦ãããã¾ããä»åã¯ã¹ã¿ãã使ãã®ã§ Secret Key ãªã©ã®é ç®ã¯é©å½ã§å¤§ä¸å¤«ã§ããè¨å®ãã¦ãç¹ã«ä½¿ç¨ãã¾ããã
ä¸è¨ã®è¨å®é ç®ã®ä¸ã«ã¯ãªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹ã®å½¢å¼ãé¸æãããããããã¦ã³ãªã¹ãããããããããã®ãã©ã¼ãããã JSON ã CSV ããé¸æã§ãã¾ãã
ãã®ç»é¢ã«ã¯ãã©ã¼ãããã®ãµã³ãã«ãè¼ã£ã¦ãã¾ãããªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹ã®ãã©ã¡ã¼ã¿ã«ã¤ãã¦ã¯å¾ã»ã©å¿ è¦ã«ãªã£ãã¿ã¤ãã³ã°ã§è©³è¿°ãã¾ãã
æå¾ã«ã¢ãã«ã®å ¥åã»åºåãã©ã¡ã¼ã¿ãå®ç¾©ãã¾ãã
ã¢ã¤ã³ã³ãå³ç«¯ããã¯ã¿åºãã¦ãã¦ä¸ç©ã ... ã
ãã®ç»é¢ã® Outputs ã® JSON Key ã¯ãã¼ãã³ãã§ç¹æ®ãªå½¢å¼ã®å ¥åãè¦æ±ãã¦ããã®ã§ãå²ã¨æ¸æããã¤ã³ãã§ãã
å
¬å¼ããã¥ã¡ã³ã ã«ã¯ $.predictions
ã®ãããªå½¢ã§å
¥åããã¨ã ãæ¸ãã¦ããããã¤å
ã»ã©ãã£ãåºåãã©ã¼ãããã®ãµã³ãã«ã«ã¯ä»¥ä¸ã®ãããªè¨è¿°ãããã®ã§ããããããå¯ãã¦ãã ããã¨ãããã¨ã®ããã§ãã
{ "predictions": [0.66, 0.55] }
é
åã®ä¸ã«ãªãã¸ã§ã¯ããç½®ããã¨ãå¯è½ã§ãä¾ãã° $.predictions.value
ã¨ããå ´åã以ä¸ã®ãã㪠JSON ããåºåãèªã¿åãã¾ãã
{ "predictions": [ { "value": 0.66 }, { "value": 0.55 }, : ] }
æå¤ã¨é«æ©è½ã§ããã
ã¡ãªã¿ã« CSV ã®å ´å㯠JSON Key ã®ä»£ããã« Position ã¨ããé ç®ã®å ¥åãè¦æ±ããã¾ãããã¡ãã¯åè¡ã®ä½åç®ã®è¦ç´ ã該å½ããåºåé ç®ã«ãªãããæå®ããå½¢ã«ãªãã¾ãã
SageMaker ã¨ã³ããã¤ã³ãã®è¦ä»¶
å ã®è¨å®ç»é¢ãããData Cloud 㨠SageMaker ã API ã¨ã³ããã¤ã³ããéãã¦é£æºãè¡ããã¨ããããã¾ãããããããçãæ·±ãæ¹ã¯ããã® API ã¨ã³ããã¤ã³ããéã㦠SageMaker ã«åºæã®ç¹æ®ãªããåãã交ããããã®ã§ã¯ãªãããã¨æãããããã¾ããã
çµè«ããè¿°ã¹ãã¨ããããªãã¨ã¯å ¨ãããã¾ãããããã§ä½¿ç¨ãã API ã¨ã³ããã¤ã³ãã¯ä¸è¬ç㪠Web ãµã¼ããæä¾ããæ®éã® API ã§ãã
ãããã SageMaker ã§ã¯ãã¢ãã«ã®ãããã¤ãè¡ã£ãå ´åãè£ã§æ©æ¢°å¦ç¿ã¢ãã«ãæè¼ãã Docker ã³ã³ããããã¹ããããä»çµã¿ã«ãªã£ã¦ããã®ã§ããããã®ã³ã³ããã®å®ä½ã¯åãªã Web ãµã¼ãã«ããã¾ãããå®éãAWS ã® å ¬å¼ããã¥ã¡ã³ã ã«ã¯ä»¥ä¸ã®ããã«è²·ãã¦ããã¾ãã
To receive inference requests, the container must have a web server listening on port 8080 and must accept POST requests to the /invocations and /ping endpoints.
é©ãã»ã©åç´ã§éã«ä¸å®ã«ãªãã¾ãã ... ã
ä¸è¨ã®èª¬æã«ã¯æ¨è«ç¨ã¨ã³ããã¤ã³ãã /invocations
ã¨ãããã¹ã«ããã¨ããæå®ãããã¾ãããData Cloud 㯠URL ã§æå®ãããã¨ã³ããã¤ã³ããæç´ã«å¼ã³åºãã¦ãããã®ã§ãä»åã¯ãã®ç¸ãããç¹ã«å®ãå¿
è¦ã¯ããã¾ããã
è¦ããã«æ®éã® Web API ãç¨æã㦠Data Cloud ã«è¨å®ããã°ããã§é£æºå¯è½ãªã®ã§ãAPI Gateway + Lambda ãªã©ã§ãµã¯ãã¨ç¨æãã¦ããã¾ãã*1
SageMaker ã¨ã³ããã¤ã³ãã®ã¹ã¿ãã®æºå
ããã§ãªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹ã®ãã©ã¼ãããã確èªãã¦ããã¾ããData Cloud ããçºè¡ããããªã¯ã¨ã¹ãã® JSON å½¢å¼ã§ã®å ¥åã¯ä»¥ä¸ã®å½¢å¼ã«ãªãã¾ãã
{ "instances": [ { "features": [<param1>, <param2>, ...] }, { "features": [<param1>, <param2>, ...] }, : ] }
Data Cloud ã§ã¯åºæ¬çã« DMO = Data Model Object ã®ï¼ã¬ã³ã¼ããå
¥åã¨ãã¦ã¢ãã«ã®æ¨è«ãè¡ããã¨ãåæã¨ãã¦ãã¾ããå¾ã£ã¦ãä¸è¨ã® instances
ã¯ãããã® DMO ã®éåã«å¯¾å¿ããinstances
ã®åè¦ç´ ã® features
ã®ä¸ã«å
¥åãã©ã¡ã¼ã¿ç¾¤ãæ ¼ç´ããã¾ãã
ä»æ¹ãã¬ã¹ãã³ã¹ã¯å ã« Data Cloud ã«è¨å®ãã Outputs ã«é©åãã¦ããã°ä½ã§ã OK ã§ããä»åã¯ä»¥ä¸ã®å½¢å¼ã«ãã¾ããã
{ "predictions": [ { "value": 0.66 }, { "value": 0.55 }, : ] }
ã¨ããããã§å®è£ ãã¾ãã
export const handler = async (event) => { const predictions = event['instances'].map(_ => { return {"value": 0.5}; }); return { predictions: predictions, }; };
ã¹ã¿ããªã®ã§è¿å´ããæ¨è«çµæ㯠0.5
ã§åºå®ãã¦ãã¾ãã
æ¨è«ã®å®è¡
SageMaker ã¨é£æºãã¦ä½æãã Predictive Model ã¯ä»¥ä¸ã®ç®æã§å©ç¨å¯è½ã§ãã
- Flow
- Prediction Job
ã¡ãªã¿ã« Data Cloud ã® Batch Data Transform ã§ã Einstein Studio ã®ã¢ãã«ã«ããæ¨è«ãå©ç¨å¯è½ã§ããããã¡ã㯠Einstein Studio ã§ä½æããã¢ãã«ã«å©ç¨ãå¶éããã¦ããããã§ãSageMaker ã¨é£æºãã¦ä½æãã Predictive Model ã¯å©ç¨ã§ããªãããã§ãã
ä»å㯠Prediction Job ãå©ç¨ãã¦æ¨è«ãå®è¡ãã¾ããEinstein Studio ã® Integrations ã¿ããã Job ãä½æãããã¨ãã§ãã¾ãã
å ã«ãè¿°ã¹ãéããEinstein Studio ã®ã¢ãã«ã¯ DMO ã®ã¬ã³ã¼ããå ¥åã«ãªããã¨ãåæã¨ãªã£ã¦ãã¾ãããã®ãããJob ãä½æããéã«ã¯ãã©ã® DMO ã¬ã³ã¼ãã®ã©ã®ãã£ã¼ã«ããã¢ãã«ã¸ã®å ¥åã¨ãã¦å©ç¨ããã®ããé¸æãã¾ãã
ä»ãJob ã®å®è¡æ¹å¼ã Job ã®å®è¡çµæãæ ¼ç´ãã DMO ã®ååã®è¨å®ãªã©ãè¡ãã¾ãããã¡ãã¯ç¹ã«é£ããç¹ã¯ãªãã®ã§å²æãã¾ãã
Job ä½æç´å¾ã¯ã¹ãã¼ã¿ã¹ã Inactive ã«ãªã£ã¦ããã®ã§ãå¿ããã« Activate ãã¦ããã¾ããæ°åç¨åº¦ã§ã¹ãã¼ã¿ã¹ã Active ã«å¤ããã®ã§ãå¾ã¯ Run ãå®è¡ããã ãã§ããå®è¡å¾ãç¹ã«åé¡ããªããã° Job ã® Last Run Status ã Success ã«å¤ããã¾ãã
ã¾ã Run ã®å®è¡åã«ãã¹ã¿ãã®ã³ã¼ãã« console.log(event)
ãæ¸ãæ·»ãã¦ããã¨ã以ä¸ã®ãããªãã°ã CloudWatch Logs ã§ç¢ºèªã§ãã¾ãã
2024-07-17T04:00:00.000Z 8d20289a-ada8-4f5e-a7e6-81106fe38731 INFO { instances: [ { features: [Array] }, { features: [Array] }, { features: [Array] }, { features: [Array] }, : ] }
ã¨ããããã§ãData Cloud ã¨ã¹ã¿ãã®é£æºãã§ãã¾ãããç°¡åã§ãããã
ãªãã¹ã¿ãã使ã£ãã®ã
SageMaker ã®ã¨ã³ããã¤ã³ãã«ã¹ã¿ããå©ç¨ãããããæ¤è¨¼ã¨ãã¦ã¯ããé åããªå°è±¡ãä¸ããããããã¾ããããå®ã¯ä»åã®æé ã Data Cloud 㨠SageMaker ãé£æºãããããã®å¿ é ã®æé ã«ãªãã¾ãã
ã¨ããã®ã¯ãä½ãé ãããç¾æç¹ã§ã¯ Data Cloud 㨠SageMaker ãç´æ¥æ¥ç¶ããæ段ããªãããã§ãã
æ¬æ稿ã®åé 㧠Data Cloud ã®è¨å®ç»é¢ãæ²è¼ãã¾ããããããããè¦ãã¨ãAPI ã¨ã³ããã¤ã³ãã®è¨å®ç»é¢ã«ããèªè¨¼é¢é£é ç®ã¯ API Key ã®ã¿ã¨ãªã£ã¦ãã¾ããããããSageMaker ã®ã¨ã³ããã¤ã³ãã§ã¯ AWS Signature V4 ã«ããç½²åãè¦æ±ããããã®ç½²åã®ããã«ã¯å°ãªãã¨ãï¼ã¤ä»¥ä¸ã®ãããã¼è¦ç´ ã®æå®ãå¿ è¦ã¨ãªãã¾ãããã®èªè¨¼é ç®ã®ä¸æ´åã«ãããData Cloud ã®ç¾å¨ã®æ çµã¿ã§ SageMaker ã¨ã³ããã¤ã³ãã®èªè¨¼ãéããã¨ãä¸å¯è½ã«ãªã£ã¦ãã¾ãã
å¾ã£ã¦ãData Cloud 㨠SageMaker ãé£æºãããã«ã¯ãAWS Lambda ãã¯ããã¨ãã仲ä»å½¹ãå¿ ãå¿ è¦ã«ãªãã¾ãããã®å¶ç´ã«ãããSageMaker ã¨ã³ããã¤ã³ãã®æ¬è³ªãåãªã Web ãµã¼ãã§ãããã¨ãç解ãã¦ããªãéçºè ã¯ããããé£æºãå§ãããã¨ããã§ããªããã¨ããã®ã Data Cloud ã®ç¾ç¶ã§ãã
ããããéã«ã¹ã¿ãã®å¼ã³åºãããã§ããã°ããã®å®ä½ã¯ Lambda ãªã®ã§ããããã SageMaker ã®ã¢ãã«ãå¼ã³åºããã¨ã¯ãã¡ãããä»ã®ã¯ã©ã¦ããã³ãã¼ã®ã¢ãã«ãå¼ã³åºãæ¾é¡ã§ããããã§ããã®ãã
ãããªããã§ãä»åã¯ã¹ã¿ãã使ã£ã Data Cloud 㨠SageMaker ã®é£æºæ©è½ã®æ¤è¨¼æ¹æ³ã«ã¤ãã¦ãéããã¾ããã
ãªã API Gateway + Lambda + SageMaker ã®æ§æã§ã¨ã³ããã¤ã³ããæ§æããæ¹æ³ã«ã¤ãã¦ã¯ Amazon ã«ããã°è¨äºãããã®ã§ããã¡ããåç §ããã®ãããããã§ããã
ã¾ã¨ã
ä»åã®å 容ãã¾ã¨ããã¨ã
- SageMaker ã®ã¨ã³ããã¤ã³ãã®æ¬è³ªã¯åãªã Web ãµã¼ãã§ãã
- Data Cloud 㨠SageMaker ã¯èªè¨¼é ç®ã®ä¸æ´åã§ç´æ¥é£æºã¯ã§ããªã
- Data Cloud 㨠SageMaker ãé£æºãããã«ã¯ Lambda ãªã©ã®ä»²ä»å½¹ãå¿ è¦
ã¨ãã£ãæãã«ãªãããã§ãã
Data Cloud 㨠SageMaker ã®é£æºãç´æ¥ã§ããªãã®ã¯æ¯çãã§ãããSageMaker ã®è£å´ã®ä»çµã¿ã«ã¤ãã¦ã®ç¥è¦ãæ·±ã¾ããå人çã«ã¯ãããªãã«åç©«ã®ããæ¤è¨¼ã§ããã
Data Cloud ã¯ã¾ã æ°ãããµã¼ãã¹ãªã®ã§ãä»å¾ã®æ¹è¯ã§ SageMaker ã¨ç´æ¥é£æºãã§ããããã«ãªããã¨ãæå¾ ãããã§ããã
以ä¸ã§ããæå¾ã¾ã§ãèªã¿ããã ãããããã¨ããããã¾ããã
*1:ä»åã¯ã¬ã¹ãã³ã¹ã« JSON ã使ç¨ããã®ã§ Lambda ã使ç¨ãã¦ãã¾ãããã¬ã¹ãã³ã¹ã CSV ã§è¿ãå ´å㯠Lambda ã®æ¡ç¨ãåé¡ã«ãªããã¨ãããã¾ããå®ã¯ Lambda 㧠JavaScript ã Python ã使ã£ãå ´åãã¬ã¹ãã³ã¹ã JSON å½¢å¼ã§ããã¨ããæé»ã®ä»®å®ããªãããCSV ããã¾ãè¿å´ãããã¨ãã§ãã¾ãããå¾ã£ã¦ããã®åé¡ãçºçããªã Java ã C# ãªã©ã®è¨èªã Lambda ã§ä½¿ããããããã Lambda ã使ããã« EC2 ãªã©ã§ API ãµã¼ããç«ã¦ãå¿ è¦ãããã¾ãã