{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "![](media/cover.png)\n\n# Tamnun ML\n\n[![PyPI pyversions](https://img.shields.io/badge/python-3.6%20%7C%203.7-blue)](https://img.shields.io/badge/python-3.6%20%7C%203.7-blue)\n[![CircleCI](https://circleci.com/gh/hiredscorelabs/tamnun-ml.svg?style=svg)](https://circleci.com/gh/hiredscorelabs/tamnun-ml)\n\n`tamnun` is a python framework for Machine and Deep learning algorithms and methods especially in the field of Natural Language Processing and Transfer Learning. The aim of `tamnun` is to provide an easy to use interfaces to build powerful models based on most recent SOTA methods.\n\nFor more about `tamnun`, feel free to read [the introduction to TamnunML on Medium](https://medium.com/hiredscore-engineering/introducing-octoml-73bd527491b1).\n\n# Getting Started\n\n`tamnun` depends on several other machine learning and deep learning frameworks like `pytorch`, `keras` and others. To install `tamnun` and all it's dependencies run:\n\n```\n$ git clone https://github.com/hiredscorelabs/tamnun-ml\n$ cd tamnun-ml\n$ python setup.py install\n```\n\nOr using PyPI:\n\n```\npip install tamnun\n```\n\nJump in and try out an example:\n\n```\n$ cd examples\n$ python finetune_bert.py\n```\n\nOr take a look at the Jupyer notebooks [here](notebooks).\n\n## BERT\n\n*BERT* stands for Bidirectional Encoder Representations from Transformers which is a language model trained by Google and introduced in their [paper](https://arxiv.org/abs/1810.04805).\nHere we use the excellent [PyTorch-Pretrained-BERT](https://pypi.org/project/pytorch-pretrained-bert/) library and wrap it to provide an easy to use [scikit-learn](https://scikit-learn.org/) interface for easy BERT fine-tuning. At the moment, `tamnun` BERT classifier supports binary and multi-class classification. To fine-tune BERT on a specific task:\n\n```python\nfrom tamnun.bert import BertClassifier, BertVectorizer\nfrom sklearn.pipeline import make_pipeline\n\nclf = make_pipeline(BertVectorizer(), BertClassifier(num_of_classes=2)).fit(train_X, train_y)\npredicted = clf.predict(test_X)\n```\n\nPlease see [this notebook](https://github.com/hiredscorelabs/tamnun-ml/blob/master/notebooks/finetune_bert.ipynb) for full code example.\n\n## Fitting (almost) any PyTorch Module using just one line\nYou can use the `TorchEstimator` object to fit any `pytorch` module with just one line:\n```python\nfrom torch import nn\nfrom tamnun.core import TorchEstimator\n\nmodule = nn.Linear(128, 2)\nclf = TorchEstimator(module, task_type='classification').fit(train_X, train_y)\n```\n\nSee [this file](https://github.com/hiredscorelabs/tamnun-ml/blob/master/examples/linear_mnist.py) for a full example of fitting `nn.Linear` module on the [MNIST](http://yann.lecun.com/exdb/mnist/) (classification of handwritten digits) dataset. \n\n## Distiller Transfer Learning\n\nThis module distills a very big (like BERT) model into a much smaller model. Inspired by this [paper](https://arxiv.org/abs/1503.02531).\n\n```python\nfrom tamnun.bert import BertClassifier, BertVectorizer\nfrom tamnun.transfer import Distiller\n\nbert_clf = make_pipeline(BertVectorizer(do_truncate=True, max_len=3), BertClassifier(num_of_classes=2))\ndistilled_clf = make_pipeline(CountVectorizer(ngram_range=(1,3)), LinearRegression())\n\ndistiller = Distiller(teacher_model=bert_clf, teacher_predict_func=bert_clf.decision_function, student_model=distilled_clf).fit(train_texts, train_y, unlabeled_X=unlabeled_texts)\n\npredicted_logits = distiller.transform(test_texts)\n```\n\nFor full BERT distillation example see [this](https://github.com/hiredscorelabs/tamnun-ml/blob/master/notebooks/distill_bert.ipynb) notebook.\n\n\n\n# Support\n\n## Getting Help\n\nYou can ask questions and join the development discussion on [Github Issues](https://github.com/hiredscorelabs/tamnun-ml/issues)\n\n\n## License\n\nApache License 2.0 (Same as Tensorflow)\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hiredscorelabs/tamnun-ml", "keywords": "Deep Learning Natural Language Processing NLP Machine Learning Transfer Learning", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "tamnun", "package_url": "https://pypi.org/project/tamnun/", "platform": "", "project_url": "https://pypi.org/project/tamnun/", "project_urls": { "Homepage": "https://github.com/hiredscorelabs/tamnun-ml" }, "release_url": "https://pypi.org/project/tamnun/0.1.1/", "requires_dist": [ "numpy (==1.15.4)", "scikit-learn (==0.20.2)", "torch (==1.1.0)", "pytorch-transformers" ], "requires_python": "", "summary": "An easy to use open-source library for advanced Deep Learning and Natural Language Processing", "version": "0.1.1" }, "last_serial": 5633031, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "b92e68f20121fe2ed789fc0c7d1da937", "sha256": "bca15802df944a0a3f72b69f78e9ddf5047e6cdee1d84e29aa8c062485f89285" }, "downloads": -1, "filename": "tamnun-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b92e68f20121fe2ed789fc0c7d1da937", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9537, "upload_time": "2019-08-05T07:40:05", "url": "https://files.pythonhosted.org/packages/28/5c/4f72b512c40e80f3c256cf0c7938e1d858db5519164cac37e4fa16898713/tamnun-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9c9a36dbf0dffe4e0645a9b0e2c3d3ac", "sha256": "92469a26865795644226d7498c179f376b5cf1e85d84b5ad4589c95872d0a97a" }, "downloads": -1, "filename": "tamnun-0.1.0.tar.gz", "has_sig": false, "md5_digest": "9c9a36dbf0dffe4e0645a9b0e2c3d3ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8510, "upload_time": "2019-08-05T07:40:07", "url": "https://files.pythonhosted.org/packages/2b/15/d3c0e3407a103a181bc3ce0ce1f47ef19537aae0377656a973ea19ef1b60/tamnun-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a7146149da0b315d642bb3e259a94b86", "sha256": "82e1684a25883f660f9057bc88bf21f7b3f9db3c49faca204b3f72eb35898624" }, "downloads": -1, "filename": "tamnun-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a7146149da0b315d642bb3e259a94b86", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9525, "upload_time": "2019-08-05T07:56:18", "url": "https://files.pythonhosted.org/packages/85/00/3905332b6dc3cd3f1d9921d64b6a6a80dc96938624389c25f960b58333ad/tamnun-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "64c8c2ad2737d1ced94bf6eb8ed71793", "sha256": "973023048316115055cdf69febf56dcfcc907cb9035476839f4d80aeeb908918" }, "downloads": -1, "filename": "tamnun-0.1.1.tar.gz", "has_sig": false, "md5_digest": "64c8c2ad2737d1ced94bf6eb8ed71793", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8534, "upload_time": "2019-08-05T07:56:20", "url": "https://files.pythonhosted.org/packages/cc/ec/7d456fbefeaf3a3bdf2b6e2d9ff8b4eab92d62592c99b92b1d93d8f76d6f/tamnun-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a7146149da0b315d642bb3e259a94b86", "sha256": "82e1684a25883f660f9057bc88bf21f7b3f9db3c49faca204b3f72eb35898624" }, "downloads": -1, "filename": "tamnun-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a7146149da0b315d642bb3e259a94b86", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9525, "upload_time": "2019-08-05T07:56:18", "url": "https://files.pythonhosted.org/packages/85/00/3905332b6dc3cd3f1d9921d64b6a6a80dc96938624389c25f960b58333ad/tamnun-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "64c8c2ad2737d1ced94bf6eb8ed71793", "sha256": "973023048316115055cdf69febf56dcfcc907cb9035476839f4d80aeeb908918" }, "downloads": -1, "filename": "tamnun-0.1.1.tar.gz", "has_sig": false, "md5_digest": "64c8c2ad2737d1ced94bf6eb8ed71793", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8534, "upload_time": "2019-08-05T07:56:20", "url": "https://files.pythonhosted.org/packages/cc/ec/7d456fbefeaf3a3bdf2b6e2d9ff8b4eab92d62592c99b92b1d93d8f76d6f/tamnun-0.1.1.tar.gz" } ] }