File size: 1,219 Bytes
b5810aa bee8b7b b5810aa bee8b7b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
---
license: apache-2.0
library_name: keras
---
# Surrogate Model (Teeny-Tiny Castle)
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.
## How to Use
```python
from datasets import load_dataset
from huggingface_hub import hf_hub_download
from keras_preprocessing.sequence import pad_sequences
# Download the surrogate model
hf_hub_download(repo_id="AiresPucrs/surrogate-model",
filename="surrogate_model.h5",
local_dir="./",
repo_type="model"
)
# Download the surrogate tokenizer file
hf_hub_download(repo_id="AiresPucrs/surrogate-model",
filename="tokenizer_surrogate_model.json",
local_dir="./",
repo_type="model"
)
surrogate_model = tf.keras.models.load_model('./surrogate_model.h5')
with open('./tokenizer_surrogate_model.json') as fp:
data = json.load(fp)
tokenizer_surrogate = tf.keras.preprocessing.text.tokenizer_from_json(data)
word_index_surrogate = tokenizer_surrogate.word_index
fp.close()
``` |