Amazon open-sources library for prediction over large output spaces

Framework improves efficiency, accuracy of applications that search for a handful of solutions in a huge space of candidates.

In the Internet age, many computational tasks involve finding a handful of solutions in an enormous space of candidates. Question-answering systems, for instance, can pull answers from anywhere on the web, while the Wikipedia taxonomy for classifying article topic classification has 500,000 terms. And of course, a product query at the Amazon Store has millions of potential matches.

Such extreme multilabel ranking (XMR) problems pose two major challenges. The first is one of scale, but the second is one of scarcity. The items in these large search spaces tend to have long-tailed distributions: most sentences rarely serve as answers to questions; most topics in the Wikipedia taxonomy rarely apply to texts; most products are rarely purchased; and so on. That means that attempts to use machine learning to solve XMR problems rarely have enough data to go on.

At Amazon, we have developed a general framework for meeting both these challenges, which we call PECOS, for prediction for enormous and correlated output spaces. After successfully using PECOS internally for key projects in product search and recommendation, we have publicly released the code to help stimulate further research on this important topic.

In the XMR context, the items retrieved from the search space are known as labels. If the task is document retrieval, the documents themselves are interpreted as candidate labels for a search string; the search string is the input. The “multilabel” in XMR indicates that a given input may have multiple labels; several different topics from the Wikipedia taxonomy, for instance, might apply to the same document.

PECOS decomposes the XMR problem into three stages:

  1. semantic label indexing, or grouping labels together according to semantic content;
  2. matching, or associating the input instance with a label group;
  3. ranking, or finding the labels in each group that best fit the input.
PECOS-framework.png
The three-stage PECOS model.
Credit: Stacy Reilly

PECOS lets users create their own algorithms to implement any of these stages, but the code release comes with a library of standard algorithms for each stage, including both a recursive linear model and a trained deep-learning model for matching.

The three-stage framework helps with both the scaling and long-tail problems. By enabling matching with groups of labels rather than individual labels, label indexing drastically reduces the search space for the matching step. It also helps with the long-tail problem, since it enables the ranking model to exploit semantic similarities between common labels and less common labels.

For machine-learning-based implementations of the ranking stage, label indexing aids in the selection of hard negatives. Machine learning models must be trained on both positive examples and negative examples; in the XMR context, most negative examples are so irrelevant as to impart little information to the model. Selecting negative examples from the same groups as the positive examples ensures that they’ll be challenging enough to improve the quality of the model.

The initial release of PECOS includes two models that implement the entire PECOS framework. One is a recursive linear model, the other a deep-learning model. In tests involving a dataset with 2.8 million labels, the deep-learning model improved the precision of the top-ranked result (precision@1) by 10% relative to the recursive linear model, but it took 265 times as long to train. It’s up to the individual users to evaluate that trade-off for their own use cases.

Semantic label indexing

Semantic label indexing has two components: a representation scheme and a grouping algorithm. For text-based inputs, the representation scheme might take advantage of pre-trained text embeddings such as Word2Vec or ELMo; for graph-based inputs, it might use information about the input’s relationships with its neighbors in the graph. PECOS includes efficient implementations of representation schemes such as positive instance indices (PII), positive instance feature aggregation (PIFA), and the graph spectrum representation.

For grouping, we’ve concentrated on clustering algorithms, but users could implement other approaches, such as approximate nearest-neighbor search. PECOS includes our implementations of the k-means and spherical k-means clustering algorithms, which feature recursive B-ary partitioning. For some value of B (usually between 2 and 16), the algorithm first partitions the label set into B clusters, then partitions each of those into B clusters, and so on.

B-ary partitioning.png
A simple example of our B-ary partitioning scheme.

In a paper about PECOS that we’ve published to the arXiv, we show that B-ary partitioning can significantly reduce the time required for semantic-label indexing, an important consideration given that we’re dealing with enormous label spaces. We also use the B-ary partitioning to implement the recursive linear model.

Built-in models

For text inputs, PECOS includes X-Transformer, which leverages pretrained transformer models from Huggingface to improve performance on extreme multilabel text classification applications. At the 2020 Conference on Knowledge Discovery and Data Mining (KDD), we presented a paper about the PECOS deep-learning model, which we also described in a related blog post on Amazon Science.

