The engineering behind Alexa's contextual speech recognition

How Alexa scales machine learning models to millions of customers.

Automatic speech recognition (ASR) is the conversion of acoustic speech to text, and with Alexa, the core ASR model for any given language is the same across customers.

But one of the ways the Alexa AI team improves ASR accuracy is by adapting models, on the fly, to customer context. For instance, Alexa can use acoustic properties of the speaker’s voice during the utterance of the wake word “Alexa” to filter out background voices when processing the customer’s request.

Echo Studio.png
Alexa's automatic speech recognition uses customer and device context to improve performance.

Alexa can also use the device context to improve performance. For instance, a device with a screen might display a list of possible responses to a query, and Alexa can bias the ASR model toward the list entries when processing subsequent instructions.

Recently, Alexa also introduced a context embedding service, which uses a large neural network trained on a variety of tasks to produce a running sequence of vector representations — or embeddings — of the past several rounds of dialogue, both the customer’s utterances and Alexa’s responses.

The context embeddings are an on-tap resource for any Alexa machine learning model, and the service can be expanded to include other types of contextual information, such as device type, customers’ skill and content preferences, and the like.

Theory into practice

At Amazon Science, we report regularly on the machine learning models — including those that use context — that enable improvements to Alexa’s speech recognizer. But rarely do we discuss the engineering effort required to bring those models into production.

Related content
Innovative training methods and model compression techniques combine with clever engineering to keep speech processing local.

To get a sense for the scale of that effort, consider just one of Alexa’s deployed context-aware ASR models, which uses conversational context to improve accuracy when Alexa asks follow-up questions to confirm its understanding of commands. For instance:

Customer: “Alexa, call Meg.”
Alexa: “Do you mean Meg Jones or Meg Bauer?”
Customer: “Bauer.”

When Alexa hears “Bauer” in the second dialogue turn, it favors the interpretation “Bauer” over the more common “power” based on the context of the previous turn. On its initial deployment, conversational-context awareness reduced the ASR error rate during such interactions by almost 26%.

The underlying machine learning model factors in the current customer utterance, the text of the previous dialogue turn (both the customer’s utterance and Alexa’s response), and relevant context information from the Alexa services invoked by the utterance. This might include entries from an address book, a list of smart-home devices connected to Alexa, or the local-search function’s classification of names the customer mentioned — names of restaurants, of movie theaters, of gas stations, and so on.

But once the model has been trained, the engineers’ work is just beginning.

Problems of scale

The first engineering problem is that there’s no way to know in advance which interactions with Alexa will require follow-up questions and responses. Embedding context information is a computationally intensive process. It would be a waste of resources to subject all customer utterances to that process, when only a fraction of them might lead to multiturn interactions.

Instead, Alexa temporarily stores relevant context information on a server; utterances are time stamped and are automatically deleted after a fixed span of time. Only utterances that elicit follow-up questions from Alexa pass to the context embedding model.

Related content
New approach improves F1 score of clarification questions by 81%.

For storage, the Alexa engineers are currently using AWS’s DynamoDB service. Like all of AWS’s storage options, DynamoDB encrypts the data it stores, so updating an entry in a DynamoDB table requires decrypting it first.

The engineering team wanted to track multiple dialogue events using only a single table entry; that way, it would be possible to decide whether or when to begin a contextual embedding with a single read operation.

If the contextual data were stored in the same entry, however, it would have to be decrypted and re-encrypted with every update about the interaction. Repeated for every customer utterance and Alexa reply every day, that would begin to add up, hogging system resources and causing delays.

Kyle Goehner.png
Senior software development engineer Kyle Goehner.

Instead, the Alexa engineers use a two-table system to store contextual information. One table records the system-level events associated with a particular Alexa interaction, such as the instruction to transcribe the customer’s utterance and the instruction to synthesize Alexa’s reply. Each of these events is represented by a single short text string, in a single table entry.

The entry also contains references to a second table, which stores the encrypted texts of the customer utterance, Alexa’s reply, and any other contextual data. Each of those data items has its own entry, so once it’s written, it doesn’t need to be decrypted until Alexa has decided to create a context vector for the associated transaction.

“We have tried to keep the database design simple and flexible,” says Kyle Goehner, who led the engineering effort behind the follow-up contextual feature. “Even at the scale of Alexa, science is constantly evolving and our systems need to be easy to understand and adapt.”

Computation window

