Views
No views yet
| Component | Details |
|---|---|
| Embedding | 106 chars -> 128d vectors |
| GRU | 512 units, dropout=0.2 |
| Dense | 106 output classes |
| Total params | 1,054,058 |
1import tensorflow as tf
2import json
3from huggingface_hub import hf_hub_download
4
5# Download files
6model_path = hf_hub_download(repo_id="ismail99/char-based-language-model", filename="model.keras")
7vocab_path = hf_hub_download(repo_id="ismail99/char-based-language-model", filename="vocab.json")
8
9# Load vocabulary and build lookup layers
10with open(vocab_path) as f:
11 vocab = json.load(f)
12
13get_ids = tf.keras.layers.StringLookup(vocabulary=vocab, mask_token=None)
14get_chars = tf.keras.layers.StringLookup(
15 vocabulary=get_ids.get_vocabulary(), invert=True, mask_token=None
16)
17
18# Load model (requires CharModel class definition)
19model = tf.keras.models.load_model(model_path)