shaunss commited on
Commit
2a25f87
·
verified ·
1 Parent(s): 4f2e1cb

Upload 12 files

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false
7
+ }
README.md CHANGED
@@ -1,3 +1,128 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: sentence-similarity
3
+ tags:
4
+ - sentence-transformers
5
+ - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+ license: mit
9
+ base_model:
10
+ - deutsche-telekom/gbert-large-paraphrase-cosine
11
+ ---
12
+
13
+ # protestclaims_gbert
14
+
15
+ This is a fine-tuned [sentence-transformers](https://www.SBERT.net) model based on [deutsche-telekom/gbert-large-paraphrase-cosine]: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
16
+
17
+ THe model was fine-tuned using manually annotated sentences from German newspapers containing information about protests and the protesters’ claims.
18
+
19
+ ## Usage (Sentence-Transformers)
20
+
21
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
22
+
23
+ ```
24
+ pip install -U sentence-transformers
25
+ ```
26
+
27
+ Then you can use the model like this:
28
+
29
+ ```python
30
+ from sentence_transformers import SentenceTransformer
31
+ sentences = ["This is an example sentence", "Each sentence is converted"]
32
+
33
+ model = SentenceTransformer('shaunss/protestclaims_gbert')
34
+ embeddings = model.encode(sentences)
35
+ print(embeddings)
36
+ ```
37
+
38
+
39
+
40
+ ## Usage (HuggingFace Transformers)
41
+ Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
42
+
43
+ ```python
44
+ from transformers import AutoTokenizer, AutoModel
45
+ import torch
46
+
47
+
48
+ #Mean Pooling - Take attention mask into account for correct averaging
49
+ def mean_pooling(model_output, attention_mask):
50
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
51
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
52
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
53
+
54
+
55
+ # Sentences we want sentence embeddings for
56
+ sentences = ['This is an example sentence', 'Each sentence is converted']
57
+
58
+ # Load model from HuggingFace Hub
59
+ tokenizer = AutoTokenizer.from_pretrained('shaunss/protestclaims_gbert')
60
+ model = AutoModel.from_pretrained('shaunss/protestclaims_gbert')
61
+
62
+ # Tokenize sentences
63
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
64
+
65
+ # Compute token embeddings
66
+ with torch.no_grad():
67
+ model_output = model(**encoded_input)
68
+
69
+ # Perform pooling. In this case, mean pooling.
70
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
71
+
72
+ print("Sentence embeddings:")
73
+ print(sentence_embeddings)
74
+ ```
75
+
76
+
77
+ <!---
78
+ ## Evaluation Results
79
+
80
+ Describe how your model was evaluated
81
+
82
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=protestclaims_gbert)
83
+ -->
84
+
85
+ ## Training
86
+ The model was trained with the parameters:
87
+
88
+ **DataLoader**:
89
+
90
+ `torch.utils.data.dataloader.DataLoader` of length 103 with parameters:
91
+ ```
92
+ {'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
93
+ ```
94
+
95
+ **Loss**:
96
+
97
+ `sentence_transformers.losses.BatchSemiHardTripletLoss.BatchSemiHardTripletLoss`
98
+
99
+ Parameters of the fit()-Method:
100
+ ```
101
+ {
102
+ "epochs": 15,
103
+ "evaluation_steps": 329.20000000000005,
104
+ "evaluator": "sentence_transformers.evaluation.BinaryClassificationEvaluator.BinaryClassificationEvaluator",
105
+ "max_grad_norm": 1,
106
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
107
+ "optimizer_params": {
108
+ "lr": 2e-05
109
+ },
110
+ "scheduler": "WarmupLinear",
111
+ "steps_per_epoch": null,
112
+ "warmup_steps": 329.20000000000005,
113
+ "weight_decay": 0.01
114
+ }
115
+ ```
116
+
117
+
118
+ ## Full Model Architecture
119
+ ```
120
+ SentenceTransformer(
121
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
122
+ (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
123
+ )
124
+ ```
125
+
126
+ ## Citing & Authors
127
+
128
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/home/shaunss/.cache/torch/sentence_transformers/deutsche-telekom_gbert-large-paraphrase-cosine/",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 1024,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 4096,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 16,
17
+ "num_hidden_layers": 24,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "torch_dtype": "float32",
21
+ "transformers_version": "4.29.2",
22
+ "type_vocab_size": 2,
23
+ "use_cache": true,
24
+ "vocab_size": 31102
25
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.22.2",
5
+ "pytorch": "1.12.1+cu102"
6
+ }
7
+ }
eval/binary_classification_evaluation_results.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ epoch,steps,cossim_accuracy,cossim_accuracy_threshold,cossim_f1,cossim_precision,cossim_recall,cossim_f1_threshold,cossim_ap,manhattan_accuracy,manhattan_accuracy_threshold,manhattan_f1,manhattan_precision,manhattan_recall,manhattan_f1_threshold,manhattan_ap,euclidean_accuracy,euclidean_accuracy_threshold,euclidean_f1,euclidean_precision,euclidean_recall,euclidean_f1_threshold,euclidean_ap,dot_accuracy,dot_accuracy_threshold,dot_f1,dot_precision,dot_recall,dot_f1_threshold,dot_ap
2
+ 0,-1,0.921067053513862,0.6174301505088806,0.658887858223893,0.6309687071437476,0.6893921334922527,0.5224368572235107,0.6568646746104293,0.9210307865892973,512.619384765625,0.6595432434660731,0.6393542199488491,0.6810488676996425,576.3082275390625,0.6604771059232328,0.9209743713733075,20.297161102294922,0.6589871484508278,0.6301267710663684,0.690618082751575,22.839641571044922,0.6603758634801408,0.921248388136686,332.421630859375,0.6571105243304414,0.6337952417109592,0.6822067086667801,287.6917419433594,0.6449042740241154
3
+ 1,-1,0.930705996131528,0.6919203996658325,0.708137328379391,0.6658669705511906,0.7561382598331347,0.5270371437072754,0.7445783186925214,0.9303836234687298,504.5845642089844,0.7081255311983836,0.6691822755652543,0.7518814915715989,583.332275390625,0.7470769619207115,0.9304198903932946,18.130956649780273,0.7079736884325364,0.6693159411497043,0.7513706793802145,22.86447525024414,0.7467618178299762,0.9311895551257253,392.57977294921875,0.7085049210563975,0.6645192078262945,0.7587263749361485,294.33001708984375,0.7292517790140433
4
+ 2,-1,0.9343931334622824,0.7136921882629395,0.7173332443079389,0.703499983629637,0.7317214370849651,0.6156739592552185,0.7600254060951601,0.9345462604771115,468.803955078125,0.7178995203231507,0.7097171381031614,0.7262727737101993,525.3678588867188,0.7615692068716018,0.9343931334622824,18.204402923583984,0.7179213501884527,0.7034676602281269,0.7329814404903797,20.98118782043457,0.7611671233527293,0.9345059638942618,448.7745666503906,0.7164497475294549,0.7015207884602833,0.7320279243997957,349.7630310058594,0.7531021507097297
5
+ 3,-1,0.9334824306898775,0.8246881365776062,0.7137666532095276,0.7052488116211814,0.7224927634939554,0.6401357650756836,0.7553650312900878,0.9333333333333333,356.225830078125,0.7140536829590931,0.7023982079325339,0.7261025029797378,526.1380615234375,0.7556749999748844,0.9334260154738878,14.090566635131836,0.7143887184130656,0.7036865750528541,0.725421420057892,20.60045051574707,0.7557456456436582,0.9337685364281109,486.42901611328125,0.7126337187989469,0.6977062873176939,0.7282138600374596,365.5035400390625,0.7538615733147203
6
+ 4,-1,0.9338531592520954,0.814205527305603,0.7100576835421153,0.6593496409597758,0.7692150519325728,0.49904677271842957,0.7792947209946086,0.9338128626692457,386.36199951171875,0.7111637991545651,0.6561132857471794,0.7762983143197685,618.905517578125,0.7805806775525649,0.9338813668600903,14.816593170166016,0.7098461102272906,0.6603657464392474,0.767342073897497,24.055896759033203,0.7795874128291687,0.9339458413926499,478.12628173828125,0.7105407997987137,0.6600829778530941,0.7693512685169419,290.177490234375,0.7739095891952419
7
+ 5,-1,0.9366618310767247,0.8182272911071777,0.7154977541614067,0.6287763473594592,0.8299676485612123,0.3864666521549225,0.7800573554713007,0.936621534493875,374.20831298828125,0.7172483863256037,0.6389798471900541,0.8173676145070662,666.6046142578125,0.7809913763265229,0.9366376531270149,14.639816284179688,0.7152236229695158,0.6532473747923764,0.7901924059254214,25.243518829345703,0.7809028159987476,0.9366416827852998,482.78955078125,0.7157549298250754,0.6280821741701591,0.8318746807423804,223.10125732421875,0.7710827491508985
8
+ 6,-1,0.9335469052224371,0.7220498323440552,0.7076933429787521,0.6993283681340604,0.7162608547590669,0.5646674633026123,0.7638088155688725,0.9334461637653128,464.3895263671875,0.7083065688495216,0.7032188769173967,0.7134684147794994,572.7876586914062,0.7641790313814547,0.9335106382978723,18.105064392089844,0.7073019698415088,0.695418942934246,0.719598161076111,22.878162384033203,0.7642659600345677,0.9339700193423598,429.23663330078125,0.7077593929048287,0.7025702972954835,0.7130257108802996,336.3193054199219,0.7590580728193954
9
+ 7,-1,0.9380641521598968,0.7339451313018799,0.7145889147907172,0.7304477718106483,0.699404052443385,0.5424098968505859,0.7802089257311332,0.9379795293359123,445.5428161621094,0.7142410341951627,0.729165927555256,0.6999148646347693,586.2467651367188,0.7812387549609684,0.9380399742101869,17.663646697998047,0.7144247480013903,0.7295119787045253,0.6999489187808615,23.065956115722656,0.780661304599755,0.9380117666021921,441.88720703125,0.7143132276985029,0.7350990990990991,0.6946705261365571,321.2008056640625,0.77632069370724
10
+ 8,-1,0.9389547066408769,0.7134076356887817,0.7362523066599563,0.7255414118036039,0.7472841818491401,0.5718396902084351,0.7837278579155966,0.938930528691167,478.111572265625,0.7356171941616092,0.7225579714905078,0.7491571598842159,574.936767578125,0.7841746458023153,0.9389506769825918,18.565975189208984,0.7355403666505123,0.7221565925050863,0.7494295930529542,22.627147674560547,0.7842885252023064,0.9388620245003224,431.0670166015625,0.7367326051576315,0.7261211800502712,0.7476587774561553,337.70526123046875,0.7731685327224174
11
+ 9,-1,0.9398331721470019,0.6916142702102661,0.7328376574983968,0.7461706783369803,0.7199727566831262,0.5889520049095154,0.772660656556971,0.9397082527401677,486.5942077636719,0.7326520748463715,0.7428851471978156,0.722697088370509,564.412353515625,0.7733164125359162,0.9396760154738878,18.512386322021484,0.73282733103961,0.7442930392638899,0.7217095181338328,22.103715896606445,0.7732477636608306,0.9398936170212766,398.99700927734375,0.7331376320140365,0.7264702932227758,0.7399284862932062,322.1018981933594,0.7649336343573698
12
+ 10,-1,0.9407519342359768,0.7781369686126709,0.739671546610896,0.7447271220960336,0.734684147794994,0.598785400390625,0.7880129413809182,0.9405988072211476,415.1871337890625,0.7390562043297139,0.7410552264868011,0.7370679380214541,560.383056640625,0.7891372156012788,0.9407599935525467,16.461021423339844,0.7394946513572076,0.7409737417943107,0.7380214541120381,22.078475952148438,0.7886224309074015,0.9407519342359768,452.0459899902344,0.7404528732058655,0.7512617412028599,0.7299506214881661,361.9554443359375,0.7780874244480435
13
+ 11,-1,0.9406108961960026,0.696799635887146,0.7308022381655281,0.7367200747482437,0.7249787161586924,0.556389570236206,0.7790594718334573,0.9403973243068988,480.479736328125,0.7296637039347159,0.742698927765237,0.7170781542652818,568.3990478515625,0.7805541007996804,0.9403892649903288,19.026138305664062,0.729687257153712,0.7402074136360451,0.7194619444917418,22.555213928222656,0.7795796849932237,0.9408204384268214,417.43902587890625,0.7324324324324324,0.7358308987798591,0.7290652136897667,323.7745666503906,0.769907397964928
14
+ 12,-1,0.9395027401676338,0.6551991701126099,0.7275134579536942,0.7447567413325724,0.7110505704069471,0.553314745426178,0.7755738324174184,0.9394906511927789,512.1928100585938,0.7277290277290278,0.7507876154263987,0.7060446109313809,576.0177001953125,0.7766925710814888,0.9393818504190845,20.226606369018555,0.7269002468876398,0.748107835363656,0.7068619104375958,22.730484008789062,0.7763753765070203,0.9395913926499033,389.4950256347656,0.7286559299261921,0.7471552279395978,0.7110505704069471,327.77191162109375,0.7644954507599309
15
+ 13,-1,0.9389144100580271,0.6844364404678345,0.728031253866959,0.7569475077194531,0.7012429763323684,0.595650315284729,0.7730647722642658,0.9388056092843327,488.16650390625,0.7276908110020341,0.757085020242915,0.7004937851183382,554.832763671875,0.7742282510583335,0.9388579948420374,19.26504135131836,0.7278375484844761,0.7509416195856874,0.7061127192235654,22.17256736755371,0.7740326348416876,0.9389627659574468,408.8873291015625,0.7288357912648895,0.7600088721304203,0.700119189511323,354.1147155761719,0.7617965621320361
16
+ 14,-1,0.9385315925209542,0.7158571481704712,0.7225264954833204,0.7560567154181087,0.6918440320108973,0.5912114381790161,0.7719068643122562,0.9385315925209542,464.43426513671875,0.7219023101415893,0.718083493379157,0.7257619615188149,608.8768920898438,0.7729928601549992,0.9385557704706641,18.424461364746094,0.721666369948371,0.7561275881365417,0.6902094329984676,21.92572784423828,0.7728280322067003,0.9384509993552547,422.6900634765625,0.7239607987517314,0.7460793524607935,0.7031159543674442,337.285888671875,0.7613874415494246
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22dceb36ad828d00b61e7a21e01042cfc77128931cdf00185be70fa7108982ee
3
+ size 1343079533
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": false,
6
+ "mask_token": "[MASK]",
7
+ "max_len": 512,
8
+ "model_max_length": 512,
9
+ "never_split": null,
10
+ "pad_token": "[PAD]",
11
+ "sep_token": "[SEP]",
12
+ "strip_accents": false,
13
+ "tokenize_chinese_chars": true,
14
+ "tokenizer_class": "BertTokenizer",
15
+ "unk_token": "[UNK]"
16
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff