Skip to main content

Russian Paraphrasers

The library for Russian paraphrase generation. Paraphrase generation is an increasingly popular task in NLP that can be used in many areas:

  • style transfer:
    • translation from rude to polite
    • translation from professional to simple language
  • data augmentation: increasing the number of examples for training ML-models
  • increasing the stability of ML-models: training models on a wide variety of examples, in different styles, with different sentiment, but the same meaning / intent of the user

Install

pip install --upgrade pip
pip install -r requirements.txt
pip install russian_paraphrasers

in this case you need to add git+https://github.com/Maluuba/nlg-eval.git@master

Warning important in requirements.txt (versions!):

sentence-transformers==0.4.0
transformers>=4.0.1
git+https://github.com/Maluuba/nlg-eval.git@master

Or you can install last version from git:

pip install git+https://github.com/RussianNLP/russian_paraphrasers@master

Usage

Open In Colab

  1. First, import one of the models and set general parameters for your paraphraser:
from russian_paraphrasers import GPTParaphraser

paraphraser = GPTParaphraser(model_name="gpt2", range_cand=False, make_eval=False)
from russian_paraphrasers import Mt5Paraphraser

paraphraser = Mt5Paraphraser(model_name="mt5-base", range_cand=False, make_eval=False)

You can choose 1) to filter candidates or not 2) to add some evaluation of best candidates or all n samples.

Arguments:

  • model_name: mt5-small, mt5-base, mt5-large, gpt2
  • range_cand: True/False
  • make_eval: True/False
  1. Pass sentence (obligatory) and parameters for generating to generate function and see the results.
sentence = "Мама мыла раму."
results = paraphraser.generate(
    sentence, n=10, temperature=1, 
    top_k=10, top_p=0.9, 
    max_length=100, repetition_penalty=1.5,
    threshold=0.7
)

You can set the threshold parameter to range candidates, it measures by similarity score between original vector and the candidate vector.

Results for one sentence look like this:

{'average_metrics': {'Bleu_1': 0.06666666665333353,
                     'Bleu_2': 2.3570227263379004e-09,
                     'Bleu_3': 8.514692649183842e-12,
                     'Bleu_4': 5.665278056606597e-13,
                     'ROUGE_L': 0.07558859975216851},
 'best_candidats': ['В чём цель существования человека?',
                    'Для чего нужна жизнь?',
                    'Что такое жизнь в смысле смысла ее существования, и зачем '
                    'она нужна человеку.'],
 'predictions': ['В чём счастье людей, проживающих в мире сегодня',
                 'В чём счастье человека?)',
                 'Для чего нужна жизнь и какова цель ее существования?',
                 'Что означает фраза в том чтобы жить жизнью?',
                 'В чём ценность человеческой Жизни?',
                 'В чём счастье людей в мире? и т. д.',
                 'Зачем нужна жизнь и что в ней главное докуменция дл',
                 'В чём цель существования человека?',
                 'Что такое жизнь в смысле смысла ее существования, и зачем '
                 'она нужна человеку.',
                 'Для чего нужна жизнь?']
}

Models

All models were fine-tuned on the same dataset (see below) and uploaded to hugging_face. Available models:

To be continued... =)

Dataset

All models were finetuned on the dataset based on two parts:

  1. part of the ParaPhraser data, about 200k filtered examples
  2. filtered questions to chatbots and filtered subtitles from here

The dataset will be available soon as well as the article with all the details.

Metadata

Release files for russian-paraphrasers 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for russian-paraphrasers 0.0.3
File Size Uploaded Provenance Actions
russian_paraphrasers-0.0.3.tar.gz 9.8 kB Without provenance Details for russian_paraphrasers-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for russian-paraphrasers 0.0.3
File Interpreter ABI Platform Actions
russian_paraphrasers-0.0.3-py3-none-any.whl Python 3 none any Details for russian_paraphrasers-0.0.3-py3-none-any.whl

Total release size: 21.7 kB

Release files / russian_paraphrasers-0.0.3.tar.gz

Download URL russian_paraphrasers-0.0.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f1fbe1048b57db69dbef33424f13cd90fc9cfe5a57951cbd9ed06c1d9c545ab2
BLAKE2b-256 checksum
How to use checksums
6405e6eeb55842596771af34e59938140ae9439ddcc2383e508e6e8c50df892e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3

Release files / russian_paraphrasers-0.0.3-py3-none-any.whl

Download URL russian_paraphrasers-0.0.3-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26ca556575ec04f9e5e52bc1a1b4c4bc15a1670d35a69380b3c8fdf8e5171d98
BLAKE2b-256 checksum
How to use checksums
0dadb502c2831b07bc868d9cf77e340ac7652fb9fa7455fd1dc4db429f8b0c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3

Security for russian-paraphrasers 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page