भाषा मॉडलों के लिए ट्रांसफर लर्निंग

Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

David Cecchini

Data Scientist

ट्रांसफर लर्निंग का विचार

ट्रांसफर लर्निंग:

  • रैंडम से बेहतर प्रारंभिक वेट्स से शुरुआत करें
  • बहुत बड़े डेटासेट पर ट्रेन किए गए मॉडल्स उपयोग करें
  • "ओपन-सोर्स" डेटा साइंस मॉडल्स
Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

उपलब्ध आर्किटेक्चर

बेस उदाहरण: I really loved this movie

  • Word2Vec
    • Continuous Bag of Words (CBOW) X = [I, really, this, movie], y = loved
    • Skip-gram X = loved, y = [I, really, this, movie]
  • FastText X = [I, rea, eal, all, lly, really, ...], y = loved
    • शब्द और कैरेक्टर n-grams उपयोग करता है
  • ELMo X = [I, really, loved, this], y = movie
    • शब्द और प्रति संदर्भ एम्बेडिंग्स उपयोग करता है
    • डीप बिडायरेक्शनल लैंग्वेज मॉडल्स (biLM) उपयोग करता है
  • Word2Vec और FastText gensim पैकेज में, और ELMo tensorflow_hub पर उपलब्ध हैं
Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

Word2Vec का उदाहरण

from gensim.models import word2vec

# Train the model w2v_model = word2vec.Word2Vec(tokenized_corpus, size=embedding_dim, window=neighbor_words_num, iter=100)
# Get top 3 similar words to "captain" w2v_model.wv.most_similar(["captain"], topn=3)
[('sweatpants', 0.7249663472175598),
('kirk', 0.7083336114883423),
('larry', 0.6495886445045471)]
Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

FastText का उदाहरण

from gensim.models import fasttext

# Instantiate the model ft_model = fasttext.FastText(size=embedding_dim, window=neighbor_words_num)
# Build vocabulary ft_model.build_vocab(sentences=tokenized_corpus)
# Train the model ft_model.train(sentences=tokenized_corpus, total_examples=len(tokenized_corpus), epochs=100)
Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

अभ्यास करते हैं!

Keras के साथ भाषा मॉडलिंग के लिए Recurrent Neural Networks (RNNs)

Preparing Video For Download...