Edwin Jose Palathinkal commited on
Commit ·
098de9c
1
Parent(s): c255ac5
Add model card with HuggingFace metadata
Browse files
README.md
CHANGED
|
@@ -1,168 +1,46 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
## 🤗 HuggingFace Model
|
| 10 |
-
|
| 11 |
-
A pre-trained version of this model is available on HuggingFace:
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
## Features
|
| 16 |
-
|
| 17 |
-
- **Transformer architecture** with cross-attention mechanism
|
| 18 |
-
- **Infinite dataset** training with early stopping
|
| 19 |
-
- **Modular design** following Python best practices
|
| 20 |
-
- **Type hints** throughout for better IDE support
|
| 21 |
-
- **Comprehensive test suite** with pytest
|
| 22 |
-
- **Modern tooling**: ruff (linting/formatting), mypy (type checking)
|
| 23 |
-
|
| 24 |
-
## Installation
|
| 25 |
|
| 26 |
-
|
| 27 |
-
# Clone the repository
|
| 28 |
-
git clone https://github.com/example/namer.git
|
| 29 |
-
cd namer
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
python -m venv .venv
|
| 33 |
-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
| 34 |
|
| 35 |
-
|
| 36 |
-
pip install -e ".[dev]"
|
| 37 |
-
```
|
| 38 |
|
| 39 |
## Usage
|
| 40 |
|
| 41 |
-
### Command Line Interface
|
| 42 |
-
|
| 43 |
-
```bash
|
| 44 |
-
# Show help
|
| 45 |
-
namer --help
|
| 46 |
-
|
| 47 |
-
# Run demonstrations
|
| 48 |
-
namer demo
|
| 49 |
-
|
| 50 |
-
# Train the model
|
| 51 |
-
namer train
|
| 52 |
-
|
| 53 |
-
# Train with custom settings
|
| 54 |
-
namer train --epochs 50 --steps 2000 --batch-size 64 --lr 0.0005
|
| 55 |
-
|
| 56 |
-
# Run interactive inference
|
| 57 |
-
namer infer
|
| 58 |
-
|
| 59 |
-
# Run quick test
|
| 60 |
-
namer test
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
### Python API
|
| 64 |
-
|
| 65 |
```python
|
| 66 |
-
|
| 67 |
|
| 68 |
-
# Load
|
| 69 |
-
model =
|
|
|
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
|
| 73 |
-
print(name) # "one hundred twenty three thousand four hundred fifty six"
|
| 74 |
```
|
| 75 |
|
| 76 |
-
##
|
| 77 |
|
| 78 |
-
``
|
| 79 |
-
namer/
|
| 80 |
-
├── namer/ # Main package
|
| 81 |
-
│ ├── __init__.py # Package exports
|
| 82 |
-
│ ├── main.py # CLI entry point
|
| 83 |
-
│ ├── models.py # Transformer model definitions
|
| 84 |
-
│ ├── data.py # Dataset classes
|
| 85 |
-
│ ├── training.py # Training loop
|
| 86 |
-
│ ├── inference.py # Inference utilities
|
| 87 |
-
│ └── utils.py # Number-to-name conversion utilities
|
| 88 |
-
├── tests/ # Test suite
|
| 89 |
-
│ ├── test_utils.py
|
| 90 |
-
│ ├── test_models.py
|
| 91 |
-
│ ├── test_data.py
|
| 92 |
-
│ └── test_inference.py
|
| 93 |
-
├── pyproject.toml # Project configuration
|
| 94 |
-
├── README.md
|
| 95 |
-
└── Makefile # Convenience commands
|
| 96 |
-
```
|
| 97 |
|
| 98 |
-
##
|
| 99 |
|
| 100 |
-
|
| 101 |
|
| 102 |
-
```
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
# Run specific test file
|
| 110 |
-
pytest tests/test_utils.py
|
| 111 |
-
```
|
| 112 |
-
|
| 113 |
-
### Linting and Formatting
|
| 114 |
-
|
| 115 |
-
```bash
|
| 116 |
-
# Check code style
|
| 117 |
-
ruff check .
|
| 118 |
-
|
| 119 |
-
# Fix auto-fixable issues
|
| 120 |
-
ruff check --fix .
|
| 121 |
-
|
| 122 |
-
# Format code
|
| 123 |
-
ruff format .
|
| 124 |
-
|
| 125 |
-
# Type checking
|
| 126 |
-
mypy namer
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
### Makefile Commands
|
| 130 |
-
|
| 131 |
-
```bash
|
| 132 |
-
make help # Show available commands
|
| 133 |
-
make install # Install dependencies
|
| 134 |
-
make train # Train the model
|
| 135 |
-
make inference # Run interactive inference
|
| 136 |
-
make test # Run tests
|
| 137 |
-
make clean # Clean generated files
|
| 138 |
-
make distclean # Deep clean including venv
|
| 139 |
```
|
| 140 |
-
|
| 141 |
-
## Model Architecture
|
| 142 |
-
|
| 143 |
-
The `NamerTransformer` uses an encoder-only architecture:
|
| 144 |
-
|
| 145 |
-
1. **Digit Embedding** - Embeds digits 0-9 (plus padding token)
|
| 146 |
-
2. **Positional Encoding** - Sinusoidal positional embeddings
|
| 147 |
-
3. **Transformer Encoder** - Multi-layer encoder with self-attention
|
| 148 |
-
4. **Cross-Attention** - Learned output queries attend to encoded digits
|
| 149 |
-
5. **Output Projection** - Projects to vocabulary for each output position
|
| 150 |
-
|
| 151 |
-
## Training
|
| 152 |
-
|
| 153 |
-
The model trains on an infinite dataset that generates random number-to-name mappings on-the-fly:
|
| 154 |
-
|
| 155 |
-
- Numbers up to 999,999 (configurable)
|
| 156 |
-
- Early stopping with patience (default: 10 epochs)
|
| 157 |
-
- Cross-entropy loss with -1 padding ignored
|
| 158 |
-
- Adam optimizer with configurable learning rate
|
| 159 |
-
|
| 160 |
-
## Requirements
|
| 161 |
-
|
| 162 |
-
- Python 3.10+
|
| 163 |
-
- PyTorch 2.0+
|
| 164 |
-
- CUDA-capable GPU (optional, falls back to CPU)
|
| 165 |
-
|
| 166 |
-
## License
|
| 167 |
-
|
| 168 |
-
MIT License - see LICENSE file for details.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
library_name: pytorch
|
| 5 |
+
tags:
|
| 6 |
+
- name-generation
|
| 7 |
+
- pytorch
|
| 8 |
+
---
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Namer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
A PyTorch model for generating names.
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
## Model Description
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
This model generates creative names based on input patterns or criteria.
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Usage
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
```python
|
| 21 |
+
import torch
|
| 22 |
|
| 23 |
+
# Load the model
|
| 24 |
+
model = torch.load("namer_model.pt", map_location="cpu")
|
| 25 |
+
model.eval()
|
| 26 |
|
| 27 |
+
# Use the model for inference
|
| 28 |
+
# (Add specific usage example based on your model's API)
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
+
## Files
|
| 32 |
|
| 33 |
+
- `namer_model.pt` - Model weights
|
| 34 |
+
- `namer/` - Source code package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
## Citation
|
| 37 |
|
| 38 |
+
If you use this model, please cite:
|
| 39 |
|
| 40 |
+
```bibtex
|
| 41 |
+
@software{namer,
|
| 42 |
+
author = {Edwin Jose Palathinkal},
|
| 43 |
+
title = {Namer: A name generation model},
|
| 44 |
+
url = {https://huggingface.co/edwinhere/namer}
|
| 45 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|