PECOS also includes a linear model, XR-Linear, which learns its matching algorithm recursively. First, it learns a B-ary partition of the label space. Then, to implement a matcher for that partition, it learns a new B-ary partition for each of the existing groups. To implement matchers for those, it learns a new B-ary partition for each, and so on, until it reaches the desired recursive depth. At that point, it learns a simple linear one-versus-all ranker for the labels in each partition.

Then, for each level of recursion, it learns a ranker for the outputs of the layer below.

Recursive matcher.png
A diagram of the recursive linear matcher.

This makes training very efficient, as the full set of weights for each recursive layer can fit in memory at once, saving time on inefficient retrieval from storage.

At inference time, XR-Linear works through the same recursion tree to identify relevant labels. For efficiency, we use beam search to restrict the search space. For instance, if the beam width is two, then at each layer of the recursion tree, the model will pursue only the two highest-weight connections to the next layer.

Beam search.gif
An example of linear ranking with a beam width of two. At each level of the tree, two nodes (green) are selected for further exploration. Each of their descendant nodes is evaluated (orange), and two of those are selected for further exploration.
Credit: Giana Bucchino

Our PECOS software has benefited from open research that has been conducted at Amazon and at other universities and companies. By open-sourcing the PECOS software, we are thrilled to contribute back to the open-research community. Our hope is to spur further research on problems where the output spaces are very large. These include zero-shot learning for extreme multilabel problems, extreme contextual bandits, and deep reinforcement learning.

For more information about the optimizations we’ve incorporated into the PECOS code release, please see our arXiv paper. The code itself can be downloaded at GitHub.

Research areas

Related content

