Tuesday, January 2, 2024

 

Use of Front Door for web applications in Azure Public Cloud.

Azure Front Door is typically used to ensure that users can access web applications in the event of a regional outage, balance requests between instances and to support rate limiting. It works well with CDN. Azure Front Door focuses on global load balancing and site-acceleration and Azure CDN offers static content caching and acceleration. By bringing security with threat protection and advanced OWASP capabilities, Azure Front Door makes CDN a remarkable cloud-native solution. 

By itself, Azure Front Door enables us to define, manage, and monitor global routing for our web traffic by optimizing the best performance and instant global failover for high availability. With Front Door, we can transform our global (multi-region) consumer and enterprise applications into robust, high-performance, and personalized modern applications, APIs, and content that reaches a global audience with Azure. Azure Front Door works at Layer 7 of HTTP/HTTPS layer and uses anycast protocol with split TCP and Microsoft’s global network for improving global connectivity. 

Front Door can be used to guarantee business continuity and disaster recovery. This provides robustness to web applications and function applications such that the state can be recovered after a user or application error, regional data center outage, or unplanned disruptions. By its nature of being purely logic, application and app services have varying options to target recovery of different scopes and levels, some of which are compared below:  

 

·                 Concepts to Understand 

Primary region and secondary region: Two regions are used to achieve higher availability and the application is deployed to each region. The designated primary receives traffic normally and the secondary receives traffic on failover.  

 

Front Door can be configured for priority routing which sends traffic to primary region until it becomes unavailable and routes traffic to secondary instead. Front Door has both routing configuration and health probes to monitor the health of each backend. Ideally, health probes should check for critical dependencies such as apps, queues, and databases.  

 

Geo-replication: is configured for storage accounts, SQL databases and Cosmos DB.  

 

 

·                 Configuration patterns

 

There are several general approaches to achieve high availability across regions which include:  

·                 Active/Passive with hot standby: Traffic goes to one region, while the other is running and ready to accept connections. The other is usually allocated in a different region and is always running.  

·                 Active/Passive with cold standby: Traffic goes to one region while the other waits on cold standby. The secondary region isn’t allocated until needed for a failover. This is less cost but takes longer.  

·                 Active/active – both regions are active, and load balanced equally. If one of the regions becomes unavailable, it is taken out of rotation.  

Monday, January 1, 2024

 

Automated Cloud IaC using Copilot:

A Copilot is an AI companion that can communicate with a user over a prompt and a response. It can be used for various services such as Azure and Security, and it respects subscription filters. Copilots help users figure out workflows, queries, code and even the links to documentation. They can even obey commands such as changing the theme to light or dark mode. Copilots are well-integrated with many connectors and types of data sources supported. They implement different Natural Language Processing models and are available in various flagship products such as Microsoft 365 and GitHub. They can help create emails, code and collaboration artifacts faster and better.   

 

This article delves into the creation of a copilot to suggest IaC code relevant to a query. It follows the same precedence as a GitHub Copilot that helps developers write code in programming languages. It is powered by the OpenAI Codex model, which is a modified production version of the Generative Pre-trained Transformer-3 aka (GPT-3). The GPT-3 AI model created by OpenAI features 175 billion parameters for language processing. This is a collaboration effort between OpenAI, Microsoft and GitHub.   

 

A copilot can be developed with no code using Azure OpenAI studio. We just need to instantiate a studio, associate a model, add the data sources, and allow the model to train. The models differ in syntactic or semantic search.  The latter uses a concept called embedding that discovers the latent meaning behind the occurrences of tokens in the given data. So it is more inclusive than the former.  A search for time will specifically search for that keyword with the GPT-3 but a search for clock will include the references to time with a model that leverages embeddings.  Either way, a search service is required to create an index over the dataset because it facilitates fast retrieval. A database such as Azure Cosmos DB can be used to assist with vector search.  

 

At present, all these resources are created in a cloud, but their functionality can also be recreated on a local Windows machine with the upcoming release of the Windows AI Studio. This helps to train the model on documents that are available only locally. Usually, the time to set up the resources is only a couple of minutes but the time to train the model on all the data is the bulk of the duration after which the model can start making responses to the queries posed by the user. The time for the model to respond once it is trained is usually in the order of a couple of seconds.  A cloud storage account has the luxury to retain documents indefinitely and with no limit to size but the training of a model on the corresponding data accrues cost and increases with the size of the data ingested to form an index.  

 

References to build the first co-pilot:  

1.      https://github.com/raja0034/azureml-examples 

2.      https://github.com/raja0034/openaidemo/blob/main/copilot.py 

References: previous articles on IaC

 

