Amazon Personalize Samples

repository·master·Indexed 20 days ago

https://github.com/aws-samples/amazon-personalize-samples

A collection of Jupyter notebooks, CloudFormation templates, and code samples for onboarding and scaling Amazon Personalize. Includes tutorials for e-commerce and video-on-demand recommenders, batch recommendations, personalized ranking, and the use of structured and unstructured metadata. Provides guidance on deploying environments via CloudFormation and using Amazon SageMaker for model implementation and MLOps patterns.

Tokens
42.5K
Snippets
101
Records
185
Agent score
70%

What's inside amazon-personalize-samples

  1. Overview of Amazon Personalize Filter Rotation

    master

    This project provides a serverless application designed to automate the rotation of Amazon Personalize filters. Since Amazon Personalize filters cannot be updated once created, you must create a new filter with a new expression and delete the old one to implement changes.

    This application automates this lifecycle by:

    • Creating new filters based on a dynamic naming template.
    • Building filter expressions using a dynamic expression template.
    • Deleting old filters using a matching expression.
    • (Optional) Publishing lifecycle events to Amazon EventBridge.
  2. Overview of Personalized Marketing Messaging with Amazon Bedrock and Amazon Personalize

    master

    This sample demonstrates how to create personalized marketing content (such as emails) for users by combining real-time item recommendations from Amazon Personalize with generative AI from Amazon Bedrock (using the Claude model).

    Workflow:

    1. Data Preparation: Uses Movielens interaction data and IMDb metadata.
    2. Recommendation: Trains an Amazon Personalize 'Top picks for you' Recommender.
    3. Prompt Engineering: Generates a prompt containing user preferences, recommendations, and demographics.
    4. Content Generation: Uses Amazon Bedrock to generate the final personalized email.
  3. Improve recommendations using metadata in Amazon Personalize

    master

    You can improve the relevance of recommendations by adding structured and unstructured metadata to your interaction, item, and user datasets. Selecting appropriate metadata and preparing it correctly for Amazon Personalize is critical for model performance.

    To explore how to implement this, refer to the provided notebook samples.

  4. Build a Personalized Marketing Campaign with Amazon Personalize and Bedrock

    master

    This project demonstrates how to combine a recommendation engine with a generative AI engine to create targeted marketing content.

    The Workflow:

    1. Recommendation Engine: Use Amazon Personalize to identify users with an affinity for specific items (e.g., specific flights).
    2. Content Generation: Use Amazon Bedrock to generate personalized marketing content tailored to those identified users.

    The Data Pipeline: Marketing request $\rightarrow$ Amazon Personalize $\rightarrow$ retrieve metadata $\rightarrow$ combine with PromptTemplate $\rightarrow$ LangChain $\rightarrow$ Amazon Bedrock & LLM $\rightarrow$ Generate content $\rightarrow$ save in JSON.

  5. Available Amazon Personalize sample use cases

    master

    This repository provides specific implementation examples for the following scenarios:

    • User Personalization: Predicts items a user will interact with using a hierarchical recurrent neural network (HRNN) with automatic exploration.
    • Related Items: Computes item similarity based on co-occurrence in user-item interaction datasets.
    • Personalized Ranking: Reranks lists of items for users based on relevance.
    • Batch Recommendations: Creates recommendations for multiple users or items in a single batch job.
    • Metadata: Demonstrates how to prepare and include metadata in your datasets.
    • Objective Optimization: Shows how to balance business objectives with recommendation relevance.
    • Updating Datasets: Provides samples for updating existing Amazon Personalize Datasets.
  6. Understand the ml-latest-small dataset structure

    master

    The ml-latest-small dataset is a MovieLens dataset used for recommendation system training. It consists of four CSV files containing ratings, tags, movie metadata, and external identifiers. All files are UTF-8 encoded and use comma-separated values with a single header row. Columns containing commas are escaped with double-quotes (").

    Key data relationships:

    • User IDs: Anonymized and consistent between ratings.csv and tags.csv.
    • Movie IDs: Consistent across all four files (links.csv, movies.csv, ratings.csv, and tags.csv).
  7. Tutorial Overview: Building a Movie Recommender

    master

    This tutorial guides you through building a movie recommender using Amazon Personalize. The workflow consists of four main stages:

    1. Environment Setup: Deploy an AWS CloudFormation stack to provision a SageMaker notebook environment.
    2. Implementation: Run the Building_the_Magic_Movie_Machine_Recommender.ipynb notebook in Amazon SageMaker to build recommenders and generate recommendations.
    3. Resource Cleanup (Notebooks): Run the Clean_Up_Resources.ipynb notebook to delete resources created during the implementation phase to avoid ongoing charges.
    4. Environment Cleanup (CloudFormation): Delete the CloudFormation stack to remove the underlying infrastructure.

    Note: While notebooks are viewable on GitHub, you must deploy the preconfigured environment via CloudFormation to execute them successfully.

  8. Explore Amazon Personalize Workshops

    master

    This repository contains several workshop-based examples designed to help you learn Amazon Personalize through different learning paths:

    • Immersion Day: A structured deep dive into the service.
    • POC in a box: A framework for quickly setting up a Proof of Concept.
    • re:Invent 2019 Workshop: Historical workshop materials from AWS re:Invent.

    You can find these examples in the ./Immersion_Day, ./POC_in_a_box, and ./Reinvent_2019 directories respectively.

  9. Overview of the AWS Step Functions Data Science SDK

    master

    The AWS Step Functions Data Science SDK is an open-source Python SDK designed to simplify the creation of machine learning workflows.

    Key capabilities include:

    • Python-based Definition: Define Step Function state machines (discrete steps that perform work, make choices, or manage timeouts) using Python code instead of Amazon States Language (JSON).
    • Step Creation: Develop individual steps that can be linked together.
    • Parameter Management: Work with parameters across different steps in the workflow.
    • Service Integration: Integrate service-specific capabilities into the workflow.
    • Visualization: Create and visualize the resulting workflow steps.
  10. Implement Generative AI with Amazon Personalize

    master

    You can combine Amazon Personalize with Amazon Bedrock to create highly personalized marketing content.

    Workflow Example: Personalized Marketing Messaging

    1. Train an Amazon Personalize 'Top picks for you' Recommender to get personalized recommendations.
    2. Generate a prompt that includes the user's preferences, recommendations, and demographics.
    3. Use Amazon Bedrock to generate a personalized email or message for each user based on that prompt.
  11. Use the SIMS recipe for item-to-item recommendations

    master

    The SIMS recipe is an item-to-item collaborative filtering algorithm designed to recommend items that are most similar to a specific target item.

    Key Characteristics:

    • Use Case: Ideal for item detail pages where you want to display 'similar items' based on user behavior (e.g., users who interacted with Item A also interacted with Item B).
    • Performance: Faster to train and easier to interpret compared to other recipes.
    • Mechanism: Uses collaborative filtering to find similarities between items.
  12. Use the User-Personalization recipe for flexible recommendations

    master

    The aws-user-personalization recipe is the recommended starting point for building user personalization use cases. It combines an HRNN-based algorithm for relevance (exploitation) with automatic exploration of new or cold items.

    Dataset Requirements:

    • Required: Interactions dataset.
    • Optional (for enhanced performance): Items dataset, Users dataset, and impression data (included in the Interactions dataset).
    • Real-time: Can model impression data when streaming real-time events via an Event Tracker.

    Note: This recipe's item cold-start capabilities are preferred over the legacy HRNN-Coldstart recipe.