This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
from transformers import AutoModelForSequenceClassification | |
################### | |
model_uri = "distilbert/distilbert-base-uncased" | |
num_classes = 2 | |
# Initialise the model | |
model = AutoModelForSequenceClassification.from_pretrained( | |
model_uri, num_labels=num_classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import torch | |
from functools import partial | |
from transformers import AutoModelForSequenceClassification | |
# Classes | |
# Define the Adapter layer | |
class Adapter(torch.nn.Module): | |
""" | |
Implements Adapter layer as described in the paper. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import torch | |
from functools import partial | |
from transformers import AutoModelForSequenceClassification | |
# Classes | |
# Define the LoRA layer | |
class LoRA(torch.nn.Module): | |
def __init__(self, in_dim, out_dim, rank, alpha) -> None: | |
""" |