File size: 5,949 Bytes
795d42e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- en
license: apache-2.0
library_name: peft
tags:
- sports
- coaching
- multimodal
- vision-language
- qwen3
- lora
- clip
- sports-ai
- athletic-performance
base_model: Qwen/Qwen3-8B
pipeline_tag: image-text-to-text
---

# AthlabLLM πŸ‹οΈ

> **A multimodal AI sports coaching assistant** β€” ask it anything about athletic performance, training technique, injury prevention, and sport-specific coaching. Feed it an image of an athlete for visual analysis.

**AthlabLLM** is built on [Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) with CLIP ViT-L/14 image encoding
and per-modality MLP projectors for image grounding. It delivers **concise, direct coaching advice** β€” no
reasoning preamble, no restating questions β€” both for text-only queries and image-conditioned analysis.

---

### Example text responses

| Prompt | Response |
|--------|----------|
| *How can I improve acceleration over the first 10 meters in a sprint?* | Focus on explosive starts with proper technique, and incorporate plyometric exercises like box jumps to enhance power and speed. |
| *What is one correction for knee valgus during squats?* | Keep the knees aligned over the toes throughout the movement. |
| *Give direct advice: I get lower-back tightness during deadlifts.* | Reduce weight and focus on maintaining a neutral spine throughout the movement. |
| *Concise plan to improve vertical jump over 6 weeks?* | Focus on plyometric exercises (box jumps, depth jumps), combine with leg strength training, 3–4 sessions per week. |
| *What pacing strategy for a beginner 5k?* | Maintain a steady, comfortable pace throughout the race, avoiding surges to conserve energy. |

---

## Architecture

```
CLIP ViT-L/14 (frozen)         β†’  2-layer MLP Projector ─┐
sentence-transformers/MiniLM   β†’  2-layer MLP Projector ───  Qwen3-8B + LoRA (r=8)
PointNet++ (optional, 3D)      β†’  2-layer MLP Projector β”€β”˜
```

| Component | Details |
|-----------|---------|
| **LLM backbone** | [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) |
| **Image encoder** | [openai/clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) (frozen, 1024-dim) |
| **Text encoder** | [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) (384-dim) |
| **Projection** | 2-layer MLP per modality, hidden dim 4096, LayerNorm |
| **LoRA** | r=8, alpha=32, dropout=0.1, target: q/k/v/o_proj |
| **Precision** | bfloat16 |
| **Context length** | 512 tokens |

---

## Training

Two-stage training pipeline on **Azure ML** (`Standard_NC24ads_A100_v4`, A100 80 GB):

| Stage | Dataset | What trains | Steps | Val Loss |
|-------|---------|-------------|-------|----------|
| **Stage 1** β€” Modality Alignment | COCO 2017 train (~118k images) | MLP projectors only (LLM frozen) | 30,000 | 2.176 |
| **Stage 2** β€” Instruction Tuning | COCO image QA + sport coaching pairs | Projectors + LLM LoRA | 4,000 | **1.192** |

**Key training details:**
- Qwen3 thinking mode disabled via `enable_thinking=False` throughout β€” clean outputs, zero chain-of-thought leakage
- Behavior echo rate: **0.0** throughout Stage 2 (model never repeats the question)
- Behavior score: **1.0** throughout Stage 2
- Stage 2 image-conditioned: every training sample has a verified COCO image (3 instruction types per image)

---

## Usage

### Installation

```bash
pip install transformers peft torch torchvision
# Clone the AthlabLLM source
git clone https://github.com/ondrabimka/AthlabLLM.git
cd AthlabLLM && pip install -e .
```

### Text-only coaching (fastest)

```python
from athlab_llm.models.multimodal_llm import MultimodalLLM

model = MultimodalLLM.from_pretrained("DabraTech/athlab-llm")
model.eval()

answer = model.generate(
    text="How can I improve my sprint start from blocks?",
    max_new_tokens=96,
    temperature=0.1,
    top_p=0.85,
    repetition_penalty=1.15,
)
print(answer)
# β†’ "Drive out at a 45-degree angle for the first 6–8 steps, keep your head
#    neutral, and push through both legs instead of popping up early."
```

### Image + text (multimodal)

```python
from PIL import Image
from athlab_llm.models.multimodal_llm import MultimodalLLM

model = MultimodalLLM.from_pretrained("DabraTech/athlab-llm")
model.eval()

image = Image.open("sprint_posture.jpg").convert("RGB")
pixel_values = model.image_encoder.preprocess_image(image)

answer = model.generate(
    text="Describe the athlete's posture and suggest one key correction.",
    image=pixel_values,
    max_new_tokens=128,
    temperature=0.1,
)
print(answer)
```

### Local REST API

```bash
# Start the server
python scripts/serve_local.py --checkpoint DabraTech/athlab-llm

# Query it
curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d '{"text": "What warm-up should I do before plyometric training?"}'
```

---

## Repository contents

| File | Description |
|------|-------------|
| `encoders.pt` | Image encoder (CLIP) + text encoder (MiniLM) + MLP projector weights |
| `llm/adapter_model.safetensors` | Qwen3-8B LoRA adapter weights (r=8) |
| `llm/adapter_config.json` | LoRA config |
| `llm/tokenizer*.json` | Qwen3 tokenizer + chat template |
| `config.yaml` | Full AthlabLLM model config |

---

## Limitations & roadmap

- **Multimodal grounding** trained on COCO captions β€” sport-specific grounding improves significantly with domain-specific image datasets (action recognition, pose estimation, etc.)
- **Hallucination**: model may describe sport elements not visible in the image; this is a known Stage 1 alignment limitation
- **Language**: English only
- **Context**: 512 token max sequence length

---

## Citation

```bibtex
@misc{athlab-llm-2026,
  title        = {AthlabLLM: Multimodal Sports Coaching Assistant},
  author       = {DabraTech},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/DabraTech/athlab-llm}},
}
```