iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📔
Using chiVe in Google Colaboratory
I was interested in this, but since the size is extremely large, I decided to try using it in Google Colaboratory. I got lost during the process as I'm not used to it, so I'm writing down the steps to load it in Google Colaboratory.
import gensim
import urllib.request
import sys
# Download
url = "https://sudachi.s3-ap-northeast-1.amazonaws.com/chive/chive-1.2-mc90_gensim.tar.gz" # Specify the file URL
urllib.request.urlretrieve(url,"chive.tar.gz")
# Extract
!tar -zxvf chive.tar.gz
It worked perfectly 🎉
vectors = gensim.models.KeyedVectors.load("chive-1.2-mc90_gensim/chive-1.2-mc90.kv")
vectors["酢橘"]
# array([-5.68204783e-02, -1.26615226e-01, 3.53190415e-02, -3.67305875e-01, ...])
print(vectors.similarity("酢橘", "徳島"))
# 0.3993048
print(vectors.most_similar("徳島", topn=5))
# [('愛媛', 0.8307707905769348), ('高知', 0.7802321910858154), ('徳島県', 0.773858904838562), ('岡山', 0.7684701681137085), ('徳島市', 0.7513154745101929)]
print(vectors.most_similar(positive=["阿波", "高知"], negative=["徳島"], topn=5))
# [('土佐', 0.6678404211997986), ('伊予', 0.5940072536468506), ('高知県', 0.5717992782592773), ('安芸', 0.5696682929992676), ('高知城', 0.5380114912986755)]
Discussion