Thursday, February 13, 2025

 This is a summary of the book titled “The Intelligence Revolution: Transforming your business with AI” written by Bernard Marr and published by Kogan Page in 2020. This is the prequel to the summary on “Generative AI in practice” also by the same author and holds even more pertinence and relevance than it did at the time. No one disputes the “transformative potential” of Artificial Intelligence anymore and the author details the way companies are embracing this revolution to achieve their strategic goals. Spotting AI opportunities and realizing it while using AI and big data ethically and respecting consumer privacy are his main purports. He calls this the Fourth Industrial Revolution and argues for using the power to better serve internal and external stakeholders. Data driven insights can help optimize solutions across all areas of consumers’ lives. The AI solutions are most effective when combined with a robust strategy that reflects your unique needs. There are best practices that can help navigate AI transformation and he suggests to invest in a four-layer technology stack to effectively seize AI opportunities. The Intelligence Revolution requires leaders to step up in new adaptive ways.

The Fourth Industrial Revolution is set to revolutionize everyday life by introducing AI and big data, transforming how people work and live. AI-driven technologies will make lab-grown food, autonomous driving, and smarter homes more accessible. Industries like farming and fishing are already leaning into technological developments, with the fishing industry potentially becoming unrecognizable in the coming years.

AI, or machines that can learn and take action independently and autonomously, is fueling advances in machine learning. There are two types of AI: narrow AI, which simulates human thought patterns, and generalized AI, which can learn and behave in ways similar to human thought and actions. Machines can already think like humans, reading text and understanding idioms and slang in over 20 languages.

The digitization of the world is driving advances in machine and deep learning, as machines learn with increasing accuracy as more data becomes available. In the age of big data, machines are even learning to identify human emotions through "affective computing." Companies must reflect on their strategic goals and how they might use AI tools to achieve desired outcomes.

AI can be leveraged to enhance business opportunities by creating smarter products, offering smart services, and optimizing business processes with smart tools. By incorporating AI capabilities into products, businesses can collect data on customers' habits and preferences, improving product design and delivering better solutions. AI is revolutionizing everyday home products, mobility and transportation, manufacturing and industry, and sports. Smart products can track users' sleep patterns, provide personalized recommendations, and enhance efficiency. Companies can also embed sensors in industrial machinery to improve efficiency and enhance employee capabilities. AI insights are changing the experience of exercise and sports, with smart boxing gloves and sensors on basketball nets providing insights for better shots. The health sector is also undergoing significant changes as people connect medical applications and devices to the Internet of Medical Things (IoMT), helping healthcare providers collect patient data and monitor vital signs. By leveraging AI, businesses can better serve internal and external stakeholders and optimize solutions across all areas of consumers' lives.

AI solutions are most effective when combined with a robust strategy that reflects your unique needs. Identify potential AI opportunities by reflecting on all possible use cases within your company, focusing on specific objectives, KPIs, and data types. Consider the legal and ethical implications of your projects, such as collecting data with users' consent. Determine the infrastructure and technology needed and identify any skills gaps or implementation challenges.

Successful AI starts with strategy, not the technology itself. Talk about change management and prioritize one to three potential applications that represent the biggest growth potential or solve major business challenges. Ethically navigate your AI transformation by embracing best practices, such as building trust, avoiding "the black box problem," embracing skepticism, checking for bias, and following official guidelines for responsible AI. This will help you navigate the legal and ethical aspects of AI transformation and ensure a positive company culture surrounding AI.

To effectively seize AI opportunities, invest in a four-layer technology stack. This includes data collection from various sources, data storage, data processing and analytics, and data output and reporting. Leaders must develop skills such as agility, emotional intelligence, cultural intelligence, humility, accountability, vision, courage, intuition, authenticity, and focus on company's core objectives.

The Intelligence Revolution requires leaders to step up in new, adaptive ways, treating change as an opportunity and navigating uncertainty. Strategic vision is vital when navigating uncertainty, as the collective use of AI across organizations could have devastating effects. However, if implemented with care, AI could dramatically improve everyday life, transform work, and help tackle challenges like climate change. The choices made now could determine whether AI becomes a "force for good" or something more dystopian.

Notice the many parallels between Marr’s and Gilbertson’s recommendations to businesses.


#Codingexercise: https://1drv.ms/w/c/d609fb70e39b65c8/EeNEEcMlb4BOu2622MeJOoYBplhXDQbaoibcr6JYyMggIw?e=0ZOwZ1