Sample test run:



 




Sunday, December 31, 2023

 

Sheena Yap Chan, a podcaster, emphasizes the importance of Asian women facing unique pressures to succeed and be high performers while navigating harmful stereotypes that limit their careers. The dominant culture expects Asian Americans to be "model" minorities, which can harm their mental health. The term "model minority" has oppressive roots and fails to capture the diversity of Asian people. Asian women often internalize model minority expectations of self-sufficiency and high performance, making them less likely to ask for help.

Toxic racist stereotypes limit Asian women, as non-Asian people may view them as quiet, submissive, and obedient, hindering their leadership potential. Mainstream media perpetuates anti-Asian stereotypes in subliminal ways, such as in COVID-19 articles. Asian women may be unable to imagine themselves in positions of power because they lack leadership role models. Chan encourages readers to prioritize their health and well-being, forge new leadership pathways, and break free from the harmful effects of intergenerational trauma.

The main takeaway for Asian Americans is to unlock their potentials by facing our trauma and to prioritize their needs. She even suggests improving the health with the ancient Hindu chakra system and to build self-confidence. These suggestions are even more pertinent to Asian-Americans because they tend to prioritize everyone else’s needs. Instead, they must practice self-care by investing in our physical, mental, spiritual, and emotional health. Find the self-care activities that appeal to you, such as listening to music, working out, napping, meditating, going to the spa, having a girl’s night, listening to podcast or getting a manicure.

Working to open your chakras can help you embrace your full potential. “Chakra” means “wheel” in Sanskrit and refers to the seven primary “subtle energy” discs running through your body. Each relates to a different body part and impacts other aspects of your life, such as creativity or self-confidence. In a healthy person, energy moves freely between each chakra but stress, poor diet, negative thoughts, or a lack of exercise can block your chakras, triggering emotional, mental, and physical ailments. The following chakras must be worked on through modalities such as breath exercises to improve the overall well-being.

1.      Muladhara – the “root chakra” is associated with being secure and grounded.

2.      Swadhisthana – the “sacral chakra” is at the bottom of the belly button and lets us tap into our creative and sexual energy

3.      Manipura – the “solar plexus chakra” is in the abdomen and balancing helps us express ourselves with confidence.

4.      Anahata – the “Heart chakra” is in the center of the chest, opening it helps us with healthy, loving relationships

5.      Vishuddha – the “throat chakra” is in the throat. Balancing it helps you express your authentic voice.

6.      Ajna – the “third eye chakra” is on the forehead. It is associated with trusting our institution.

7.      Sahasrara – the “Crown Chakra” sits at the top of the head and balancing it connects us to higher self-purpose.

Self-confidence can be built by believing in yourself to remember that you have the power to achieve your dreams, educating yourself to pursue different approaches to building self-confidence and taking action to align our actions to achieving our goals.

Kamala Harris, the VP of United States, Kim Ng, the first woman general manager of a major sports team, Savitri Jindal, the world’s richest Asian woman, and Sanda Oh, the first Asian actress to win several golden globes remain inspirational.

Sheena Yap Chan hosts the award-winning podcast “The Tao of self-confidence”, which interviews Asian women on their “inner journeys to self-confidence.”

Previous book summaries: https://1drv.ms/w/s!Ashlm-Nw-wnWhOYIIwJbPCitSu_D5A?e=bz918M

 #codingexercise 

https://1drv.ms/w/s!Ashlm-Nw-wnWhOYp_QOtRtp3TXRjxg?e=SbvjXx

Saturday, December 30, 2023

 

This is the summary of a book titled “Crossover Creativity” and published by Harriman House in 2023. Dave Trott, the author is a creative director, copywriter and author of several books.

Crossover creativity is the process of combining seemingly disconnected ideas, resulting in new ideas when a reaction occurs between two existing things, and as described by creative director Dave Trott. This process is influenced by creative people and companies like Picasso, Banksy, and IBM. To find creative solutions, marketers should be different, respond quickly to challenges, and reduce complexity. Overcoming fear of criticism and going against the flow can lead to moments of creative genius. The quality of your brief is crucial for campaign success, and good branding requires a human element. Delivering an entertaining, simple, and true message is essential. Accidents can inspire unexpected creativity, and mistakes can sink your campaign. Be wary of unbelievable promises and focus on selling a product, not an idea. To find creative solutions, be different, respond quickly, and reduce complexity. Middle managers can slow down the creative process, so it's essential to be agile and adaptable.

 

To maximize the chances of generating new ideas, marketers should remain open to new perspectives and do things differently, even if it disrupts their current understanding and patterns. They should also be wary of unbelievable promises, as they are selling a product, not an idea.

 

