임베딩된 설명 시각화하기
이제 제품 설명에서 임베딩을 생성했으니, 직접 살펴볼 차례예요! 임베딩 데이터의 차원을 1,536개에서 2개로 줄이기 위해 t-SNE를 사용해 시각화를 훨씬 쉽게 만들 거예요.
이전 연습 문제에서 다뤘던 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로 임포트되어 있어요.
이 연습은 강의의 일부입니다
OpenAI API로 시작하는 임베딩 Introduction
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create categories and embeddings lists using list comprehensions
categories = [product[____] for product in products]
embeddings = [product[____] for product in products]