File size: 1,805 Bytes
d018134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
---
language: en
library_name: tensorflow
tags:
  - character-level
  - text-generation
  - gru
  - tensorflow
  - keras
pipeline_tag: text-generation
---

# Character-Based Language Model (GRU)

A character-level text generation model trained on ~2,700 business news articles.
Generates text one character at a time using a GRU recurrent neural network.

## Model Architecture

| Component | Details |
|-----------|--------|
| Embedding | 106 chars -> 128d vectors |
| GRU | 512 units, dropout=0.2 |
| Dense | 106 output classes |
| Total params | 1,054,058 |

## Usage

```python
import tensorflow as tf
import json
from huggingface_hub import hf_hub_download

# Download files
model_path = hf_hub_download(repo_id="ismail99/char-based-language-model", filename="model.keras")
vocab_path = hf_hub_download(repo_id="ismail99/char-based-language-model", filename="vocab.json")

# Load vocabulary and build lookup layers
with open(vocab_path) as f:
    vocab = json.load(f)

get_ids = tf.keras.layers.StringLookup(vocabulary=vocab, mask_token=None)
get_chars = tf.keras.layers.StringLookup(
    vocabulary=get_ids.get_vocabulary(), invert=True, mask_token=None
)

# Load model (requires CharModel class definition)
model = tf.keras.models.load_model(model_path)
```

## Training Details

- **Dataset**: 2,692 business news articles (~4,483,812 characters after cleaning)
- **Sequence length**: 100
- **Epochs**: 30 (with early stopping, patience=5)
- **Optimizer**: Adam
- **Validation split**: 10%

## Limitations

This is a small character-level model trained on a narrow domain (business news).
It produces plausible-looking news-style text but not factually accurate content.
Out-of-domain seeds will produce lower quality output.


license: mit

language:
- en
- 
pipeline_tag: text-generation
---