Wednesday, February 12, 2025

 Infrastructure engineering for AI projects often deal with text based inputs for analysis and predictions whether they are sourced from chatbots facing the customers, service ticket notes, or a variety of data stores and warehouses but the ability to convert text into audio format is also helpful for many scenarios, including DEI requirements and is quite easy to setup and offers the convenience to listen when screens are small, inadequate for usability and are difficult to read. Well-known audio formats can be played on any device and not just phones.

Although there are many dedicated text-to-speech software and online services available, some for free, and with programmability via web requests, there are built-in features of the public cloud service portfolio that make such capabilities more mainstream and at par with the rest of the AI/ML pipelines. This article includes one such implementation towards the end but first an introduction to this feature and capabilities as commercially available.

Most audio is characterized by amplitude as measured in decibels preferably at least 24db, the stream or bit rate which should preferably be at least 192kbps, and a limiter. Different voices can be generated with variations in amplitude, pitch, and tempo much like how singing is measured. Free text-to-speech software, whether standalone, or online gives conveniences in the input and output formats. For example, Natural Reader allows you to load documents and convert them to audio files. Balabolka can save narrations as a variety of audio file formats with customizations for pronunciations and voice settings. Panopreter Basic, also free software, add both input formats and mp3 output format. TTSMaker supports 100+ languages and 600+ AI voices for commercial purposes. Murf AI although not entirely free has a converter that supports 200+ realistic AI voices and 20+ languages. Licensing and distribution uses varies with each software maker.

Public-cloud based capabilities for text-to-speech can be instantiated with a resource initialization from the corresponding service in their service portfolio. The following explains just how to do that.

Sample implementation:

1. Get text input over a web api:

from flask import Flask, request, jsonify, send_file

import os

import azure.cognitiveservices.speech as speechsdk

app = Flask(__name__)

# Azure Speech Service configuration

SPEECH_KEY = "<your-speech-api-key>"

SERVICE_REGION = "<your-region>"

speech_config = speechsdk.SpeechConfig(subscription=SPEECH_KEY, region=SERVICE_REGION)

speech_config.speech_synthesis_voice_name = "en-US-JennyNeural" # Set desired voice

@app.route('/text-to-speech', methods=['POST'])

def text_to_speech():

    try:

        # Check if text is provided directly or via file

        if 'text' in request.form:

            text = request.form['text']

        elif 'file' in request.files:

            file = request.files['file']

            text = file.read().decode('utf-8')

        else:

            return jsonify({"error": "No text or file provided"}), 400

        # Generate speech from text

        audio_filename = "output.mp3"

        synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

        result = synthesizer.speak_text_async(text).get()

        if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:

            # Save audio to file

            with open(audio_filename, "wb") as audio_file:

                audio_file.write(result.audio_data)

            return send_file(audio_filename, as_attachment=True)

        else:

            return jsonify({"error": f"Speech synthesis failed: {result.reason}"}), 500

    except Exception as e:

        return jsonify({"error": str(e)}), 500

if __name__ == "__main__":

    app.run(host="0.0.0.0", port=5000)

2. Prerequisites to run the script:

a. pip install flask azure-cognitiveservices-speech

b. Create an Azure Speech resource in the Azure portal and retrieve the SPEECH_KEY and SERVICE_REGION from the resources’ keys and endpoint section and use them in place of `<your-speech-api-key>` and `<your-region>` above

c. Save the script and run it in any host as `python app.py`

3. Sample trial

a. With curl request as `curl -X POST -F "text=Hello, this is a test." http://127.0.0.1:5000/text-to-speech --output output.mp3`

b. Or as file attachment with `curl -X POST -F "file=@example.txt" http://127.0.0.1:5000/text-to-speech --output output.mp3`

c. The mp3 audio file generated can be played.

Reference: previous articles

CodingExercise-02-12-2025



Tuesday, February 11, 2025

 There are N points (numbered from 0 to N−1) on a plane. Each point is colored either red ('R') or green ('G'). The K-th point is located at coordinates (X[K], Y[K]) and its color is colors[K]. No point lies on coordinates (0, 0).

We want to draw a circle centered on coordinates (0, 0), such that the number of red points and green points inside the circle is equal. What is the maximum number of points that can lie inside such a circle? Note that it is always possible to draw a circle with no points inside.

