pere commited on
Commit
3cdf7bc
1 Parent(s): 7a36f7c

first push

Browse files
.gitattributes CHANGED
@@ -51,3 +51,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
54
+ *.csv filter=lfs diff=lfs merge=lfs -text
55
+ *.jsonl filter=lfs diff=lfs merge=lfs -text
56
+ *.json filter=lfs diff=lfs merge=lfs -text
create_multilingual_simCSE.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import jsonlines
3
+ import argparse
4
+ import pandas as pd
5
+ import pprint
6
+ from random import *
7
+
8
+ def main(args):
9
+ mainDict = {}
10
+ with jsonlines.open(args.norwegian_input_file) as reader:
11
+ for obj in reader:
12
+ #Check if the value already exists
13
+ neutral = ""
14
+ entailment = ""
15
+ contradiction = ""
16
+ prompt = ""
17
+
18
+ if mainDict.get(obj['promptID'], None):
19
+ prompt = obj['sentence1']
20
+ entailment = mainDict[obj['promptID']].get('entailment','')
21
+ contradiction = mainDict[obj['promptID']].get('contradiction','')
22
+ neutral = mainDict[obj['promptID']].get('neutral','')
23
+
24
+ if obj['gold_label'] == "neutral":
25
+ neutral = obj['sentence2']
26
+ elif obj['gold_label'] == "contradiction":
27
+ contradiction = obj['sentence2']
28
+ elif obj['gold_label'] == "entailment":
29
+ entailment = obj['sentence2']
30
+
31
+ mainDict[obj['promptID']] = {'prompt': prompt, 'entailment' : entailment, 'neutral' : neutral, 'contradiction' : contradiction}
32
+
33
+ myList = []
34
+ for promptID in mainDict:
35
+ myList.append({'sent0':mainDict[promptID]['prompt'], 'sent1':mainDict[promptID]['entailment'], 'hard_neg':mainDict[promptID]['contradiction']})
36
+
37
+ df = pd.DataFrame.from_records(myList)
38
+
39
+ #Drop empty
40
+ df.replace("", float("NaN"), inplace=True)
41
+ df.dropna(subset = ["sent0","sent1","hard_neg"], inplace=True)
42
+
43
+ #Get the english file
44
+ english = pd.read_csv(args.english_input_file)
45
+
46
+ #Get the multilingual lookup file
47
+ multi = pd.read_csv(args.multilingual_input_file, sep='\t')
48
+ multi.columns=['id','english','norwegian']
49
+ multi['english'] = multi['english'].str.strip()
50
+ multi['norwegian'] = multi['norwegian'].str.strip()
51
+
52
+ #Create dictionary
53
+ mydict = {}
54
+ for index,row in multi.iterrows():
55
+ mydict[row['norwegian']] = row['english']
56
+
57
+ merged = df.copy()
58
+ for index, row in merged.iterrows():
59
+ flip = randint(1,6)
60
+ if flip == 3 or flip == 4 or flip == 5:
61
+ merged.at[index, 'sent0'] = mydict.get(row['sent0'],row['sent0'])
62
+
63
+ if flip == 2 or flip == 4 or flip == 6:
64
+ merged.at[index, 'sent1'] = mydict.get(row['sent1'],row['sent1'])
65
+
66
+ if flip == 1 or flip == 5 or flip == 6:
67
+ merged.at[index,'hard_neg'] = mydict.get(row['hard_neg'],row['hard_neg'])
68
+
69
+
70
+ combined = pd.concat([df, english, merged])
71
+
72
+ combined = combined.sample(frac=1).reset_index(drop=True)
73
+
74
+ #Save csv
75
+ combined.to_csv(args.output_file, index=False)
76
+
77
+ if __name__ == '__main__':
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument('--norwegian_input_file', help="Norwegian json file.", required=True)
80
+ parser.add_argument('--english_input_file', help="English csv file.", required=True)
81
+ parser.add_argument('--multilingual_input_file', help="Multilingual tsv file.", required=True)
82
+ parser.add_argument('--output_file', help="Output file.", required=True)
83
+
84
+ args = parser.parse_args()
85
+ main(args)
create_multilingual_small_simCSE.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import jsonlines
3
+ import argparse
4
+ import pandas as pd
5
+ import pprint
6
+ from random import *
7
+
8
+ def main(args):
9
+ mainDict = {}
10
+ with jsonlines.open(args.norwegian_input_file) as reader:
11
+ for obj in reader:
12
+ #Check if the value already exists
13
+ neutral = ""
14
+ entailment = ""
15
+ contradiction = ""
16
+ prompt = ""
17
+
18
+ if mainDict.get(obj['promptID'], None):
19
+ prompt = obj['sentence1']
20
+ entailment = mainDict[obj['promptID']].get('entailment','')
21
+ contradiction = mainDict[obj['promptID']].get('contradiction','')
22
+ neutral = mainDict[obj['promptID']].get('neutral','')
23
+
24
+ if obj['gold_label'] == "neutral":
25
+ neutral = obj['sentence2']
26
+ elif obj['gold_label'] == "contradiction":
27
+ contradiction = obj['sentence2']
28
+ elif obj['gold_label'] == "entailment":
29
+ entailment = obj['sentence2']
30
+
31
+ mainDict[obj['promptID']] = {'prompt': prompt, 'entailment' : entailment, 'neutral' : neutral, 'contradiction' : contradiction}
32
+
33
+ myList = []
34
+ for promptID in mainDict:
35
+ myList.append({'sent0':mainDict[promptID]['prompt'], 'sent1':mainDict[promptID]['entailment'], 'hard_neg':mainDict[promptID]['contradiction']})
36
+
37
+ df = pd.DataFrame.from_records(myList)
38
+
39
+ #Drop empty
40
+ df.replace("", float("NaN"), inplace=True)
41
+ df.dropna(subset = ["sent0","sent1","hard_neg"], inplace=True)
42
+
43
+ #Get the english file
44
+ english = pd.read_csv(args.english_input_file)
45
+
46
+ #Get the multilingual lookup file
47
+ #multi = pd.read_csv(args.multilingual_input_file, sep='\t')
48
+ #multi.columns=['id','english','norwegian']
49
+ #multi['english'] = multi['english'].str.strip()
50
+ #multi['norwegian'] = multi['norwegian'].str.strip()
51
+
52
+ #Create dictionary
53
+ #mydict = {}
54
+ #for index,row in multi.iterrows():
55
+ # mydict[row['norwegian']] = row['english']
56
+
57
+ #merged = df.copy()
58
+ #for index, row in merged.iterrows():
59
+ # flip = randint(1,6)
60
+ # if flip == 3 or flip == 4 or flip == 5:
61
+ # merged.at[index, 'sent0'] = mydict.get(row['sent0'],row['sent0'])
62
+ #
63
+ # if flip == 2 or flip == 4 or flip == 6:
64
+ # merged.at[index, 'sent1'] = mydict.get(row['sent1'],row['sent1'])
65
+ #
66
+ # if flip == 1 or flip == 5 or flip == 6:
67
+ # merged.at[index,'hard_neg'] = mydict.get(row['hard_neg'],row['hard_neg'])
68
+
69
+
70
+ combined = pd.concat([df, english])
71
+
72
+ combined = combined.sample(frac=1).reset_index(drop=True)
73
+
74
+ #Save csv
75
+ combined.to_csv(args.output_file, index=False)
76
+
77
+ if __name__ == '__main__':
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument('--norwegian_input_file', help="Norwegian json file.", required=True)
80
+ parser.add_argument('--english_input_file', help="English csv file.", required=True)
81
+ parser.add_argument('--output_file', help="Output file.", required=True)
82
+
83
+ args = parser.parse_args()
84
+ main(args)
create_simCSE.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import jsonlines
3
+ import argparse
4
+ import pandas as pd
5
+ import pprint
6
+
7
+ def main(args):
8
+ mainDict = {}
9
+ with jsonlines.open(args.input_file) as reader:
10
+ for obj in reader:
11
+ #Check if the value already exists
12
+ neutral = ""
13
+ entailment = ""
14
+ contradiction = ""
15
+ prompt = ""
16
+
17
+ if mainDict.get(obj['promptID'], None):
18
+ prompt = obj['sentence1']
19
+ entailment = mainDict[obj['promptID']].get('entailment','')
20
+ contradiction = mainDict[obj['promptID']].get('contradiction','')
21
+ neutral = mainDict[obj['promptID']].get('neutral','')
22
+
23
+ if obj['gold_label'] == "neutral":
24
+ neutral = obj['sentence2']
25
+ elif obj['gold_label'] == "contradiction":
26
+ contradiction = obj['sentence2']
27
+ elif obj['gold_label'] == "entailment":
28
+ entailment = obj['sentence2']
29
+
30
+ mainDict[obj['promptID']] = {'prompt': prompt, 'entailment' : entailment, 'neutral' : neutral, 'contradiction' : contradiction}
31
+
32
+ myList = []
33
+ for promptID in mainDict:
34
+ myList.append({'sent0':mainDict[promptID]['prompt'], 'sent1':mainDict[promptID]['entailment'], 'hard_neg':mainDict[promptID]['contradiction']})
35
+
36
+ df = pd.DataFrame.from_records(myList)
37
+
38
+ #Drop empty
39
+ df.replace("", float("NaN"), inplace=True)
40
+ df.dropna(subset = ["sent0","sent1","hard_neg"], inplace=True)
41
+
42
+ #Save csv
43
+ df.to_csv(args.output_file, index=False)
44
+
45
+ if __name__ == '__main__':
46
+ parser = argparse.ArgumentParser()
47
+ parser.add_argument('--input_file', help="Input file.", required=True)
48
+ parser.add_argument('--output_file', help="Output file.", required=True)
49
+
50
+ args = parser.parse_args()
51
+ main(args)
mnli_no_en_for_simcse.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f47fbce5e124610dbdfd4e91c1382e706f5b9776921e5d2eb23c030334026645
3
+ size 106691470
mnli_no_en_small_for_simcse.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f99e56cc162bdd808e619ac6d73e6441f47eb848973d685d360bb4c99000806
3
+ size 77804651
mnli_no_for_simcse.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3a3d7fb9905ec57c1bc62a578c88002dc9a20f3ebcbd2c675c1a549172aadf8
3
+ size 28826475
multinli_1.0_dev_matched_no_mt.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0e9f90a0967a2d5e650db95a16cb7b0fa8f9c8822eae4a30c9c7baf8119bf4a
3
+ size 4755492
multinli_1.0_dev_mismatched_no_mt.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cfebf1dc8c9a02a824197abce39e9a6002cdbb226275e52219677da43b92b60
3
+ size 4856954
multinli_1.0_train_no_mt.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d333b35562b2293ad9917a108968a0a6d0ceca27098376bfe32fd6879d8285cf
3
+ size 187700447
nli_for_simcse.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0747687ec3594fa449d2004fd3757a56c24bf5f7428976fb5b67176775a68d48
3
+ size 48978197
xnli_dev_no_mt.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46ea82fab04f63b8e783f7a55a165c9181e63d8c0c098018ed01f39d87dfeab4
3
+ size 1193913
xnli_test_no_mt.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:815aba6a5b452cd9a82bc8c037e124ab5cd46548ebca1df74665dd622aef74ca
3
+ size 2402537