--- language: en license: mit tags: - pytorch - rnn - character-level - text-generation - custom-model library_name: pytorch --- # CharRNN — Character-Level Text Generation Model ## Model Description Yeh ek **character-level RNN (Recurrent Neural Network)** model hai jo PyTorch mein from scratch train kiya gaya hai. Yeh model ek chhote English text corpus par train hua hai aur agla character predict karta hai diye gaye seed text ke based par. Model ka architecture simple hai: - **Embedding Layer**: Characters ko 64-dimensional vectors mein convert karta hai - **RNN Layer**: 256 hidden units ke saath sequence process karta hai - **Linear Layer**: Hidden state se vocabulary ke scores (logits) banata hai Yeh model **educational purposes** ke liye perfect hai — seekhne ke liye ke RNN kaise kaam karta hai, character-level prediction kaise hoti hai, aur PyTorch mein custom models kaise banate hain. ## Model Details ### Model Type - **Architecture**: Simple RNN (Recurrent Neural Network) - **Task**: Character-level text generation - **Framework**: PyTorch - **Language**: English ### Hyperparameters | Parameter | Value | |---|---| | Embedding Size | 64 | | Hidden Size | 256 | | Sequence Length | 20 | | Learning Rate | 0.001 | | Optimizer | Adam | | Loss Function | CrossEntropyLoss | | Epochs | 30 | | Batch Size | 32 | ### Files | File | Description | |---|---| | `simple_rnn.pth` | Trained model weights | | `config.json` | Model architecture configuration | | `vocab.json` | Character-to-index and index-to-character mappings | | `model.py` | CharRNN class definition | ## Uses ### Direct Use Yeh model seed text leta hai aur uske based par agla character predict karta hai. Isse aap text generate kar sakte ho — ek seed do, aur model character-by-character naya text banata hai. ### Out-of-Scope Use - **Yeh model chhote corpus par train hua hai** — isliye iska output limited vocabulary aur patterns tak mehdood hai. - **Yeh model hallucinate kar sakta hai** — kyunki yeh character-level hai, yeh aise words bana sakta hai jo actual English mein nahi hain. - **Production use ke liye recommended nahi** — yeh ek seekhne wala project hai. ## How to Use ### Step 1: Install Dependencies ```bash pip install torch huggingface_hub