{"id":1484,"date":"2020-06-23T09:00:10","date_gmt":"2020-06-23T16:00:10","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=1484"},"modified":"2020-06-22T22:55:21","modified_gmt":"2020-06-23T05:55:21","slug":"azure-cosmos-db-ai-engineers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/azure-cosmos-db-ai-engineers\/","title":{"rendered":"Azure Cosmos DB for AI Engineers"},"content":{"rendered":"<p>In this &#8220;<strong><em>Azure Cosmos DB for AI Engineers&#8221;<\/em><\/strong>\u00a0 blog post, you will learn how <a href=\"https:\/\/docs.microsoft.com\/learn\/certifications\/roles\/ai-engineer\" target=\"_blank\" rel=\"noopener noreferrer\">AI Engineers<\/a> can use <a href=\"https:\/\/azure.microsoft.com\/services\/cosmos-db\/\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Cosmos DB<\/a> to support their AI solutions, focusing on storing and analyzing unstructured or semi-structured data.<\/p>\n<p>AI Engineers design and implement intelligent apps and agents that simulate human perception using cognitive services, machine learning, and knowledge mining. Typical scenarios are anomaly detection, language understanding, text mining, search, among others. Let&#8217;s see why Azure Cosmos DB is the perfect database for AI Architectures on <a href=\"https:\/\/azure.microsoft.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Azure<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Azure Cosmos DB and Azure Cognitive Services<\/h2>\n<p><a href=\"https:\/\/www.azure.com\/cognitive\" target=\"_blank\" rel=\"noopener noreferrer\">Cognitive Services<\/a> bring AI within reach of every developer\u2014without requiring machine-learning expertise. All it takes is an API call to embed the ability to see, hear, speak, search, understand, and accelerate decision-making into your apps.<\/p>\n<p>All those APIs return JSON documents, a native format for Azure Cosmos DB. AI applications may store those results in raw format just adding a unique ID, what is required for all documents in Azure Cosmos DB. There are three main reasons why you would save the results from Cognitive Services.<\/p>\n<ul>\n<li>Reuse, avoiding the cost and the latency processing over and over the same data. An example is sentiment analysis, you don\u2019t need to submit the same review to the text analytics API more than once.<\/li>\n<li>Historic, for any kind compliance about data lineage.<\/li>\n<li>Advanced analytics, that now is supported for <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/analytical-store-introduction\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Cosmos DB analytical store<\/a> through <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/configure-synapse-link\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Synapse Link<\/a>. An example would be an IoT scenario, where you are use Anomaly Detector API and save the anomalies for reporting, analytics, etc.<\/li>\n<\/ul>\n<p>Check out our <a href=\"https:\/\/www.youtube.com\/watch?v=x51LvBC5QTs\" target=\"_blank\" rel=\"noopener noreferrer\">video on IoT Anomaly Detection<\/a> with <a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/whats-new-in-azure-cosmos-db-nov-2019\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jupyter Notebooks support<\/a>, using <a href=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Python<\/a> and Cognitive Services.<\/p>\n<p>&nbsp;<\/p>\n<h2>Azure Cosmos DB and Azure Cognitive Search<\/h2>\n<p><a href=\"https:\/\/docs.microsoft.com\/azure\/search\/search-what-is-azure-search\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Cognitive Search<\/a> is a search-as-a-service cloud solution that gives developers APIs and tools for adding a rich search experience over private, heterogeneous content in web, mobile, and enterprise applications. It\u2019s the Microsoft service for knowledge mining that AI to detect entities, read text in images, among other human capabilities. The metadata created with AI is always loaded into a searchable index, that allows full text search with natural language processing. Azure Cosmos DB plays 3 roles:<\/p>\n<ul>\n<li>Data Source, allowing data enrichment on top of the Azure Cosmos DB data.<\/li>\n<li>Data store for the insights found within the enrichment pipeline, for uses other than search. This is accomplished with a <a href=\"https:\/\/docs.microsoft.com\/azure\/search\/cognitive-search-custom-skill-interface\" target=\"_blank\" rel=\"noopener noreferrer\">Custom Skill<\/a>, that allows you to customize, filter, and store the data you need. This is a real time and granular approach to save Azure Cognitive Search data in Azure Cosmos DB.<\/li>\n<li>Data store for enriched data, since the pipeline can export all metadata to a storage account, in table or JSON format. Unlike the above option, here all data is exported, and you will have to batch load the data in Azure Cosmos DB using a tool like <a href=\"https:\/\/docs.microsoft.com\/azure\/data-factory\/introduction\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Data Factory<\/a>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Azure Cosmos DB and Bots<\/h2>\n<p><a href=\"https:\/\/dev.botframework.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Bot Service<\/a> enables you to build intelligent, enterprise-grade bots with ownership and control of your data. From a simple Q&amp;A bot to a sophisticated virtual assistant, the open source SDK connects your bot to popular channels and devices. And you can give your bot the ability to speak, listen, and understand your users because of the native integration to Cognitive Services. Azure Cosmos DB plays 3 roles:<\/p>\n<ul>\n<li>State management. While bots are stateless applications, the conversations must be stateful to avoid loss of context and force the user to repeat information already provided. Bots SDK V4+ use Azure Cosmos DB as a built-in option for this cache management.<\/li>\n<li>Data store for master data: login, password, previous transactions, actual balance, etc.<\/li>\n<li>Data store for new information: orders, user behavior logging, feedbacks, etc. A bot is a web application running your code, and you may want to use Cognitive Services to create an intelligent agent. Here you can apply the same suggestion of the first topic and save the results of the API calls in Azure Cosmos DB.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Azure Cosmos DB in AI Architectures<\/h2>\n<p>AI Applications can leverage key Azure Cosmos DB capabilities like <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/high-availability\" target=\"_blank\" rel=\"noopener noreferrer\">geographic distribution<\/a>, <a href=\"https:\/\/docs.microsoft.com\/azure\/cosmos-db\/how-to-multi-master?tabs=api-async\" target=\"_blank\" rel=\"noopener noreferrer\">multi master writes<\/a>, and <a href=\"https:\/\/azure.microsoft.com\/support\/legal\/sla\/cosmos-db\/v1_3\/\" target=\"_blank\" rel=\"noopener noreferrer\">performance SLAs<\/a> to avoid costs and latency, keeping the data close to your users. Because of its performance, there is no need of any other cache service for your solution. In the reference AI Architecture diagram below you can see a geographically distributed Intelligent Bot\u00a0 using Azure Cosmos DB, Cognitive Services, and Azure Cognitive Search. For cloud-native <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hybrid_transactional\/analytical_processing\" target=\"_blank\" rel=\"noopener noreferrer\">HTAP<\/a> (Hybrid Transactional and Analytical Processing) capabilities, the AI Architecture also has Azure Synapse Link for near real time analytics with <a href=\"https:\/\/docs.microsoft.com\/azure\/synapse-analytics\/sql\/on-demand-workspace-overview\">SQL serverless<\/a> and <a href=\"https:\/\/docs.microsoft.com\/azure\/synapse-analytics\/spark\/apache-spark-overview\">Apache Spark<\/a> for Azure Synapse Analytics.<\/p>\n<p>&nbsp;<\/p>\n<p><figure id=\"attachment_1481\" aria-labelledby=\"figcaption_attachment_1481\" class=\"wp-caption alignnone\" ><img decoding=\"async\" class=\"wp-image-1481 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/06\/HTAP-AI-diagram-1.png\" alt=\"Cosmos DB in Reference Solution AI Architecture\" width=\"1046\" height=\"646\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/06\/HTAP-AI-diagram-1.png 1046w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/06\/HTAP-AI-diagram-1-300x185.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/06\/HTAP-AI-diagram-1-1024x632.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2020\/06\/HTAP-AI-diagram-1-768x474.png 768w\" sizes=\"(max-width: 1046px) 100vw, 1046px\" \/><figcaption id=\"figcaption_attachment_1481\" class=\"wp-caption-text\">Distributed Intelligent Bot Reference Architecture using Cognitive Services and Azure Cosmos DB.<\/figcaption><\/figure><\/p>\n<h2><\/h2>\n<h2>Conclusion<\/h2>\n<p>Azure Cosmos DB is an important tool for AI engineers engaged into AI applications that will ingest, store, and process semi structured data. Use can use the <a href=\"https:\/\/docs.microsoft.com\/learn\/browse\/?roles=ai-engineer\" target=\"_blank\" rel=\"noopener noreferrer\">AI Engineer Learning Path<\/a> and the <a href=\"http:\/\/aka.ms\/cosmosdbworkshop\" target=\"_blank\" rel=\"noopener noreferrer\">Azure Cosmos DB Workshops<\/a> to learn more about these technologies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how AI Engineers can use Azure Cosmos DB for AI Applications.<\/p>\n","protected":false},"author":21894,"featured_media":1481,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1610,1216,19],"tags":[1236,1615,1228,1617,1614,1229,1312],"class_list":["post-1484","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-analytics","category-tips-and-tricks","tag-ai","tag-azure-search","tag-azure-synapse-link","tag-bots","tag-cognitive-services","tag-htap","tag-python"],"acf":[],"blog_post_summary":"<p>Learn how AI Engineers can use Azure Cosmos DB for AI Applications.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/21894"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=1484"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/1484\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/1481"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=1484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=1484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=1484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}