# ValueError: Pooling mode 'mean' not supported for this model. Expected 'cls' pooling.

- **ID:** `llm/embedding-model-mismatch-pooling`
- **Domain:** llm
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using a sentence-transformer model with an incompatible pooling method during embedding generation, often due to model card misreading.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| sentence-transformers 2.2.0 | active | — | — |
| sentence-transformers 2.3.0 | active | — | — |
| transformers 4.35.0 | active | — | — |

## Workarounds

1. **Change pooling mode to 'cls' explicitly: model = SentenceTransformer('model-name', device='cpu'); embeddings = model.encode(sentences, pool='cls')** (95% success)
   ```
   Change pooling mode to 'cls' explicitly: model = SentenceTransformer('model-name', device='cpu'); embeddings = model.encode(sentences, pool='cls')
   ```
2. **Use a different model that supports 'mean' pooling, e.g., 'all-MiniLM-L6-v2'** (85% success)
   ```
   Use a different model that supports 'mean' pooling, e.g., 'all-MiniLM-L6-v2'
   ```

## Dead Ends

- **Upgrading sentence-transformers to latest version without checking model compatibility** — Pooling mode is model-specific, not version-specific; upgrade doesn't change model internals. (90% fail)
- **Setting pooling mode to 'auto' hoping library will infer correctly** — Auto-detection may default to unsupported mode if model config is ambiguous. (70% fail)
