# -*- coding: utf-8 -*-
from distutils.core import setup

packages = \
['laserembeddings']

package_data = \
{'': ['*'], 'laserembeddings': ['data/.gitkeep']}

install_requires = \
['numpy>=1.15.4,<2.0.0',
 'sacremoses>=0.0.33,<0.1.0',
 'subword-nmt>=0.3.6,<0.4.0',
 'torch>=1.0.1.post2,<2.0.0']

setup_kwargs = {
    'name': 'laserembeddings',
    'version': '0.1.2',
    'description': 'Production-ready LASER multilingual embeddings',
    'long_description': "# LASER embeddings\n\n[![Travis (.org) branch](https://img.shields.io/travis/yannvgn/laserembeddings/master?style=flat-square)](https://travis-ci.org/yannvgn/laserembeddings)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/laserembeddings?style=flat-square)\n[![PyPI](https://img.shields.io/pypi/v/laserembeddings.svg?style=flat-square)](https://pypi.org/project/laserembeddings/)\n[![PyPI - License](https://img.shields.io/pypi/l/laserembeddings.svg?style=flat-square)](https://github.com/yannvgn/laserembeddings/blob/master/LICENSE)\n\nlaserembeddings is a pip-packaged, production-ready port of Facebook Research's [LASER](https://github.com/facebookresearch/LASER) (Language-Agnostic SEntence Representations) to compute multilingual sentence embeddings.\n\n🎁 **Version 0.1.2 is out. What's new?**\n- Korean is now fully supported ✅\n- A [bug](https://bugs.python.org/issue37723) in Python 3.7 (<= 3.7.4) and 3.8 (<= 3.8.0 beta 3) affecting the tokenizer performance was patched as a temporary solution until next Python releases 🐛\n\n## Context\n\n[LASER](https://github.com/facebookresearch/LASER) is a collection of scripts and models created by Facebook Research to compute **multilingual sentence embeddings** for zero-shot cross-lingual transfer. \n\nWhat does it mean? LASER is able to transform sentences into **language-independent vectors**. Similar sentences get mapped to close vectors (in terms of cosine distance), regardless of the input language.\n\nThat is great, especially if you don't have training sets for the language(s) you want to process: you can build a classifier on top of LASER embeddings, train it on whatever language(s) you have in your training data, and let it classify texts in any language.\n\n**The aim of the package is to make LASER as easy-to-use and easy-to-deploy as possible: zero-config, production-ready, etc., just a two-liner to install.**\n\n👉 👉 👉 For detailed information, have a look at the amazing [LASER repository](https://github.com/facebookresearch/LASER), read its [presentation article](https://code.fb.com/ai-research/laser-multilingual-sentence-embeddings/) and its [research paper](https://arxiv.org/abs/1812.10464). 👈 👈 👈\n\n## Getting started\n\nYou'll need Python 3.6 or higher.\n\n### Installation\n\n```\npip install laserembeddings\n```\n\n### Downloading the pre-trained models\n\n```\npython -m laserembeddings download-models\n```\n\nThis will download the models to the default `data` directory next to the source code of the package. Use `python -m laserembeddings download-models path/to/model/directory` to download the models to a specific location.\n\n### Usage\n\n```python\nfrom laserembeddings import Laser\n\nlaser = Laser()\n\nembeddings = laser.embed_sentences(\n    ['let your neural network be polyglot',\n     'use multilingual embeddings!'],\n    lang='en')  # lang is used for tokenization\n\n# embeddings is a N*1024 (N = number of sentences) NumPy array\n```\n\nIf you downloaded the models into a specific directory:\n\n```python\nfrom laserembeddings import Laser\n\npath_to_bpe_codes = ...\npath_to_bpe_vocab = ...\npath_to_encoder = ...\n\nlaser = Laser(path_to_bpe_codes, path_to_bpe_vocab, path_to_encoder)\n\n# you can also supply file objects instead of file paths\n```\n\nIf you want to pull the models from S3:\n\n```python\nfrom io import BytesIO, StringIO\nfrom laserembeddings import Laser\nimport boto3\n\ns3 = boto3.resource('s3')\nMODELS_BUCKET = ...\n\nf_bpe_codes = StringIO(s3.Object(MODELS_BUCKET, 'path_to_bpe_codes.fcodes').get()['Body'].read().decode('utf-8'))\nf_bpe_vocab = StringIO(s3.Object(MODELS_BUCKET, 'path_to_bpe_vocabulary.fvocab').get()['Body'].read().decode('utf-8'))\nf_encoder = BytesIO(s3.Object(MODELS_BUCKET, 'path_to_encoder.pt').get()['Body'].read())\n\nlaser = Laser(f_bpe_codes, f_bpe_vocab, f_encoder)\n```\n\n## What are the differences with the original implementation?\n\nSome dependencies of the original project have been replaced with pure-python dependencies, to make this package easy to install and deploy.\n\nHere's a summary of the differences:\n\n| Part of the pipeline | LASER dependency (original project) | laserembeddings dependency (this package) | Reason |\n|----------------------|-------------------------------------|----------------------------------------|--------|\n| Normalization / tokenization | [Moses](https://github.com/moses-smt/mosesdecoder) | [Sacremoses](https://github.com/alvations/sacremoses) | Moses is implemented in Perl |\n| BPE encoding | [fastBPE](https://github.com/glample/fastBPE) | [subword-nmt](https://github.com/rsennrich/subword-nmt) | fastBPE cannot be installed via pip and requires compiling C++ code |\n\nThe following features have not been implemented yet:\n- romanize, needed to process Greek (el)\n- Chinese text segmentation, needed to process Chinese (zh, cmn, wuu and yue)\n- Japanese text segmentation, needed to process Japanese (ja, jpn)\n\n## Will I get the exact same embeddings?\n\n**For most languages, in most of the cases, yes.**\n\nSome slight (and not so slight 🙄) differences exist for some languages due to differences in the implementation of the Tokenizer.\n\n**[An exhaustive comparison of the embeddings generated with LASER and laserembeddings](tests/report/comparison-with-LASER.md) is automatically generated and will be updated for each new release.**\n\n## FAQ\n\n**How can I train the encoder?**\n\nYou can't. LASER models are pre-trained and do not need to be fine-tuned. The embeddings are generic and perform well without fine-tuning. See https://github.com/facebookresearch/LASER/issues/3#issuecomment-404175463.\n\n## Credits\n\nThanks a lot to the creators of [LASER](https://github.com/facebookresearch/LASER) for open-sourcing the code of LASER and releasing the pre-trained models. All the kudos should go to them 👏.\n\nA big thanks to the creators of [Sacremoses](https://github.com/alvations/sacremoses) and [Subword Neural Machine Translation](https://github.com/rsennrich/subword-nmt/) for their great packages.\n\n## Testing\n\nFirst you'll need to checkout this repository and install it (in a virtual environment if you want). Also make sure to have [Poetry](https://github.com/sdispater/poetry) installed.\n\n```\npeotry install\n```\n\nThen, to run the tests:\n\n```\npoetry run pytest\n```\n\n### Testing the similarity between the embeddings computed with LASER and laserembeddings\n\nFirst, download the test data.\n\n```\npython -m laserembeddings download-test-data\n```\n\n👉 If you want to know more about the contents and the generation of the test data, check out the [laserembeddings-test-data](https://github.com/yannvgn/laserembeddings-test-data) repository.\n\nThen, run the test with `SIMILARITY_TEST` env. variable set to `1`.\n\n```\nSIMILARITY_TEST=1 poetry run pytest tests/test_laser.py\n```\n\nNow, have a coffee ☕️ and wait for the test to finish.\n\nThe similarity report will be generated here: [tests/report/comparison-with-LASER.md](tests/report/comparison-with-LASER.md).\n",
    'author': 'yannvgn',
    'author_email': 'hi@yannvgn.io',
    'url': 'https://github.com/yannvgn/laserembeddings',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
