Skip to content

[BUG] error with embedder config using huggingface provider #4145

@prusswan

Description

@prusswan

Description

Despite the fix in #4005, I am getting error when running crewai run using huggingface provider for embedder. Crewai version is 1.7.1/1.7.2

It is unclear what the pydantic validation error is referring to: "Error: could not convert string to float:"

Steps to Reproduce

Using the config from https://docs.crewai.com/en/concepts/memory#hugging-face-embeddings

        # ... snipped 
        return Crew(
            agents=self.agents,  # Automatically collected by the @agent decorator
            tasks=self.tasks,    # Automatically collected by the @task decorator.
            process=Process.sequential,
            verbose=True,
            memory=True,
            embedder={
                "provider":"huggingface",
                "config": {
                    #"api_key": "your-hf-token",  # Optional for public models
                    "model": "sentence-transformers/all-MiniLM-L6-v2"
                }
            }
        )

Expected behavior

crewai run should work without error

Screenshots/Code snippets

N/A

Operating System

Windows 11

Python Version

3.12

crewAI Version

1.7.1

crewAI Tools Version

1.7.1

Virtual Environment

Venv

Evidence

> crewai run
Running the Crew
Traceback (most recent call last):
  File "D:\data\crewai_ia\market-researcher\src\seo_crew\main.py", line 28, in run
    seo_crew_instance = SeoCrew().crew()
                        ^^^^^^^^^^^^^^^^
  File "D:\data\crewai_ia\market-researcher\.venv\Lib\site-packages\crewai\project\utils.py", line 70, in wrapper
    result = meth(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "D:\data\crewai_ia\market-researcher\.venv\Lib\site-packages\crewai\project\annotations.py", line 237, in wrapper
    crew_instance: Crew = _call_method(meth, self, *args, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\data\crewai_ia\market-researcher\.venv\Lib\site-packages\crewai\project\annotations.py", line 163, in _call_method
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\data\crewai_ia\market-researcher\src\seo_crew\crew.py", line 91, in crew
    return Crew(
           ^^^^^
  File "D:\data\crewai_ia\market-researcher\.venv\Lib\site-packages\pydantic\main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Crew
  Value error, Failed to initialize embedder. Please check your configuration or connection.
Provider: huggingface
Error: could not convert string to float: 'error' [type=value_error, input_value={'agents': [Agent(role=Ke...ers/all-MiniLM-L6-v2'}}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\data\crewai_ia\market-researcher\.venv\Scripts\run_crew.exe\__main__.py", line 10, in <module>
  File "D:\data\crewai_ia\market-researcher\src\seo_crew\main.py", line 32, in run
    raise Exception(f"An error occurred while running the crew: {e}")
Exception: An error occurred while running the crew: 1 validation error for Crew
  Value error, Failed to initialize embedder. Please check your configuration or connection.
Provider: huggingface
Error: could not convert string to float: 'error' [type=value_error, input_value={'agents': [Agent(role=Ke...ers/all-MiniLM-L6-v2'}}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error
An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.

Possible Solution

It's not a solution, but the error does not appear when memory=False. I was also able to use a locally hosted embedding model using openai provider.

Additional context

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions