Cacifer RNN Dreamer

...

Cacifer RNN Dreamer

A small character-level SimpleRNN trained on my own Cacifer stories (Cacifer the cat, Romé, Dania, Deonardo, San Michele, Valiponte, etc.).
It learns to speak in that world’s voice and sometimes says strange, beautiful things like “carred his old ask.”

  • Framework: Keras / TensorFlow
  • Context length: 60 characters
  • Vocabulary: 124 characters (letters, punctuation, emojis)

Files

  • cacifer_rnn_dreamer.keras – Keras model file
  • char_to_idx.json – mapping from character → index
  • idx_to_char.json – mapping from index → character

Usage

import json
import numpy as np
from tensorflow.keras.models import load_model

model = load_model("cacifer_rnn_dreamer.keras", compile=False)
char_to_idx = json.load(open("char_to_idx.json"))
idx_to_char = {int(k): v for k, v in json.load(open("idx_to_char.json")).items()}
seq_len = 60

def sample_char(probs, temperature=0.7):
    probs = np.asarray(probs).astype("float64")
    probs = np.log(probs + 1e-8) / temperature
    probs = np.exp(probs) / np.sum(probs)
    return np.random.choice(len(probs), p=probs)

def generate(seed, length=400, temperature=0.7):
    x = seed[-seq_len:]
    for _ in range(length):
        x_idx = np.array([[char_to_idx.get(c, 0) for c in x]])
        preds = model.predict(x_idx, verbose=0)[0]
        next_idx = sample_char(preds, temperature)
        x += idx_to_char[next_idx]
    return x

seed = "I am Cacifer, a cat, listening to the bells and the breathing of the guests."
print(generate(seed, length=400, temperature=0.7))

---
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support