Write a function that, given two arrays of integers X, Y and a string colors, returns an integer specifying the maximum number of points inside a circle containing an equal number of red points and green points.

Examples:

1. Given X = [4, 0, 2, −2], Y = [4, 1, 2, −3] and colors = "RGRR", your function should return 2. The circle contains points (0, 1) and (2, 2), but not points (−2, −3) and (4, 4).

class Solution {

    public int solution(int[] X, int[] Y, String colors) {

        // find the maximum

        double max = Double.MIN_VALUE;

        int count = 0;

        for (int i = 0; i < X.length; i++)

        {

            double dist = X[i] * X[i] + Y[i] * Y[i];

            if (dist > max)

            {

                max = dist;

            }

        }

        for (double i = Math.sqrt(max) + 1; i > 0; i -= 0.1)

        {

            int r = 0;

            int g = 0;

            for (int j = 0; j < colors.length(); j++)

            {

                if (Math.sqrt(X[j] * X[j] + Y[j] * Y[j]) > i)

                {

                    continue;

                }

                if (colors.substring(j, j+1).equals("R")) {

                    r++;

                }

                else {

                    g++;

                }

            }

            if ( r == g && r > 0) {

                int min = r * 2;

                if (min > count)

                {

                    count = min;

                }

            }

        }

        return count;

    }

}

Compilation successful.

Example test: ([4, 0, 2, -2], [4, 1, 2, -3], 'RGRR')

OK

Example test: ([1, 1, -1, -1], [1, -1, 1, -1], 'RGRG')

OK

Example test: ([1, 0, 0], [0, 1, -1], 'GGR')

OK

Example test: ([5, -5, 5], [1, -1, -3], 'GRG')

OK

Example test: ([3000, -3000, 4100, -4100, -3000], [5000, -5000, 4100, -4100, 5000], 'RRGRG')

OK


Monday, February 10, 2025

 A previous article described the formation of a UAV swarm when aligning to a point, line and plane. While the shape formations in these cases are known, the size depends on the number of units in the formation, the minimum distance between units, the presence of external infringements and constraints and the margin required to maintain from such constraints. The article also described the ability to distribute drones to spread as close to the constraints using self-organizing maps which is essentially drawing each unit to the nearest real-world element that imposes a constraint. This establishes the maximum boundaries for the space that the UAV swarm occupies with the core being provided by the point, line, or plane that the units must align to. Given the minimum-maximum combination and the various thresholds for the factors cited, the size of the shape for the UAV swarm at a point of time can be determined.

This article argues that the vectorization, clustering and model does not just apply to the UAV swarm formation in space but also applies to maintaining a balance between constraints and sizing and determining the quality of the formation, using Vector-Search-as-a-judge. The idea is borrowed from LLM-as-a-judge which helps to constantly evaluate and monitor many AI applications of various LLMs used for specific domains including Retrieval Augmented Generation aka RAG based chatbots. By virtue of automated evaluation with over 80% agreement on human judgements and a simple 1 to 5 grading scale, the balance between constraints and sizing can be consistently evaluated and even enforced. It may not be at par with human grading and might require several auto-evaluation samples but these can be conducted virtually without any actual flights of UAV swarms. A good choice of hyperparameters is sufficient to ensure reproducibility, single-answer grading, and reasoning about the grading process. Emitting the metrics for correctness, comprehensiveness and readability is sufficient in this regard. The overall workflow for this judge is also similar to the self-organizing map in terms of data preparation, indexing relevant data, and information retrieval.

As with all AI models, it is important to ensure AI safety and security to include a diverse set of data and to leverage the proper separation of the read-write and read-only accesses needed between the model and the judge. Use of a feedback loop to emit the gradings as telemetry and its inclusion into the feedback loop for the model when deciding on the formation shape and size, albeit optional, can ensure the parameters of remaining under the constraints imposed is always met.

The shape and size of the UAV formation is deterministic at a point of time but how it changes over time depends on the selection of waypoints between source and destination as well as the duration permitted for the swarm to move collectively or stream through and regroup at the waypoint. A smooth trajectory was formed between the waypoints and each unit could adhere to the trajectory by tolerating formation variations.

Perhaps, the biggest contribution of the vectorization of all constraints in a landscape is that a selection of waypoints offering the least resistance for the UAV swarm to keep its shape and size to pass through can be determined by an inverse metric to the one that was used for self-organizing maps.


