File size: 6,020 Bytes
91180f7
 
7ed414d
 
 
91180f7
7ed414d
91180f7
beab205
91180f7
 
7ed414d
 
 
 
 
 
 
 
 
 
1b3a9d8
 
 
7ed414d
 
 
 
 
1b3a9d8
7ed414d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b3a9d8
7ed414d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b3a9d8
 
 
 
 
 
 
7ed414d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b3a9d8
7ed414d
 
1b3a9d8
 
7ed414d
 
 
1b3a9d8
 
 
 
7ed414d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
title: Trollsona
emoji: 🧌
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 5.50.0
app_file: app.py
pinned: true
---

# Trollsona / Your Troll Alterego

**Tagline:** Summon the little menace living behind your respectable personality.

**Track:** An Adventure in Thousand Token Wood

**Build target:** Hugging Face Space, Gradio app, small-model constraint `<=32B`.

**GitHub repo:** https://github.com/rthgit/Trollsona

**Official Build Small Space:** https://huggingface.co/spaces/build-small-hackathon/Trollsona

**Backup Space:** https://huggingface.co/spaces/RthItalia/Trollsona

Trollsona is a playful Gradio experience that turns a short user confession into a theatrical troll alter ego. The app returns a dossier-style result card with a trollsona name, a warm roast, one useful slap, and a goblin meter.

Built with a compact RthItalia model derived from `Qwen/Qwen2.5-3B-Instruct`, under `32B` parameters. The deployed Space is configured to try that model first, then a lightweight Qwen 0.5B model, then the deterministic local fallback if model loading or generation is unavailable.

The official public Space currently runs the lightweight Qwen fallback on CPU, while the custom RthItalia compact 3B path is enabled automatically when CUDA is available.

## Features

- Immersive Gradio UI for Hugging Face Spaces
- Theatrical trollsona result card
- Local Hugging Face Transformers generation path for the primary AI runtime
- Secondary lightweight Transformers model fallback
- Deterministic fallback generator for final resilience
- Safe roast guard for non-hateful, non-identity-targeted humor
- Persona dropdown, sting slider, and useful-truth checkbox
- Source/fallback notes hidden behind `See the cursed paperwork`

## Model Runtime

Trollsona uses a small-model cascade:

1. `RthItalia/nano_compact_3b_qkvfp16`
   - compact `Qwen/Qwen2.5-3B-Instruct`-derived model by RthItalia
   - preferred runtime when CUDA is available
   - loaded with `trust_remote_code=True`

2. `Qwen/Qwen2.5-0.5B-Instruct`
   - lightweight hosted CPU fallback model
   - currently active on the official public Hugging Face Space running on `cpu-basic`

3. Deterministic fallback
   - used only if both model paths are unavailable or return unsafe/invalid output
   - keeps the demo stable and reproducible

Constraint:

```text
small model only, <=32B parameters
```

Space model-first behavior:

```bash
TROLLSONA_ENABLE_MODEL=1
```

Recommended Hugging Face Space variables:

```text
TROLLSONA_ENABLE_MODEL=1
TROLLSONA_MODEL_ID=RthItalia/nano_compact_3b_qkvfp16
TROLLSONA_FALLBACK_MODEL_ID=Qwen/Qwen2.5-0.5B-Instruct
TROLLSONA_MAX_NEW_TOKENS=200
```

Local fallback-safe behavior if no variable is set:

```bash
TROLLSONA_ENABLE_MODEL=0
```

Deterministic fallback only:

```bash
TROLLSONA_ENABLE_MODEL=0
```

Implementation notes:

- `bitsandbytes` is not required
- primary RthItalia path expects CUDA
- CPU-only Spaces use the Qwen 0.5B model before the deterministic fallback
- source/runtime/fallback details are hidden in `See the cursed paperwork`

## Stack

- Python
- Gradio
- Hugging Face Spaces
- Hugging Face Transformers, primary model path
- PyTorch, model backend

Required secrets:

```text
[ASSENTE]
```

## Run Locally

```bash
pip install -r requirements.txt
python app.py
```

Open:

```text
http://127.0.0.1:7860
```

Model-first run:

```bash
TROLLSONA_ENABLE_MODEL=1 python app.py
```

Deterministic fallback run:

```bash
TROLLSONA_ENABLE_MODEL=0 python app.py
```

## Hugging Face Space

Required files:

- `app.py`
- `requirements.txt`
- `README.md`
- `assets/style.css`

Space SDK:

```text
Gradio
```

Official Build Small Space URL:

```text
https://huggingface.co/spaces/build-small-hackathon/Trollsona
```

Backup Space URL:

```text
https://huggingface.co/spaces/RthItalia/Trollsona
```

## Safety

Trollsona roasts habits, vibe, wording, overthinking, productivity rituals, internet behavior, startup energy, and harmless personal lore.

It avoids:

- protected-class targeting
- identity-based insults
- appearance insults
- threats or self-harm content
- sexual content
- profanity or slurs
- cruelty or humiliation

If generated model output fails the safety guard, the app replaces it with a safe fallback card.

## Hackathon Fit

- Built as a Gradio app for Hugging Face Space
- Fits `An Adventure in Thousand Token Wood`
- Supports the `<=32B` small-model constraint
- Uses `RthItalia/nano_compact_3b_qkvfp16` as the primary AI path when CUDA is available
- Keeps `Qwen/Qwen2.5-0.5B-Instruct` as a secondary model fallback
- Runs without mandatory cloud APIs
- Keeps deterministic fallback as a reliability guard
- Produces short, whimsical, shareable output

## Codex Track

Built with OpenAI Codex.

Public GitHub repo: https://github.com/rthgit/Trollsona

Codex-attributed commits include:

- `3fe2db1` Polish Trollsona dossier UI and grotesque prompt voice with Codex
- `4f196a6` Add RthItalia model cascade with Codex
- `8a1b09d` Document hosted model cascade QA with Codex
- `aad1a45` Finalize Trollsona submission packaging with Codex

- Space README repo link: present
- Demo video: https://youtu.be/p2m9tac8lF8
- Social post: https://www.linkedin.com/posts/christian-quintino-de-luca-72b808344_buildsmall-gradio-huggingface-ugcPost-7468732928114651137-zX2a/

## Known Limits

- Official public Space link: https://huggingface.co/spaces/build-small-hackathon/Trollsona
- Backup Space link: https://huggingface.co/spaces/RthItalia/Trollsona
- Demo video: https://youtu.be/p2m9tac8lF8
- Social post URL: https://www.linkedin.com/posts/christian-quintino-de-luca-72b808344_buildsmall-gradio-huggingface-ugcPost-7468732928114651137-zX2a/
- Primary RthItalia model path requires CUDA; CPU-only Spaces use the secondary model fallback before deterministic fallback
- First model-backed generation can be slower on cold Spaces while model files load
- Exact model-backed behavior on upgraded Space hardware: [AMBIGUO], because upgraded hardware has not been tested