Exemple #1
0
 def __init__(self, hparams, num_labels):
     super().__init__()
     self.hparams = hparams
     model_name_or_path = "monologg/koelectra-base-discriminator"
     config = AutoConfig.from_pretrained(model_name_or_path,
                                         num_labels=num_labels)
     self.model = AutoModelForSequenceClassification.from_pretrained(
         model_name_or_path, config=config)
     self.num_labels = num_labels
Exemple #2
0
def test_conversion_adaptive_model_classification():
    farm_model = Converter.convert_from_transformers(
        "deepset/bert-base-german-cased-hatespeech-GermEval18Coarse",
        device="cpu")
    transformer_model = farm_model.convert_to_transformers()[0]
    transformer_model2 = AutoModelForSequenceClassification.from_pretrained(
        "deepset/bert-base-german-cased-hatespeech-GermEval18Coarse")
    # compare weights
    for p1, p2 in zip(transformer_model.parameters(),
                      transformer_model2.parameters()):
        assert (p1.data.ne(p2.data).sum() == 0)