Edwin Jose Palathinkal commited on
Commit ·
7b5123e
1
Parent(s): 098de9c
Update model card with accurate description of integer-to-English conversion
Browse files
README.md
CHANGED
|
@@ -3,35 +3,95 @@ language: en
|
|
| 3 |
license: mit
|
| 4 |
library_name: pytorch
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
| 7 |
- pytorch
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
# Namer
|
| 11 |
|
| 12 |
-
A PyTorch model
|
| 13 |
|
| 14 |
## Model Description
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Usage
|
| 19 |
|
|
|
|
|
|
|
| 20 |
```python
|
| 21 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
|
|
|
|
| 29 |
```
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
## Files
|
| 32 |
|
| 33 |
-
|
| 34 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Citation
|
| 37 |
|
|
@@ -40,7 +100,11 @@ If you use this model, please cite:
|
|
| 40 |
```bibtex
|
| 41 |
@software{namer,
|
| 42 |
author = {Edwin Jose Palathinkal},
|
| 43 |
-
title = {Namer:
|
| 44 |
url = {https://huggingface.co/edwinhere/namer}
|
| 45 |
}
|
| 46 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
license: mit
|
| 4 |
library_name: pytorch
|
| 5 |
tags:
|
| 6 |
+
- text-generation
|
| 7 |
+
- number-to-text
|
| 8 |
- pytorch
|
| 9 |
+
- transformer
|
| 10 |
---
|
| 11 |
|
| 12 |
# Namer
|
| 13 |
|
| 14 |
+
A PyTorch transformer model that converts **integers to their English names** (e.g., `42` → "forty two", `123` → "one hundred twenty three").
|
| 15 |
|
| 16 |
## Model Description
|
| 17 |
|
| 18 |
+
Namer is a sequence-to-sequence transformer trained to read digits of a number and generate the corresponding English textual representation. It handles numbers from 0 up to billions, learning the patterns of English number naming conventions.
|
| 19 |
+
|
| 20 |
+
**Example conversions:**
|
| 21 |
+
| Integer | English Name |
|
| 22 |
+
|---------|-------------|
|
| 23 |
+
| 0 | zero |
|
| 24 |
+
| 42 | forty two |
|
| 25 |
+
| 123 | one hundred twenty three |
|
| 26 |
+
| 1000 | one thousand |
|
| 27 |
+
| 1234567 | one million two hundred thirty four thousand five hundred sixty seven |
|
| 28 |
|
| 29 |
## Usage
|
| 30 |
|
| 31 |
+
### Quick Start
|
| 32 |
+
|
| 33 |
```python
|
| 34 |
import torch
|
| 35 |
+
from namer import load_namer_model, predict_number_name
|
| 36 |
+
|
| 37 |
+
# Load model
|
| 38 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 39 |
+
model = load_namer_model("namer_model.pt", device)
|
| 40 |
+
|
| 41 |
+
# Convert number to name
|
| 42 |
+
name = predict_number_name(model, 42)
|
| 43 |
+
print(f"42 -> '{name}'") # Output: forty two
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### Interactive Mode
|
| 47 |
|
| 48 |
+
```bash
|
| 49 |
+
python -m namer infer
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
Then enter numbers to convert interactively.
|
| 53 |
+
|
| 54 |
+
### API
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from namer.inference import predict_number_name
|
| 58 |
|
| 59 |
+
# Single prediction
|
| 60 |
+
name = predict_number_name(model, 123456)
|
| 61 |
+
# Returns: "one hundred twenty three thousand four hundred fifty six"
|
| 62 |
```
|
| 63 |
|
| 64 |
+
## Model Architecture
|
| 65 |
+
|
| 66 |
+
- **Type**: Sequence-to-sequence transformer
|
| 67 |
+
- **Input**: Digits of the integer (as token indices)
|
| 68 |
+
- **Output**: English words representing the number
|
| 69 |
+
- **Vocabulary**: English number words (zero-nineteen, twenty-ninety, hundred, thousand, million, billion, etc.)
|
| 70 |
+
|
| 71 |
## Files
|
| 72 |
|
| 73 |
+
| File | Description |
|
| 74 |
+
|------|-------------|
|
| 75 |
+
| `namer_model.pt` | Trained model weights |
|
| 76 |
+
| `namer/models.py` | Transformer architecture |
|
| 77 |
+
| `namer/inference.py` | Prediction utilities |
|
| 78 |
+
| `namer/utils.py` | Encoding/decoding utilities |
|
| 79 |
+
|
| 80 |
+
## Training
|
| 81 |
+
|
| 82 |
+
To train from scratch:
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
python -m namer train
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## Installation
|
| 89 |
+
|
| 90 |
+
```bash
|
| 91 |
+
git clone https://huggingface.co/edwinhere/namer
|
| 92 |
+
cd namer
|
| 93 |
+
pip install -e .
|
| 94 |
+
```
|
| 95 |
|
| 96 |
## Citation
|
| 97 |
|
|
|
|
| 100 |
```bibtex
|
| 101 |
@software{namer,
|
| 102 |
author = {Edwin Jose Palathinkal},
|
| 103 |
+
title = {Namer: Integer to English Name Converter},
|
| 104 |
url = {https://huggingface.co/edwinhere/namer}
|
| 105 |
}
|
| 106 |
```
|
| 107 |
+
|
| 108 |
+
## Links
|
| 109 |
+
|
| 110 |
+
- [GitHub Repository](https://github.com/edwinhere/namer)
|