bastitx commited on
Commit
58ef84f
·
1 Parent(s): a757ba2

add Aleph-Alpha-GermanWeb-Grammar-Classifier-BERT model

Browse files
Files changed (3) hide show
  1. README.md +26 -0
  2. config.json +26 -0
  3. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Aleph-Alpha-GermanWeb-Classifier-BERT
2
+
3
+ ## Example Snippet
4
+
5
+ ```python
6
+ import torch
7
+ from transformers import BertTokenizer, BertForSequenceClassification
8
+
9
+ device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
10
+
11
+ model = BertForSequenceClassification.from_pretrained("Aleph-Alpha/Aleph-Alpha-GermanWeb-Grammar-Classifier-BERT", num_labels=2).to(device)
12
+
13
+ tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
14
+
15
+ # disclaimer: short text is not in the model distribution
16
+ text = 'Das ist ein Beispieltext, um die Grammatik zu überprüfen.'
17
+
18
+ target_names = ['Low Quality', 'High Quality']
19
+
20
+ with torch.no_grad():
21
+ prediction = torch.argmax(
22
+ model(**tokenizer(text, return_tensors='pt', truncation=True, padding=True).to(device)).logits
23
+ ).item()
24
+ print(target_names[prediction])
25
+
26
+ ```
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bert-base-uncased",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.48.3",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d45b4eefc547d7752ed074fd4699ddfcfd98e7245be8596bc5ac663b60e47df
3
+ size 437958648