microsoft/graphrag · error · ValueError
Each item in ModelConfig.mock_responses must be a float.
Error message
Each item in ModelConfig.mock_responses must be a float.
What it means
MockLLMEmbedding validates every entry of ModelConfig.mock_responses is a float (integers are rejected too, due to the strict isinstance check). This guarantees the mock returns well-formed embedding vectors.
Source
Thrown at packages/graphrag-llm/graphrag_llm/embedding/mock_llm_embedding.py:52
self,
*,
model_config: "ModelConfig",
tokenizer: "Tokenizer",
metrics_store: "MetricsStore",
**kwargs: Any,
):
"""Initialize MockLLMEmbedding."""
self._tokenizer = tokenizer
self._metrics_store = metrics_store
mock_responses = model_config.mock_responses
if not isinstance(mock_responses, list) or len(mock_responses) == 0:
msg = "ModelConfig.mock_responses must be a non-empty list of embedding responses."
raise ValueError(msg)
if not all(isinstance(resp, float) for resp in mock_responses):
msg = "Each item in ModelConfig.mock_responses must be a float."
raise ValueError(msg)
self._mock_responses = mock_responses # type: ignore
def embedding(
self, /, **kwargs: Unpack["LLMEmbeddingArgs"]
) -> "LLMEmbeddingResponse":
"""Sync embedding method."""
input = kwargs.get("input")
response = create_embedding_response(
self._mock_responses, batch_size=len(input)
)
self._mock_index += 1
return response
async def embedding_async(
self, /, **kwargs: Unpack["LLMEmbeddingArgs"]
) -> "LLMEmbeddingResponse":
"""Async embedding method."""View on GitHub (pinned to f40e9a26ce)
Solutions
- Ensure every element is a float literal, e.g. [0.1, 0.0, 1.0] (use 1.0 not 1 in YAML/JSON)
- If values come from external data, coerce with [float(x) for x in values] before building ModelConfig
Example fix
# before ModelConfig(type=LLMProviderType.MockLLM, mock_responses=[1, 0, 1]) # after ModelConfig(type=LLMProviderType.MockLLM, mock_responses=[1.0, 0.0, 1.0])
Defensive patterns
Strategy: type-guard
Validate before calling
cfg_dict["mock_responses"] = [float(x) for x in raw_responses] # coerce before ModelConfig(**cfg_dict)
Type guard
def is_float_list(v) -> bool:
return isinstance(v, list) and len(v) > 0 and all(isinstance(x, float) for x in v) Prevention
- Write floats explicitly (1.0 not 1) in YAML/JSON fixtures
- Coerce external numeric data with float() before building mock configs
When it happens
Trigger: mock_responses containing strings (["0.1"]), ints ([1, 2]), None, or nested lists when constructing MockLLMEmbedding.
Common situations: YAML mock_responses: [1, 0, 1] parsed as ints; JSON config with string numbers; copy-pasted fixture data of the wrong type.
Related errors
- ModelConfig.mock_responses must be a non-empty list of embed
- ModelConfig.type '{strategy}' is not registered in the Compl
- request_id needs to be passed as a keyword argument
- Reports missing {source_col} column
- Response must be a list of dictionaries.
AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27).
Data as JSON: /api/errors/396f855b332d2547.
Report an issue: GitHub.