VC
VC

服務生醫產業超過25年,經歷研發/產品管理/事業開發/銷售業務/品保法規等工作,工作橫跨美國,台灣,產品經歷家用醫材/專業醫材/實驗室設備等,在這個園地貢獻自己一點經驗及想法。

一點數學 - 向量空間

(编辑过)
這是我寫給自己的筆記
https://upload.wikimedia.org/wikipedia/commons/2/2f/Linear_subspaces_with_shading.svg

其實最近寫文章興趣缺缺,不像以前文思泉湧時一天寫了1~2周的份,沒想到與@白舟 的對話,想到最近研究一個有趣的課題。

是這樣子,最近動手做GPT的研究,打算試做一個客服問答服務,所以研究了一個OpenAI的範本,如下

How to build an AI that can answer questions about your website

裡面的術語如token, embedding對我來說是沒學過的,所以我就問ChatGPT,結果其提到是向量的觀念,居然我很快就懂了,其實我修過博士班的數學,但現在的程度只會加減乘除。

這裡先把ChatGPT解說的向量介紹如下

問:從資料科學的角度來說明向量
答:從資料科學的角度來看,向量通常被描述為一系列有序數字的集合,這些數字被稱為向量的元素或成分。向量可以是一維的(也就是只有一列的矩陣),也可以是多維的。
在資料科學中,向量通常被用來表示資料的特徵或屬性。例如,一個人可以用一個包含他們年齡、身高和體重的向量來表示。在這個例子中,向量的三個元素分別代表人的年齡、身高和體重。
向量還可以用於數學運算,如加法、減法、乘法和除法。向量的加法和減法是逐元素進行的,即將兩個向量的對應元素相加或相減。向量的乘法有多種,包括點積和叉積等。
在機器學習和深度學習中,向量通常被用來表示數據的特徵,而這些特徵被用來訓練模型。在這種情況下,向量的元素通常是數字,這些數字可以表示像像素、單詞頻率等不同的特徵。通過將向量與模型進行訓練,我們可以預測新的數據點所屬的類別或執行其他任務。

簡言之,這是一種數學技巧來描述一個事物,用數學的方式把其特性及屬性描述出來,具體的展現就是數字,也就是電腦可以處理的格式。

該連結裡面提到的token是一種元素,也就是形成每個句子的元素。

而embedding是一種手法,把這些文字內容,用向量手法表示出來, 也就是把這些元素(token)用數學組成的方式來描述這些文字內容,以利AI瞭解內容的關聯性。

有興趣的可參考以下我與ChatGPT的對談。

Q:Thus, each token is a basic unit, and embedding process is to represent the content in the vector space consisted of these units?
Ans
Yes, that's a good way to think about it. Each token can be thought of as a basic unit of meaning in the text, like a building block, and the embedding process is a way to represent the content of the text using vectors that are constructed from these basic units.
The embedding vectors are constructed in such a way that they capture the meaning of the tokens and their relationships to each other. This allows the model to process the text more efficiently and effectively, as the vector representations are more compact and easier to work with than the original text.
Overall, the embedding process is a way to transform the discrete, symbolic representation of text into a continuous, low-dimensional vector representation that captures the meaning of the text. The resulting vectors are then used by the NLP model to perform various tasks, such as language modeling, sentiment analysis, or machine translation.

Q:What is embedding in data scienece?

Ans:
In data science, the term "embedding" usually refers to a technique used to represent high-dimensional data, such as text or images, in a lower-dimensional space. The goal of an embedding is to capture the most important features of the data while reducing its complexity.

For example, in natural language processing (NLP), word embeddings are commonly used to represent words as dense vectors of real numbers. These vectors capture the semantic relationships between words, allowing machine learning models to better understand the meaning of text.

In computer vision, image embeddings are used to represent images as feature vectors. These embeddings are learned by deep neural networks, which can capture complex patterns in the visual data.

In general, embeddings are used in data science to reduce the dimensionality of data, facilitate machine learning algorithms, and improve their accuracy. They are widely used in various applications such as recommendation systems, search engines, image recognition, and natural language processing.


其實,只要掌握token, embedding的觀念,就可以瞭解GPT的訓練資料是怎麼餵的。


PS:

寫起來沒多少,居然是花了快30年的領悟。

我是工科出身,物理觀念還算不錯,但數學沒有天份,聯考低標,大學,研究所都是靠苦讀,我一直認為數學要具體為工程所用才有意義,有一次上了一個很理論的數學,就是向量空間,雖然有點嗤之以鼻,但間接感受到數學與神之間的關係,所以就沒有把數學家當瘋子看。

30年後,所有以前高難度工程數學的解題技巧全忘光光,只剩會加減乘除,但很奇怪,向量空間的哲學一直在我腦中,在請教ChatGPT的過程中,沒有學過的資料科學觀念,居然領悟了。

這是30年前的種子,居然現在開花。

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…
加载中…

发布评论