OpenBMB/ChatDev · error · ValueError
LocalEmbedding requires model_path parameter
Error message
LocalEmbedding requires model_path parameter
What it means
LocalEmbedding requires params.model_path to point at a local sentence-transformers model. Without it there is nothing to load, so __init__ raises before loading the model.
Source
Thrown at runtime/node/agent/memory/embedding.py:171
elif self.chunk_strategy == 'weighted':
# Weighted aggregation (earlier chunks weigh more)
weights = [1.0 / (i + 1) for i in range(len(chunk_embeddings))]
total_weight = sum(weights)
return [sum(chunk[i] * weights[j] for j, chunk in enumerate(chunk_embeddings)) / total_weight
for i in range(len(chunk_embeddings[0]))]
else:
# Default to the first chunk
return chunk_embeddings[0]
class LocalEmbedding(EmbeddingBase):
def __init__(self, embedding_config: EmbeddingConfig):
super().__init__(embedding_config)
self.model_path = embedding_config.params.get('model_path')
self.device = embedding_config.params.get('device', 'cpu')
self._fallback_dim = 768 # Default; updated after first successful call
if not self.model_path:
raise ValueError("LocalEmbedding requires model_path parameter")
# Load the local embedding model (e.g., sentence-transformers)
try:
from sentence_transformers import SentenceTransformer
self.model = SentenceTransformer(self.model_path, device=self.device)
except ImportError:
raise ImportError("sentence-transformers is required for LocalEmbedding")
def get_embedding(self, text):
# Preprocess text before encoding
processed_text = self._preprocess_text(text)
if not processed_text:
return [0.0] * self._fallback_dim
try:
embedding = self.model.encode(processed_text, convert_to_tensor=False)
result = embedding.tolist()View on GitHub (pinned to 4fb2db0ea9)
Solutions
- Add params={'model_path': '/path/to/model-or-repo-id'} to the embedding config
- Use a valid sentence-transformers model id (e.g. 'sentence-transformers/all-MiniLM-L6-v2')
- Verify the key is exactly 'model_path' (snake_case)
Example fix
# before
EmbeddingConfig(provider='local', params={'device': 'cpu'})
# after
EmbeddingConfig(provider='local', params={'model_path': 'sentence-transformers/all-MiniLM-L6-v2', 'device': 'cpu'}) Defensive patterns
Strategy: validation
Validate before calling
if embedding_config.provider == 'local' and not embedding_config.params.get('model_path'):
raise ConfigError('local embedding requires params.model_path') Prevention
- Schema-validate params for local provider
- Use exact key 'model_path'
When it happens
Trigger: provider='local' with no params dict or no 'model_path' key: EmbeddingConfig(provider='local', params={'device':'cpu'}) — device alone is not enough.
Common situations: Assuming 'local' downloads a default model; forgetting to include the path to the downloaded model directory; typo like 'modelPath' or 'path' in params.
Related errors
AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27).
Data as JSON: /api/errors/3de41691dc7602f3.
Report an issue: GitHub.