Commit
ยท
020a95f
1
Parent(s):
6eb3128
Add Hugging Face metadata to README with indigo-purple theme
Browse files
README.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
|
|
@@ -6,23 +30,23 @@ A clean, modern web app that demonstrates how AI language models predict the nex
|
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
-
  A clean, modern web app that demonstrates how AI language models predict the next word in a sequence. Built with Gradio for easy deployment and secure token management.
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
-
## โจ Features
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
-
- **๐ฎ Real-time Predictions**: Updates automatically as you type
|
| 18 |
|
| 19 |
- **๐ Secure**: Uses environment variables for API tokens
|
| 20 |
|
| 21 |
-
- **โก Fast**: Serverless API calls with instant results
|
| 22 |
|
| 23 |
- **๐ฑ Responsive**: Clean, mobile-friendly interface
|
| 24 |
|
| 25 |
-
- **๐ Easy Deploy**: One-click deployment to HF Spaces## โจ Features๐ฏ **Note**: This project has been converted to a Gradio app! See `README-gradio.md` for the latest version.
|
| 26 |
|
| 27 |
|
| 28 |
|
|
@@ -30,72 +54,145 @@ A clean, modern web app that demonstrates how AI language models predict the nex
|
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
-
1. **Install dependencies
|
| 34 |
|
| 35 |
```bash
|
| 36 |
|
| 37 |
-
pip install -r requirements.txt
|
| 38 |
|
| 39 |
```
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
2. **Set your HF token:**
|
| 44 |
|
| 45 |
-
|
| 46 |
|
| 47 |
**Option A: Using .env file (Recommended for local development)**
|
| 48 |
|
| 49 |
-
```bash-
|
| 50 |
|
| 51 |
# Copy the template
|
| 52 |
|
| 53 |
-
cp .env.example .env
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
-
# Edit .env and add your token
|
| 58 |
|
| 59 |
# HF_NEXT_TOKEN_PREDICTOR_TOKEN=hf_your_actual_token_here
|
| 60 |
|
| 61 |
-
```
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
-
**Option B: Using environment variable**
|
| 66 |
|
| 67 |
```bash
|
| 68 |
|
| 69 |
-
export HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Linux/Mac
|
| 70 |
|
| 71 |
$env:HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Windows PowerShell
|
| 72 |
|
| 73 |
-
```
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
-
3. **Run the app:**
|
| 78 |
|
| 79 |
```bash
|
| 80 |
|
| 81 |
-
python app.py
|
| 82 |
|
| 83 |
```
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
4. **Open browser:** Navigate to `http://127.0.0.1:7860`
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
## ๐ง Deploy to HF Spaces
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
1. Create a new **Gradio Space** on Hugging Face
|
| 96 |
|
|
|
|
|
|
|
| 97 |
2. Upload `app.py` and `requirements.txt` ```bash- **๐ Easy Deploy**: One-click deployment to HF Spaces```
|
| 98 |
|
|
|
|
| 99 |
3. Set `HF_NEXT_TOKEN_PREDICTOR_TOKEN` as a **repository secret** (not as .env file)
|
| 100 |
|
| 101 |
4. Your demo is live! โจ # Copy the template
|
|
|
|
| 1 |
+
---# Next-Token Predictor# Next-Token Predictor# Next-Token Predictor---
|
| 2 |
+
|
| 3 |
+
title: Next-Token Predictor
|
| 4 |
+
|
| 5 |
+
emoji: ๐ฎ
|
| 6 |
+
|
| 7 |
+
colorFrom: indigo
|
| 8 |
+
|
| 9 |
+
colorTo: purpleA clean, modern web app that demonstrates how AI language models predict the next word in a sequence. Built with Gradio for easy deployment and secure token management.
|
| 10 |
+
|
| 11 |
+
sdk: gradio
|
| 12 |
+
|
| 13 |
+
sdk_version: 4.44.0
|
| 14 |
+
|
| 15 |
+
app_file: app.py
|
| 16 |
+
|
| 17 |
+
pinned: false  A clean, modern web app that demonstrates how AI language models predict the next word in a sequence. Built with Gradio for easy deployment and secure token management.title:# Next-Token Predictor
|
| 18 |
+
|
| 19 |
+
short_description: Demonstrate how AI language models predict the next word in a sequence
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# Next-Token Predictor## โจ Features
|
| 26 |
|
| 27 |
|
| 28 |
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
+
  - **๐ฎ Real-time Predictions**: Updates automatically as you type  A clean, modern web app that demonstrates how AI language models predict the next word in a sequence. Built with Gradio for easy deployment and secure token management.
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
+
## โจ Features- **๐ Secure**: Uses environment variables for API tokens
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
+
- **๐ฎ Real-time Predictions**: Updates automatically as you type- **โก Fast**: Serverless API calls with instant results
|
| 42 |
|
| 43 |
- **๐ Secure**: Uses environment variables for API tokens
|
| 44 |
|
| 45 |
+
- **โก Fast**: Serverless API calls with instant results- **๐ฑ Responsive**: Clean, mobile-friendly interface
|
| 46 |
|
| 47 |
- **๐ฑ Responsive**: Clean, mobile-friendly interface
|
| 48 |
|
| 49 |
+
- **๐ Easy Deploy**: One-click deployment to HF Spaces- **๐ Easy Deploy**: One-click deployment to HF Spaces## โจ Features๐ฏ **Note**: This project has been converted to a Gradio app! See `README-gradio.md` for the latest version.
|
| 50 |
|
| 51 |
|
| 52 |
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
+
1. **Install dependencies:**## ๐ Quick Start
|
| 58 |
|
| 59 |
```bash
|
| 60 |
|
| 61 |
+
pip install -r requirements.txt
|
| 62 |
|
| 63 |
```
|
| 64 |
|
| 65 |
+
1. **Install dependencies:**- **๐ฎ Real-time Predictions**: Updates automatically as you type  
|
| 66 |
|
| 67 |
2. **Set your HF token:**
|
| 68 |
|
| 69 |
+
```bash
|
| 70 |
|
| 71 |
**Option A: Using .env file (Recommended for local development)**
|
| 72 |
|
| 73 |
+
```bash pip install -r requirements.txt- **๐ Secure**: Uses environment variables for API tokens
|
| 74 |
|
| 75 |
# Copy the template
|
| 76 |
|
| 77 |
+
cp .env.example .env ```
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
+
# Edit .env and add your token:- **โก Fast**: Serverless API calls with instant resultsA web application that demonstrates how AI language models predict the next word in a sequence. Originally built with HTML/JavaScript, now available as a streamlined Gradio app for easier deployment and better security.
|
| 82 |
|
| 83 |
# HF_NEXT_TOKEN_PREDICTOR_TOKEN=hf_your_actual_token_here
|
| 84 |
|
| 85 |
+
```2. **Set your HF token:**
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
+
**Option B: Using environment variable** - **๐ฑ Responsive**: Clean, mobile-friendly interface
|
| 90 |
|
| 91 |
```bash
|
| 92 |
|
| 93 |
+
export HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Linux/Mac **Option A: Using .env file (Recommended for local development)**
|
| 94 |
|
| 95 |
$env:HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Windows PowerShell
|
| 96 |
|
| 97 |
+
``` ```bash- **๐ Easy Deploy**: One-click deployment to HF Spaces## โจ Features
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
+
3. **Run the app:** # Copy the template
|
| 102 |
|
| 103 |
```bash
|
| 104 |
|
| 105 |
+
python app.py cp .env.example .env
|
| 106 |
|
| 107 |
```
|
| 108 |
|
| 109 |
+
|
| 110 |
|
| 111 |
4. **Open browser:** Navigate to `http://127.0.0.1:7860`
|
| 112 |
|
| 113 |
+
# Edit .env and add your token:## ๐ Quick Start## ๐ Quick Start
|
| 114 |
|
| 115 |
## ๐ง Deploy to HF Spaces
|
| 116 |
|
| 117 |
+
# HF_NEXT_TOKEN_PREDICTOR_TOKEN=hf_your_actual_token_here
|
| 118 |
+
|
| 119 |
+
1. Create a new **Gradio Space** on Hugging Face
|
| 120 |
+
|
| 121 |
+
2. Upload `app.py` and `requirements.txt` ```
|
| 122 |
+
|
| 123 |
+
3. Set `HF_NEXT_TOKEN_PREDICTOR_TOKEN` as a **repository secret** (not as .env file)
|
| 124 |
+
|
| 125 |
+
4. Your demo is live! โจ
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
## ๐ฐ Cost **Option B: Using environment variable**1. **Install dependencies:**- **๐ฎ Real-time Predictions**: Updates automatically as you type
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
With HF Pro account ($20/month): ```bash
|
| 134 |
+
|
| 135 |
+
- **$2.00/month** in free API calls
|
| 136 |
+
|
| 137 |
+
- **~$0.0001** per prediction export HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Linux/Mac ```bash
|
| 138 |
+
|
| 139 |
+
- **2,000-20,000** free predictions/month
|
| 140 |
+
|
| 141 |
+
$env:HF_NEXT_TOKEN_PREDICTOR_TOKEN="hf_your_token_here" # Windows PowerShell
|
| 142 |
+
|
| 143 |
+
## ๐ฏ Try It
|
| 144 |
+
|
| 145 |
+
``` pip install -r requirements.txt- **๐ Secure**: Uses environment variables for API tokens **For the latest Gradio version**, see `README-gradio.md` and run:
|
| 146 |
+
|
| 147 |
+
Type "Twinkle, twinkle, little " and watch the AI predict "star"!
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
The app demonstrates how language models work by showing real-time probability distributions for the next token in any sequence.
|
| 152 |
+
|
| 153 |
+
3. **Run the app:** ```
|
| 154 |
+
|
| 155 |
+
## ๐ Security Notes
|
| 156 |
+
|
| 157 |
+
```bash
|
| 158 |
+
|
| 159 |
+
- **โ
.env file**: Safe for local development (ignored by git)
|
| 160 |
+
|
| 161 |
+
- **โ
Environment variables**: Work everywhere python app.py- **โก Fast**: Serverless API calls with instant results```bash
|
| 162 |
+
|
| 163 |
+
- **โ
HF Spaces secrets**: Secure for production deployment
|
| 164 |
+
|
| 165 |
+
- **โ Never commit**: Your actual token to version control ```
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
## ๐ Project Structure2. **Set your HF token:**
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
```4. **Open browser:** Navigate to `http://127.0.0.1:7860`
|
| 174 |
+
|
| 175 |
+
โโโ app.py # Main Gradio application
|
| 176 |
+
|
| 177 |
+
โโโ requirements.txt # Python dependencies - **๐ฑ Responsive**: Clean, mobile-friendly interfacepython app.py
|
| 178 |
+
|
| 179 |
+
โโโ .env.example # Template for environment variables
|
| 180 |
+
|
| 181 |
+
โโโ .env # Your actual tokens (git ignored)## ๐ง Deploy to HF Spaces
|
| 182 |
+
|
| 183 |
+
โโโ .gitignore # Protects secrets from being committed
|
| 184 |
+
|
| 185 |
+
โโโ README.md # This file **Option A: Using .env file (Recommended for local development)**
|
| 186 |
+
|
| 187 |
+
```
|
| 188 |
|
| 189 |
1. Create a new **Gradio Space** on Hugging Face
|
| 190 |
|
| 191 |
+
## ๐ค Contributing
|
| 192 |
+
|
| 193 |
2. Upload `app.py` and `requirements.txt` ```bash- **๐ Easy Deploy**: One-click deployment to HF Spaces```
|
| 194 |
|
| 195 |
+
Feel free to improve the API parsing, add features, or enhance the design!
|
| 196 |
3. Set `HF_NEXT_TOKEN_PREDICTOR_TOKEN` as a **repository secret** (not as .env file)
|
| 197 |
|
| 198 |
4. Your demo is live! โจ # Copy the template
|