def start(num_encoder: int, num_decoder: int) -> nn.Module: distill_config = make_config(num_encoder, num_decoder) student_encoder_layer, student_decoder_layer = make_layer(num_encoder, num_decoder) student = AsianBartForConditionalGeneration(distill_config) model = make_student_model(student) return model
def __init__(self, lang: str, device="cpu") -> None: self.model = AsianBartForConditionalGeneration.from_pretrained( "model_name").to(device) self.tokenizer = AsianBartTokenizer.from_pretrained( "hyunwoongko/asian-bart-ecjk") if lang == "ko": self.lang_code = "ko_KR" elif lang == "en": self.lang_code = "en_XX" elif lang == "zh": self.lang_code = "zh_XX" else: raise NotImplementedError(f"wrong language code : {lang}")
from itertools import combinations from collections import OrderedDict from typing import List import torch.nn as nn import json """ 12_3 0,1,2,3,4,5,6,7,8,9,10,11 => 3, 7 ,12 To Leverage All Knowledge """ teacher_model = AsianBartForConditionalGeneration.from_pretrained( "hyunwoongko/asian-bart-ecjk" ) teacher_config = AsianBartConfig.from_pretrained( "hyunwoongko/asian-bart-ecjk" ) encoder_teacher_layers= [ i for i in range(teacher_config.encoder_layers) ] decoder_teacher_layers= [ i for i in range(teacher_config.decoder_layers) ]