IN, KA, Bangalore
AWS Infrastructure Services (AIS) AWS Infrastructure Services owns the design, planning, delivery, and operation of all AWS global infrastructure. In other words, we’re the people who keep the cloud running. We support all AWS data centers and all of the servers, storage, networking, power, and cooling equipment that ensure our customers have continual access to the innovation they rely on. We work on the most challenging problems, with thousands of variables impacting the supply chain — and we’re looking for talented people who want to help. You’ll join a diverse team of software, hardware, and network engineers, supply chain specialists, security experts, operations managers, and other vital roles. You’ll collaborate with people across AWS to help us deliver the highest standards for safety and security while providing seemingly infinite capacity at the lowest possible cost for our customers. And you’ll experience an inclusive culture that welcomes bold ideas and empowers you to own them to completion. Do you love problem solving? Are you looking for real world Supply Chain challenges? Do you have a desire to make a major contribution to the future, in the rapid growth environment of Cloud Computing? Amazon Web Services is looking for a highly motivated, Data Scientist to help build scalable, predictive and prescriptive business analytics solutions that supports AWS Supply Chain and Procurement organization. You will be part of the Supply Chain Analytics team working with Global Stakeholders, Data Engineers, Business Intelligence Engineers and Business Analysts to achieve our goals. We are seeking an innovative and technically strong data scientist with a background in optimization, machine learning, and statistical modeling/analysis. This role requires a team member to have strong quantitative modeling skills and the ability to apply optimization/statistical/machine learning methods to complex decision-making problems, with data coming from various data sources. The candidate should have strong communication skills, be able to work closely with stakeholders and translate data-driven findings into actionable insights. The successful candidate will be a self-starter, comfortable with ambiguity, with strong attention to detail and ability to work in a fast-paced and ever-changing environment. Key job responsibilities - Demonstrate thorough technical knowledge on feature engineering of massive datasets, effective exploratory data analysis, and model building using industry standard time Series Forecasting techniques like ARIMA, ARIMAX, Holt Winter and formulate ensemble model. - Proficiency in both Supervised(Linear/Logistic Regression) and UnSupervised algorithms(k means clustering, Principle Component Analysis, Market Basket analysis). - Experience in solving optimization problems like inventory and network optimization . Should have hands on experience in Linear Programming. - Work closely with internal stakeholders like the business teams, engineering teams and partner teams and align them with respect to your focus area - Detail-oriented and must have an aptitude for solving unstructured problems. You should work in a self-directed environment, own tasks and drive them to completion. - Excellent business and communication skills to be able to work with business owners to develop and define key business questions and to build data sets that answer those questions - Work with distributed machine learning and statistical algorithms to harness enormous volumes of data at scale to serve our customers About the team About AWS Diverse Experiences AWS values diverse experiences. Even if you do not meet all of the qualifications and skills listed in the job description, we encourage candidates to apply. If your career is just starting, hasn’t followed a traditional path, or includes alternative experiences, don’t let it stop you from applying. Why AWS? Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform. We pioneered cloud computing and never stopped innovating — that’s why customers from the most successful startups to Global 500 companies trust our robust suite of products and services to power their businesses. Inclusive Team Culture Here at AWS, it’s in our nature to learn and be curious. Our employee-led affinity groups foster a culture of inclusion that empower us to be proud of our differences. Ongoing events and learning experiences, including our Conversations on Race and Ethnicity (CORE) and AmazeCon (gender diversity) conferences, inspire us to never stop embracing our uniqueness. Mentorship & Career Growth We’re continuously raising our performance bar as we strive to become Earth’s Best Employer. That’s why you’ll find endless knowledge-sharing, mentorship and other career-advancing resources here to help you develop into a better-rounded professional. Work/Life Balance We value work-life harmony. Achieving success at work should never come at the expense of sacrifices at home, which is why we strive for flexibility as part of our working culture. When we feel supported in the workplace and at home, there’s nothing we can’t achieve in the cloud.
US, NY, New York
Come build the future of smart security with us. Are you interested in helping shape the future of devices and services designed to keep people close to what’s important? ABOUT RING We started in a garage in 2012 when our founder asked a simple question: what if you could answer the front door from your phone? What if you could be there without needing to actually, you know, be there? After many late nights and endless tinkering, our first Video Doorbell was born. That invention has grown into over a decade of groundbreaking products and next-level features. And at the core of all that, everything we’ve done and everything we’ve yet to build, is that same inventor's spirit and drive to bridge the distance between people and what they care about. Whatever it is, at Ring we’re committed to helping you be there for it. (https://www.ring.com) ABOUT THE ROLE The Senior Data Scientist within Ring Data Science and Engineering plays a pivotal role in shaping how we carry the voice of our customers. We strive to understand their behaviors and preferences in order to provide them with the best experience connecting with the places, people and things that matter to them. This role will build scalable solutions and models to support our business functions (Subscriptions, Product, Customer Service). By leveraging a range of methods including statistical analysis and machine learning, you will explain, quantify, predict and prescribe in support of informing critical business decisions. You will translate business goals into agile, insightful analytics. You will seek to create value for both stakeholders and customers and inform findings in a clear, actionable way to managers and senior leaders. Key job responsibilities - Drive shared understanding among business, engineering, and science teams of domain knowledge of processes, system structures, and business requirements. - Apply domain knowledge to identify product roadmap, growth, engagement, and retention opportunities; quantify impact; and inform prioritization. - Advocate technical solutions to business stakeholders, engineering teams, and executive level decision makers. - Lead development and validation of state-of-the-art technical designs (data pipelines, data models, causal inference, predictive models, data insights/visualizations, etc) - Contribute to the hiring and development of others - Communicate strategy, progress, and impact to senior leadership A day in the life Translate/Interpret • Complex and interrelated datasets describing customer behavior, messaging, content, product design and financial impact. Measure/Quantify/Expand • Retrieve, synthesize, and present critical data in a format that is immediately useful to answering specific questions or improving system performance. • Analyze historical data to identify trends and support decision making. • Improve upon existing methodologies by developing new data sources, testing model enhancements, and fine-tuning model parameters. • Provide requirements to develop analytic capabilities, platforms, and pipelines. • Apply statistical or machine learning knowledge to specific business problems and data. Explore/Enlighten • Formalize assumptions about how users are expected to behave, create statistical definition of the outlier, and develop methods to systematically identify these outliers. Work out why such examples are outliers and define if any actions needed. • Given anecdotes about anomalies or generate automatic scripts to define anomalies, deep dive to explain why they happen, and identify fixes. • Make decisions and recommendations. • Build decision-making models and propose solution for the business problem you defined. • Conduct written and verbal presentation to share insights and recommendations to audiences of varying levels of technical sophistication. • Utilize code (Python/R/SQL) for data analyzing and modeling algorithms.
US, WA, Seattle
Interested in helping build Prime's content and offer personalization system to drive huge business impact on millions of customers? Join our team of Scientists and Engineers developing algorithms to adaptively generate, optimize, and personalize the customer experience with Amazon Prime. This includes identifying who our customers are and providing them with personalized relevant content. As an ML scientist, you will partner directly with product owners to intake, build, and directly apply your modeling solutions. There are numerous scientific and technical challenges you will get to tackle in this role, such as deep learning and reinforcement learning, and their application to various types of contextual, multi-step optimization of the customer journey. We employ techniques from supervised learning, multi-armed bandits, optimization, and RL - while this role is focused on the space of discriminative and generative recommender systems. As the central science team within Prime, our expertise gets routinely called upon to weigh in on a variety of topics. We also emphasize the need and value of scientific research and have developed a strong publication and patent record (internally/externally) which you will be a part of. You will also utilize and be exposed to the latest in ML technologies and infrastructure: AWS technologies (EMR/Spark, Redshift, Sagemaker, DynamoDB, S3, ...), various ML algorithms and techniques (Random Forests, Neural Networks, supervised/unsupervised/semi-supervised/reinforcement learning, LLMs), and statistical modeling techniques. Major responsibilities - Build and develop machine learning models and supporting infrastructure at TB scale, in coordination with software engineering teams. - Leverage Bandits, Supervised Learning, and Reinforcement Learning for Contextual Recommendation and Optimization Systems. - Develop offline policy estimation tools and integrate with reporting systems. - Establish scalable, efficient, automated processes for large scale data analyses, model development, model validation and model implementation. - Analyze and extract relevant information from large amounts of Amazon’s historical business data to help automate and optimize key processes. - Work closely with the business to understand their problem space, identify the opportunities and formulate the problems. - Use machine learning, data mining, statistical techniques and others to create actionable, meaningful, and scalable solutions for the business problems. - Design, develop and evaluate highly innovative models and statistical approaches to understand and predict customer behavior and to solve business problems.
US, WA, Seattle
The AWS Central Economics & Sciences team is looking for a PhD economist. The ideal candidate will be an expert in reduced form causal inference, be comfortable with estimating structural models, and have experience with ML techniques. Working knowledge of python is a plus. You will learn about cloud products, including compute, storage, and databases. You will work on analytic projects requested by senior leadership. You will get the opportunity to learn new techniques. You will be a part of a team with experienced business partners, economists, and data scientists. Key job responsibilities -Conduct econometric analyses using methods in causal inference. -Develop prescriptive recommendations with structural economic models About the team ACES works on high-impact projects for AWS service teams and leadership. This position will support the pricing team to develop and implement mechanisms for AWS to use pricing strategically to grow the business and improve customer experience.
DE, BE, Berlin
The Amazon Robotics team is seeking an experienced Applied Scientist to join our team. In this role you will apply the latest trends in research to solve real-world problems in robotics and AI. You will collaborate with a team of scientists and engineers building these applications. We holistically design, build, and deliver end-to-end robotic systems. Our team is also responsible for core infrastructure and tools that serve as the backbone of our robotic applications, enabling roboticists, machine learning scientists, software engineers, and hardware engineers to collaborate and deploy systems in the field. Key job responsibilities • Research, design, implement and evaluate complex perception, motion planning, and decision making algorithms integrating across multiple disciplines and leveraging machine learning. • Create experiments and prototype implementations of new learning algorithms and prediction techniques. • Work closely with software engineering team members to drive scalable, real-time implementations. • Collaborate with machine learning and robotic controls experts to implement and deploy algorithms, such as machine learning models. • Collaborate closely with hardware engineering team members on developing systems from prototyping to production level. • Represent Amazon in academia community through publications and scientific presentations. • Work with stakeholders across hardware, science, and operations teams to iterate on systems design and implementation. We are looking for applied scientists with expertise in any of the following: - Computer vision (including but not limited to tracking, object recognition, visual SLAM, motion prediction, reconstruction) - Machine learning (e.g. reinforcement learning, supervised learning, Bayesian methods, online learning systems, ML for robotics)
DE, BE, Berlin
The Amazon Robotics team is seeking an experienced Applied Scientist to join our team. In this role you will apply the latest trends in research to solve real-world problems in robotics and AI. You will collaborate with a team of scientists and engineers building these applications. We holistically design, build, and deliver end-to-end robotic systems. Our team is also responsible for core infrastructure and tools that serve as the backbone of our robotic applications, enabling roboticists, machine learning scientists, software engineers, and hardware engineers to collaborate and deploy systems in the field. Key job responsibilities We have several open positions for candidates with varying levels of experience. We seek candidates who can: - Research, design, implement and evaluate novel algorithms for dexterous robotics - Work on end-to-end robotics systems, creating scalable systems for many applications - Collaborate closely with team members on developing systems from prototyping to production level - Collaborate with teams spread all over the world, in particular Boston and Seattle - Work closely with software engineering teams to drive Amazon scale, real-time implementations - Be driven by business goals We are looking for applied scientists with expertise in any of the following: - Computer vision (including but not limited to tracking, object recognition, visual SLAM, motion prediction, reconstruction) - Machine learning (e.g. reinforcement learning, supervised learning, Bayesian methods, online learning systems, ML for robotics) - Control (e.g. impedance and direct force control, dynamics, trajectory control, motion planning, simulation)
TW, TPE, Taipei
Amazon Lab126 is an inventive research and development company that designs and engineers high-profile consumer electronics. Lab126 began in 2004 as a subsidiary of Amazon.com, Inc., originally creating the best-selling Kindle family of products. Since then, we have produced groundbreaking devices like Fire tablets, Fire TV, and Amazon Echo. What will you help us create? Key job responsibilities You will be working on developing Computer Vision algorithms to improve deep learning models including reducing the sample complexity, improving generalization ability, boosting model robustness, etc. You will be a critical science contributor and can create a significant business impact to the company. This opportunity requires excellent technical, problem-solving, and communication skills. An ideal candidate will have a high teamwork mentality coupled with a strong bias for action yet always insisting on the highest standards. We also aim to publish our innovation and findings to computer vision top conferences including CVPR, ICCV, ECCV. A day in the life In this role, you will work closely with other researchers in the team to research, design, and deliver science components powering computer vision and active learning algorithms to cost-effectively create very large-scale training datasets for various computer vision/robotics applications. You will have the unique opportunity to work on multiple popular Computer Vision tasks altogether, therefore, embrace the great potential to innovate more. About the team We are a smart team of doers that work passionately to apply cutting-edge advances in robotics and software to solve real-world challenges that will transform our customers’ experiences in ways we can’t even imagine yet. The team is using computer vision, machine learning, sensor fusion, real-time and distributed systems to convert requirements into concrete deliverables. A Researcher on this team will translate business and functional requirements into working code. Comfort with a high degree of ambiguity and ability to solve problems that haven’t been solved to scale before are essential.
IN, KA, Bengaluru
Do you want to join an innovative team of scientists who use machine learning and statistical techniques to help Amazon provide the best customer experience by preventing eCommerce fraud? Are you excited by the prospect of analyzing and modeling terabytes of data and creating state-of-the-art algorithms to solve real world problems? Do you like to own end-to-end business problems/metrics and directly impact the profitability of the company? Do you enjoy collaborating in a diverse team environment? If yes, then you may be a great fit to join the Amazon Buyer Risk Prevention (BRP) Machine Learning group. We are looking for a talented scientist who is passionate to build advanced algorithmic systems that help manage safety of millions of transactions every day. Key job responsibilities • Demonstrate proficiency in supervised algorithms (tree-based models, neural networks) and unsupervised algorithms (clustering). • Rapidly design, prototype, and test multiple hypotheses in a high-ambiguity environment, utilizing quantitative analysis and business judgment. • Report findings in a scientifically rigorous manner. • Collaborate with software engineers, product managers, and domain experts to identify and address challenges requiring innovative solutions for our products. • Acquire knowledge of Amazon's diverse data resources and determine when, how, and which resources to leverage or exclude. • Integrate successful experiments into large-scale, highly complex production services by collaborating with software engineering teams. • Maintain technical documentation and effectively communicate results to diverse audiences. • Evaluate trade-offs by considering complexity, long-term benefits, and the reusability of existing solution
US, CA, Palo Alto
Amazon is investing heavily in building a world class advertising business and we are responsible for defining and delivering a collection of self-service performance advertising products that drive discovery and sales. Our products are strategically important to our Retail and Marketplace businesses driving long term growth. We deliver billions of ad impressions and millions of clicks daily and are breaking fresh ground to create world-class products. We are highly motivated, collaborative and fun-loving with an entrepreneurial spirit and bias for action. With a broad mandate to experiment and innovate, we are growing at an unprecedented rate with a seemingly endless range of new opportunities. This position will be part of the Sponsored Product Demand Utilization team within the Amazon Advertising organization. Our team focuses on helping shoppers discover the Sponsored Products they need and on helping advertisers reach shoppers that will engage with their products. We utilize leading-edge engineering and science technologies, including generative AI and LLMs, to understand shopper intents and connect them with the right Sponsored Products. We are seeking a science leader for our team within the Sponsored Products & Brands organization. You'll be working with talented scientists, engineers, and product managers to innovate on behalf of our customers. An ideal candidate is able to navigate through ambiguous requirements, working with various partner teams, and has experience in generative AI, large language models (LLMs), information retrieval, and ads recommendation systems. Using a combination of generative AI and online experimentation, our scientists develop insights and optimizations that enable the monetization of Amazon properties while enhancing the experience of hundreds of millions of Amazon shoppers worldwide. If you're fired up about being part of a dynamic, driven team, then this is your moment to join us on this exciting journey! Key job responsibilities - Serve as a tech lead for defining the science roadmap for projects using GenAI to understand shoppers intent, help them discover the right products, and explain how they are related to their shopping mission. - Build POCs, optimize and deploy models into production, run experiments, perform deep dives on experiment data to gather actionable learnings and communicate them to senior leadership - Work closely with software engineers on detailed requirements, technical designs and implementation of end-to-end solutions in production - Work closely with product managers to contribute to our mission, and proactively identify opportunities where cutting edge science can help improve customer experience - Research new machine learning approaches to drive continued scientific innovation - Be a member of the Amazon-wide machine learning community, participating in internal and external meetups, hackathons and conferences - Help attract and recruit technical talent, mentor scientists and engineers in the team
US, NY, New York
We are looking for a motivated and experienced Data Scientist with experience in Machine Learning (ML), Artificial Intelligence (AI), Big Data, and Service Oriented Architecture with deep understanding in advertising businesses, to be part of a team of talented scientists and engineers to innovate, iterate, and solve real world problem with cutting-edge AWS technologies. In this role, you will take a leading role in defining the problem, innovating the ML/AI solutions, and information the tech roadmap. You will join a cross-functional, fun-loving team, working closely with scientists and engineers on a daily basis. You will innovate on behalf of our customers by prototyping, delivering functional proofs of concept (POCs), and partnering with our engineers to productize and scale successful POCs. If you are passionate about creating the future, come join us as we have fun, and make history. Key job responsibilities - Define and execute a research & development roadmap that drives data-informed decision making for marketers and advertisers - Establish and drive data hygiene best practices to ensure coherence and integrity of data feeding into production ML/AI solutions - Collaborate with colleagues across science and engineering disciplines for fast turnaround proof-of-concept prototyping at scale - Partner with product managers and stakeholders to define forward-looking product visions and prospective business use cases - Drive and lead of culture of data-driven innovations within and outside across Amazon Ads Marketing orgs About the team Marketing Decision Science provides science products to enable Amazon Ads Marketing to deliver relevant and compelling guidance across marketing channels to prospective and active advertisers for success on Amazon. We own the product, technology and deployment roadmap for AI- and analytics-powered products across Amazon Ads Marketing. We analyze the needs, experiences, and behaviors of Amazon advertisers at petabytes scale, to deliver the right marketing communications to the right advertiser at the right team to help them make the data-informed advertising decisions. Our science-based products enable applications and synergies across Ads organization, spanning marketing, product, and sales use cases.