gbure

Graph-based approaches on unsupervised relation extraction evaluated as a fewshot problem
git clone https://esimon.eu/repos/gbure.git
Log | Files | Refs | README | LICENSE

contrastive_alignment.py (1232B)


      1 from gbure.model.contrastive_alignment import Model
      2 from gbure.model.fewshot import Model as EvalModel
      3 from torch.optim import Adam as Optimizer
      4 from torch.optim.lr_scheduler import LinearLR as Scheduler
      5 
      6 
      7 dataset_name = "T-REx"
      8 graph_name = "T-REx"
      9 unsupervised = "triplet"
     10 
     11 eval_dataset_name = "FewRel"
     12 valid_name = "7def1330ba9527d6"
     13 shot = 1
     14 way = 5
     15 
     16 margin = 1
     17 neighborhood_size = 3
     18 filter_empty_neighborhood = True
     19 sinkhorn_blur = 0.05
     20 
     21 # Necessary to make a distance
     22 linguistic_similarity = "euclidean"
     23 undefined_poison_whole_meta = True
     24 
     25 # From section 4.3
     26 blank_probability = 0.7
     27 
     28 # From section 5
     29 transformer_model = "bert-base-cased"
     30 max_epoch = 10
     31 sample_per_epoch = 100000
     32 learning_rate = 3e-5
     33 accumulated_batch_size = 256
     34 clip_gradient = 1
     35 
     36 # Guessed
     37 post_transformer_layer = "linear"  # Maybe we should change this depending on the subsequent task?
     38 max_sentence_length = 100  # Maybe should be 40 (from footnote 2, guessed from ACL slides)
     39 language_model_weight = 0
     40 edge_sampling = "uniform-inverse degree"
     41 
     42 # From BERT
     43 mlm_probability = 0.15
     44 mlm_masked_probability = 0.8
     45 mlm_random_probability = 0.1
     46 
     47 # Implementation details
     48 seed = 0
     49 amp = True
     50 initial_grad_scale = 1
     51 batch_size = 2
     52 eval_batch_size = 1
     53 workers = 2