athlab-llm / README.md
0ndre's picture
Add model card: architecture, training details, usage examples
795d42e verified
|
Raw History Blame Contribute Delete
5.95 kB
---
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}},
}
```