GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [Bug]: negative batch_size silently drops inputs in EmbeddingModelBase · Issue #3449 · agentscope-ai/agentscope Closed Labels DescriptionPrerequisites
Background / DescriptionI have searched existing issues and PRs, and searched indexed discussions, and found no matching report for EmbeddingModelBase constructor validation. A custom provider that passes This is an invalid-configuration handling bug in the documented custom-provider extension point. The built-in providers use positive constants; this report does not demonstrate a failure with their defaults. At main commit Expected: reject nonpositive batch sizes with a clear Error MessagesNo error occurs for the negative value. An offline probe using the actual base implementation observed: | batch_size | Construction | Result for 5 inputs | Provider batch sizes | | --- | --- | --- | --- | | -1 | succeeds | 0 embeddings, no exception | none | | 0 | succeeds | ValueError: range() arg 3 must not be zero | none | | 1 | succeeds | 5 ordered embeddings | 1, 1, 1, 1, 1 | | 2 | succeeds | 5 ordered embeddings | 2, 2, 1 | | 5 | succeeds | 5 ordered embeddings | 5 | Steps to ReproduceWith this revision installed, save the following as import asyncio from agentscope.credential import OpenAICredential from agentscope.embedding import EmbeddingModelBase, EmbeddingResponse class LocalEmbedding(EmbeddingModelBase[str]): def __init__(self, batch_size): super().__init__( credential=OpenAICredential(api_key="offline-test-only"), model="offline-stub", dimensions=1, parameters=None, context_size=1024, batch_size=batch_size, max_retries=0, retry_delay=0, ) self.calls = [] async def _call_api(self, inputs, **kwargs): self.calls.append(list(inputs)) return EmbeddingResponse( embeddings=[[float(len(item))] for item in inputs], ) async def main(): for size in (-1, 2): model = LocalEmbedding(size) response = await model(["a", "bb", "ccc", "dddd", "eeeee"]) print(size, response.embeddings, model.calls) asyncio.run(main()) Output: Environment
Proposed scopeAdd a positivity check in the base constructor, explain the requirement in its docstring and custom-provider documentation, and cover negative/zero values, positive batching and empty input with offline tests. Constructor-contract tests currently give 2 failures and 4 passes: both invalid sizes are accepted, while positive batching and valid empty input pass. An alternative is to validate on every call. Constructor validation catches the bad configuration earlier and matches the existing dimensions validation; handling direct mutation of Related #3341 / #3343 address the analogous issue in I would like to contribute this focused fix if the scope is acceptable. Investigation, reproduction and this draft used Codex assistance. Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |