임베딩: 대화식 연습 문제
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
TensorFlow의 임베딩 프로젝터를 기반으로 하는 다음 위젯은 10,000개의 word2vec
정적 벡터를 3차원 공간으로 평면화합니다. 이와 같은 차원의 축소는 오해를 유발할 수 있습니다. 기존 고차원 공간에서 서로 가장 가까이 있던 포인트들이 3차원 투영에서는 원래보다 멀리 있는 것으로 나타날 수 있기 때문입니다. 가장 가까운 n개의 포인트는 보라색으로 강조 표시됩니다. 여기서 n은 사용자가 Isolate __ points에서 선택한 값입니다. 오른쪽의 사이드바에는 최근접 이웃이 표시됩니다.
이 실험에서는 위의 위젯을 사용하여 word2vec
임베딩을 살펴봅니다.
작업 1
다음 단어의 최근접 이웃 20개를 찾아보고, 해당 그룹이 클라우드의 어디에 있는지 살펴보세요.
iii
, third
, three
tao
, way
orange
, yellow
, juice
결과에서 어떤 점을 확인할 수 있나요?
답변을 보려면 여기를 클릭하세요
iii
, third
, three
는 시맨틱 유사성이 있긴 하지만 텍스트상으로 서로 다른 컨텍스트에 등장하며 이 임베딩 공간에서는 가까이 있지 않은 것으로 보입니다. word2vec
에서 iii
는 third
보다 iv
에 가까이 있습니다.
마찬가지로, way
는 tao
의 직역이긴 하지만, 이들 단어는 사용된 데이터 세트에서 서로 완전히 다른 그룹과 함께 가장 자주 등장하므로 두 벡터는 서로 무척 멀리 있습니다.
orange
의 처음 몇 개의 최근접 이웃은 색상이지만, 과일 orange
와 관련 있는 juice
와 peel
은 각각 14번째와 18번째 최근접 이웃입니다. 또한 Prince of Orange(Orange 지역의 Prince)라는 컨텍스트에서 사용되는 prince
는 17번째 최근접 이웃입니다. 이 투영에서 orange
와 가장 가까운 단어들은 yellow
와 그 밖의 색상이며, juice
와 가장 가까운 단어에는 orange
가 포함되지 않습니다.
작업 2
이 학습 데이터의 몇 가지 특성을 파악해 보세요. 예를 들어, 다음 단어의 최근접 이웃 100개를 찾아보고, 해당 그룹이 클라우드의 어디에 있는지 살펴보세요.
boston
, paris
, tokyo
, delhi
, moscow
, seoul
(함정 질문입니다)
jane
, sarah
, john
, peter
, rosa
, juan
답변을 보려면 여기를 클릭하세요
boston
의 최근접 이웃 중에는 미국의 다른 도시들이 많습니다. paris
의 최근접 이웃 중에는 유럽의 다른 도시들이 많습니다. tokyo
와 delhi
의 결과는 다른 양상을 보입니다. 하나는 세계 각지의 여행 허브 도시들과 연관이 있고, 다른 하나는 india
및 관련 단어들과 연관이 있습니다. seoul
은 이 간소화된 단어 벡터 세트에 등장하지 않습니다.
이 데이터 세트는 미국의 국내 지리와 관련된 다수의 문서와 유럽 지역의 지리와 관련된 어느 정도의 문서를 포함하나 그 밖의 국가 또는 지역에 관한 상세한 내용은 포함하지 않는 것으로 보입니다.
마찬가지로, 이 데이터 세트는 다수의 영어 남자 이름과 일부 영어 여자 이름을 포함하나 그 밖의 언어로 된 이름은 훨씬 적게 포함하는 것으로 보입니다. 'rosa'의 최근접 이웃이 'scrooge'와 'mcduck'인 이유는 Don Rosa가 디즈니의 Scrooge McDuck 코믹스 작가이자 삽화가이기 때문인 것으로 보입니다.
실제로 word2vec
의 사전 학습된 단어 벡터는 2013년까지의 Google 뉴스 기사를 학습한 결과입니다.
작업 3
임베딩은 단지 단어로만 제한되지 않습니다. 이미지, 오디오, 그 밖의 데이터도 임베딩될 수 있습니다. 이번 작업에서는 다음 단계를 따르세요.
- TensorFlow의 임베딩 프로젝터를 엽니다.
- DATA라는 제목의 왼쪽 사이드바에서 Mnist with images를 선택합니다. 그러면 손글씨 숫자로 구성된 MNIST 데이터베이스의 임베딩 투영이 표시됩니다.
- 클릭하여 회전을 멈추고 이미지 하나를 선택합니다. 확대 또는 축소하여 살펴봅니다.
- 오른쪽 사이드바에서 최근접 이웃을 살펴봅니다. 예상 외의 결과가 있나요?
- 일부
7
의 최근접 이웃이 1
인 이유는 무엇일까요? 일부 8
의 최근접 이웃이 9
인 이유는 무엇일까요?
- 투영 공간의 가장자리에 있는 이미지와 투영 공간의 중앙에 있는 이미지 간에 다른 점이 있나요?
이 임베딩을 생성한 모델은 이미지 데이터, 즉 픽셀을 입력받고 있으며, 각 이미지에 대해 숫자 벡터 표현을 선택하고 있다는 사실을 기억하세요. 모델은 손글씨 숫자를 사람이 하는 것처럼 실제 숫자에 자동적으로 연관 짓지 않습니다.
답변을 보려면 여기를 클릭하세요
획이 얇게 표현된 7
의 벡터 표현은 모양이 유사하기 때문에 손글씨 1
벡터에 가까이 배치되어 있습니다. 8
, 9
, 그리고 일부 5
와 3
도 마찬가지입니다.
투영 공간의 바깥쪽에 있는 손글씨 숫자들은 아홉 개의 숫자 중 하나로 보다 뚜렷하게 구분되고 다른 숫자들과 크게 다릅니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-05-16(UTC)
[null,null,["최종 업데이트: 2025-05-16(UTC)"],[],[],null,["# Embeddings: Interactive exercises\n\nThe following widget, based on TensorFlow's\n[Embedding Projector](https://projector.tensorflow.org/), flattens 10,000\n`word2vec` static vectors into a 3D space. This collapse of dimensions can be\nmisleading, because the points closest to each other in the original\nhigh-dimensional space may appear farther apart in the 3D projection. The\nclosest *n* points are highlighted in purple, with *n* chosen by the user in\n**Isolate __ points**. The sidebar on the right identifies those nearest\nneighbors. \n\nIn these experiments, you'll play with the `word2vec` embeddings in the widget\nabove.\n\nTask 1\n------\n\nTry to find the 20 nearest neighbors for the following, and see where the\ngroups fall in the cloud.\n\n- `iii`, `third`, and `three`\n- `tao` and `way`\n- `orange`, `yellow`, and `juice`\n\nWhat do you notice about these results? \n**Click here for our answer**\n\nEven though `iii`, `third`, and `three`\nare semantically similar, they appear in different contexts in text and\ndon't appear to be close together in this embedding space. In\n`word2vec`, `iii` is closer to `iv` than to\n`third`.\n\nSimilarly, while `way` is a direct translation of `tao`,\nthese words most frequently occur with completely different groups of words\nin the dataset used, and so the two vectors are very far apart.\n\nThe first several nearest neighbors of `orange` are colors, but\n`juice` and `peel`, related to the meaning of\n`orange` as fruit, show up as the 14th\nand 18th nearest neighbors. `prince`, meanwhile, as in the\nPrince of Orange, is 17th. In the projection, the words closest to\n`orange` are `yellow` and other\ncolors, while the closest words to `juice` don't include\n`orange`.\n\nTask 2\n------\n\nTry to figure out some characteristics of the training data. For example, try\nto find the 100 nearest neighbors for the following, and see where the groups\nare in the cloud:\n\n- `boston`, `paris`, `tokyo`, `delhi`, `moscow`, and `seoul` (this is a trick question)\n- `jane`, `sarah`, `john`, `peter`, `rosa`, and `juan`\n\n**Click here for our answer**\n\nMany of the nearest neighbors to `boston` are other cities in\nthe US. Many of the nearest neighbors to `paris` are other cities\nin Europe. `tokyo` and `delhi` don't seem to have\nsimilar results: one is associated with cities around the world that are\ntravel hubs, while the other is associated with `india` and related\nwords. `seoul` doesn't appear in this trimmed-down set of\nword vectors at all.\n\nIt seems that this dataset contains many documents related to US national\ngeography, some documents relate to European regional geography, and not\nmuch fine-grained coverage of other countries or regions.\n\nSimilarly, this dataset seems to contain many male English names, some female\nEnglish names, and far fewer names from other languages. Note that Don Rosa\nwrote and illustrated Scrooge McDuck comics for Disney, which is the likely\nreason that \\`scrooge\\` and \\`mcduck\\` are among the nearest neighbors for \\`rosa\\`.\n\nThe pre-trained word vectors offered by `word2vec` were in fact\ntrained on\n[Google News articles up to 2013](https://code.google.com/archive/p/word2vec/).\n\nTask 3\n------\n\nEmbeddings aren't limited to words. Images, audio, and other data can also be\nembedded. For this task:\n\n1. Open TensorFlow's [Embedding Projector](https://projector.tensorflow.org/).\n2. In the left sidebar titled **Data** , choose **Mnist with images** . This brings up a projection of the embeddings of the [MNIST](https://developers.google.com/machine-learning/glossary#mnist) database of handwritten digits.\n3. Click to stop the rotation and choose a single image. Zoom in and out as needed.\n4. Look in the right sidebar for nearest neighbors. Are there any surprises?\n\n- Why do some `7`s have `1`s as their nearest neighbor? Why do some `8`s have `9` as their nearest neighbor?\n- Is there anything about the images on the edges of the projection space that seem different from the images in the center of the projection space?\n\nKeep in mind that the model that created these embeddings is receiving image\ndata, which is to say, pixels, and choosing a numerical vector representation\nfor each image. The model doesn't make an automatic mental association\nbetween the image of the handwritten digit and the numerical digit itself. \n**Click here for our answer**\n\nDue to similarities in shape, the vector representations of some of the\nskinnier, narrower `7`s are placed closer to the vectors for\nhandwritten `1`s. The same thing happens for some `8`s\nand `9`s, and even some of the `5`s and `3`s.\n\nThe handwritten digits on the outside of the projection space appear\nmore strongly definable as one of the nine digits and strongly differentiated\nfrom other possible digits.\n| **Key terms:**\n|\n| - [Embedding vector](/machine-learning/glossary#embedding-vector)\n- [Embedding space](/machine-learning/glossary#embedding-space) \n[Help Center](https://support.google.com/machinelearningeducation)"]]