alexkueck commited on
Commit
ada63db
·
1 Parent(s): 67a8e1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -14,13 +14,27 @@ import evaluate
14
 
15
 
16
  #####################################################
17
- #Hilfsfunktionen für das training
18
  #####################################################
19
  #Datensets in den Tokenizer schieben...
20
  def tokenize_function(examples):
21
  return tokenizer(examples["text"])
22
 
23
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
 
26
  #neues Model testen nach dem Training
 
14
 
15
 
16
  #####################################################
17
+ #Hilfsfunktionen für das Training
18
  #####################################################
19
  #Datensets in den Tokenizer schieben...
20
  def tokenize_function(examples):
21
  return tokenizer(examples["text"])
22
 
23
+ #Funktion, die den gegebenen Text aus dem Datenset gruppiert
24
+ def group_texts(examples):
25
+ # Concatenate all texts.
26
+ concatenated_examples = {k: sum(examples[k], []) for k in examples.keys()}
27
+ total_length = len(concatenated_examples[list(examples.keys())[0]])
28
+ # We drop the small remainder, we could add padding if the model supported it instead of this drop, you can
29
+ # customize this part to your needs.
30
+ total_length = (total_length // block_size) * block_size
31
+ # Split by chunks of max_len.
32
+ result = {
33
+ k: [t[i : i + block_size] for i in range(0, total_length, block_size)]
34
+ for k, t in concatenated_examples.items()
35
+ }
36
+ result["labels"] = result["input_ids"].copy()
37
+ return result
38
 
39
 
40
  #neues Model testen nach dem Training