Challenges in crossover creativity require challenging traditional Western concepts of intelligence, especially those that dominate in marketing and advertising. Creative ideas have little value unless they can be applied practically. To find creative solutions, marketers should be different, respond to challenges quickly, and reduce complexity. Being different can give a competitive advantage, as individuals with working-class backgrounds may have more "street smarts" than those from middle-class backgrounds.

 

Middle managers within organizations can hinder idea generation by obsessing over irrelevant minutiae, being overly cautious, worrying too much about decision propriety, and constantly referring matters to committees. Eschewing agility for scrupulous observation of process can result in dull advertisements. When facing situations that require fast, immediate solutions, marketers should either take action or do nothing.

 

In conclusion, crossing over creativity is essential for marketers to stand out from the competition and develop the mindset needed to seize opportunities today.

 

Previous Book Summaries: BookSummary30.docx

Summarizing Software: https://booksonsoftware.com/text/

CodingExercise-12-30-2023.docx

Friday, December 29, 2023

 

Sheena Yap Chan, a podcaster, emphasizes the importance of Asian women facing unique pressures to succeed and be high performers while navigating harmful stereotypes that limit their careers. The dominant culture expects Asian Americans to be "model" minorities, which can harm their mental health. The term "model minority" has oppressive roots and fails to capture the diversity of Asian people. Asian women often internalize model minority expectations of self-sufficiency and high performance, making them less likely to ask for help.

Toxic racist stereotypes limit Asian women, as non-Asian people may view them as quiet, submissive, and obedient, hindering their leadership potential. Mainstream media perpetuates anti-Asian stereotypes in subliminal ways, such as in COVID-19 articles. Asian women may be unable to imagine themselves in positions of power because they lack leadership role models. Chan encourages readers to prioritize their health and well-being, forge new leadership pathways, and break free from the harmful effects of intergenerational trauma.

The main takeaway for Asian Americans is to unlock their potentials by facing our trauma and to prioritize their needs. She even suggests improving the health with the ancient Hindu chakra system and to build self-confidence. These suggestions are even more pertinent to Asian-Americans because they tend to prioritize everyone else’s needs. Instead, they must practice self-care by investing in our physical, mental, spiritual, and emotional health. Find the self-care activities that appeal to you, such as listening to music, working out, napping, meditating, going to the spa, having a girl’s night, listening to podcast or getting a manicure.

Working to open your chakras can help you embrace your full potential. “Chakra” means “wheel” in Sanskrit and refers to the seven primary “subtle energy” discs running through your body. Each relates to a different body part and impacts other aspects of your life, such as creativity or self-confidence. In a healthy person, energy moves freely between each chakra but stress, poor diet, negative thoughts, or a lack of exercise can block your chakras, triggering emotional, mental, and physical ailments. The following chakras must be worked on through modalities such as breath exercises to improve the overall well-being.

1.       Muladhara – the “root chakra” is associated with being secure and grounded.

2.       Swadhisthana – the “sacral chakra” is at the bottom of the belly button and lets us tap into our creative and sexual energy

3.       Manipura – the “solar plexus chakra” is in the abdomen and balancing helps us express ourselves with confidence.

4.       Anahata – the “Heart chakra” is in the center of the chest, opening it helps us with healthy, loving relationships

5.       Vishuddha – the “throat chakra” is in the throat. Balancing it helps you express your authentic voice.

6.       Ajna – the “third eye chakra” is on the forehead. It is associated with trusting our institution.

7.       Sahasrara – the “Crown Chakra” sits at the top of the head and balancing it connects us to higher self-purpose.

Self-confidence can be built by believing in yourself to remember that you have the power to achieve your dreams, educating yourself to pursue different approaches to building self-confidence and taking action to align our actions to achieving our goals.

Kamala Harris, the VP of United States, Kim Ng, the first woman general manager of a major sports team, Savitri Jindal, the world’s richest Asian woman, and Sanda Oh, the first Asian actress to win several golden globes remain inspirational.

Sheena Yap Chan hosts the award-winning podcast “The Tao of self-confidence”, which interviews Asian women on their “inner journeys to self-confidence.”

Previous book summaries: https://1drv.ms/w/s!Ashlm-Nw-wnWhOYIIwJbPCitSu_D5A?e=bz918M

 

Thursday, December 28, 2023

Summarizer code snippets

 

These are some code snippets to summarize text:

1.       Using genism

from gensim.summarization import summarize

