unknown commited on
Commit
4b78e2e
1 Parent(s): 5aeacfd
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## How to use
2
+
3
+ ```python
4
+ import logging
5
+ from simpletransformers.seq2seq import Seq2SeqModel, Seq2SeqArgs
6
+
7
+ logging.basicConfig(level=logging.INFO)
8
+ transformers_logger = logging.getLogger("transformers")
9
+ transformers_logger.setLevel(logging.WARNING)
10
+
11
+ model_args = Seq2SeqArgs()
12
+
13
+ # 加载本地训练好的模型
14
+ model = Seq2SeqModel(
15
+ encoder_decoder_type="bart",
16
+ encoder_decoder_name="NTUYG/SOTitle-java-BART",
17
+ args=model_args,
18
+ )
19
+
20
+ describe = """
21
+ I am a beginner at Android Java development but I have a few years of school + uni experience in Java. I am trying to write to a text file in an assets folder in my app using FileOutputStream but it doesn't seem to write to it at all since I am using InputStream to read the file after and there haven't any updates. Here is my code
22
+ """
23
+ code = """
24
+ private void updateTextFile(String update) {
25
+ FileOutputStream fos = null;
26
+
27
+ try
28
+ {
29
+ fos = openFileOutput("Questions",MODE_PRIVATE);
30
+ fos.write("Testing".getBytes());
31
+ }
32
+ catch (FileNotFoundException e)
33
+ {
34
+ e.printStackTrace();
35
+ }
36
+ catch (IOException e)
37
+ {
38
+ e.printStackTrace();
39
+ }
40
+ finally
41
+ {
42
+ if(fos!=null)
43
+ {
44
+ try
45
+ {
46
+ fos.close();
47
+ }
48
+ catch (IOException e)
49
+ {
50
+ e.printStackTrace();
51
+ }
52
+ }
53
+ }
54
+
55
+ String text = "";
56
+
57
+ try
58
+ {
59
+ InputStream is = getAssets().open("Questions");
60
+ int size = is.available();
61
+ byte[] buffer = new byte[size];
62
+ is.read(buffer);
63
+ is.close();
64
+ text = new String(buffer);
65
+ }
66
+ catch (IOException e)
67
+ {
68
+ e.printStackTrace();
69
+ }
70
+ System.out.println("Tesing output " + text);
71
+ }
72
+ """
73
+
74
+ from nltk import word_tokenize
75
+
76
+ describe = describe.replace('\n',' ').replace('\r',' ')
77
+ describe = ' '.join(word_tokenize(describe))
78
+ code = code.replace('\n',' ').replace('\r',' ')
79
+ code = ' '.join(word_tokenize(code))
80
+
81
+ # human : Java Android Cant seem to update text file using FileOutputStream
82
+
83
+ body = describe + ' <code> ' + code +' </code>'
84
+ print(
85
+ model.predict(
86
+ [
87
+ body
88
+ ]
89
+ )
90
+ )
91
+ ```
92
+
config.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/bart-large",
3
+ "activation_dropout": 0.1,
4
+ "activation_function": "gelu",
5
+ "add_bias_logits": false,
6
+ "add_final_layer_norm": false,
7
+ "architectures": [
8
+ "BartForConditionalGeneration"
9
+ ],
10
+ "attention_dropout": 0.1,
11
+ "bos_token_id": 0,
12
+ "classif_dropout": 0.1,
13
+ "classifier_dropout": 0.0,
14
+ "d_model": 1024,
15
+ "decoder_attention_heads": 16,
16
+ "decoder_ffn_dim": 4096,
17
+ "decoder_layerdrop": 0.0,
18
+ "decoder_layers": 12,
19
+ "decoder_start_token_id": 2,
20
+ "dropout": 0.1,
21
+ "early_stopping": true,
22
+ "encoder_attention_heads": 16,
23
+ "encoder_ffn_dim": 4096,
24
+ "encoder_layerdrop": 0.0,
25
+ "encoder_layers": 12,
26
+ "eos_token_id": 2,
27
+ "force_bos_token_to_be_generated": false,
28
+ "gradient_checkpointing": false,
29
+ "id2label": {
30
+ "0": "LABEL_0",
31
+ "1": "LABEL_1",
32
+ "2": "LABEL_2"
33
+ },
34
+ "init_std": 0.02,
35
+ "is_encoder_decoder": true,
36
+ "label2id": {
37
+ "LABEL_0": 0,
38
+ "LABEL_1": 1,
39
+ "LABEL_2": 2
40
+ },
41
+ "max_position_embeddings": 1024,
42
+ "model_type": "bart",
43
+ "no_repeat_ngram_size": 3,
44
+ "normalize_before": false,
45
+ "num_beams": 4,
46
+ "num_hidden_layers": 12,
47
+ "pad_token_id": 1,
48
+ "scale_embedding": false,
49
+ "task_specific_params": {
50
+ "summarization": {
51
+ "length_penalty": 1.0,
52
+ "max_length": 128,
53
+ "min_length": 12,
54
+ "num_beams": 4
55
+ },
56
+ "summarization_cnn": {
57
+ "length_penalty": 2.0,
58
+ "max_length": 142,
59
+ "min_length": 56,
60
+ "num_beams": 4
61
+ },
62
+ "summarization_xsum": {
63
+ "length_penalty": 1.0,
64
+ "max_length": 62,
65
+ "min_length": 11,
66
+ "num_beams": 6
67
+ }
68
+ },
69
+ "transformers_version": "4.2.0",
70
+ "use_cache": true,
71
+ "vocab_size": 50265
72
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
model_args.json ADDED
@@ -0,0 +1 @@
 
