The concept and implementation __python of "Python into NLP" NLP wordembedding

Source: Internet
Author: User

Background
How to represent the semantics that a word contains.

Apple. Fruit. Iphone.
Apple, pear, these two words related.

The expression of a language
Symbolism: Bags-of-word, high dimension, too sparse, lack of semantics, simple model
Distributed representation: Word embedding, low dimension, more dense, inclusive semantics, training complex

Word Embedding
Core ideas: Semantically related words that have similar contextual contexts, such as apples and pears
The thing to do: train each word into a word vector

Practice
Based on Gensim package and Chinese wiki corpus
Gensim:http://radimrehurek.com/gensim/models/word2vec.html
Chinese Wikipedia: Link https://pan.baidu.com/s/1qXKIPp6 password Kade

# Load Package from
gensim.models import Word2vec from
Gensim.models.word2vec import linesentence

# Training Model
sentences = linesentence (' wiki.zh.word.text ')
model = Word2vec (sentences, size=128, window=5, min_count=5, workers =4)

# Save Model
model.save (' word_embedding_128 ')

# load Model
= Word2vec.load ("word_embedding_128")

# Use model
items = model.most_similar (U ' China ')
model.similarity (U ' man ',  u ' woman ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.