HumanSignal / label-studio-ml-backend

Configs and boilerplates for Label Studio's Machine Learning backend
Apache License 2.0
544 stars 249 forks source link

Machine Learning with Conversation Slot filling #526

Open sandeepbhutani304 opened 5 months ago

sandeepbhutani304 commented 5 months ago

We are trying to put huggingface-ner sample as machine learning model behind template - Conversational AI - Intent classification and slot filling. We are able to do the prediction using below code. In below code we have taken text of each dialog and sent to the model. Model is returning predictions as well.

We are now stuck at display the predictions back to UI. Please tell us what changes are needed, so that the UI accepts the returned predictions in json reply, and show them in the dialogues.

if "entity_slot" in li._control_tags:
                from_name = 'ParagraphLabels'; to_name='dialogue'; #TODO: not sure what is purpose of this
                dialogues = [task['data']['humanMachineDialogue'] for task in tasks]
                for dialogue in dialogues:
                    for turn in dialogue:
                        if 'text' in turn:
                            texts.append(turn['text'])
niklub commented 5 months ago

Hello!

In order to return predictions for <ParagraphLabels>, you have to follow the JSON format for predictions' value: https://labelstud.io/tags/paragraphs#Example-JSON . Try to replace plain text NER with the format expected by Paragraphs. Also, make sure the model is selected in Label Studio project Settings > Annotation > Live Predictions . Let me know if any of these recipes helps.