### Install Parrot Paraphraser Dependencies with ROCm Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md Clones the Parrot Paraphraser repository, navigates into the directory, and installs the required dependencies from the `requirements-rocm.txt` file using pip. ```sh git clone https://github.com/PrithivirajDamodaran/Parrot_Paraphraser.git cd Parrot_Paraphraser pip install -r requirements-rocm.txt ``` -------------------------------- ### Installing Parrot Paraphraser using pip Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md This command installs the Parrot paraphraser directly from the GitHub repository using pip. It fetches the latest version of the package and its dependencies, making it ready for use in a Python environment. ```Python pip install git+https://github.com/PrithivirajDamodaran/Parrot_Paraphraser.git ``` -------------------------------- ### Installing Dependencies with pip Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/requirements-rocm.txt This command installs the dependencies listed in the requirements file using pip, including an extra index URL for PyTorch with ROCm support. It ensures that all necessary packages are installed for the project to function correctly. ```bash pip install --extra-index-url https://download.pytorch.org/whl/rocm5.6 torch torchvision torchaudio tensorflow-rocm>=2.13 transformers[torchhub] sentencepiece python-Levenshtein fuzzywuzzy sentence-transformers pandas ``` -------------------------------- ### Sample NLU Data in Rasa Format Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md This JSON snippet shows a sample of NLU data in Rasa format. It includes an example utterance with intent and entity annotations, demonstrating how slots are defined with start and end positions, values, and entity types. This format is used for training NLU models. ```json { "rasa_nlu_data": { "common_examples": [ { "text": "i would like to find a flight from charlotte to las vegas that makes a stop in st. louis", "intent": "flight", "entities": [ { "start": 35, "end": 44, "value": "charlotte", "entity": "fromloc.city_name" }, { "start": 48, "end": 57, "value": "las vegas", "entity": "toloc.city_name" }, { "start": 79, "end": 88, "value": "st. louis", "entity": "stoploc.city_name" } ] }, ... ] } } ``` -------------------------------- ### Controlling Paraphrase Diversity with do_diverse Knob Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md This example demonstrates how to control the diversity of generated paraphrases using the `do_diverse` knob. Setting `do_diverse` to `True` results in a wider variety of paraphrases compared to the default `do_diverse = False`. ```text ------------------------------------------------------------------------------ Input_phrase: How are the new Macbook Pros with M1 chips? ------------------------------------------------------------------------------ 'what do you think about the new macbook pro m1? ' 'how is the new macbook pro m1? ' 'how are the new macbook pros? ' 'what do you think about the new macbook pro m1 chips? ' 'how good is the new macbook pro m1 chips? ' 'how is the new macbook pro m1 chip? ' 'do you like the new macbook pro m1 chips? ' 'how are the new macbook pros with m1 chips? ' ``` -------------------------------- ### Initializing and Basic Paraphrasing with Parrot Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md This code snippet demonstrates how to initialize the Parrot paraphraser model and generate paraphrases for a list of input phrases. It initializes the model with a specified tag, iterates through a list of phrases, and prints the generated paraphrases for each phrase. ```python from parrot import Parrot import torch import warnings warnings.filterwarnings("ignore") ''' uncomment to get reproducable paraphrase generations def random_state(seed): torch.manual_seed(seed) if torch.cuda.is_available(): torch.cuda.manual_seed_all(seed) random_state(1234) ''' #Init models (make sure you init ONLY once if you integrate this to your code) parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5") phrases = ["Can you recommend some upscale restaurants in Newyork?", "What are the famous places we should not miss in Russia?" ] for phrase in phrases: print("-"*100) print("Input_phrase: ", phrase) print("-"*100) para_phrases = parrot.augment(input_phrase=phrase, use_gpu=False) for para_phrase in para_phrases: print(para_phrase) ``` -------------------------------- ### Verify PyTorch GPU Availability with CUDA Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md Verifies if PyTorch can detect the CUDA-enabled GPU. It imports the torch library and prints whether CUDA is available. ```python python3 -c 'import torch; print(torch.cuda.is_available())' ``` -------------------------------- ### Override GFX Version for ROCm Driver Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md Sets the `HSA_OVERRIDE_GFX_VERSION` environment variable to "fool" the ROCm driver and enable GPU detection. It then verifies GPU availability using PyTorch. ```sh HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 -c 'import torch; print(torch.cuda.is_available())' # OR export HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 -c 'import torch; print(torch.cuda.is_available())' ``` -------------------------------- ### Advanced Paraphrasing Options Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md This code snippet showcases the various knobs available in the `parrot.augment` function for fine-tuning the paraphrasing process. These knobs include `use_gpu`, `diversity_ranker`, `do_diverse`, `max_return_phrases`, `max_length`, `adequacy_threshold`, and `fluency_threshold`. ```python para_phrases = parrot.augment(input_phrase=phrase, use_gpu=False, diversity_ranker="levenshtein", do_diverse=False, max_return_phrases = 10, max_length=32, adequacy_threshold = 0.99, fluency_threshold = 0.90) ``` -------------------------------- ### Parrot BibTeX Citation Source: https://github.com/prithivirajdamodaran/parrot_paraphraser/blob/main/README.md BibTeX entry for citing the Parrot paraphraser in academic works. Includes author, title, year, and version information. ```bibtex @misc{prithivida2021parrot, author = {Prithiviraj Damodaran}, title = {Parrot: Paraphrase generation for NLU.}, year = 2021, version = {v1.0} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.