Skip to content
Advertisement

Tag: huggingface-transformers

How to replace PyTorch model layer’s tensor with another layer of same shape in Huggingface model?

Given a Huggingface model, e.g. I can access a layer’s tensor as such: [out]: Given the another tensor of the same shape that I’ve pre-defined from somewhere else, in this case, for illustration, I’m creating a random tensor but this can be any tensor that is pre-defined. Note: I’m not trying to replace a layer with a random tensor but

Load a model as DPRQuestionEncoder in HuggingFace

I would like to load the BERT’s weights (or whatever transformer) into a DPRQuestionEncoder architecture, such that I can use the HuggingFace save_pretrained method and plug the saved model into the RAG architecture to do end-to-end fine-tuning. But I got the following error I am using the last version of Transformers. Answer As already mentioned in the comments, DPRQuestionEncoder does

Can BERT output be fixed in shape, irrespective of string size?

I am confused about using huggingface BERT models and about how to make them yield a prediction at a fixed shape, regardless of input size (i.e., input string length). I tried to call the tokenizer with the parameters padding=True, truncation=True, max_length = 15, but the prediction output dimensions for inputs = [“a”, “a”*20, “a”*100, “abcede”*20000] are not fixed. What am

Hugging Face: NameError: name ‘sentences’ is not defined

I am following this tutorial here: https://huggingface.co/transformers/training.html – though, I am coming across an error, and I think the tutorial is missing an import, but i do not know which. These are my current imports: Current code: The error: Answer The error states that you do not have a variable called sentences in the scope. I believe the tutorial presumes

Advertisement