Tuesday, May 31, 2022

RuntimeError for input token sequence longer than 512 tokens for BERT



import transformers as ppb
import torch
import numpy as np
print(ppb.__version__)



4.19.2



input_sentence_1 = "In recent years, a lot of hype has developed around the promise of neural networks and their ability to classify and identify input data, and more recently the ability of certain network architectures to generate original content. Companies large and small are using them for everything from image captioning and self-driving car navigation to identifying solar panels from satellite images and recognizing faces in security camera videos. And luckily for us, many NLP applications of neural nets exist as well. While deep neural networks have inspired a lot of hype and hyperbole, our robot overlords are probably further off than any clickbait cares to admit. Neural networks are, however, quite powerful tools, and you can easily use them in an NLP chatbot pipeline to classify input text, summarize documents, and even generate novel works. This chapter is intended as a primer for those with no experience in neural networks. We don’t cover anything specific to NLP in this chapter, but gaining a basic understanding of what is going on under the hood in a neural network is important for the upcoming chapters. If you’re familiar with the basics of a neural network, you can rest easy in skipping ahead to the next chapter, where you dive back into processing text with the various flavors of neural nets. Although the mathematics of the underlying algorithm, backpropagation, are outside this book’s scope, a high-level grasp of its basic functionality will help you understand language and the patterns hidden within. As the availability of processing power and memory has exploded over the course of the decade, an old technology has come into its own again. First proposed in the 1950s by Frank Rosenblatt, the perceptron1 offered a novel algorithm for finding patterns in data. The basic concept lies in a rough mimicry of the operation of a living neuron cell. As electrical signals flow into the cell through the dendrites (see figure 5.1) into the nucleus, an electric charge begins to build up. When the cell reaches a certain level of charge, it fires, sending an electrical signal out through the axon. However, the dendrites aren’t all created equal. The cell is more “sensitive” to signals through certain dendrites than others, so it takes less of a signal in those paths to fire the axon."
print(input_sentence_1)
print("Char count", len(input_sentence_1))
print("Word Count:", len(input_sentence_1.split(" ")))



In recent years, a lot of hype has developed around the promise of neural networks and their ability to classify and identify input data, and more recently the ability of certain network architectures to generate original content. Companies large and small are using them for everything from image captioning and self-driving car navigation to identifying solar panels from satellite images and recognizing faces in security camera videos. And luckily for us, many NLP applications of neural nets exist as well. While deep neural networks have inspired a lot of hype and hyperbole, our robot overlords are probably further off than any clickbait cares to admit. Neural networks are, however, quite powerful tools, and you can easily use them in an NLP chatbot pipeline to classify input text, summarize documents, and even generate novel works. This chapter is intended as a primer for those with no experience in neural networks. We don’t cover anything specific to NLP in this chapter, but gaining a basic understanding of what is going on under the hood in a neural network is important for the upcoming chapters. If you’re familiar with the basics of a neural network, you can rest easy in skipping ahead to the next chapter, where you dive back into processing text with the various flavors of neural nets. Although the mathematics of the underlying algorithm, backpropagation, are outside this book’s scope, a high-level grasp of its basic functionality will help you understand language and the patterns hidden within. As the availability of processing power and memory has exploded over the course of the decade, an old technology has come into its own again. First proposed in the 1950s by Frank Rosenblatt, the perceptron1 offered a novel algorithm for finding patterns in data. The basic concept lies in a rough mimicry of the operation of a living neuron cell. As electrical signals flow into the cell through the dendrites (see figure 5.1) into the nucleus, an electric charge begins to build up. When the cell reaches a certain level of charge, it fires, sending an electrical signal out through the axon. However, the dendrites aren’t all created equal. The cell is more “sensitive” to signals through certain dendrites than others, so it takes less of a signal in those paths to fire the axon.
Char count 2309
Word Count: 382



input_sentence_2 = "The biology that controls these relationships is most certainly beyond the scope of this book, but the key concept to notice here is the way the cell weights incoming signals when deciding when to fire. The neuron will dynamically change those weights in the decision making process over the course of its life. You are going to mimic that process. Rosenblatt’s original project was to teach a machine to recognize images. The original perceptron was a conglomeration of photo-receptors and potentiometers, not a computer in the current sense. But implementation specifics aside, Rosenblatt’s concept was to take the features of an image and assign a weight, a measure of importance, to each one. The features of the input image were each a small subsection of the image. A grid of photo-receptors would be exposed to the image. Each receptor would see one small piece of the image. The brightness of the image that a particular photoreceptor could see would determine the strength of the signal that it would send to the associated “dendrite.” Each dendrite had an associated weight in the form of a potentiometer. Once enough signal came in, it would pass the signal into the main body of the “nucleus” of the “cell.” Once enough of those signals from all the potentiometers passed a certain threshold, the perceptron would fire down its axon, indicating a positive match on the image it was presented with. If it didn’t fire for a given image, that was a negative classification match. Think “hot dog, not hot dog” or “iris setosa, not iris setosa.” So far there has been a lot of hand waving about biology and electric current and photo-receptors. Let’s pause for a second and peel out the most important parts of this concept. Basically, you’d like to take an example from a dataset, show it to an algorithm, and have the algorithm say yes or no. That’s all you’re doing so far. The first piece you need is a way to determine the features of the sample. Choosing appropriate features turns out to be a surprisingly challenging part of machine learning. In “normal” machine learning problems, like predicting home prices, your features might be square footage, last sold price, and ZIP code. Or perhaps you’d like to predict the species of a certain flower using the Iris dataset.2 In that case your features would be petal length, petal width, sepal length, and sepal width. In Rosenblatt’s experiment, the features were the intensity values of each pixel (subsections of the image), one pixel per photo receptor."
print(input_sentence_2)
print("Char count", len(input_sentence_2))
print("Word Count:", len(input_sentence_2.split(" ")))



The biology that controls these relationships is most certainly beyond the scope of this book, but the key concept to notice here is the way the cell weights incoming signals when deciding when to fire. The neuron will dynamically change those weights in the decision making process over the course of its life. You are going to mimic that process. Rosenblatt’s original project was to teach a machine to recognize images. The original perceptron was a conglomeration of photo-receptors and potentiometers, not a computer in the current sense. But implementation specifics aside, Rosenblatt’s concept was to take the features of an image and assign a weight, a measure of importance, to each one. The features of the input image were each a small subsection of the image. A grid of photo-receptors would be exposed to the image. Each receptor would see one small piece of the image. The brightness of the image that a particular photoreceptor could see would determine the strength of the signal that it would send to the associated “dendrite.” Each dendrite had an associated weight in the form of a potentiometer. Once enough signal came in, it would pass the signal into the main body of the “nucleus” of the “cell.” Once enough of those signals from all the potentiometers passed a certain threshold, the perceptron would fire down its axon, indicating a positive match on the image it was presented with. If it didn’t fire for a given image, that was a negative classification match. Think “hot dog, not hot dog” or “iris setosa, not iris setosa.” So far there has been a lot of hand waving about biology and electric current and photo-receptors. Let’s pause for a second and peel out the most important parts of this concept. Basically, you’d like to take an example from a dataset, show it to an algorithm, and have the algorithm say yes or no. That’s all you’re doing so far. The first piece you need is a way to determine the features of the sample. Choosing appropriate features turns out to be a surprisingly challenging part of machine learning. In “normal” machine learning problems, like predicting home prices, your features might be square footage, last sold price, and ZIP code. Or perhaps you’d like to predict the species of a certain flower using the Iris dataset.2 In that case your features would be petal length, petal width, sepal length, and sepal width. In Rosenblatt’s experiment, the features were the intensity values of each pixel (subsections of the image), one pixel per photo receptor.
Char count 2518
Word Count: 426