1
+ {"adam_epsilon": 1e-08, "best_model_dir": "with_code/best_model", "cache_dir": "cache_dir/", "config": {}, "cosine_schedule_num_cycles": 0.5, "custom_layer_parameters": [], "custom_parameter_groups": [], "dataloader_num_workers": 0, "do_lower_case": false, "dynamic_quantize": false, "early_stopping_consider_epochs": false, "early_stopping_delta": 0, "early_stopping_metric": "eval_loss", "early_stopping_metric_minimize": true, "early_stopping_patience": 3, "encoding": null, "adafactor_eps": [1e-30, 0.001], "adafactor_clip_threshold": 1.0, "adafactor_decay_rate": -0.8, "adafactor_beta1": null, "adafactor_scale_parameter": true, "adafactor_relative_step": true, "adafactor_warmup_init": true, "eval_batch_size": 8, "evaluate_during_training": true, "evaluate_during_training_silent": true, "evaluate_during_training_steps": 2000, "evaluate_during_training_verbose": true, "evaluate_each_epoch": true, "fp16": true, "gradient_accumulation_steps": 1, "learning_rate": 4e-05, "local_rank": -1, "logging_steps": 50, "manual_seed": null, "max_grad_norm": 1.0, "max_seq_length": 512, "model_name": "facebook/bart-large", "model_type": "bart", "multiprocessing_chunksize": 500, "n_gpu": 1, "no_cache": false, "no_save": false, "not_saved_args": [], "num_train_epochs": 50, "optimizer": "AdamW", "output_dir": "with_code/", "overwrite_output_dir": true, "process_count": 10, "polynomial_decay_schedule_lr_end": 1e-07, "polynomial_decay_schedule_power": 1.0, "quantized_model": false, "reprocess_input_data": true, "save_best_model": true, "save_eval_checkpoints": true, "save_model_every_epoch": true, "save_optimizer_and_scheduler": true, "save_steps": 4000, "scheduler": "linear_schedule_with_warmup", "silent": false, "skip_special_tokens": true, "tensorboard_dir": null, "thread_count": null, "train_batch_size": 4, "train_custom_parameters_only": false, "use_cached_eval_features": false, "use_early_stopping": true, "use_multiprocessing": false, "wandb_kwargs": {}, "wandb_project": null, "warmup_ratio": 0.06, "warmup_steps": 45000, "weight_decay": 0.0, "model_class": "Seq2SeqModel", "base_marian_model_name": "facebook/bart-large", "dataset_class": null, "do_sample": false, "early_stopping": true, "evaluate_generated_text": true, "length_penalty": 2.0, "max_length": 20, "max_steps": -1, "num_beams": 1, "num_return_sequences": 1, "repetition_penalty": 1.0, "top_k": null, "top_p": null, "use_multiprocessed_decoding": false, "src_lang": "en_XX", "tgt_lang": "ro_RO"}
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:207a4aec91dfe4ca63a2b3bf90abfe54b29f9084e4eb365b78339f0b826d0e27
3
+ size 1625568367
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
1
+ {"bos_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "eos_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "unk_token": {"content": "<unk>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "sep_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "pad_token": {"content": "<pad>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "cls_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true}}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
1
+ {"errors": "replace", "unk_token": {"content": "<unk>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "bos_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "eos_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "add_prefix_space": false, "sep_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "cls_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "pad_token": {"content": "<pad>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "model_max_length": 1024, "name_or_path": "facebook/bart-large"}
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b4e0726acd6192d6c8abc13417d2b0d63d26e54f0b0c6904c80f118fa221e36
3
+ size 2991
vocab.json ADDED
The diff for this file is too large to render. See raw diff