mindsdb icon indicating copy to clipboard operation
mindsdb copied to clipboard

Change model dictionaries to json format

Open 0xMimir opened this issue 1 year ago • 4 comments

Short description of current behavior

I have huggingface sentiment analyzer and sentiment explain comes as text in next format:

{'Neutral': 0.6581241488456726, 'Bullish': 0.34162577986717224, 'Bearish': 0.00025005039060488343}

which is not valid json and can't be converted to json or jsonb in postgresql,

This is also how most json is saved in project TRAINING_OPTIONS in table models is save as

{'target': 'sentiment', 'using': {'task': 'text-classification', 'model_name': 'ElKulako/cryptobert', 'input_column': 'content', 'max_length': 512}}

Video or screenshots

No response

Expected behavior

No response

How to reproduce the error

Create a model

CREATE MODEL mindsdb.sentiment_classifier
PREDICT sentiment
USING
  engine = 'huggingface',
  task = 'text-classification',
  model_name = 'cardiffnlp/twitter-roberta-base-sentiment',
  input_column = 'text_short',
  labels = ['negative', 'neutral', 'positive'];

Query the model

SELECT * from mindsdb.sentiment_classifier where text_short = 'this is good day'
sentiment|sentiment_explain                                                                                  |text_short      |
---------+---------------------------------------------------------------------------------------------------+----------------+
positive |{'positive': 0.9830580353736877, 'neutral': 0.014908154495060444, 'negative': 0.002033873461186886}|this is good day|

Anything else?

No response

0xMimir avatar May 27 '23 05:05 0xMimir

thanks for this @0xMimir - we'll add to our backlog!

tomhuds avatar May 29 '23 18:05 tomhuds

I think there are two issues here, the JSON output from HuggingFace models and the TRAINING_OPTIONS format.

@StpMax @ea-rus should we open a new issue for the latter? We'll take a look at the HF formatting in the meantime.

paxcema avatar Jan 23 '24 21:01 paxcema

@paxcema should we keep this open?

ZoranPandovski avatar Jul 10 '24 13:07 ZoranPandovski

Seems important for user experience, so I would say yes.

paxcema avatar Jul 10 '24 17:07 paxcema