By using AWS re:Post, you agree to the Terms of Use

Read output json files | Batch Recommendations Inference Job


After created a Batch inference job to get Batch Recommendation I cannot figure it out how to delivery recommendation to my application (React Native) from file stored on S3 Bucket.

1 Answer

It sounds like you're trying to query batch inference results in a real-time web application... Which is a little surprising as wouldn't a Personalize "Campaign" for real-time inference seem like a better fit here? In that case you'd be able to call the GetRecommendations API or similar for a user ID on-demand.

But assuming you have a use case that does require batch Personalize inference and real-time querying:

In general (as shown in the examples here in the developer guide), Personalize batch inference results are in JSON-Lines format: Each file being a newline-separated list of JSON objects.

It's possible to use S3 Select to query a subset of records directly from an object in S3 (examples here). You could also consider Amazon Athena (e.g. blog post here) for querying across multiple sharded files.

However, depending on your usage profile and latency requirements, you may want to index the batch job results into some kind of database for retrieval instead of querying the batch files each time. For example, DynamoDB could give very fast performance for indexing and querying recommendations by user ID. You could consider AWS Glue to implement this ETL from S3 to DynamoDB/database in a serverless but scalable way.

Finally, regardless of whether you're using a direct S3 API or a database (or a Personalize real-time campaign), your application client will need some IAM-linked authentication to demonstrate it's allowed to access your data. This might be with Amazon Cognito or some other approach. the personalization-apis sample shows several options proxying through API Gateway.

answered 5 months ago
  • Hi, @Alex_T. Thank you for your answer. I'll try each possibilities.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions