Artificial Inteligence

In the previous chapter, you designed the system, selected its architecture, and outlined an initial implementation plan. The kitchen is already up and running, the oven is on, but it’s still missing a chef.

Keeping up with current trends, you’ve probably heard about artificial intelligence, a “magical” program that understands what people write, responds in natural language, and seems capable of handling almost any task. I’m sure you’ve wondered how to make use of it. Instead of relying on a human cook in our kitchen, we can bring in a tireless robot. But how do you actually build one?

To use something effectively, you need to understand it. Tools are meant to be used, but only if you know how they work. Artificial intelligence is not just a chatbot, it’s a vast field of computer science. That’s why in this chapter we will cover its most important concepts.

Why Is Artificial Intelligence So Important?

To understand how important this topic is, it is worth looking at the history of computer science. In the past, programs were written in the form of 01010101000100.., which was incomprehensible to humans. Over time, programming languages emerged, allowing developers to understand complex programs. However, a program written in a programming language is still converted into an unreadable form so that it can be executed, and this process is handled by an algorithm.

Artificial intelligence is not based on an algorithm, but on the concept of a human neuron. A traditional algorithm is a rigid recipe that a cook must follow exactly, down to the gram. AI, on the other hand, is an experienced head chef who, based on thousands of prepared dishes (data), simply “feels” how much salt to add, even though no one explicitly wrote it in the instructions.

It is worth noting that artificial intelligence does not think like a human, it simply predicts very well. For it to work properly, it requires thousands, if not millions, of such neurons and vast amounts of data. Poorly selected data can lead to poor results; if you teach an AI that spaghetti is made from rice, the final model will repeat that. 

What possibilities does artificial intelligence give you? Here are the capabilities of an AI chef:

  • Generating images of finished meals 
  • Providing professional guidance during cooking
  • Menu planning and analysis of food trends
  • Creating recipes from scratch, based on a photo or a list of ingredients

What does this mean for you? You should not build an artificial intelligence model from scratch. When creating an AI chef, it would be very difficult to train it on your own to recognize dishes from images or generate recipes. You would have to prepare thousands of cookbooks for it to process. Instead, ready-made models trained on massive datasets are required, and they are already available for use. These models differ significantly in their applications:

  • Image: allow generating images
  • Audio: specialize in creating audio content such as podcasts, cooking sounds, and even mimicking animals
  • Nano/Mini: their purpose is to minimize usage costs

In other words, if a chef had read 1000 cookbooks, they would be able to create a tiramisu recipe. Professional companies and dedicated hobbyists have created models that are ready to use, either paid or free.

Predictive AI: Forecasting the Future

The goal of these artificial intelligence systems is to predict events or certain values based on data we already have. They do not create anything new. In business, they are used for price estimation in stores, sales forecasting, or even fraud detection.

Where could such a model be useful for you? A robot chef could suggest dishes to returning customers before they place an order, or even prepare meals in advance before customers arrive. This type of AI could also manage recipes by maintaining a pool of them, removing less popular ones and introducing better options.

To function properly, this type of AI requires a large dataset; the model will not work without historical data from the restaurant. This data must span a long period, one or two months may not be enough. Remember, the most common mistake companies make is focusing on the model instead of the quality of the data: there should be a lot of it, it should be error-free, and it should come from a reliable source.

Computer Vision: Can a Computer Have Eyes?

The main task of these models is to detect patterns in images. AI receives, for example, a medical scan and determines whether a patient is ill, supporting the work of a doctor. This makes it possible to detect very small and seemingly insignificant details. This is not the only application; this type of model can highlight elements in an image, recognize text from images, and even track vehicles in real time.

How does this relate to your kitchen? If you give your kitchen robot “eyes,” it can assess the quality of a meal based on its appearance. It can also recognize returning customers, what they eat, how they behave, and whether they are satisfied or disappointed with their meal.

Unfortunately, this type of solution is costly. Every image must be properly processed, which takes time. It also requires a specialized model that, for example, can recognize dishes. These models are demanding and expensive, so it is worth starting with a simple, low-cost model when building an MVP.

Generative AI: Creating Something from Nothing

Because a model can estimate data, modern scientists and engineers came up with an idea: what if the value being predicted was a word, or a pixel in an image? Generative AI, based on learned patterns, can produce an entire image, video, or even a chapter of a book.

This is possible because the trained model has seen millions of images, texts, and videos, and can generate similar outputs. Relating this to an AI chef, a model that has seen thousands of photos of spaghetti will be able to distinguish that dish from others. The chef will also be able to create a recipe, because it has seen millions of them.

Since AI can generate text, why not use text as input? Describe in your own words what you want to achieve, and the artificial intelligence will understand it, process it, and return a result. This is what we call a prompt, which I will describe in the next chapter.

When generating data, it is important to be aware of “hallucinations.” The model predicts, it does not think. As a result, it may sometimes produce outputs that do not make sense or are unrelated to the topic. This is why you need to be careful and create good prompts. A model that receives a well-defined goal, constraints, and context will be less likely to produce irrelevant outputs. You should also keep in mind the context window — AI has a limit on how much text it can process and how much it can return. As a result, a long input may lead to a shorter response if the limit is reached.

Summary

You now have a solid understanding of artificial intelligence and how generative AI differs from predictive AI and computer vision. However, as you may have noticed, AI does not act on its own. It cannot take initiative; it only responds to what the user provides. In the next chapter, I will show you how to give your chosen model “hands” so it can plan and act on its own.

Materials

Self-study materials that are related to this topic:

  1. What is artificial intelligence?
  2. Types of AI with Examples