{"record":{"id":"c4113a0b2e25c95a","repo":"BerriAI/litellm","slug":"sentence-transformers-requires-2-sentences","errorCode":null,"errorMessage":"sentence transformers requires 2+ sentences","messagePattern":"sentence transformers requires 2\\+ sentences","errorType":"exception","errorClass":"HuggingFaceError","httpStatus":400,"severity":"error","filePath":"litellm/llms/huggingface/embedding/handler.py","lineNumber":148,"sourceCode":"            else:\n                data[k] = v\n\n        return data\n\n    def _transform_input(\n        self,\n        input: list,\n        model: str,\n        call_type: Literal[\"sync\", \"async\"],\n        optional_params: dict,\n        embed_url: str,\n    ) -> dict:\n        data: dict = {}\n\n        ## TRANSFORMATION ##\n        if \"sentence-transformers\" in model:\n            if len(input) == 0:\n                raise HuggingFaceError(\n                    status_code=400,\n                    message=\"sentence transformers requires 2+ sentences\",\n                )\n            data = {\"inputs\": {\"source_sentence\": input[0], \"sentences\": input[1:]}}\n        else:\n            data = {\"inputs\": input}\n\n            task_type: Final = optional_params.pop(\"input_type\", None)\n\n            if call_type == \"sync\":\n                hf_task: Final = get_hf_task_embedding_for_model(model=model, task_type=task_type, api_base=HF_HUB_URL)\n            elif call_type == \"async\":\n                return self._async_transform_input(model=model, task_type=task_type, embed_url=embed_url, input=input)\n\n            data = self._transform_input_on_pipeline_tag(input=input, pipeline_tag=hf_task)\n\n        if len(optional_params.keys()) > 0:\n            data = self._process_optional_params(data=data, optional_params=optional_params)","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/huggingface/embedding/handler.py#L130-L166","documentation":"Error \"sentence transformers requires 2+ sentences\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/huggingface/embedding/handler.py:148 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass at least two sentences in the input list; this task compares pairs of sentences."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}