xlnet | Generalized Autoregressive Pretraining for Language | Natural Language Processing library

 by   zihangdai Python Version: Current License: Apache-2.0

kandi X-RAY | xlnet Summary

kandi X-RAY | xlnet Summary

xlnet is a Python library typically used in Artificial Intelligence, Natural Language Processing, Deep Learning, Pytorch, Tensorflow, Bert applications. xlnet has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However xlnet build file is not available. You can install using 'pip install xlnet' or download it from GitHub, PyPI.

XLNet is a new unsupervised language representation learning method based on a novel generalized permutation language modeling objective. Additionally, XLNet employs Transformer-XL as the backbone model, exhibiting excellent performance for language tasks involving long context. Overall, XLNet achieves state-of-the-art (SOTA) results on various downstream language tasks including question answering, natural language inference, sentiment analysis, and document ranking.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              xlnet has a medium active ecosystem.
              It has 6044 star(s) with 1179 fork(s). There are 172 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 172 open issues and 88 have been closed. On average issues are closed in 41 days. There are 17 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of xlnet is current.

            kandi-Quality Quality

              xlnet has 0 bugs and 0 code smells.

            kandi-Security Security

              xlnet has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              xlnet code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              xlnet is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              xlnet releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              xlnet has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              xlnet saves you 3244 person hours of effort in developing the same functionality from scratch.
              It has 6971 lines of code, 362 functions and 16 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed xlnet and discovered the below as its top functions. This is intended to give you an instant insight into xlnet implemented functionality, and help decide if they suit your requirements.
            • Convert examples to features
            • Encode pieces into pieces
            • Preprocess text
            • Encode piece ids
            • Augment model_fn
            • Enqueue infeed ops and dequeue them
            • Get the object
            • Invoke input_fn on each host
            • Preprocess training data
            • Reads a squad example file
            • Create training data
            • Construct input_fn
            • Build a file - based input function
            • Calculate precision - recall curve
            • Runs predictions on the model
            • Initialize TPU
            • Process a single feature
            • Wrap the computation in a while loop
            • Return the ids of the given text
            • Get examples from a set of examples
            • Read a squad example file
            • Create examples from QNLI
            • Configure TPU
            • Inserts a stopping signal
            • Call input_fn
            • Writes predictions to file
            • Transformer transformer
            • Train the model
            Get all kandi verified functions for this library.

            xlnet Key Features

            No Key Features are available at this moment for xlnet.

            xlnet Examples and Code Snippets

            Ensemble
            Pythondot img1Lines of Code : 228dot img1License : Permissive (MIT)
            copy iconCopy
            python ensemble_squad.py \
              --name ensemble-weighted \
              --model_type placeholder \
              --model_name_or_path placeholder \
              --do_train \
              --do_eval \
              --do_weighted_ensemble \
              --do_lower_case \
              --train_file data/train-v2.0.json \
              --per_gpu_tr  
            Original Training script
            Pythondot img2Lines of Code : 90dot img2License : Permissive (MIT)
            copy iconCopy
            export SQUAD_DIR=/path/to/SQUAD
            
            python run_squad.py \
              --model_type bert \
              --model_name_or_path bert-base-cased \
              --do_train \
              --do_eval \
              --do_lower_case \
              --train_file $SQUAD_DIR/train-v1.1.json \
              --predict_file $SQUAD_DIR/dev-v1.1.js  
            Training, evaluation and test
            Pythondot img3Lines of Code : 19dot img3License : Permissive (Apache-2.0)
            copy iconCopy
            CUDA_VISIBLE_DEVICES=0,1 python run.py \
            --model_type xlnet \
            --model_name_or_path xlnet-large-cased \
            --do_test \
            --do_train \
            --do_eval \
            --data_dir data \
            --output_dir xlnet_large_commonsenseQA \
            --max_seq_length 256 \
            --eval_steps 200 \
            --per_gpu  
            sentence-transformers - train sts qqp crossdomain
            Pythondot img4Lines of Code : 119dot img4License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            """
            The script shows how to train Augmented SBERT (Domain-Transfer/Cross-Domain) strategy for STSb-QQP dataset.
            For our example below we consider STSb (source) and QQP (target) datasets respectively.
            
            Methodology:
            Three steps are followed for AugSBER  
            sentence-transformers - train sts indomain bm25
            Pythondot img5Lines of Code : 117dot img5License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            """
            The script shows how to train Augmented SBERT (In-Domain) strategy for STSb dataset with BM25 sampling.
            We utlise easy and practical elasticsearch (https://www.elastic.co/) for BM25 sampling.
            
            Installations:
            For this example, elasticsearch to be   
            sentence-transformers - train sts indomain semantic
            Pythondot img6Lines of Code : 116dot img6License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            """
            The script shows how to train Augmented SBERT (In-Domain) strategy for STSb dataset with Semantic Search Sampling.
            
            
            Methodology:
            Three steps are followed for AugSBERT data-augmentation strategy with Semantic Search - 
                1. Fine-tune cross-enco  

            Community Discussions

            QUESTION

            ValueError: Unrecognized model in ./MRPC/. Should have a `model_type` key in its config.json, or contain one of the following strings in its name
            Asked 2022-Jan-13 at 14:10

            Goal: Amend this Notebook to work with Albert and Distilbert models

            Kernel: conda_pytorch_p36. I did Restart & Run All, and refreshed file view in working directory.

            Error occurs in Section 1.2, only for these 2 new models.

            For filenames etc., I've created a variable used everywhere:

            ...

            ANSWER

            Answered 2022-Jan-13 at 14:10
            Explanation:

            When instantiating AutoModel, you must specify a model_type parameter in ./MRPC/config.json file (downloaded during Notebook runtime).

            List of model_types can be found here.

            Solution:

            Code that appends model_type to config.json, in the same format:

            Source https://stackoverflow.com/questions/70697470

            QUESTION

            Spacy-Transformers: Access GPT-2?
            Asked 2021-Aug-28 at 05:16

            I'm using Spacy-Transformers to build some NLP models.

            The Spacy-Transformers docs say:

            spacy-transformers

            spaCy pipelines for pretrained BERT, XLNet and GPT-2

            The sample code on that page shows:

            ...

            ANSWER

            Answered 2021-Aug-28 at 05:16

            The en_core_web_trf uses a specific Transformers model, but you can specify arbitrary ones using the TransformerModel wrapper class from spacy-transformers. See the docs for that. An example config:

            Source https://stackoverflow.com/questions/68946827

            QUESTION

            Extracting embedding values of NLP pertained models from tokenized strings
            Asked 2021-Aug-18 at 13:40

            I am using huggingface pipeline to extract embeddings of words in a sentence. As far as I know, first a sentence will be turned into a tokenized strings. I think the length of the tokenized string might not be equal to the number of words in the original sentence. I need to retrieve word embedding of a particular sentence.

            For example, here is my code:

            ...

            ANSWER

            Answered 2021-Aug-18 at 08:10

            As you may know, huggingface tokenizer contains frequent subwords as well as complete ones. So if you are willing to extract word embeddings for some tokens you should consider that may contain more than one vector! In addition, huggingface pipelines encode input sentences at the first steps and this would be performed by adding special tokens to beginning & end of the actual sentence.

            Source https://stackoverflow.com/questions/68812870

            QUESTION

            RuntimeError: shape '[4, 512]' is invalid for input of size 1024 while while evaluating test data
            Asked 2021-Aug-06 at 08:30

            I am trying XLnet over Jigsaw toxic dataset.

            When I train my data with

            ...

            ANSWER

            Answered 2021-Aug-06 at 08:21

            I think the problem is that the training dataset's d['input_ids'] was of size 4*512 = 2048 so it could be divided into 4 and 512. But the testing dataset's d['input_ids'] is of size 1024, which cannot be divided into 4 and 512.

            Since you haven't given the model description, i can't say if you should change it to (-1, 512) or (4, -1) [using -1 in reshape tells numpy to figure that dimension out automatically.

            e.g. reshaping an array of 2048 elements into (4, 512) can be done by reshape(4,512) and reshape(-1, 512) and reshape(4, -1) as well.

            Source https://stackoverflow.com/questions/68678278

            QUESTION

            AttributeError: 'NoneType' object has no attribute 'tokenize'
            Asked 2021-Jun-01 at 11:20

            I am trying to use XLNET through transformers. however i keep getting the issue "AttributeError: 'NoneType' object has no attribute 'tokenize'". I am unsure of how to proceed. if anyone could point me in the right direction it would be appreciated.

            ...

            ANSWER

            Answered 2021-Jun-01 at 11:20

            QUESTION

            BERT to XLNET train model
            Asked 2021-May-17 at 21:16

            I'm trying to do something like this in XLNet but I can't find this part in the documentation, any help would be valuable, thanks!

            ...

            ANSWER

            Answered 2021-May-17 at 21:16

            To solve this, let's first see what exactly hides behind the bert.bert property. For this, we can inspect the source code of the library for the TFBertModel class. There, we can see that it is defined as

            Source https://stackoverflow.com/questions/67564014

            QUESTION

            Using XLNet for sentiment analysis - setting the correct reshape parameters
            Asked 2021-Feb-24 at 23:07

            Following this link, I am trying to use my own data to do sentiment analysis. But I get this error:

            ...

            ANSWER

            Answered 2021-Feb-01 at 05:28

            However you haven't posted your sample data but it is evident that how you are using your reshape function. With respect to your question to reshape d["input_ids"] into shape (4,64) then d["input_ids"] should be an array of size 256 but actually in your dataset which you are feeding the model with is of size 64

            So you need to reshape d["input_ids"] with something like (1,64) or (2,32) or (4,16) etc as per how your data is, whose multiple is 64.

            Just illustrate the same:

            Source https://stackoverflow.com/questions/65852264

            QUESTION

            OSError: Can't load tokenizer
            Asked 2021-Feb-20 at 16:21

            I want to train an XLNET language model from scratch. First, I have trained a tokenizer as follows:

            ...

            ANSWER

            Answered 2021-Feb-20 at 16:21

            QUESTION

            Errors appear when training an XLNET model
            Asked 2021-Feb-18 at 12:33

            I am trying to train an XLNET model as the following. I want to set the hyperparameters by myself without using any pretrained models.

            ...

            ANSWER

            Answered 2021-Feb-18 at 12:33

            You should use a TFRecord dataset instead of a text file.

            Source https://stackoverflow.com/questions/66207138

            QUESTION

            H20 Driverless AI, Not able to load custom recipe
            Asked 2021-Feb-09 at 05:36

            I am using H2O DAI 1.9.0.6. I am tring to load custom recipe (BERT pretained model using custom recipe) on Expert settings. I am using local file to upload. However upload is not happning. No error, no progress nothing. After that activity I am not able to see this model under RECIPE tab.

            Took Sample Recipe from below URL and Modified for my need. Thanks for the person who created this Recipe.

            https://github.com/h2oai/driverlessai-recipes/blob/master/models/nlp/portuguese_bert.py

            Custom Recipe

            ...

            ANSWER

            Answered 2021-Feb-08 at 02:28

            Check that your custom recipe has is_enabled() returning True.

            Source https://stackoverflow.com/questions/66058403

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install xlnet

            You can install using 'pip install xlnet' or download it from GitHub, PyPI.
            You can use xlnet like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/zihangdai/xlnet.git

          • CLI

            gh repo clone zihangdai/xlnet

          • sshUrl

            git@github.com:zihangdai/xlnet.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Natural Language Processing Libraries

            transformers

            by huggingface

            funNLP

            by fighting41love

            bert

            by google-research

            jieba

            by fxsjy

            Python

            by geekcomputers

            Try Top Libraries by zihangdai

            mos

            by zihangdaiPython

            cegan_iclr2017

            by zihangdaiPython

            reexamine-srnn

            by zihangdaiPython

            ERAC-VAML

            by zihangdaiPython

            pytorch_xworld

            by zihangdaiPython