Delaying the creation of the context vector until the necessity arises poses a challenge, however, as it requires the execution of a complex computation in the middle of a customer’s interaction with Alexa. The engineers’ solution was to hide the computation time under Alexa’s reply to the customer’s request.

All Alexa interactions are initiated by a customer utterance, and almost all customer utterances elicit replies from Alexa. The event that triggers the creation of the context vector is re-opening the microphone to listen for a reply.

The texts of Alexa’s replies are available to the context model before Alexa actually speaks them, and the instruction to reopen the microphone follows immediately upon the instruction to begin the reply. This gives Alexa a narrow window of opportunity in which to produce the context vector.

Compute-window.cropped.png
Because the instruction to re-open the microphone (expect-speech directive) follows immediately upon the instruction to begin executing Alexa’s reply (speak directive), the reply itself buys the context model enough time to produce a context vector.

If the context model fails to generate a context vector in the available time, the ASR model simply operates as it normally would, without contextual information. As Goehner puts it, the contextual-ASR model is a “best-effort” model. “We’re trying to introduce accuracy improvement without introducing possible points of failure,” he says.

Consistent reads

To ensure that contextual ASR can work in real time, the Alexa engineers also took advantage of some of DynamoDB’s special features.

Like all good database systems, DynamoDB uses redundancy to ensure data availability; any data written to a DynamoDB server is copied multiple times. If the database is facing heavy demand, however, then when new data is written, there can be a delay in updating the copies. Consequently, a read request that gets routed to one of the copies may sometimes retrieve data that’s out of date.

To guard against this, every time Alexa writes new information to the contextual-ASR data table, it simultaneously requests the updated version of the entry recording the status of the interaction, ensuring that it never gets stale information. If the entry includes a record of the all-important instruction to re-open the microphone, Alexa initiates the creation of the contextual vector; if it doesn’t, Alexa simply discards the data.

Related content
Arabic posed unique challenges for speech recognition, language understanding, and speech synthesis.

“This work is the culmination of very close collaboration between scientists and engineers to design contextual machine learning to operate at Alexa scale,” says Debprakash Patnaik, a software development manager who leads the engineering teams behind the new system.

“We launched this service for US English language and saw promising improvements in speech recognition errors,” says Rumit Sehlot, a software development manager at Amazon. “We also made it very easy to experiment with other contextual signals offline to see whether the new context is relevant. One recent success story has been adding the context of local information — for example, when a customer asks about nearby coffee shops and later requests driving directions to one of them.”

“We recognize that after we’ve built and tested our models, the work of bringing those models to our customers has just begun,” adds Ivan Bulyko, an applied-science manager for Alexa Speech. “It takes sound design to make these services at scale, and that’s something the Alexa engineering team reliably provides.”

Research areas

Related content

