Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The isnan method doesn't work on Numpy arrays with non-numeric #1873

Open
baifachuan opened this issue Aug 5, 2024 · 3 comments
Open

The isnan method doesn't work on Numpy arrays with non-numeric #1873

baifachuan opened this issue Aug 5, 2024 · 3 comments

Comments

@baifachuan
Copy link

baifachuan commented Aug 5, 2024

My DataFrame has a column with list type, but the value is None, when I use:

tools: list = None
df=pd.Series(
            [
                tools
            ],
            index=[     
                "tools"
            ],
        )
PandasCodec.encode_request(df, use_bytes=False)

Always found this errors if mlserver >= 1.4.0:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

I found the code:

https://github.com/SeldonIO/MLServer/blob/release/1.4.0/mlserver/codecs/numpy.py#L108

How can I make it work correctly on versions above 1.4.0?

@ramonpzg
Copy link
Contributor

ramonpzg commented Aug 6, 2024

Hi @baifachuan -- Thanks for bringing this up. I can see the kind of error you are getting and I can also replicate it locally. I am having difficulties understanding your use case though, would you please describe what you are trying to do?

@baifachuan
Copy link
Author

Hi @baifachuan -- Thanks for bringing this up. I can see the kind of error you are getting and I can also replicate it locally. I am having difficulties understanding your use case though, would you please describe what you are trying to do?

Hi @ramonpzg thanks for your replay, I deployed a locally privatized large language model (LLM) through Seldon.

These parameters need to be passed to Seldon when chat with LLM.

df=pd.Series(
            [
                tools
            ],
            index=[     
                "tools"
            ],
        )

df is the chat parameters, because tools is LLM TOOL list, So they definitely won't be of a numerical type.

@bwallima
Copy link

Is there any update regarding that bug? I am experiencing the same issue. This problem occurs as soon as there is an attempt to pass any non-numeric values. For instance, I have a dfthat contains text values, some of which can be None. A fix would be to check for float values in mlserver/codecs/numpy.py row 109: if isinstance(val, float) and np.isnan(val)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants