DEV Community

Cover image for AI 101 - A Beginner's Introduction to Artificial Intelligence
Blackwatch
Blackwatch

Posted on

AI 101 - A Beginner's Introduction to Artificial Intelligence

You have probably used AI today, maybe even before getting out of bed. Unlocked your phone with your face? That's AI. Opened YouTube and it showed you exactly the video you wanted to watch? AI again. AI is everywhere around us, but what actually is it?? Let's understand it from scratch, no fancy maths, no complex words.

What Makes Humans Intelligent?

There are many factors, but two important ones are:

  1. Autonomy - Freedom to act and take our own decisions.
  2. Adaptability - Learning from experience and improving with time.

Artificial Intelligence

AI is the process of making computer programs intelligent, just like humans.

Similarly, the things which make a program intelligent are:

  1. Autonomy - The program's ability to assist or work independently, without someone telling it every single step.
  2. Adaptability - The program's ability to improve as it analyzes more data.

Example - Keyboard suggestions (Predictive text)

As we type, the keyboard suggests the most likely next words (working on its own) and keeps learning from each new sentence we type (adaptability). Ever noticed that after a while it starts suggesting your friend's nickname or the slang you use a lot? That's it learning from you.

Calculator

Not an AI tech. It can't operate on its own and can't learn from the user's input, it only does what it is asked to do. 2 + 2 will always be 4, no matter how many times you ask it.

AI vs Machine Learning vs Deep Learning

People use these words like they all mean the same thing, but they don't. Think of them as circles inside circles.

Deep Learning inside Machine Learning inside AI

  • AI - The biggest circle. Any technique that makes machines act smart.
  • Machine Learning (ML) - A part of AI. Instead of telling the machine every rule, we let it learn from data.
  • Deep Learning - A part of ML that uses "neural networks", loosely inspired by how neurons in our brain are connected. It needs a lot of data and computing power, but it is behind things like face unlock, voice assistants and the AI chatbots we use today.

If you want to go deeper into these layers, check out my article Layers in AI.

How AI Can Be Useful for Us

  • It can reduce our workload
  • It can do our repetitive work for us
  • It can improve the quality of our work

Some real world uses

  1. Farmers - Using AI based apps to check if their crops are healthy or not, or chatting with AI to improve their yields.
  2. Doctors - AI helps in analyzing X-rays and scans, so doctors can find tiny signs of sickness or injury that might be hard to see.

AI you already use (without even noticing)

AI you already use: recommendations, maps, face unlock, spam filter, chatbots

  • Netflix / YouTube - Recommending what to watch next
  • Google Maps - Predicting traffic and finding the fastest route
  • Face unlock - Recognizing your face to unlock your phone
  • Email spam filter - Keeping junk mail out of your inbox
  • Chatbots - ChatGPT, Claude, Gemini etc. answering your questions

Note - AI is a tool, and it's on us how we use it.

Algorithms

Ever wondered how we can teach technology to learn new things?? We are trying to make machines like us by giving them intelligence, but still they can't learn just like us. We learn from experiences, from patterns, etc. Machines don't have real world experiences, so how do they learn? For that, we have algorithms.

An algorithm, in a nutshell, is a set of step by step instructions to achieve or complete something.

Example - Make me tea

  1. Boil the water
  2. Add sugar and tea
  3. Add milk
  4. Let it cook for 5 minutes
  5. Serve it hot

See, this is an algorithm too, detailed step by step instructions to make tea. Similarly, we use algorithms to train our programs so that they can understand things.

Normal Programs vs Machine Learning

Now here's the interesting part. In the tea example, we wrote every single step ourselves. That's how normal programs work, just like our calculator.

  • Normal program - We write the rules → the computer follows them.
  • Machine learning - We give examples → the computer figures out the rules on its own.

Normal program vs machine learning: who writes the rules?

Let's say we want a program to tell if an email is spam or not. With a normal program, we would have to write every rule ourselves, "if it says FREE MONEY, mark it spam", "if it has 20 links, mark it spam" and so on. But spammers keep coming up with new tricks, we can't write rules for all of them.

With machine learning, we just show it thousands of emails marked as "spam" and "not spam", and it finds the patterns by itself. So here the algorithm's job isn't to make tea, it's to guide the machine on how to learn from the data.

Key Parts of Machine Learning

First let's understand how the human brain works. Let's take an example of "How you prepare for an examination".

  1. Brain - The place where we store everything we learn.
  2. Notes - We take notes for understanding and learning purposes.
  3. Studying - Now we study those notes and start making connections between them, this is the adaptability we talked about.
  4. Prepared Brain - Now the brain is trained to tackle most of the questions related to that subject.

Brain + Notes + Studying = Prepared Brain

Now coming to machine learning. Programs use mathematical instructions/operations to find patterns in data to make predictions.

Parts of Machine Learning

  1. Model (Brain) - The storing and learning part of AI.
  2. Data (Notes) - The data given to the model.
  3. Training (Studying) - The model analyzes the data to find patterns among them and learn from them. There are different ways through which AI learns, we will see them in a moment.
  4. Trained Model (Prepared Brain) - Now the model is ready to be used and make predictions.

Model + Data + Training = Trained Model

Exam preparation vs machine learning

Training vs Using the Model

Training is the studying part. It takes a lot of time, data and computing power, and happens once (or from time to time to update the model). Using the trained model to answer questions or do tasks is called inference, it's like writing the exam. You don't re-study the whole book for every question, you just use what you already learned.

Features

In terms of AI, and in humans too, features are pieces of information that help us tell things apart. Take a circle and a square for example. How do you know which one is which?

Circle vs square: features tell things apart

Feature Circle Square
Corners 0 4
Straight sides 0 4
Curved edge Yes No

You never consciously think about this, your brain just does it. But a machine needs these features to tell them apart.

Same goes for our spam example. Features of an email can be - does it contain "FREE MONEY", is the sender unknown, does it have too many links. The model looks at these features and learns which combination usually means spam. The better the features, the better the model will understand.

Types of Learning

Remember we said there are different ways through which AI learns? Here are the three main ones.

Three ways AI learns: supervised, unsupervised, reinforcement

1. Supervised Learning - Learning with flashcards

Remember the flashcards from childhood? A picture of an apple with "Apple" written below it. Here, the data comes with the answers (we call them labels). For example, thousands of emails already marked as "spam" or "not spam". The model learns from these and then predicts for new emails.

2. Unsupervised Learning - Sorting a pile of Lego

Imagine someone hands you a big pile of mixed Lego pieces and doesn't tell you anything. You will still start grouping them by color, size or shape on your own. Here the data has no labels, and the model finds groups and patterns by itself. For example, an online store grouping its customers by their shopping habits.

3. Reinforcement Learning - Training a dog with treats

When a dog does the right thing, it gets a treat. When it does the wrong thing, no treat. Slowly it learns what to do. Same way, the AI tries something, gets a reward or a penalty, and improves by trial and error. This is how AI learns to play games like chess, and how robots learn to walk.

Will AI Always Give the Correct Answer??

Now we can ask questions from the model or ask it to perform tasks. But the real question is, will it return the correct answer all the time??

The answer is no. There is always a possibility of AI producing a wrong answer, and most of the time it is because of the data provided. That's why the more data, and of good quality, the better the accuracy of the model.

Imagine a model trained only on the English language, and users are asking questions in their native language, like Spanish, Chinese, Hindi or Japanese. Do you think it will be able to produce correct answers?

Just for a moment, imagine yourself in this situation. Will you be able to answer a question asked to you in a language you don't understand??

It's just like the old story of the blind men and the elephant. Each one touches only one part and is sure he knows the whole truth. One says it's a snake, one says it's a wall, one says it's a rope. AI is the same, it only knows what its data showed it.

The blind men and the elephant - Sketchplanations
Image credit: Sketchplanations

And sometimes AI makes mistakes very confidently. Chatbots can give an answer that sounds totally correct but is completely made up, like a fake fact or a book that doesn't even exist. This is called hallucination. So remember, sounding confident doesn't mean being correct.

What a hallucination looks like

Bias

Remember how AI learns from the data we give it? So if the data is unfair, the AI will be unfair too. This is called bias.

Real example - Amazon once built an AI tool to screen job resumes. It was trained on resumes from the past 10 years, and most of those came from men, since the tech industry was mostly male. So the AI learned that male candidates are "better" and started ranking down resumes that had the word "women's" in them, like "women's chess club captain". Amazon had to scrap the tool.

The AI wasn't evil, it just copied the pattern from the data it was given.

Safety and Responsibilities

AI is now widely used and has become a part of our day to day life. But there are still risks in depending on it too much, because the possibility still exists that AI may not produce accurate results, which may lead to wrong decisions.

Imagine a medical model isn't trained on enough data. It can create false emergencies, saying a patient is sick although the patient is fine.

So it's always advised to check the AI's result ourselves, as a second check, to make sure no false result is delivered to the other side. There have been real cases of false arrests because of this. In 2020, Robert Williams in Detroit, USA was wrongly arrested because a facial recognition system matched his photo to a suspect's, and it was trusted without checking properly.

When mistakes happen, who is responsible, the AI or humans?

We need to understand one thing here, AI is just a tool, built by a human and used by a human. So ultimately the whole responsibility lies on humans. AI doesn't have feelings and emotions, it works on the data it is trained on. And who gives the data? Humans. Who uses the AI? Humans.

So we are responsible for whatever happens because of AI.

So how can we reduce the harm?

Now that's the question we need to look into. We can do it from two perspectives.

1. Developer/Creator of AI tools

As the creator of the tool, it's my responsibility to:

  • Feed high quality and diverse data for the AI to find patterns and learn from. High quality data helps in understanding, while diverse data reduces bias, which is really important.
  • Listen to users' feedback to improve on the go.
  • Be honest about the limitations of the tool.

2. User of AI tools

  • Do not trust the tool blindly. Always double check the output, as it may produce wrong results.
  • Always make sure you are using the tool for a good cause and not to harm others in any way.
  • If you find any bug or any place for improvement, give feedback to the creator so they can improve it.
  • Avoid sharing your personal details like passwords, bank details or ID numbers with AI tools, as your chats may be stored and even used to train the model.

Common Myths About AI

  1. "AI thinks and feels like humans" - No. It finds patterns in data. It doesn't have feelings, and it doesn't understand things the way we do.
  2. "AI is always right" - We just saw that it isn't. Wrong data, bias and hallucinations can all lead to wrong answers.
  3. "AI will replace all jobs" - AI will change a lot of jobs and take over many repetitive tasks, but people who know how to use AI well will have a big advantage. Calculators didn't replace mathematicians.
  4. "AI is something new" - The term "Artificial Intelligence" was actually coined back in the 1950s. It just became popular recently because we now have a lot more data and computing power.

Quick Recap

  • AI - Making programs intelligent, with autonomy and adaptability.
  • Machine Learning - A part of AI where machines learn from data instead of fixed rules.
  • Deep Learning - A part of ML that uses neural networks.
  • Algorithm - Step by step instructions to complete something.
  • Model - The "brain" that learns and makes predictions.
  • Training - The model studying the data to find patterns.
  • Inference - Using the trained model to answer questions.
  • Features - Pieces of information that help tell things apart.
  • Labels - The correct answers attached to the data.
  • Bias - When AI becomes unfair because of unfair data.
  • Hallucination - When AI confidently gives a made up answer.

What's Next?

Now that you know the basics, you can check out:

AI is just a tool, a really powerful one. The more we understand it, the better we can use it, and the better we can make sure it's used for good.

This was a small walkthrough of AI and how it works. I hope you found it helpful.

Until next time.

Peace ✌️

Top comments (0)