def shrinktext(request):

    text = request.POST.get('text','')

    text = text.split('.')

    text = '\n'.join(text)

    try:

       summary = summarize(text)

       summary_list = []

       for line in summary.splitlines():

           if line not in summary_list:

              summary_list.append(line)

       summary = '\n'.join(summary_list)

    except Exception as e:

       summary = str(e)

       if type(e).__name__ == "TypeError":

          summary = ''.join(text.splitlines()[0:1])

2.       Using langchain

!pip install openai tiktoken chromadb langchain

 

# Set env var OPENAI_API_KEY or load from a .env file

# import dotenv

 

# dotenv.load_dotenv()

from langchain.chains.summarize import load_summarize_chain

from langchain.chat_models import ChatOpenAI

from langchain.document_loaders import WebBaseLoader

 

loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")

docs = loader.load()

 

llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-1106")

chain = load_summarize_chain(llm, chain_type="stuff")

 

chain.run(docs)

 

OR with documents in a single prompt:

from langchain.chains.combine_documents.stuff import StuffDocumentsChain

from langchain.chains.llm import LLMChain

from langchain.prompts import PromptTemplate

 

# Define prompt

prompt_template = """Write a concise summary of the following:

"{text}"

CONCISE SUMMARY:"""

prompt = PromptTemplate.from_template(prompt_template)

 

# Define LLM chain

llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-16k")

llm_chain = LLMChain(llm=llm, prompt=prompt)

 

# Define StuffDocumentsChain

stuff_chain = StuffDocumentsChain(llm_chain=llm_chain, document_variable_name="text")

 

docs = loader.load()

print(stuff_chain.run(docs))

 

3.       Using cloud apis

setx LANGUAGE_KEY your-key

setx LANGUAGE_ENDPOINT your-endpoint

pip install azure-ai-textanalytics==5.3.0

# This example requires environment variables named "LANGUAGE_KEY" and "LANGUAGE_ENDPOINT"

key = os.environ.get('LANGUAGE_KEY')

endpoint = os.environ.get('LANGUAGE_ENDPOINT')

 

from azure.ai.textanalytics import TextAnalyticsClient

from azure.core.credentials import AzureKeyCredential

 

# Authenticate the client using your key and endpoint

def authenticate_client():

    ta_credential = AzureKeyCredential(key)

    text_analytics_client = TextAnalyticsClient(

            endpoint=endpoint,

            credential=ta_credential)

    return text_analytics_client

 

client = authenticate_client()

 

# Example method for summarizing text

def sample_extractive_summarization(client, document):

    from azure.core.credentials import AzureKeyCredential

    from azure.ai.textanalytics import (

        TextAnalyticsClient,

        ExtractiveSummaryAction

    )

 

    poller = client.begin_analyze_actions(

        document,

        actions=[

            ExtractiveSummaryAction(max_sentence_count=4)

        ],

    )

 

    document_results = poller.result()

    return document_results

 

sample_extractive_summarization(client)

 

 

There are variations possible with the LLM context window or the keyword versus latent-semantic model or the pipeline but the above provide readable summary.

Wednesday, December 27, 2023

 

Transformers work very well because of three components: 1. Positional Encoding, 2. Attention and 3. Self-Attention.  Positional encoding is about enhancing the data with positional information rather than encoding it in the structure of the network. As we train the network on lots of text data, the transformers learn to interpret those positional encodings. It really helped transformers easier to train than RNN. Attention refers to a concept that originated from the paper aptly titled “Attention is all you need”. It is a structure that allows a text model to look at every single word  in the original sentence when deciding to translate the word in the output. A heat map for attention helps with understanding the word and its grammar. While attention is for understanding the alignment of words, self-attention is for understanding the underlying meaning of a word to disambiguate it from other usages. This often involves an internal representation of the word also referred to as its state. When attention is directed towards the input text, there can be differences understood between say “server, can I have the check” and the “I crashed the server” to interpret the references to a human versus a machine server. The context of the surrounding words helps with this state.

BERT, an NLP model, make use of attention and can be used for a variety of purposes such as text summarization, question answering, classification and finding similar sentences. BERT also helps with  Google search and Google cloud AutoML language. Google has made BERT available for download via TensorFlow library while Hugging Face company has made Transformers available in Python language.

A recent study on Copilot by Gartner found that the most successful pilots focus on demonstrating business potential, not on technical feasibility. The difference between the two is the realization of the transformative potential of this technology. Since the technology is still broad and emerging, IT leaders find it hard to prioritize generative AI use cases. Mature AI partners involve business partners and software engineers as key members of their AI projects. Generative AI allows for faster development cycle than traditional AI projects. As always but more so from shorter development cycles, success is realized via rapid testing, refinement, and the elimination of low priority and severity use cases.