US, NY, New York
AWS AI is looking for passionate, talented, and inventive Applied Scientists with a strong machine learning background to help build industry-leading Conversational AI Systems. Our mission is to provide a delightful experience to Amazon’s customers by pushing the envelope in Natural Language Understanding (NLU), Dialog Systems including Generative AI with Large Language Models (LLMs) and Applied Machine Learning (ML). As part of our AI team in Amazon AWS, you will work alongside internationally recognized experts to develop novel algorithms and modeling techniques to advance the state-of-the-art in human language technology. Your work will directly impact millions of our customers in the form of products and services that make use language technology. You will gain hands on experience with Amazon’s heterogeneous text, structured data sources, and large-scale computing resources to accelerate advances in language understanding. We are hiring in all areas of human language technology: NLU, Dialog Management, Conversational AI, LLMs and Generative AI. About the team 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. Hybrid Work We value innovation and recognize this sometimes requires uninterrupted time to focus on a build. We also value in-person collaboration and time spent face-to-face. Our team affords employees options to work in the office every day or in a flexible, hybrid work model near one of our U.S. Amazon offices.
US, WA, Seattle
An information-rich and accurate product catalog is a strategic asset for Amazon. It powers unrivaled product discovery, informs customer buying decisions, offers a large selection, and positions Amazon as the first stop for shopping online. We use data analysis and statistical and machine learning techniques to proactively identify relationships between products within the Amazon product catalog. This problem is challenging due to sheer scale (billions of products in the catalog), diversity (products ranging from electronics to groceries to instant video across multiple languages) and multitude of input sources (millions of sellers contributing product data with different quality). Amazon’s Item and Relationship Identity Systems group is looking for an innovative and customer-focused applied scientist to help us make the world’s best product catalog even better. We believe that failure and innovation are inseparable twins. In this role, you will partner with technology and business leaders to build new state-of-the-art algorithms, models, and services to infer product-to-product relationships that matter to our customers. You will work in a collaborative environment where you can experiment with massive data from the world’s largest product catalog, work on challenging problems, quickly implement and deploy your algorithmic ideas at scale, understand whether they succeed via statistically relevant experiments across millions of customers. Key job responsibilities * Map business requirements and customer needs to a scientific problem. * Align the research direction to business requirements and make the right judgments on research/development schedule and prioritization. * Research, design and implement scalable machine learning (ML), natural language, or computational models to solve problems that matter to our customers in an iterative fashion. * Mentor and develop junior applied scientists and developers who work on data science problems in the same organization. * Stay informed on the latest machine learning, natural language and/or artificial intelligence trends and make presentations to the larger engineering and applied science communities.
US, CA, San Diego
Are you passionate about automation, knowledge extraction, and artificial intelligence through the use of Machine Learning, Natural Language Processing, Recommender systems, Computer Vision, and Optimization? We have a team of experienced scientists with a critical business mission making revolutionary leaps forward in these spaces. On this team you will work with an immense and diverse corpus of text, image, and audio to build generative and discriminative models, analyze and model customer reading behavior to measure engagement and detect risks, study and optimize manufacturing and fulfillment processes, and build AI-based systems for helping indie authors with marketing their books. This will involve combining methods from several science domains with domain knowledge across multiple businesses into sophisticated ML workflows. Our team has mature areas and green-field opportunities. We offer scientific autonomy, value end-to-end ownership, and have a strong customer-focused culture. Come join us as we revolutionize the book industry and deliver an amazing experience to our Kindle authors and readers. Key job responsibilities As a Machine Learning Scientist at Amazon, you will connect with world leaders in your field working on similar problems. You will be working with large distributed systems of data and providing technical leadership to the product managers, teams, and organizations building machine learning solutions. You will be tackling Machine Learning challenges in Supervised, Unsupervised, and Semi-supervised Learning; utilizing modern methods such as deep learning and classical methods from statistical learning theory, detection, estimation. MLS’s are specialists with the knowledge to help drive the scientific vision for our products. They are externally aware of the state-of-the-art in their respective field of expertise and are constantly focused on advancing that state-of-the-art for improving Amazon’s products and services. Great candidates for this position will have experience in the areas of data science, machine learning, NLP, optimization, computer vision, or statistics. You will have hands-on experience with multiple science initiatives as well as be able to balance technical strength with business judgment to make decisions about technology, models and methodological choices. You will strive for simplicity, and demonstrate significant creativity and high judgment. About the team Kindle Direct Publishing (KDP) and Print-On-Demand (POD) have empowered a new wave of self-motivated creators, tearing down barriers that once blocked writers from reaching readers. Our team builds rich applications that empower anyone to realize their dream of becoming an author. We strive to provide an experience that is powerful, simple, and accessible to all. We build tools that enable authors to design high quality digital and print books, reaching readers all around the world. This role will help ensure we maintain the trust of both our Authors and Readers by ensuring all books published to Amazon meet our standards.
US, WA, Bellevue
Do you want to work on a team where you are encouraged to build and have the autonomy to push boundaries? Invention has become second nature at Amazon, and the pace of innovation is only accelerating with breadth of our businesses expanding. Amazon’s growth requires leaders who move fast, have an entrepreneurial spirit to create new products, have an unrelenting tenacity to get things done, and are capable of breaking down and solving complex problems. The AIM, Planning team within SCOT comprises of S&OP, Inventory Prediction and Entitlement and Long-Term Capacity and Topology Planning. The team's charter is broad and complex and aimed at optimizing the utilization of fulfillment facilities and resources by accurately predicting demand and inventory efficiency measures while reducing stockouts and excess inventory costs across planning horizons, from short-term (within 13 weeks) to the long-term (13 weeks to 5 years). The team's north star is to be the reliable, single source of truth for inventory units and cube demand at granularities ranging from an FC’s bins to overall network level, and across planning horizons as close as next week to as far out as 3-5 years. To get there, we enhance or re-develop models and mechanisms where existing ones fail to account for structural shifts in supply chains, buying programs, or customer behaviors. We create new systems where science-based recommendations are currently lacking and being replaced by heuristics and offline human goal-seeking approaches. We strive to completely eliminate non-scientific interventions in our forecast guidance and capacity recommendations, and replace them with a system-driven outlook to uncover underlying root causes when departing from SCOT plans and recommendations. We institute authoritative and economics-based framework missing today to drive inventory efficiency measures for Retail buying programs (short/long-lead buys) and FBA plans that solve for capacity constraints in the most economical manner across horizons. This is a unique, high visibility opportunity for a senior science leader someone who wants to have business impact, dive deep into large-scale economic problems, enable measurable actions on the Consumer economy, and work closely with product managers, engineers, other scientists and economists. We are a Day 1 team, with a charter to be disruptive through the use of ML and bridge the Science and Engineering gaps that exist today. A day in the life In this pivotal role, you will be a technical leader in operations research or machine learning, with significant scope, impact, and visibility. Your solutions have the potential to drive billions of dollars in impact for Amazon's supply chain globally. As a senior scientist manager on the team, you will engage in every facet of the process—from idea generation, business analysis and scientific research to development and deployment of advanced models—granting you a profound sense of ownership. From day one, you will collaborate with experienced scientists, engineers, and product managers who are passionate about their work. Moreover, you will collaborate with Amazon's broader decision and research science community, enriching your perspective and mentoring fellow engineers and scientists. The successful candidate will have the strong expertise in applying operations research methodologies to address a wide variety of supply chain problems. You will strive for simplicity, demonstrate judgment backed by mathematical rigor, as you continually seek opportunities to innovate, build, and deliver. Entrepreneurial spirit, adaptability to diverse roles, and agility in a fast-paced, high-energy, highly collaborative environment are essential.
US, WA, Seattle
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 Use machine learning and statistical techniques to create scalable risk management systems Learning and understanding large amounts of Amazon’s historical business data for specific instances of risk or broader risk trends Design, development and evaluation of highly innovative models for risk management Working closely with software engineering teams to drive real-time model implementations and new feature creations Working closely with operations staff to optimize risk management operations, Establishing scalable, efficient, automated processes for large scale data analyses, model development, model validation and model implementation Tracking general business activity and providing clear, compelling management reporting on a regular basis Research and implement novel machine learning and statistical approaches
US, WA, Seattle
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 Use machine learning and statistical techniques to create scalable risk management systems Learning and understanding large amounts of Amazon’s historical business data for specific instances of risk or broader risk trends Design, development and evaluation of highly innovative models for risk management Working closely with software engineering teams to drive real-time model implementations and new feature creations Working closely with operations staff to optimize risk management operations, Establishing scalable, efficient, automated processes for large scale data analyses, model development, model validation and model implementation Tracking general business activity and providing clear, compelling management reporting on a regular basis Research and implement novel machine learning and statistical approaches
US, WA, Bellevue
We are a part of Amazon Alexa organization where our mission is “delight customers through contextual and personalized proactive experiences that keep customers informed, engaged, and productive without cognitive burden”. We are developing advanced systems to deliver engaging, intuitive, and adaptive content recommendations across all Amazon surfaces. We aim to facilitate seamless reasoning and customer experiences, surpassing the capabilities of previous machine learning models. We are looking for a passionate, talented, and resourceful Senior Applied Scientist in the field of Natural Language Processing (NLP), Large Language Model (LLM), Recommender Systems and/or Information Retrieval, to invent and build scalable solutions for a state-of-the-art context-aware personal assistant. A successful candidate will have strong machine learning background and a desire to push the envelope in one or more of the above areas. The ideal candidate would also enjoy operating in dynamic environments, be self-motivated to take on challenging problems to deliver big customer impact, shipping solutions via rapid experimentation and then iterating on user feedback and interactions. Key job responsibilities As a Senior Applied Scientist, you will leverage your technical expertise and experience to demonstrate leadership in tackling large complex problems, setting the direction and collaborating with applied scientists and engineers to develop novel algorithms and modeling techniques to enable timely, relevant and delightful recommendations and conversations. Your work will directly impact our customers in the form of products and services that make use of various machine learing, deep learning and language model technologies. You will leverage Amazon’s heterogeneous data sources and large-scale computing resources to accelerate advances in the state of art.
US, WA, Bellevue
Amazon is seeking an exceptional Applied Science Manager to join AGI Info Content team. In this role, you will be at the forefront of developing and enhancing the intelligence of AmazonBot crawler and content processing. The team is a key enabler of Amazon's AGI initiatives such as data pipelines for Olympus model training and collecting data for AGI Info grounding services. Our systems operate on web scale. This requires great combination of innovation to utilize all SOTA ML techniques in combination with model optimization to operate on 100k+ requests/decision per second. Your work will directly impact the quality and efficiency of our data acquisition efforts, ultimately benefiting millions of customers worldwide. Key job responsibilities - Design, develop, and implement advanced algorithms and machine learning models to improve the intelligence and effectiveness of our web crawler and content processing pipelines. - Collaborate with cross-functional teams to identify and prioritize crawling targets, ensuring alignment with business objectives - Analyze and optimize crawling strategies to maximize coverage, freshness, and quality of acquired data while minimizing operational costs as well as dive deep into data to select the highest quality data for LLM model training and grounding. - Conduct in-depth research to stay at the forefront of web acquisition and processing. - Develop and maintain scalable, fault-tolerant systems to handle the vast scale of Amazon's web crawling operations - Monitor and analyze performance metrics, identifying opportunities for improvement and implementing data-driven optimizations - Mentor and guide junior team members, fostering a culture of innovation and continuous learning
US, CA, Palo Alto
We are building GenAI based shopping assistant for Amazon. We reimage Amazon Search with an interactive conversational experience that helps you find answers to product questions, perform product comparisons, receive personalized product suggestions, and so much more, to easily find the perfect product for your needs. We’re looking for the best and brightest across Amazon to help us realize and deliver this vision to our customers right away. This will be a once in a generation transformation for Search, just like the Mosaic browser made the Internet easier to engage with three decades ago. If you missed the 90s—WWW, Mosaic, and the founding of Amazon and Google—you don’t want to miss this opportunity.
US, WA, Seattle
he Amazon Search Mission Understanding (SMU) team is at the forefront of revolutionizing the online shopping experience through the Amazon search page. Our ambition extends beyond facilitating a seamless shopping journey; we are committed to creating the next generation of intelligent shopping assistants. Leveraging cutting-edge Large Language Models (LLMs), we aim to redefine navigation and decision-making in e-commerce by deeply understanding our users' shopping missions, preferences, and goals. By developing responsive and scalable solutions, we not only accomplish the shopping mission but also foster unparalleled trust among our customers. Through our advanced technology, we generate valuable insights, providing a guided navigation system into various search missions, ensuring a comprehensive and holistic shopping experience. Our dedication to continuous improvement through constant measurement and enhancement of the shopper experience is crucial, as we strategically navigate the balance between immediate results and long-term business growth. We are seeking an Applied Scientist who is not just adept in the theoretical aspects of Machine Learning (ML), Artificial Intelligence (AI), and Large Language Models (LLMs) but also possesses a pragmatic, hands-on approach to navigating the complexities of innovation. The ideal candidate will have a profound expertise in developing, deploying, and contributing to the next-generation shopping search engine, including but not limited to Retrieval-Augmented Generation (RAG) models, specifically tailored towards enhancing the Rufus application—an integral part of our mission to revolutionize shopping assistance. You will take the lead in conceptualizing, building, and launching groundbreaking models that significantly improve our understanding of and capabilities in enhancing the search experience. A successful applicant will display a comprehensive skill set across machine learning model development, implementation, and optimization. This includes a strong foundation in data management, software engineering best practices, and a keen awareness of the latest developments in distributed systems technology. We are looking for individuals who are determined, analytically rigorous, passionate about applied sciences, creative, and possess strong logical reasoning abilities. Join the Search Mission Understanding team, a group of pioneering ML scientists and engineers dedicated to building core ML models and developing the infrastructure for model innovation. As part of Amazon Search, you will experience the dynamic, innovative culture of a startup, backed by the extensive resources of Amazon.com (AMZN), a global leader in internet services. Our collaborative, customer-centric work environment spans across our offices in Palo Alto, CA, and Seattle, WA, offering a unique blend of opportunities for professional growth and innovation. Key job responsibilities In this role you will leverage your engineering background and expertise to help build the next generation of our mission understanding models and data collection framework. On a day-to-day basis, you will: * Interface with Applied Scientists, Product Managers, and Program Managers to determine requirements for production systems * Analyze log data to determine future system design and configure parameters Build scalable and production-ready data pipelines to extract features from petabytes of raw data Integrate models and algorithms in complex, real-time production systems on immense scale * Design and execute experiments to determine the impact of models and algorithms you intend to deploy in production * Run analysis reports of web-experiments to identify benefits and risk of launching the models and algorithms * Serve as a liaison to our customer/seller-facing partner teams in case of escalations Project manage cross-functional Machine Learning initiatives