視覺化嵌入後的商品描述
你已經從商品描述建立了嵌入向量(embedding),現在該來探索它們了!你將使用 t-SNE 把嵌入向量的維度從 1,536 降到 2,這樣資料就更容易視覺化。
你會從上一個練習中使用過的 products 字典清單開始,其中包含商品資訊,以及你從 'short_description' 產生的嵌入向量。以下是 products 的預覽,供你參考:
products = [
{
"title": "Smartphone X1",
"short_description": "The latest flagship smartphone with AI-powered features and 5G connectivity.",
"price": 799.99,
"category": "Electronics",
"features": [
"6.5-inch AMOLED display",
"Quad-camera system with 48MP main sensor",
"Face recognition and fingerprint sensor",
"Fast wireless charging"
],
"embedding": [-0.014650369994342327, ..., 0.008677126839756966]
},
...
]
matplotlib.pyplot 與 numpy 已分別以 plt 與 np 匯入。
本練習屬於課程
Introduction to Embeddings with the OpenAI API
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create categories and embeddings lists using list comprehensions
categories = [product[____] for product in products]
embeddings = [product[____] for product in products]