项目作者: rajveermalviya

项目描述 :
This is machine learning model that is trained to predict next word in the sequence. Model is defined in keras and then converted to tensorflow-js model for the web, check the web implementation at
高级语言: Python
项目地址: git://github.com/rajveermalviya/language-modeling.git
创建时间: 2018-07-09T18:18:36Z
项目社区:https://github.com/rajveermalviya/language-modeling

开源协议:MIT License

下载


Language Modeling

This is machine learning model that is trained to predict next word in the sequence.
Model is defined in keras and then converted to tensorflowjs model using tfjs_converter.

See it working!

Dependencies

To install all dependencies at once use:

  1. pip3 install -r requirements.txt

Usage

First create necessary directories or else you will get an error.

  1. mkdir model/checkpoint
  2. mkdir web/dist/web_model

Once you have your dependencies installed via pip, train the model by running :

  1. python3 train.py

After training you can either use the model by running :

  1. python3 test.py

After running test.py your output should be :

  1. Enter atleast 3 words:
  2. welcome to new
  3. indexes of last 3 words : [4402, 5, 35]
  4. prediction indexes : [92, 1, 2645, 1491, 189, 1762, 207, 362, 2261, 1727]
  5. 1 - welcome to new york
  6. 2 - welcome to new <unk>
  7. 3 - welcome to new york-based
  8. 4 - welcome to new england
  9. 5 - welcome to new products
  10. 6 - welcome to new jersey
  11. 7 - welcome to new debt
  12. 8 - welcome to new loans
  13. 9 - welcome to new hampshire
  14. 10 - welcome to new ventures

or by converting the model to tensorflow js model by running :

  1. tensorflowjs_converter --input_format=keras /model/model.h5 /web/dist/web_model

Then Read the README.md in /web directory

License MIT © Rajveer Malviya