The rise of Large Language Models (LLMs) has significantly popularized the use of AI by providing a more human-like way of interacting with the AI technology. LLMs are generative AI systems that are designed to engage in human-like conversations. Before the introduction of such models, interacting with AI systems often required specialized knowledge, limiting their use to experts or those with backgrounds in AI and ML.
大型語言模型(LLM)的興起,透過提供一種更貼近人類的方式與 AI 技術互動,大幅提升了 AI 的普及程度。LLM 是設計用來進行類人對話的生成式 AI 系統。在這類模型出現之前,與 AI 系統互動通常需要專業知識,僅限具備 AI 與 ML 背景的專家使用。
LLMs are trained using sophisticated algorithms, such as Generative Pre-trained Transformers (GPT) and on extensive datasets. LLMs can also be coupled with algorithms, such as Generative Adversarial Networks (GANs) or Variational Autoencoders (VAEs) to generate images based on text, which is known as multi-modality. These advanced algorithms are based on neural networks, inspired by the neurons in the human brain.
LLM 使用複雜的演算法(例如生成式預訓練轉換器,GPT)並在大量資料集上進行訓練。LLM 也可以搭配生成對抗網路(GAN)或變分自編碼器(VAE)等演算法,根據文字產生圖片,這稱為多模態。這些先進演算法都是以神經網路為基礎,其靈感來自人類大腦中的神經元。
Here you'll learn the basics of neural networks and how they relate to algorithms, such as Generative Pre-trained Transformers (GPT), Generative Adversarial Networks (GANs), and Variational Autoencoders (VAEs).
在此,你將學習神經網路的基礎知識,以及它們與生成式預訓練轉換器(GPT)、生成對抗網路(GAN)與變分自編碼器(VAE)等演算法的關係。
The Neural Network—The Building Block of AI
神經網路:AI 的基本組成單元
A neural network consists of a series of interconnected nodes, often referred to as neurons. These nodes are typically organized into layers, as shown in the following figure.
神經網路由一系列互相連接的節點組成,通常稱為神經元。這些節點通常按層組織,如下圖所示。

Within this structure, every node in one layer is connected to every node in the next layer, facilitating the flow of information from the input layer, through one or more "hidden" layers, to the output layer. This architecture allows the neural network to process and transform input data step by step until it reaches the final output.
在這種結構中,某一層的每個節點都與下一層的每個節點相連,使資訊能從輸入層,經過一或多個「隱藏」層,流向輸出層。這種架構讓神經網路能逐步處理與轉換輸入資料,直到得出最終輸出。
In a neural network, each node holds a numerical value. The connections between the nodes are associated with weights, which are numerical values that influence how much one node affects the other. These weights determine the strength and direction of the influence that a node has on the nodes in the subsequent layer to which it is connected. To calculate the value of the first node in a hidden layer, you take each input from the preceding layer and multiply it by the corresponding weight that connects it to this node. Then, you sum up all these products. This summed value represents the initial input to the node before any further processing. Each node, apart from the input layer, has an additional parameter, which is called a bias, that is added to the initial summed value, which helps the neural network to learn more patterns. For instance, without bias, a neuron's output would always be zero whenever all its inputs are zero.
在神經網路中,每個節點都持有一個數值。節點之間的連接關聯著權重,這是會影響一個節點對另一個節點影響程度的數值。這些權重決定了某節點對其所連接之下一層節點所產生影響的強度與方向。要計算隱藏層第一個節點的值,你要取前一層的每個輸入,乘以連接到此節點的相應權重,然後將這些乘積加總。這個加總值代表節點在進一步處理前的初始輸入。除了輸入層之外,每個節點還有一個額外參數,稱為偏差(bias),會加到初始加總值上,有助於神經網路學習更多模式。舉例來說,若沒有偏差,當所有輸入都為零時,某個神經元的輸出也永遠會是零。
The real computational work happens within the "hidden layers," which you can think of as a series of adjustable knobs, that fine-tune the network’s ability to solve problems.
真正的運算工作發生在「隱藏層」中,你可以將其想像成一系列可調整的旋鈕,用來微調網路解決問題的能力。

When a neural network is first set up, the hidden layers are initialized with randomly selected weights and biases, which are the parameters that will adjust as the network learns. In the following figure, you can see the training process.
當神經網路首次建立時,隱藏層會以隨機選取的權重與偏差初始化,這些參數會在網路學習過程中逐步調整。下圖顯示了訓練過程。

During training, the network receives input data at the input layer. After the data has moved through the hidden layers, the network produces output at the output layer. The network's output is compared to the actual expected result, and the difference between them is calculated. This difference is known as the error and evaluates how well the network performed. To improve the performance of the neural network, a technique that is called backpropagation is used. During this step, the weights and biases are recalculated so the error between the real and expected output is minimized. The entire process is repeated numerous times until the error is small enough.
在訓練期間,網路在輸入層接收輸入資料。資料經過隱藏層處理後,網路會在輸出層產生輸出。網路的輸出會與實際預期結果做比較,並計算兩者間的差異。這個差異稱為誤差,用來評估網路的表現好壞。為了提升神經網路的效能,會使用一種稱為反向傳播(backpropagation)的技術。在此步驟中,會重新計算權重與偏差,使實際輸出與預期輸出之間的誤差最小化。整個過程會重複多次,直到誤差夠小為止。
To clarify, imagine you want to train a neural network to recognize whether a provided IP is valid or not. Assume four nodes at the input layer, one for each octet, a single hidden layer, and one output node that gives a 1 if the IP is valid and 0 otherwise.
為了說明清楚,假設你想訓練一個神經網路來辨識所提供的 IP 是否有效。假設輸入層有四個節點,每個八位元組(octet)各一個,一個隱藏層,以及一個輸出節點,若 IP 有效則輸出 1,否則輸出 0。

At first, the weights and biases of the hidden layer are randomly defined. Assume you check whether 10.10.20.1 is valid, and the output returns a 0, since the neural network estimated that this was not the valid IP.
一開始,隱藏層的權重與偏差是隨機定義的。假設你要檢查 10.10.20.1 是否有效,而輸出結果為 0,因為神經網路判定這不是有效的 IP。
Now you use backpropagation to recalculate the weights and biases, so that you get a value of 1 at the output. You repeat this process until you get the expected results for any IP. Note, however, that this is a very simplified, high-level overview of how a neural network works. Also note that there are different kinds of neural networks that are used for specific tasks.
現在你使用反向傳播重新計算權重與偏差,使輸出結果變為 1。你重複這個過程,直到對任何 IP 都能得到預期結果。不過請注意,這只是神經網路運作方式的一個非常簡化、高層次的概述。另請注意,還有各種不同類型的神經網路,用於特定任務。
Advanced Algorithms Used in Generative AI
生成式 AI 中使用的進階演算法
Three revolutionary neural network architectures have significantly shaped the landscape of artificial intelligence: Generative Pre-trained Transformers (GPT), Generative Adversarial Networks (GANs), and Variational Autoencoders (VAEs). Each of these architectures offers unique capabilities and has found widespread applications across various domains, from natural language processing to image generation and beyond.
三種革命性的神經網路架構已大幅形塑了人工智慧的樣貌:生成式預訓練轉換器(GPT)、生成對抗網路(GAN),以及變分自編碼器(VAE)。這些架構各自提供獨特的能力,並已廣泛應用於從自然語言處理到圖像生成等各種領域。
GPTis based on the transformer architecture. Transformers rely on two neural networks, which are called an encoder, and a decoder, respectively. The encoder is used to process the input text and capture its meaning and context, while the decoder is used to generate text based on the encoder's output. The transformer uses a technique that is known as self-attention, which lets the model decide how important each word in a sentence is, no matter where the words are located in relation to each other. This full architecture is used in tasks such as machine translation where both the input and output are important and differ from each other (for example, translating English text to French). GPT, however, utilizes only the decoder component of the transformer architecture. This is because GPT is designed primarily for tasks that involve generating text from a given prompt rather than transforming text from one form to another. This design makes it ideally suited for generating coherent and contextually connected text based on the input that it receives. GPT can be used in networking to generate device configurations, analyze errors and warnings, and even generate programming code to help with automation tasks.
GPT是以轉換器(transformer)架構為基礎。轉換器依賴兩個神經網路,分別稱為編碼器(encoder)與解碼器(decoder)。編碼器用來處理輸入文字並擷取其意義與語境,而解碼器則根據編碼器的輸出來產生文字。轉換器使用一種稱為自注意力(self-attention)的技術,讓模型能判斷句子中每個字詞的重要程度,無論這些字詞彼此的位置關係如何。這種完整架構被用於機器翻譯之類的任務中,此類任務的輸入與輸出都很重要且彼此不同(例如將英文文字翻譯為法文)。然而,GPT 只使用轉換器架構中的解碼器部分。這是因為 GPT 主要是為了根據給定提示產生文字的任務而設計,而非將文字從一種形式轉換為另一種形式。這種設計使其非常適合根據所接收的輸入,產生連貫且語境相關的文字。GPT 可用於網路領域,例如產生裝置設定、分析錯誤與警告訊息,甚至產生程式碼以協助自動化任務。
A GANconsists of two neural networks: a generator and a discriminator. These networks compete with each other to create new data based on a given training dataset. In the context of networking, GANs can be used to generate synthetic network traffic that mimics real-world data. This synthetic data can be used to train other AI models to detect anomalies or cybersecurity threats. Here, the generator produces fake network traffic from training samples, while the discriminator evaluates this new content against actual data to determine its authenticity. If the discriminator identifies the data as fake, it notifies the generator of the error, prompting the cycle to repeat. Over time, both the generator and the discriminator improve at creating more realistic data and detecting fakes, respectively.
GAN由兩個神經網路組成:產生器(generator)與判別器(discriminator)。這兩個網路彼此競爭,根據給定的訓練資料集建立新資料。在網路領域中,GAN 可用於產生模仿真實世界資料的合成網路流量。這些合成資料可用來訓練其他 AI 模型,以偵測異常或網路安全威脅。在此,產生器會根據訓練樣本產生偽造的網路流量,而判別器則將這些新內容與實際資料進行比對,以判定其真實性。若判別器判定資料為偽造,就會將錯誤回報給產生器,促使這個循環重新開始。隨著時間推移,產生器與判別器分別在產生更逼真的資料,以及偵測偽造內容方面都會愈來愈進步。
A VAEis a neural network that is designed for compressing data into a condensed form that is called latent space, and then reconstructing it back to its original form. VAE consists of an encoder and a decoder. The encoder reduces the input data into this smaller, essential representation, while the decoder attempts to recreate the original data from this compressed version as accurately as possible. You can imagine the encoder as an artist that observes a person—input data—and creates a simplified pencil sketch—latent space representation. This sketch captures the essential features—the shape of the face, the eyes, nose, and mouth, but it doesn’t include every detail. It's more like an impression of the person rather than a detailed photograph. Now the decoder looks at the sketch and tries to create a detailed portrait of the person. The better the sketch represents the key features, the more accurate the portrait. VAEs can be used in networking for anomaly detection. By learning to encode and decode normal traffic patterns, VAEs can detect unusual patterns that deviate from the norm. When a VAE struggles to reconstruct network data accurately, it might indicate potential anomalies such as cyber attacks, network failures, or unauthorized access attempts.
VAE是一種神經網路,設計用來將資料壓縮成一種稱為潛在空間(latent space)的濃縮形式,再將其重建回原始形式。VAE 由一個編碼器與一個解碼器組成。編碼器將輸入資料簡化為這種較小、精要的表示形式,而解碼器則嘗試盡可能準確地從這個壓縮版本重建出原始資料。你可以把編碼器想像成一位藝術家,觀察一個人(輸入資料),並畫出一幅簡化的鉛筆素描(潛在空間表示)。這幅素描擷取了關鍵特徵:臉型、眼睛、鼻子與嘴巴的輪廓,但不包含每一個細節,比較像是對這個人的印象,而非詳細的照片。接著,解碼器會依據這幅素描,嘗試繪製出這個人的詳細肖像。素描愈能呈現關鍵特徵,肖像就愈準確。VAE 可用於網路領域中的異常偵測。透過學習編碼與解碼正常的流量模式,VAE 能偵測出偏離常態的異常模式。當 VAE 難以準確重建網路資料時,可能代表存在潛在異常,例如網路攻擊、網路故障或未經授權的存取嘗試。