Saturday, February 15, 2025

 This is the summary of a book titled “Generative AI in practice” written by Bernard Marr and published by Wiley in 2024 so it’s almost hot off the press. It surveys 100+ amazing ways Generative Artificial Intelligence is changing business and society.  GenAI gives companies a competitive advantage but also poses unintended risks at societal and organizational levels. Urging for its use towards good, the author explains how it is poised to disrupt industries across sectors and calls for usage in a way that inspires innovation, openness and collaboration. It provides a leap in our understanding and efficiency and will likely result in productivity savings across  Carefully identifying and mitigating the risks when harnessing this power, is going to be a ubiquitous requirement. Higher engagement with the potential to draw customers towards retail, gaming, software and product development and a shift that goes beyond organizational hierarchies is going to be the norm. 

Gen AI, a groundbreaking subset of AI, is poised to disrupt work and life in radical ways. The concept of machines displaying human-like intelligence dates back to 1950 when Alan Turing introduced the Turing Test. Advances in predictive analytics, data mining, big data, and deep learning have set the stage for GenAI models. GenAI demonstrates significant creative power through the development of neural networks, particularly "generative models," which push the boundaries of what humans once believed machines could do. The use of automation and human-machine collaboration could save 70% of the time some processes now require. GenAI will affect nearly every industry, making many workers redundant while creating productivity savings. McKinsey anticipates that GenAI will boost the global economy by US$4.4 trillion each year. Jobs that may experience redundancies include content creators, graphic designers, stock traders, translators, paralegals, factory workers, clerical workers, and journalists. While AI will eliminate some jobs, it will also create new ones, such as data curators and cleaners, and AI prompt engineers, trainers, and ethics officers. 

GenAI has the potential to revolutionize various industries, including education, healthcare, and legal services. However, it is crucial to identify and mitigate risks, such as the spread of misinformation, dependence on AI, and potential harms in critical sectors like defense. Organizations must ensure the ethical use of GenAI by assessing and mitigating risks, implementing robust data governance, preventing data bias, and embracing transparency and accountability. 

In education, GenAI can help teachers personalize student learning experiences, providing feedback on struggling students. In healthcare, GenAI chatbots can provide individualized health advice and assist doctors in providing hyperpersonalized patient care. GenAI can also accelerate drug discovery and development by generating new molecular structures. 

 

In law, GenAI can create efficiencies for law firms by predicting case outcomes, using chatbots to expand services, and improving legal services. Additionally, GenAI and intelligent systems will revolutionize customer service and engagement, with companies like Octopus Energy seeing significant gains. 

In conclusion, while GenAI has the potential to transform various industries, organizations must ensure the ethical use of AI and seek support from AI and data experts when faced with complex issues. 

GenAI is set to revolutionize the video game industry by assisting developers in every stage of game development, including character creation, 2D model creation, and non-linear storylines. It can also automate musical scores, produce immersive soundscapes, and generate quests and missions. GenAI can also create simulated players to test gameplay experiences and use data analysis to predict potential issues. Unity's AI marketplace offers developers solutions like voice generators and asset creation mechanisms, while the Auctoria platform allows users to create game assets more easily. GenAI is expected to accelerate software and product development, speeding up delivery and boosting creative ideation. It can also help designers complete their code and detect bugs, and open up the possibility of creating digital twins. However, embracing GenAI requires a shift in organizational culture, shifting towards curiosity, humility, adaptability, and collaboration. Companies must rethink traditional approaches to work, giving employees autonomy to collaborate on cross-functional teams within a learning culture that prioritizes openness.  

Friday, February 14, 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.

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