Sunday, February 9, 2025

 #codingexercise 

Merge two BSTs 

One method to do this is to use two auxiliary stacks for two BSTs.  If we get a element smaller from the trees, we print it. If the element is greater, we push it to the stack for the next iteration. 

We use the iterative inorder traversal :  

  • Create an empty stack S 

  • Initialize current node as root 

  • Push the current node to stack S, set current to current.left, until current is NULL 

  • If the current is null and stack is not empty then 

  • Pop the top item from stack 

  • Print the popped item 

  • Set current = popped_item.right 

  • Goto step 3 

  • If current is null and the stack is empty, then we are done. 

To merge the BST we do the following: 

Initialize two stacks s1 and s2 from null. 

If the first tree is null, do iterative inorder traversal of second to print the merge 

If the second tree is null, do iterative inorder traversal of first to print the merge 

Set current in tree 1 to be cur1 and current in tree 2 to be cur2 

While either cur1 or cur 2 is not null or  one of the stacks is not empty: 

  • If cur 1 or cur 2 is not null 

  • For both the tree, if the current is not null, push it onto the stack, set current to current.left This will be repeated by the while until current is nul is null 

  • Else 

  • If either of the stacks is empty, then one tree is exhausted, print the other tree.  Do this for both stacks. 

  • Set the current of each tree to the popped element from respective tree 

  • Compare the two current and execute an iteration of step3 from iterative inorder traversal above  - the smaller of the two current nodes is printed, the larger pushed back on its corresponding stack 

At the end of the while loop, both stacks should be empty and the currents must be pointing to null and both the trees would be printed. 


#CODINGEXERCISE: CodingExercise-02-09-2025.docx

Saturday, February 8, 2025

 

This is a summary of the book titled “Project Management Step-by-Step: How to plan and manage a highly successful project” written by Richard Newton and published by Pearson Business in 2024. The author reminds readers that a project is an undertaking with clear endpoint and while it can be as small as cooking for a dinner party to as big as launching a business, he advises on how to get it done on time and on budget. The skill is both significant and worthwhile for people starting out on their professional journey and comes in all-the-handier as projects grow in size and complexity. Projects emerge in stages and with multiple dimensions including scope, quality and risk. Someone with this skill should know everything that the project seeks to achieve. So, working backwards from the objective and coming up with a clear project definition and project plan is helpful. Continuously monitoring the progress at every stage of the project, and completing the fit and finish at the end are good practice. Stakeholders and customers must be made aware of the deliverables and the project manager must remain flexible in how to get there.

Project management is essential for those starting professional careers, as it involves a series of stages and multiple dimensions, including scope, quality, and risk. A specialized approach is necessary for complex projects, such as launching a rocket or a company. Projects typically go through at least five stages: Project Definition, Project Plan, Execution, Checking Deliverables, and Closing Down. A project manager must state the project's scope and target, work with their team to fulfill goals, and determine acceptable risk levels. They must also understand standard details like completion time, staff and materials requirements, and costs. A specialized approach is necessary for complex projects with high stakes, as countless details can go wrong.

Project managers must understand the purpose and goals of their projects to ensure successful completion within financial and time constraints. They should ask simple, structured questions to understand the project's "why" and "what." They should also consider potential conflicts with other ongoing projects and potential stumbling blocks. Client-driven constraints like time and budget should be considered, and a broader definition should be agreed upon. Project managers must communicate with clients to ensure they understand the potential implications of changing plans.

A clear Project Definition and Project Plan are essential for project managers, outlining the project's purpose, responsibilities, and potential timelines. A Project Plan outlines the necessary work, tasks, and resources needed to complete the project. Estimating the time each task takes is a challenging aspect of formulating a project plan, but it is essential to estimate the time each task typically absorbs. Consultation with experienced individuals or comparing tasks with existing time frames can help clarify the process.

Project managers must stay actively involved throughout a project's life cycle to ensure it is completed on time and on budget. A solid Project Plan should allocate resources and provide leadership to move the project forward. A project manager's primary daily task is to manage and measure progress according to the Project Plan. Regularly assess progress, monitor budget allocation, and anticipate repercussions of running over budget.

Successful projects end with all loose ends tied up, and the Project Plan should include completion time, details, and expenses. The project manager is responsible for the project's final deliverables, and they must test them themselves to ensure they function as expected and meet the client's needs.

After completing a project, continue to support the client and stay updated on how the current project operates to learn how to perform even better on the next project.

To ensure customer satisfaction and high-quality standards, it is essential to test and integrate deliverables. Integration is a separate task that requires time and resources and should be included in the project plan. It is crucial to line up with people who can handle the integration process. Once the deliverables are complete, they need to function in the project's targeted environment. Change management issues must be addressed, and employees must be trained to demonstrate that the new deliverables will work for them. Project management is dynamic, and quality managers should stay open to alternative approaches. Agile project management, for example, focuses on experimentation and continuous improvement. A daily stand-up is a common practice in many organizations, where team members report on their progress, plans, and challenges. This helps team members help each other in a timely manner, leading to a productive agile project team.

#Codingexercise: tilesandfloor.docx

Friday, February 7, 2025

 This is a summary of the book titled “From pessimism to promise” written by Payal Arora and published by MIT Press in 2024. The author is a digital anthropologist who reconciles diverse take on the digital future where the Global South are eager for it and the West is mostly apprehensive. Western policymakers are focused on breaking up large tech companies and regulate AI and social media. She contends that AI design should focus on relationships and how people can develop technology for positive ends. She asks us to imagine the possibilities of a creative economy that engages young people, especially when these technologies encourage pleasure and intimacy. It can be used for surveillance in a police state but can also be used to care for others. And it could support a green economy. In fact, AI cannot stand apart from the physical multicultural world. We must just design AI such that it avoids the Global South’s colonial past.

Western users have negative attitudes towards digital technologies, viewing platforms as traps and algorithms as manipulative. This has led to a "pessimism paralysis" where Westerners are more likely to accept the status quo than try to change it. However, young people in the Global South, including China and India, see digital culture as a source of joy, inspiration, and liberation. Nearly 90% of youth worldwide live in the Global South, and they are optimistic about the future and eager to use digital platforms to change their lives and the world. AI design should focus on relationships and how people can develop technology for positive ends, rather than grandiose plans to "save the world." Tech designers should focus on the relationships between real people, concrete circumstances, and actionable policies, rather than looking at things in black-and-white or binary ways. The real world is messy, and technology that will benefit humans in their daily lives requires designing with the on-the-ground contexts and experiences of users in mind.

The concept of the "creative class" has evolved, with the next big movement in digital culture and the creative economy likely coming from the tens of millions of young people in the Global South. These young people, weighed down by social and political pressures, are eager to define their digital futures and are looking to their people as creative assets, legitimate markets, and content partners. Social media apps like TikTok and Bigo have thrived in the Global South due to their focus on the poor and marginalized, allowing them to gain greater visibility and engage in the creative economy.

Digital technologies should be designed to encourage pleasure and intimacy, as 35% of internet downloads are connected to pornography, with one-third of the porn-viewing audience being women. In countries where open discussion of sex and sexuality is taboo, young people often turn to digital pornography as a form of sex education. Countries in the Global South, like India, are proactive in controlling access to online sexual content, but NGOs have embraced social media campaigns and apps to broaden access to sex education.

Digital innovators are exploring ways for young people to build ties online that prioritize romance and relationships over sex. Platforms like Soulgate and FRND aim to create an open, pleasurable, and safe environment for young people to connect. Digital technologies can be used for surveillance in a police state, but they can also be used to care for others. A surveillance system of care that moves away from watching each other as a form of policing to watching over one another as a form of recognition and compassion is needed to rebuild social trust.

Design AI in ways that support a green economy is crucial for promoting environmental and social goals. Over half of a product's environmental impact is shaped by decisions made at the design phase. Indigenous communities in the Global South have developed four categories of design approaches: frugality, collectivity, subsistence, and repair. These approaches focus on reimagining power relations, valuing diversity, and repurposing existing structures.

AI cannot stand apart from the physical, multicultural world, as it is a human activity that is incorporated into people's lives. To promote sustainable, green design, it is essential to evaluate the material costs of incorporating AI and digital automation into human life. The digital future must promote the health of the environment and human societies, and companies, entrepreneurs, and designers must adopt a multicultural and multilingual approach.

AI design must move past the colonial past and "decolonize" AI and its datasets and algorithms. Businesses and institutions must not only state moral and political principles but also work towards a more inclusive and equitable digital culture.