Skip to content

Commit

Permalink
test wav2vec KOR Zeroth finetuned HuggingFace
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvulong committed Dec 25, 2023
1 parent 9141a39 commit f1b45f6
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 6 deletions.
107 changes: 107 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"_name_or_path": "/nfs/datab/longnv/wav2vec2-xls-r-300m-korean.bin",
"activation_dropout": 0.1,
"adapter_kernel_size": 3,
"adapter_stride": 2,
"add_adapter": false,
"apply_spec_augment": true,
"architectures": [
"Wav2Vec2ForCTC"
],
"attention_dropout": 0.0,
"bos_token_id": 1,
"classifier_proj_size": 256,
"codevector_dim": 768,
"contrastive_logits_temperature": 0.1,
"conv_bias": true,
"conv_dim": [
512,
512,
512,
512,
512,
512,
512
],
"conv_kernel": [
10,
3,
3,
3,
3,
2,
2
],
"conv_stride": [
5,
2,
2,
2,
2,
2,
2
],
"ctc_loss_reduction": "mean",
"ctc_zero_infinity": false,
"diversity_loss_weight": 0.1,
"do_stable_layer_norm": true,
"eos_token_id": 2,
"feat_extract_activation": "gelu",
"feat_extract_dropout": 0.0,
"feat_extract_norm": "layer",
"feat_proj_dropout": 0.0,
"feat_quantizer_dropout": 0.0,
"final_dropout": 0.0,
"hidden_act": "gelu",
"hidden_dropout": 0.0,
"hidden_size": 1024,
"initializer_range": 0.02,
"intermediate_size": 4096,
"layer_norm_eps": 1e-05,
"layerdrop": 0.0,
"mask_feature_length": 64,
"mask_feature_min_masks": 0,
"mask_feature_prob": 0.25,
"mask_time_length": 10,
"mask_time_min_masks": 2,
"mask_time_prob": 0.75,
"model_type": "wav2vec2",
"num_adapter_layers": 3,
"num_attention_heads": 16,
"num_codevector_groups": 2,
"num_codevectors_per_group": 320,
"num_conv_pos_embedding_groups": 16,
"num_conv_pos_embeddings": 128,
"num_feat_extract_layers": 7,
"num_hidden_layers": 24,
"num_negatives": 100,
"output_hidden_size": 1024,
"pad_token_id": 1204,
"proj_codevector_dim": 768,
"tdnn_dilation": [
1,
2,
3,
1,
1
],
"tdnn_dim": [
512,
512,
512,
512,
1500
],
"tdnn_kernel": [
5,
3,
3,
1,
1
],
"torch_dtype": "float32",
"transformers_version": "4.17.0.dev0",
"use_weighted_layer_sum": false,
"vocab_size": 1207,
"xvector_output_dim": 512
}
13 changes: 8 additions & 5 deletions models/sslassist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch.nn.functional as F
from torch import Tensor
import fairseq

from transformers import AutoModel

___author__ = "Hemlata Tak"
__email__ = "[email protected]"
Expand All @@ -21,9 +21,11 @@ class SSLModel(nn.Module):
def __init__(self,device):
super(SSLModel, self).__init__()

cp_path = '/datac/longnv/SSL_Anti-spoofing/pretrained/xlsr2_300m.pt' # Change the pre-trained XLSR model path.
model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task([cp_path])
self.model = model[0]
cp_path = '/nfs/datab/longnv/wav2vec2-xls-r-300m-korean.bin' # Change the pre-trained XLSR model path.
# model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task([cp_path])
model = AutoModel.from_pretrained("./")
# self.model = model[0]
self.model = model
self.device=device
self.out_dim = 1024
return
Expand All @@ -45,7 +47,8 @@ def extract_feat(self, input_data):
input_tmp = input_data

# [batch, length, dim]
emb = self.model(input_tmp, mask=False, features_only=True)['x']
# emb = self.model(input_tmp, mask=False, features_only=True)['x']
emb = self.model(input_tmp).last_hidden_state
return emb


Expand Down
2 changes: 1 addition & 1 deletion oc_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def collate_fn(self, batch):


# WandB – Initialize a new run
wandb.init(project="oc_classifier", entity="longnv")
wandb.init(project="oc_classifier-kor", entity="longnv")

# Number of epochs
num_epochs = 100
Expand Down

0 comments on commit f1b45f6

Please sign in to comment.