Keras
nicholasKluge commited on
Commit
bee8b7b
1 Parent(s): e2505a9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -0
README.md CHANGED
@@ -1,3 +1,36 @@
1
  ---
2
  license: apache-2.0
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ library_name: keras
4
  ---
5
+ # Surrogate Model (Teeny-Tiny Castle)
6
+
7
+ This model is part of a tutorial tied to the [Teeny-Tiny Castle](https://github.com/Nkluge-correa/TeenyTinyCastle), an open-source repository containing educational tools for AI Ethics and Safety research.
8
+
9
+ ## How to Use
10
+
11
+ ```python
12
+ from datasets import load_dataset
13
+ from huggingface_hub import hf_hub_download
14
+ from keras_preprocessing.sequence import pad_sequences
15
+
16
+ # Download the surrogate model
17
+ hf_hub_download(repo_id="AiresPucrs/surrogate-model",
18
+                 filename="surrogate_model.h5",
19
+                 local_dir="./",
20
+                 repo_type="model"
21
+ )
22
+
23
+ # Download the surrogate tokenizer file
24
+ hf_hub_download(repo_id="AiresPucrs/surrogate-model",
25
+                 filename="tokenizer_surrogate_model.json",
26
+                 local_dir="./",
27
+                 repo_type="model"
28
+ )
29
+ surrogate_model = tf.keras.models.load_model('./surrogate_model.h5')
30
+
31
+ with open('./tokenizer_surrogate_model.json') as fp:
32
+ data = json.load(fp)
33
+ tokenizer_surrogate = tf.keras.preprocessing.text.tokenizer_from_json(data)
34
+ word_index_surrogate = tokenizer_surrogate.word_index
35
+ fp.close()
36
+ ```