model_class, tokenizer_class, pretrained_weights = (ppb.BertModel, ppb.BertTokenizer, 'bert-base-uncased') 
tokenizer = tokenizer_class.from_pretrained(pretrained_weights)
model = model_class.from_pretrained(pretrained_weights)



Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: ['cls.seq_relationship.weight', 'cls.predictions.decoder.weight', 'cls.predictions.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.dense.bias', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.weight']
- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).



def get_embedding(in_list):
    tokenized = [tokenizer.encode(x, add_special_tokens=True) for x in in_list]
    
    max_len = 0
    for i in tokenized:
        if len(i) > max_len:
            max_len = len(i)

    padded = np.array([i + [0]*(max_len-len(i)) for i in tokenized])
    
    attention_mask = np.where(padded != 0, 1, 0)
    
    input_ids = torch.LongTensor(padded)
    attention_mask = torch.tensor(attention_mask)

    with torch.no_grad():
        last_hidden_states = model(input_ids = input_ids, attention_mask = attention_mask)
        
    features = last_hidden_states[0][:,0,:].numpy()
    return features 

string_embeddings = get_embedding([input_sentence_1, input_sentence_2])   



Token indices sequence length is longer than the specified maximum sequence length for this model (560 > 512). Running this sequence through the model will result in indexing errors

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [12], in <cell line: 1>()
----> 1 string_embeddings = get_embedding([input_sentence_1, input_sentence_2])

Input In [11], in get_embedding(in_list)
        14 attention_mask = torch.tensor(attention_mask)
        16 with torch.no_grad():
---> 17     last_hidden_states = model(input_ids = input_ids, attention_mask = attention_mask)
        19 features = last_hidden_states[0][:,0,:].numpy()
        20 return features

File E:\programfiles\Anaconda3\envs\transformers\lib\site-packages\torch\nn\modules\module.py:1102, in Module._call_impl(self, *input, **kwargs)
    1098 # If we don't have any hooks, we want to skip the rest of the logic in
    1099 # this function, and just call forward.
    1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
    1101         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102     return forward_call(*input, **kwargs)
    1103 # Do not call functions when jit is used
    1104 full_backward_hooks, non_full_backward_hooks = [], []

File E:\programfiles\Anaconda3\envs\transformers\lib\site-packages\transformers\models\bert\modeling_bert.py:983, in BertModel.forward(self, input_ids, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, encoder_hidden_states, encoder_attention_mask, past_key_values, use_cache, output_attentions, output_hidden_states, return_dict)
    981 if hasattr(self.embeddings, "token_type_ids"):
    982     buffered_token_type_ids = self.embeddings.token_type_ids[:, :seq_length]
--> 983     buffered_token_type_ids_expanded = buffered_token_type_ids.expand(batch_size, seq_length)
    984     token_type_ids = buffered_token_type_ids_expanded
    985 else:

RuntimeError: The expanded size of the tensor (560) must match the existing size (512) at non-singleton dimension 1.  Target sizes: [2, 560].  Tensor sizes: [1, 512]



Tags: Machine Learning, Natural Language Processing, Python, Technology

Maximum input length test for BertTokenizer



import transformers as ppb
import torch
import numpy as np

print(ppb.__version__)




4.19.2



input_sentence_1 = "In recent years, a lot of hype has developed around the promise of neural networks and their ability to classify and identify input data, and more recently the ability of certain network architectures to generate original content. Companies large and small are using them for everything from image captioning and self-driving car navigation to identifying solar panels from satellite images and recognizing faces in security camera videos. And luckily for us, many NLP applications of neural nets exist as well. While deep neural networks have inspired a lot of hype and hyperbole, our robot overlords are probably further off than any clickbait cares to admit. Neural networks are, however, quite powerful tools, and you can easily use them in an NLP chatbot pipeline to classify input text, summarize documents, and even generate novel works. This chapter is intended as a primer for those with no experience in neural networks. We don’t cover anything specific to NLP in this chapter, but gaining a basic understanding of what is going on under the hood in a neural network is important for the upcoming chapters. If you’re familiar with the basics of a neural network, you can rest easy in skipping ahead to the next chapter, where you dive back into processing text with the various flavors of neural nets. Although the mathematics of the underlying algorithm, backpropagation, are outside this book’s scope, a high-level grasp of its basic functionality will help you understand language and the patterns hidden within. As the availability of processing power and memory has exploded over the course of the decade, an old technology has come into its own again. First proposed in the 1950s by Frank Rosenblatt, the perceptron1 offered a novel algorithm for finding patterns in data. The basic concept lies in a rough mimicry of the operation of a living neuron cell. As electrical signals flow into the cell through the dendrites (see figure 5.1) into the nucleus, an electric charge begins to build up. When the cell reaches a certain level of charge, it fires, sending an electrical signal out through the axon. However, the dendrites aren’t all created equal. The cell is more “sensitive” to signals through certain dendrites than others, so it takes less of a signal in those paths to fire the axon. The biology that controls these relationships is most certainly beyond the scope of this book, but the key concept to notice here is the way the cell weights incoming signals when deciding when to fire. The neuron will dynamically change those weights in the decision making process over the course of its life. You are going to mimic that process."
print(input_sentence_1)
print("Char count", len(input_sentence_1))
print("Word Count:", len(input_sentence_1.split(" ")))



In recent years, a lot of hype has developed around the promise of neural networks and their ability to classify and identify input data, and more recently the ability of certain network architectures to generate original content. Companies large and small are using them for everything from image captioning and self-driving car navigation to identifying solar panels from satellite images and recognizing faces in security camera videos. And luckily for us, many NLP applications of neural nets exist as well. While deep neural networks have inspired a lot of hype and hyperbole, our robot overlords are probably further off than any clickbait cares to admit. Neural networks are, however, quite powerful tools, and you can easily use them in an NLP chatbot pipeline to classify input text, summarize documents, and even generate novel works. This chapter is intended as a primer for those with no experience in neural networks. We don’t cover anything specific to NLP in this chapter, but gaining a basic understanding of what is going on under the hood in a neural network is important for the upcoming chapters. If you’re familiar with the basics of a neural network, you can rest easy in skipping ahead to the next chapter, where you dive back into processing text with the various flavors of neural nets. Although the mathematics of the underlying algorithm, backpropagation, are outside this book’s scope, a high-level grasp of its basic functionality will help you understand language and the patterns hidden within. As the availability of processing power and memory has exploded over the course of the decade, an old technology has come into its own again. First proposed in the 1950s by Frank Rosenblatt, the perceptron1 offered a novel algorithm for finding patterns in data. The basic concept lies in a rough mimicry of the operation of a living neuron cell. As electrical signals flow into the cell through the dendrites (see figure 5.1) into the nucleus, an electric charge begins to build up. When the cell reaches a certain level of charge, it fires, sending an electrical signal out through the axon. However, the dendrites aren’t all created equal. The cell is more “sensitive” to signals through certain dendrites than others, so it takes less of a signal in those paths to fire the axon. The biology that controls these relationships is most certainly beyond the scope of this book, but the key concept to notice here is the way the cell weights incoming signals when deciding when to fire. The neuron will dynamically change those weights in the decision making process over the course of its life. You are going to mimic that process.
Char count 2658
Word Count: 442



model_class, tokenizer_class, pretrained_weights = (ppb.BertModel, ppb.BertTokenizer, 'bert-base-uncased') 



tokenizer = tokenizer_class.from_pretrained(pretrained_weights)
model = model_class.from_pretrained(pretrained_weights)



Some weights of the model checkpoint at bert-base-uncased were not used when initializing BertModel: [
'cls.predictions.transform.LayerNorm.bias', 
'cls.seq_relationship.bias', 
'cls.seq_relationship.weight', 
'cls.predictions.transform.dense.bias', 
'cls.predictions.bias', 
'cls.predictions.decoder.weight', 
'cls.predictions.transform.LayerNorm.weight', 
'cls.predictions.transform.dense.weight'
]

- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).

- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).



tokenized = tokenizer.encode(input_sentence_1, add_special_tokens=True)



Token indices sequence length is longer than the specified maximum sequence length for this model (543 > 512). Running this sequence through the model will result in indexing errors



print("First ten tokens:", tokenized[:10])
print("Number of tokens:", len(tokenized))



First ten tokens: [101, 1999, 3522, 2086, 1010, 1037, 2843, 1997, 1044, 18863]
Number of tokens: 543

Tags: Technology,Machine Learning,Natural Language Processing,Python,

Alternate env.yml file for installing Python Package 'transformers' for BERT

ENV.YML FILE:

name: transformers channels: - conda-forge dependencies: - python=3.9 - pip - pandas - openpyxl - ipykernel - jupyter - tensorflow - pip: - transformers (base) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter>conda env create -f env.yml Collecting package metadata (repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.11.0 latest version: 4.12.0 Please update conda by running $ conda update -n base conda Downloading and Extracting Packages pyrsistent-0.18.1 | 85 KB | #### | 100% filelock-3.7.0 | 12 KB | #### | 100% tensorboard-plugin-w | 668 KB | #### | 100% aiohttp-3.8.1 | 545 KB | #### | 100% libcblas-3.9.0 | 4.5 MB | #### | 100% ipywidgets-7.7.0 | 103 KB | #### | 100% astunparse-1.6.3 | 15 KB | #### | 100% click-8.1.3 | 146 KB | #### | 100% bleach-5.0.0 | 123 KB | #### | 100% abseil-cpp-20210324. | 2.1 MB | #### | 100% requests-oauthlib-1. | 22 KB | #### | 100% tensorflow-2.6.0 | 4 KB | #### | 100% cryptography-37.0.2 | 1.1 MB | #### | 100% soupsieve-2.3.1 | 33 KB | #### | 100% tokenizers-0.12.1 | 3.1 MB | #### | 100% google-auth-oauthlib | 19 KB | #### | 100% libblas-3.9.0 | 4.5 MB | #### | 100% libprotobuf-3.14.0 | 2.3 MB | #### | 100% nbformat-5.4.0 | 104 KB | #### | 100% zeromq-4.3.4 | 8.9 MB | #### | 100% pywinpty-2.0.5 | 224 KB | #### | 100% attrs-21.4.0 | 49 KB | #### | 100% entrypoints-0.4 | 9 KB | #### | 100% libssh2-1.10.0 | 227 KB | #### | 100% markdown-3.3.7 | 67 KB | #### | 100% cachetools-4.2.4 | 12 KB | #### | 100% hdf5-1.12.1 | 23.0 MB | #### | 100% idna-3.3 | 55 KB | #### | 100% argon2-cffi-21.3.0 | 15 KB | #### | 100% mkl-2021.4.0 | 181.7 MB | #### | 100% wrapt-1.14.1 | 49 KB | #### | 100% nest-asyncio-1.5.5 | 9 KB | #### | 100% prompt-toolkit-3.0.2 | 252 KB | #### | 100% python-fastjsonschem | 243 KB | #### | 100% ca-certificates-2022 | 180 KB | #### | 100% libzlib-1.2.12 | 67 KB | #### | 100% beautifulsoup4-4.11. | 96 KB | #### | 100% openssl-1.1.1o | 5.7 MB | #### | 100% aiosignal-1.2.0 | 12 KB | #### | 100% jupyterlab_pygments- | 17 KB | #### | 100% jupyter_client-7.3.1 | 90 KB | #### | 100% qtconsole-base-5.3.0 | 90 KB | #### | 100% asttokens-2.0.5 | 21 KB | #### | 100% yarl-1.7.2 | 127 KB | #### | 100% argon2-cffi-bindings | 34 KB | #### | 100% tensorboard-data-ser | 12 KB | #### | 100% terminado-0.15.0 | 28 KB | #### | 100% flit-core-3.7.1 | 44 KB | #### | 100% joblib-1.1.0 | 210 KB | #### | 100% _tflow_select-2.3.0 | 3 KB | #### | 100% prometheus_client-0. | 49 KB | #### | 100% scipy-1.8.1 | 27.2 MB | #### | 100% nbconvert-pandoc-6.5 | 4 KB | #### | 100% werkzeug-2.1.2 | 237 KB | #### | 100% pandoc-2.18 | 18.1 MB | #### | 100% libcurl-7.83.1 | 303 KB | #### | 100% pytorch-1.10.2 | 200.0 MB | #### | 100% keras-preprocessing- | 34 KB | #### | 100% nbconvert-core-6.5.0 | 425 KB | #### | 100% flatbuffers-2.0.6 | 1.9 MB | #### | 100% matplotlib-inline-0. | 11 KB | #### | 100% sacremoses-0.0.53 | 427 KB | #### | 100% tzdata-2022a | 121 KB | #### | 100% cffi-1.15.0 | 229 KB | #### | 100% jupyter-1.0.0 | 7 KB | #### | 100% tornado-6.1 | 651 KB | #### | 100% krb5-1.19.3 | 847 KB | #### | 100% requests-2.27.1 | 53 KB | #### | 100% tensorboard-2.6.0 | 5.0 MB | #### | 100% pyjwt-2.4.0 | 19 KB | #### | 100% multidict-6.0.2 | 47 KB | #### | 100% pyzmq-23.0.0 | 456 KB | #### | 100% pytz-2022.1 | 242 KB | #### | 100% rsa-4.8 | 31 KB | #### | 100% transformers-4.19.2 | 2.0 MB | #### | 100% pycparser-2.21 | 100 KB | #### | 100% libuv-1.43.0 | 365 KB | #### | 100% mkl-service-2.4.0 | 52 KB | #### | 100% jupyter_core-4.10.0 | 105 KB | #### | 100% decorator-5.1.1 | 12 KB | #### | 100% pyparsing-3.0.9 | 79 KB | #### | 100% grpcio-1.46.3 | 2.0 MB | #### | 100% jedi-0.18.1 | 994 KB | #### | 100% icu-68.2 | 16.4 MB | #### | 100% jpeg-9e | 348 KB | #### | 100% dataclasses-0.8 | 10 KB | #### | 100% pysocks-1.7.1 | 28 KB | #### | 100% huggingface_hub-0.7. | 65 KB | #### | 100% yaml-0.2.5 | 62 KB | #### | 100% future-0.18.2 | 742 KB | #### | 100% intel-openmp-2022.1. | 3.7 MB | #### | 100% openpyxl-3.0.9 | 153 KB | #### | 100% traitlets-5.2.1.post | 85 KB | #### | 100% tinycss2-1.1.1 | 23 KB | #### | 100% markupsafe-2.1.1 | 25 KB | #### | 100% jinja2-3.1.2 | 99 KB | #### | 100% numpy-1.22.4 | 6.1 MB | #### | 100% ninja-1.11.0 | 300 KB | #### | 100% brotlipy-0.7.0 | 329 KB | #### | 100% tqdm-4.64.0 | 81 KB | #### | 100% qtpy-2.1.0 | 43 KB | #### | 100% certifi-2022.5.18.1 | 151 KB | #### | 100% pure_eval-0.2.2 | 14 KB | #### | 100% sqlite-3.38.5 | 1.3 MB | #### | 100% tbb-2021.5.0 | 148 KB | #### | 100% protobuf-3.14.0 | 261 KB | #### | 100% python-3.9.13 | 17.9 MB | #### | 100% mistune-0.8.4 | 55 KB | #### | 100% tensorflow-estimator | 288 KB | #### | 100% async-timeout-4.0.2 | 9 KB | #### | 100% oauthlib-3.2.0 | 90 KB | #### | 100% importlib_metadata-4 | 4 KB | #### | 100% h5py-3.6.0 | 1.1 MB | #### | 100% nbconvert-6.5.0 | 6 KB | #### | 100% typing-extensions-4. | 8 KB | #### | 100% tensorflow-base-2.6. | 110.3 MB | #### | 100% pyopenssl-22.0.0 | 49 KB | #### | 100% importlib-metadata-4 | 33 KB | #### | 100% jsonschema-4.5.1 | 57 KB | #### | 100% prompt_toolkit-3.0.2 | 5 KB | #### | 100% pywin32-303 | 6.9 MB | #### | 100% giflib-5.2.1 | 85 KB | #### | 100% snappy-1.1.9 | 55 KB | #### | 100% win_inet_pton-1.1.0 | 9 KB | #### | 100% qtconsole-5.3.0 | 5 KB | #### | 100% frozenlist-1.3.0 | 40 KB | #### | 100% absl-py-1.0.0 | 95 KB | #### | 100% pip-22.1.1 | 1.5 MB | #### | 100% notebook-6.4.11 | 6.3 MB | #### | 100% urllib3-1.26.9 | 100 KB | #### | 100% debugpy-1.6.0 | 3.2 MB | #### | 100% stack_data-0.2.0 | 21 KB | #### | 100% ipykernel-6.13.0 | 186 KB | #### | 100% cached_property-1.5. | 11 KB | #### | 100% zlib-1.2.12 | 110 KB | #### | 100% packaging-21.3 | 36 KB | #### | 100% pygments-2.12.0 | 817 KB | #### | 100% jupyterlab_widgets-1 | 133 KB | #### | 100% google-auth-1.35.0 | 81 KB | #### | 100% importlib_resources- | 22 KB | #### | 100% ipython-8.4.0 | 1.1 MB | #### | 100% pandocfilters-1.5.0 | 11 KB | #### | 100% jupyter_console-6.4. | 23 KB | #### | 100% psutil-5.9.1 | 370 KB | #### | 100% pandas-1.4.2 | 11.0 MB | #### | 100% nbclient-0.6.3 | 65 KB | #### | 100% zipp-3.8.0 | 12 KB | #### | 100% executing-0.8.3 | 18 KB | #### | 100% opt_einsum-3.3.0 | 53 KB | #### | 100% python-flatbuffers-1 | 19 KB | #### | 100% widgetsnbextension-3 | 1.2 MB | #### | 100% cached-property-1.5. | 4 KB | #### | 100% typing_extensions-4. | 27 KB | #### | 100% regex-2022.4.24 | 343 KB | #### | 100% parso-0.8.3 | 69 KB | #### | 100% setuptools-62.3.2 | 1.4 MB | #### | 100% liblapack-3.9.0 | 4.5 MB | #### | 100% charset-normalizer-2 | 35 KB | #### | 100% pyqt-5.12.3 | 4.8 MB | #### | 100% pyyaml-6.0 | 154 KB | #### | 100% blinker-1.4 | 13 KB | #### | 100% pyu2f-0.1.5 | 31 KB | #### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: / Enabling notebook extension jupyter-js-widgets/extension... - Validating: ok done # # To activate this environment, use # # $ conda activate transformers # # To deactivate an active environment, use # # $ conda deactivate (base) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter> (base) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter>conda activate transformers (transformers) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter>python -m ipykernel install --user --name transformers Installed kernelspec transformers in C:\Users\Ashish Jain\AppData\Roaming\jupyter\kernels\transformers
Tags: Technology,Artificial Intelligence,Machine Learning,Natural Language Processing,Python,

Monday, May 30, 2022

Installing Python Package 'transformers' for BERT

TRIAL 1: Failure

Using Conda Prompt: conda install -c huggingface transformers Using YAML file: name: transformers channels: - conda-forge dependencies: - pip - pip: - transformers LOGS: (base) C:\Users\ash\Desktop>conda env create -f env.yml Collecting package metadata (repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.12.0 latest version: 4.13.0 Please update conda by running $ conda update -n base -c defaults conda Downloading and Extracting Packages libzlib-1.2.12 | 67 KB | #### | 100% setuptools-62.3.2 | 1.4 MB | #### | 100% xz-5.2.5 | 211 KB | #### | 100% libffi-3.4.2 | 41 KB | #### | 100% bzip2-1.0.8 | 149 KB | #### | 100% tzdata-2022a | 121 KB | #### | 100% ucrt-10.0.20348.0 | 1.2 MB | #### | 100% vc-14.2 | 13 KB | #### | 100% tk-8.6.12 | 3.5 MB | #### | 100% python_abi-3.10 | 4 KB | #### | 100% sqlite-3.38.5 | 1.3 MB | #### | 100% vs2015_runtime-14.29 | 1.3 MB | #### | 100% wheel-0.37.1 | 31 KB | #### | 100% openssl-3.0.3 | 10.0 MB | #### | 100% ca-certificates-2022 | 180 KB | #### | 100% python-3.10.4 | 16.2 MB | #### | 100% pip-22.1.1 | 1.5 MB | #### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done Installing pip dependencies: \ Ran pip subprocess with arguments: ['C:\\Users\\ash\\Anaconda3\\envs\\transformers\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Users\\ash\\Desktop\\condaenv.xzuashl6.requirements.txt'] Pip subprocess output: Collecting transformers Downloading transformers-4.19.2-py3-none-any.whl (4.2 MB) ---------------------------------------- 4.2/4.2 MB 2.6 MB/s eta 0:00:00 Collecting tqdm>=4.27 Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB) ---------------------------------------- 78.4/78.4 kB 1.1 MB/s eta 0:00:00 Collecting pyyaml>=5.1 Downloading PyYAML-6.0-cp310-cp310-win_amd64.whl (151 kB) -------------------------------------- 151.7/151.7 kB 1.8 MB/s eta 0:00:00 Collecting regex!=2019.12.17 Downloading regex-2022.4.24-cp310-cp310-win_amd64.whl (262 kB) -------------------------------------- 262.0/262.0 kB 3.2 MB/s eta 0:00:00 Collecting requests Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB) ---------------------------------------- 63.1/63.1 kB 3.3 MB/s eta 0:00:00 Collecting numpy>=1.17 Downloading numpy-1.22.4-cp310-cp310-win_amd64.whl (14.7 MB) ---------------------------------------- 14.7/14.7 MB 2.9 MB/s eta 0:00:00 Collecting packaging>=20.0 Downloading packaging-21.3-py3-none-any.whl (40 kB) -------------------------------------- 40.8/40.8 kB 984.2 kB/s eta 0:00:00 Collecting tokenizers!=0.11.3,<0.13,>=0.11.1 Downloading tokenizers-0.12.1-cp310-cp310-win_amd64.whl (3.3 MB) ---------------------------------------- 3.3/3.3 MB 2.4 MB/s eta 0:00:00 Collecting filelock Downloading filelock-3.7.0-py3-none-any.whl (10 kB) Collecting huggingface-hub<1.0,>=0.1.0 Downloading huggingface_hub-0.7.0-py3-none-any.whl (86 kB) ---------------------------------------- 86.2/86.2 kB 1.2 MB/s eta 0:00:00 Collecting typing-extensions>=3.7.4.3 Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB) Collecting pyparsing!=3.0.5,>=2.0.2 Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB) ---------------------------------------- 98.3/98.3 kB 1.9 MB/s eta 0:00:00 Collecting colorama Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB) Collecting certifi>=2017.4.17 Downloading certifi-2022.5.18.1-py3-none-any.whl (155 kB) -------------------------------------- 155.2/155.2 kB 2.3 MB/s eta 0:00:00 Collecting charset-normalizer~=2.0.0 Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB) Collecting urllib3<1.27,>=1.21.1 Downloading urllib3-1.26.9-py2.py3-none-any.whl (138 kB) -------------------------------------- 139.0/139.0 kB 2.1 MB/s eta 0:00:00 Collecting idna<4,>=2.5 Downloading idna-3.3-py3-none-any.whl (61 kB) ---------------------------------------- 61.2/61.2 kB 1.6 MB/s eta 0:00:00 Installing collected packages: tokenizers, urllib3, typing-extensions, regex, pyyaml, pyparsing, numpy, idna, filelock, colorama, charset-normalizer, certifi, tqdm, requests, packaging, huggingface-hub, transformers Successfully installed certifi-2022.5.18.1 charset-normalizer-2.0.12 colorama-0.4.4 filelock-3.7.0 huggingface-hub-0.7.0 idna-3.3 numpy-1.22.4 packaging-21.3 pyparsing-3.0.9 pyyaml-6.0 regex-2022.4.24 requests-2.27.1 tokenizers-0.12.1 tqdm-4.64.0 transformers-4.19.2 typing-extensions-4.2.0 urllib3-1.26.9 done # # To activate this environment, use # # $ conda activate transformers # # To deactivate an active environment, use # # $ conda deactivate (base) C:\Users\ash\Desktop> -------------------------------------------- (base) C:\Users\ash\Desktop>conda activate transformers (transformers) C:\Users\ash\Desktop>pip install ipykernel jupyter (transformers) C:\Users\ash\Desktop>python -m ipykernel install --user --name transformers Installed kernelspec transformers in C:\Users\ash\AppData\Roaming\jupyter\kernels\transformers -------------------------------------------- TESTING IN PYTHON: >>> import transformers as ppb None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used. -------------------------------------- (transformers) C:\Users\ash>conda install -c conda-forge tensorflow Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: - Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort.\ failed UnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your environment: Specifications: - tensorflow -> python[version='3.5.*|3.6.*|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.8.*|3.7.*|3.9.*'] Your python: python=3.10 If python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that. -------------------------------------

TRIAL 2: Success

$ conda env remove -n transformers --all ENV.YML: name: transformers channels: - conda-forge dependencies: - python=3.9 - pip - pandas - pip: - transformers - tensorflow ALTERNATIVE (NOT TRIED) ENV.YML FILE: name: transformers channels: - conda-forge dependencies: - python=3.9 - pip - pandas - openpyxl - ipykernel - jupyter - tensorflow - pip: - transformers LOGS: (base) C:\Users\ash\Desktop>conda env create -f env.yml Collecting package metadata (repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.12.0 latest version: 4.13.0 Please update conda by running $ conda update -n base -c defaults conda Downloading and Extracting Packages setuptools-62.3.2 | 1.4 MB | #### | 100% python-3.9.13 | 17.9 MB | #### | 100% python_abi-3.9 | 4 KB | #### | 100% pandas-1.4.2 | 11.0 MB | #### | 100% numpy-1.22.4 | 6.1 MB | #### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done Installing pip dependencies: / Ran pip subprocess with arguments: ['C:\\Users\\ash\\Anaconda3\\envs\\transformers\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'C:\\Users\\ash\\Desktop\\condaenv.m0blf3oh.requirements.txt'] Pip subprocess output: Collecting transformers Using cached transformers-4.19.2-py3-none-any.whl (4.2 MB) Collecting tensorflow Downloading tensorflow-2.9.1-cp39-cp39-win_amd64.whl (444.0 MB) -------------------------------------- 444.0/444.0 MB 1.7 MB/s eta 0:00:00 Collecting requests Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB) Collecting regex!=2019.12.17 Downloading regex-2022.4.24-cp39-cp39-win_amd64.whl (262 kB) -------------------------------------- 262.1/262.1 kB 2.7 MB/s eta 0:00:00 Collecting tokenizers!=0.11.3,<0.13,>=0.11.1 Downloading tokenizers-0.12.1-cp39-cp39-win_amd64.whl (3.3 MB) ---------------------------------------- 3.3/3.3 MB 3.0 MB/s eta 0:00:00 Collecting filelock Using cached filelock-3.7.0-py3-none-any.whl (10 kB) Collecting pyyaml>=5.1 Downloading PyYAML-6.0-cp39-cp39-win_amd64.whl (151 kB) -------------------------------------- 151.6/151.6 kB 3.0 MB/s eta 0:00:00 Collecting tqdm>=4.27 Using cached tqdm-4.64.0-py2.py3-none-any.whl (78 kB) Collecting packaging>=20.0 Using cached packaging-21.3-py3-none-any.whl (40 kB) Collecting huggingface-hub<1.0,>=0.1.0 Using cached huggingface_hub-0.7.0-py3-none-any.whl (86 kB) Requirement already satisfied: numpy>=1.17 in c:\users\ash\anaconda3\envs\transformers\lib\site-packages (from transformers->-r C:\Users\ash\Desktop\condaenv.m0blf3oh.requirements.txt (line 1)) (1.22.4) Requirement already satisfied: six>=1.12.0 in c:\users\ash\anaconda3\envs\transformers\lib\site-packages (from tensorflow->-r C:\Users\ash\Desktop\condaenv.m0blf3oh.requirements.txt (line 2)) (1.16.0) Collecting termcolor>=1.1.0 Downloading termcolor-1.1.0.tar.gz (3.9 kB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Collecting tensorflow-io-gcs-filesystem>=0.23.1 Downloading tensorflow_io_gcs_filesystem-0.26.0-cp39-cp39-win_amd64.whl (1.5 MB) ---------------------------------------- 1.5/1.5 MB 3.0 MB/s eta 0:00:00 Collecting protobuf<3.20,>=3.9.2 Downloading protobuf-3.19.4-cp39-cp39-win_amd64.whl (895 kB) -------------------------------------- 895.7/895.7 kB 2.0 MB/s eta 0:00:00 Collecting absl-py>=1.0.0 Downloading absl_py-1.0.0-py3-none-any.whl (126 kB) -------------------------------------- 126.7/126.7 kB 1.1 MB/s eta 0:00:00 Collecting typing-extensions>=3.6.6 Using cached typing_extensions-4.2.0-py3-none-any.whl (24 kB) Collecting libclang>=13.0.0 Downloading libclang-14.0.1-py2.py3-none-win_amd64.whl (14.2 MB) -------------------------------------- 14.2/14.2 MB 701.7 kB/s eta 0:00:00 Collecting astunparse>=1.6.0 Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB) Collecting google-pasta>=0.1.1 Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB) ---------------------------------------- 57.5/57.5 kB 1.5 MB/s eta 0:00:00 Requirement already satisfied: setuptools in c:\users\ash\anaconda3\envs\transformers\lib\site-packages (from tensorflow->-r C:\Users\ash\Desktop\condaenv.m0blf3oh.requirements.txt (line 2)) (62.3.2) Collecting tensorflow-estimator<2.10.0,>=2.9.0rc0 Downloading tensorflow_estimator-2.9.0-py2.py3-none-any.whl (438 kB) -------------------------------------- 438.7/438.7 kB 2.7 MB/s eta 0:00:00 Collecting tensorboard<2.10,>=2.9 Downloading tensorboard-2.9.0-py3-none-any.whl (5.8 MB) ---------------------------------------- 5.8/5.8 MB 2.9 MB/s eta 0:00:00 Collecting opt-einsum>=2.3.2 Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB) ---------------------------------------- 65.5/65.5 kB 1.2 MB/s eta 0:00:00 Collecting gast<=0.4.0,>=0.2.1 Downloading gast-0.4.0-py3-none-any.whl (9.8 kB) Collecting wrapt>=1.11.0 Downloading wrapt-1.14.1-cp39-cp39-win_amd64.whl (35 kB) Collecting grpcio<2.0,>=1.24.3 Downloading grpcio-1.46.3-cp39-cp39-win_amd64.whl (3.5 MB) ---------------------------------------- 3.5/3.5 MB 2.7 MB/s eta 0:00:00 Collecting keras-preprocessing>=1.1.1 Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB) ---------------------------------------- 42.6/42.6 kB 1.0 MB/s eta 0:00:00 Collecting h5py>=2.9.0 Downloading h5py-3.7.0-cp39-cp39-win_amd64.whl (2.6 MB) ---------------------------------------- 2.6/2.6 MB 2.8 MB/s eta 0:00:00 Collecting flatbuffers<2,>=1.12 Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB) Collecting keras<2.10.0,>=2.9.0rc0 Downloading keras-2.9.0-py2.py3-none-any.whl (1.6 MB) ---------------------------------------- 1.6/1.6 MB 2.7 MB/s eta 0:00:00 Requirement already satisfied: wheel<1.0,>=0.23.0 in c:\users\ash\anaconda3\envs\transformers\lib\site-packages (from astunparse>=1.6.0->tensorflow->-r C:\Users\ash\Desktop\condaenv.m0blf3oh.requirements.txt (line 2)) (0.37.1) Collecting pyparsing!=3.0.5,>=2.0.2 Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB) Collecting google-auth<3,>=1.6.3 Downloading google_auth-2.6.6-py2.py3-none-any.whl (156 kB) -------------------------------------- 156.7/156.7 kB 2.4 MB/s eta 0:00:00 Collecting tensorboard-plugin-wit>=1.6.0 Downloading tensorboard_plugin_wit-1.8.1-py3-none-any.whl (781 kB) -------------------------------------- 781.3/781.3 kB 3.3 MB/s eta 0:00:00 Collecting markdown>=2.6.8 Downloading Markdown-3.3.7-py3-none-any.whl (97 kB) ---------------------------------------- 97.8/97.8 kB 1.4 MB/s eta 0:00:00 Collecting tensorboard-data-server<0.7.0,>=0.6.0 Downloading tensorboard_data_server-0.6.1-py3-none-any.whl (2.4 kB) Collecting werkzeug>=1.0.1 Downloading Werkzeug-2.1.2-py3-none-any.whl (224 kB) -------------------------------------- 224.9/224.9 kB 2.3 MB/s eta 0:00:00 Collecting google-auth-oauthlib<0.5,>=0.4.1 Downloading google_auth_oauthlib-0.4.6-py2.py3-none-any.whl (18 kB) Collecting idna<4,>=2.5 Using cached idna-3.3-py3-none-any.whl (61 kB) Collecting certifi>=2017.4.17 Using cached certifi-2022.5.18.1-py3-none-any.whl (155 kB) Collecting urllib3<1.27,>=1.21.1 Using cached urllib3-1.26.9-py2.py3-none-any.whl (138 kB) Collecting charset-normalizer~=2.0.0 Using cached charset_normalizer-2.0.12-py3-none-any.whl (39 kB) Collecting colorama Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB) Collecting pyasn1-modules>=0.2.1 Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB) -------------------------------------- 155.3/155.3 kB 2.3 MB/s eta 0:00:00 Collecting cachetools<6.0,>=2.0.0 Downloading cachetools-5.2.0-py3-none-any.whl (9.3 kB) Collecting rsa<5,>=3.1.4 Downloading rsa-4.8-py3-none-any.whl (39 kB) Collecting requests-oauthlib>=0.7.0 Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB) Collecting importlib-metadata>=4.4 Downloading importlib_metadata-4.11.4-py3-none-any.whl (18 kB) Collecting zipp>=0.5 Downloading zipp-3.8.0-py3-none-any.whl (5.4 kB) Collecting pyasn1<0.5.0,>=0.4.6 Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB) ---------------------------------------- 77.1/77.1 kB 2.2 MB/s eta 0:00:00 Collecting oauthlib>=3.0.0 Downloading oauthlib-3.2.0-py3-none-any.whl (151 kB) -------------------------------------- 151.5/151.5 kB 3.0 MB/s eta 0:00:00 Building wheels for collected packages: termcolor Building wheel for termcolor (setup.py): started Building wheel for termcolor (setup.py): finished with status 'done' Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4832 sha256=34e6470d92e16cedf1b846cf239d01ce6c05ddff3b0ec5437ceff54ea7de2d15 Stored in directory: c:\users\ash\appdata\local\pip\cache\wheels\b6\0d\90\0d1bbd99855f99cb2f6c2e5ff96f8023fad8ec367695f7d72d Successfully built termcolor Installing collected packages: tokenizers, termcolor, tensorboard-plugin-wit, pyasn1, libclang, keras, flatbuffers, zipp, wrapt, werkzeug, urllib3, typing-extensions, tensorflow-io-gcs-filesystem, tensorflow-estimator, tensorboard-data-server, rsa, regex, pyyaml, pyparsing, pyasn1-modules, protobuf, opt-einsum, oauthlib, keras-preprocessing, idna, h5py, grpcio, google-pasta, gast, filelock, colorama, charset-normalizer, certifi, cachetools, astunparse, absl-py, tqdm, requests, packaging, importlib-metadata, google-auth, requests-oauthlib, markdown, huggingface-hub, transformers, google-auth-oauthlib, tensorboard, tensorflow Successfully installed absl-py-1.0.0 astunparse-1.6.3 cachetools-5.2.0 certifi-2022.5.18.1 charset-normalizer-2.0.12 colorama-0.4.4 filelock-3.7.0 flatbuffers-1.12 gast-0.4.0 google-auth-2.6.6 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.46.3 h5py-3.7.0 huggingface-hub-0.7.0 idna-3.3 importlib-metadata-4.11.4 keras-2.9.0 keras-preprocessing-1.1.2 libclang-14.0.1 markdown-3.3.7 oauthlib-3.2.0 opt-einsum-3.3.0 packaging-21.3 protobuf-3.19.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-3.0.9 pyyaml-6.0 regex-2022.4.24 requests-2.27.1 requests-oauthlib-1.3.1 rsa-4.8 tensorboard-2.9.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.9.1 tensorflow-estimator-2.9.0 tensorflow-io-gcs-filesystem-0.26.0 termcolor-1.1.0 tokenizers-0.12.1 tqdm-4.64.0 transformers-4.19.2 typing-extensions-4.2.0 urllib3-1.26.9 werkzeug-2.1.2 wrapt-1.14.1 zipp-3.8.0 done # # To activate this environment, use # # $ conda activate transformers # # To deactivate an active environment, use # # $ conda deactivate (base) C:\Users\ash\Desktop>conda activate transformers (transformers) C:\Users\ash\Desktop>conda install -c conda-forge jupyter ipykernel (transformers) C:\Users\ash\Desktop>python -m ipykernel install --user --name transformers Installed kernelspec transformers in C:\Users\ash\AppData\Roaming\jupyter\kernels\transformers

TESTING LOGS

import warnings warnings.filterwarnings('ignore') print(ppb.__version__) # 4.19.2 model_class, tokenizer_class, pretrained_weights = (ppb.BertModel, ppb.BertTokenizer, 'bert-base-uncased') tokenizer = tokenizer_class.from_pretrained(pretrained_weights) model = model_class.from_pretrained(pretrained_weights) OUTPUT: Downloading: 100% 226k/226k [00:01<00:00, 253kB/s] Downloading: 100% 28.0/28.0 [00:00<00:00, 921B/s] Downloading: 100% 570/570 [00:00<00:00, 14.5kB/s] --------------------------------------------------------------------------- ImportError Traceback (most recent call last) Input In [9], in <cell line: 2>() 1 tokenizer = tokenizer_class.from_pretrained(pretrained_weights) ----> 2 model = model_class.from_pretrained(pretrained_weights) File ~\Anaconda3\envs\transformers\lib\site-packages\transformers\utils\import_utils.py:788, in DummyObject.__getattr__(cls, key) 786 if key.startswith("_"): 787 return super().__getattr__(cls, key) --> 788 requires_backends(cls, cls._backends) File ~\Anaconda3\envs\transformers\lib\site-packages\transformers\utils\import_utils.py:776, in requires_backends(obj, backends) 774 failed = [msg.format(name) for available, msg in checks if not available()] 775 if failed: --> 776 raise ImportError("".join(failed)) ImportError: BertModel requires the PyTorch library but it was not found in your environment. Checkout the instructions on the installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment. FIX: (transformers) C:\Users\ash>conda install -c pytorch pytorch Collecting package metadata (current_repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.12.0 latest version: 4.13.0 Please update conda by running $ conda update -n base -c defaults conda ## Package Plan ## environment location: C:\Users\ash\Anaconda3\envs\transformers added / updated specs: - pytorch The following packages will be downloaded: package | build ---------------------------|----------------- cudatoolkit-11.3.1 | h59b6b97_2 545.3 MB libuv-1.40.0 | he774522_0 255 KB openssl-1.1.1o | h2bbff1b_0 4.8 MB pytorch-1.11.0 |py3.9_cuda11.3_cudnn8_0 1.23 GB pytorch pytorch-mutex-1.0 | cuda 3 KB pytorch ------------------------------------------------------------ Total: 1.77 GB The following NEW packages will be INSTALLED: blas pkgs/main/win-64::blas-1.0-mkl cudatoolkit pkgs/main/win-64::cudatoolkit-11.3.1-h59b6b97_2 libuv pkgs/main/win-64::libuv-1.40.0-he774522_0 pytorch pytorch/win-64::pytorch-1.11.0-py3.9_cuda11.3_cudnn8_0 pytorch-mutex pytorch/noarch::pytorch-mutex-1.0-cuda typing_extensions pkgs/main/noarch::typing_extensions-4.1.1-pyh06a4308_0 The following packages will be SUPERSEDED by a higher-priority channel: openssl conda-forge::openssl-1.1.1o-h8ffe710_0 --> pkgs/main::openssl-1.1.1o-h2bbff1b_0 Proceed ([y]/n)? y Downloading and Extracting Packages libuv-1.40.0 | 255 KB | #### | 100% openssl-1.1.1o | 4.8 MB | #### | 100% pytorch-mutex-1.0 | 3 KB | #### | 100% cudatoolkit-11.3.1 | 545.3 MB | #### | 100% pytorch-1.11.0 | 1.23 GB | #### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done (transformers) C:\Users\ash>
Tags: Technology,Artificial Intelligence,Machine Learning,Natural Language Processing,Python,

Sunday, May 29, 2022

Google offers practice problems on various math concepts from various tutoring websites (Dot Product)

Tags: Mathematical Foundations for Data Science,

Add vectors - magnitude & direction to component

Ques 1:

Ans:
Ques 2:
Ans 2:
Ques 3:
Ans 3:
Ques 4:
Ans 4:
Tags: Mathematical Foundations for Data Science,

Vedic Multiplication (for tables till 99)

Upto which number do you know your tables? 

At least Upto 10, awesome! 

You have crossed the mountain! 

Don't worry for the rest of the tables! 

From 11th to 99th, any table, very easy! 

How to write Table of any two digit number?

For example Table of *87*

First write down *table of 8 then write down table of 7 beside it*

08 0 7 (08+0) 87
---------------------------
16 1 4 (16+1) 174
24 2 1 (24+2) 261
32 2 8 (32+2) 348
40 3 5 (40+3) 435
48 4 2 (48+4) 522
56 4 9 (56+4) 609
64 5 6 (64+5) 696
72 6 3 (72+6) 783
80 7 0 (80+7) 870

Now table of 38

03 0 8 (3+0) 38
06 1 6 (6+1) 76
09 2 4 (9+2) 114
12 3 2 (12+3) 152
15 4 0 (15+4) 190
18 4 8 (18+4) 228
21 5 6 (21+5) 266
24 6 4 (24+6) 304
27 7 2 (27+7) 342
30 8 0 (30+8) 380
33 8 8 (33+8) 418
36 9 6 (36+9) 456

Now table of 92

09 02 (09+0) 92
18 04 (18+0) 184
27 06 (27+0) 276
36 08 (36+0) 368
45 10 (45+1) 460
54 12 (54+1) 552
63 14 (63+1) 644
72 16 (72+1) 736
81 18 (81+1) 828
90 20 (90+2) 920
99 22 (99+2) 1012
108 24 (108+2) 1104

This way one can make Tables from 10 to 99
Tags: Mathematical Foundations for Data Science,

Saturday, May 28, 2022

survival8 Marketing Through Facebook, LinkedIn and Twitter (2022 May 29)


Top 10 Locations in Last 24 Hours

India 259 United States 109 Ireland 20 Sweden 18 France 16 Canada 9 United Kingdom 8 Qatar 8 Brazil 6 Other 36

Top 20 Locations in Last 24 Hours

World View

Doughnut Chart

India 259 United States 109 Ireland 20 Sweden 18 France 16 Canada 9 United Kingdom 8 Qatar 8 Brazil 6 Germany 6 Indonesia 6 Russia 6 Croatia 5 Singapore 4 South Korea 2 Turkey 2 United Arab Emirates 1 Italy 1 Japan 1 Other 2
Tags: Technology,Investment,Management,

Add Vectors (7 Questions, 2022-May-28)


Ques 1:

Ans:
Ques 2:
Ans:
Ques 3:
Ques 4:

Ques 5 (with answer)

Ques 6 (with answer)

Ques 7:
Ans 7:
Tags: Mathematical Foundations for Data Science,

Sample Lease Deed for Rental Accommodation Business in Delhi (May 2022)

Index of Journals

Note: Lease Deeds extending beyond 11 months are supposed to be attested by the Notary.

LEASE DEED BY AND BETWEEN Ashish Jain (As the Lessor) AND Pankaj Shukla (As the Lessee) TABLE OF CONTENTS 1. DEFINITIONS AND INTERPRETATION 2. GRANT OF LEASE 3. TERM 4. RENT, AND SECURITY 5. OTHER CHARGES 6. OCCUPATION OF ROOM; OWNERSHIP; PERMITTED USE; USAGE; ASSIGNMENT AND SUB-LEASE 7. NOTICE PERIOD, REFUNDABLE SECURITY AND MINIMUM DURATION OF STAY 8. RENT REVISION 9. ROOM FURNISHING TERMS This Deed of Lease (“Lease deed”) is made at New Delhi on the __24-th__ day of ___May____ 2022 (“Execution Date”): BY AND BETWEEN Mr. Ashish Jain (hereinafter referred to as the “LESSOR” which expression shall, unless repugnant to the context or meaning thereof be deemed mean and include its representatives, successors and permitted assigns) of the One Part. AND Mr. Pankaj Shukla (hereinafter referred to as the “LESSEE” which expression shall, unless repugnant to the context or meaning thereof be deemed mean and include its representatives, successors and permitted assigns) of the Other Part. (The Lessor and the Lessee are hereinafter collectively referred to as the “Parties” and individually as a “Party”) WHEREAS: A. The Lessor is the owner and in possession of property being plot admeasuring: Length: 621 in. Width: 221 in. (Equivalent to 137241 square inch or 88.54 square meters) hereunder ("House Plot"), situated at the House number: 1141 Street number: 75 Deva Ram Park Tri Nagar Delhi – 110035 B. The Lessee shall be provided physical possession of the room adjoining street 73, mezzanine floor within 30 (thirty) days of the Execution Date along with the execution and delivery of the Possession Letter (defined hereafter) by the Parties. C. Now therefore, relying on the representations, warranties, covenants, and undertakings made by the Lessee, the Parties are entering into this lease on the terms and conditions set out herein below. NOW, THEREFORE, IN CONSIDERATION OF THE FOREGOING AND THE COVENANTS AND AGREEMENTS SET FORTH IN THIS LEASE DEED, THE RECEIPT AND SUFFICIENCY OF WHICH IS HEREBY ACKNOWLEDGED, AND INTENDING TO BE LEGALLY BOUND HEREBY, THE PARTIES AGREE AS FOLLOWS: 1. DEFINITIONS AND INTERPRETATION (a) "Rent": Monthly rent paid for the month on the 1st of the month. (b) "Person" means any natural person. 2. GRANT OF LEASE 2.1. Subject to the provisions of this Lease Deed and undertakings made by the Lessee in this Lease Deed the Lessor hereby grants unto the Lessee with effect from the Execution Date, lease of the room for the sole and exclusive purpose of the staying for a period of 11 (Eleven) months. 2.2. The Lessee has made assessment of taking the room on lease and the Lessee shall not make any claim regarding any change in market or business conditions. 3. TERM 3.1. Subject to compliance by the Lessee of each of the terms and conditions set out under this Lease Deed and timely performance of all the Lessee’s obligations including timely payment of Rent to the Lessor, the lease of the Street no. 75, Mezzanine floor room hereby granted to the Lessee shall commence from the Execution Date. 3.2. The Lessor may terminate this Lease Deed shall there be delay or nonpayment default of rent payment clause. Upon expiration of the Term or termination of this Lease Deed, the lease hereby granted shall stand cancelled and revoked forthwith but without prejudice to the rights of the Lessor against the Lessee in respect of any matter or thing occurring or arising prior to such termination or expiration. 3.3 On expiry of the Term or early termination of this Lease Deed by the Lessor, the Lessee shall handover to the Lessor, vacant and peaceful possession of the room, together with all the fixtures within 30 (Thirty) days of such expiry or termination. Upon such expiry of the Term or early termination of this Lease Deed, the Lessee shall ensure that its other immovable structures constructed at the room are not damaged, moved, destroyed in any manner, along with fixtures or permanent fittings or objects, which may lead to any form of structural damage to the property at the room. The Lessee shall have the right to remove all his movables at the end of the term without causing any damage to the room. 3.4 This lease deed is effective from 01-Jun-2022 till 30-Apr-2023. 4. RENT, AND SECURITY 4.1. The rent of the room adjoining street no. 73, mezzanine floor is Rs. 3500 (Rupees Three Thousand Five Hundred only). 4.2. The security of the room adjoining street no. 73, mezzanine floor is Rs. 3500 (Rupees Three Thousand Five Hundred only) has been paid by the Lessee to the Lessor. Security shall be returned at the time of expiration of the Lease Deed. 4.3. The rent for lease of room by the Lessee to Lessor shall be payable on the first day of every month. 5. OTHER CHARGES Water: Rs 150 paid monthly Electricity is charged at the rate of Rs 7.5 per unit of electricity consumption as noted in the sub-meter of the room. Dr. Aquaguard (Eureka Forbes) Usage: Rs 50 monthly 6. OCCUPATION OF ROOM; OWNERSHIP; PERMITTED USE; USAGE; ASSIGNMENT AND SUB-LEASE 6.1. Handover of Possession: Subject to the terms of this Lease Deed, the Lessee shall handover the possession of the room within 30 (thirty) days from the starting of the notice period of one month and the Lessee shall accept such possession with immediate effect. 6.2. Assignment/ Sub-letting/ Mortgage, etc. the Lessee shall not directly or indirectly transfer, assign, sell, mortgage, pledge, assign, hypothecate, encumber or part with room Premises or any part thereof and/or the benefits arising out of this Lease Deed or any part thereof, or sublet, under-let or part with the possession of the room Premises or any part thereof without obtaining prior written approval from Lessor at any time during the Term. 7. NOTICE PERIOD, REFUNDABLE SECURITY AND MINIMUM DURATION OF STAY The lessor and lessee shall each give a notice period of 30 days at the time of declaring termination of the lease deed. Minimum duration of stay for refundable security is: 6 months In case, minimum duration criteria of stay is violated, security shall not be refunded. 8. RENT REVISION Rent will be increased every 11 months by 10% of the last months’ rent. 9. ROOM FURNISHING TERMS The lessee will be provided with following items as the rent will accrue with the lessor and expenses of the items can be covered: 9.1. Two Dewan 9.2. One Godrej Almirah (metallic) Unforeseen requests will be covered depending on the accrued rent. The ownership of the items will remain with the lessor. IN WITNESS WHEREOF THE PARTIES HERETO HAVE HEREUNTO SET AND SUBSCRIBED THEIR RESPECTIVE HANDS THE DAY AND YEAR FIRST ABOVE WRITTEN. ________________ [Name of LESSOR] Name and Sign WITNESSED By Name and Sign ________________ [Name of LESSEE] By Name and Sign WITNESSED By Name and Sign
Tags: Journal

Friday, May 27, 2022

Tri Nagar Home Renovation Notes (2022 May 28)

Index of Journals

1. Amar Building Materials for Tiles 1

2. Amar Building Materials for Tiles 2

3. Estimate for doors for bathroom and toilets by Vijay Mittal and Md Aslam

4. Md Aslam (Plumber) 1

5. Md Aslam (Plumber) and Mason 2

6. Md Aslam (Plumber) 3

7. Md Nizamuddin (Painter Material) - First Week of Apr-2022 (1)

8. Md Nizamuddin (Painter Material) - First Week of Apr-2022 (2)

9. Plumber Material List 20220523

10. Ram Sajiwal (mason) estimate for tiles for ground floor bathroom

11. Tejbhan Vidhayak (Mason)

12. Tejbhan Vidhayak for Ground Floor Bathroom Tiles 20220526

13. Vijay Mittal (Contractor)

14. Flench

Tags:Technology,Journal,Investment,Management,