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

[FEATURE] Add score attribute for suggestions associated to a multi label question #4638

Closed
6 tasks done
jfcalvo opened this issue Mar 7, 2024 · 1 comment · Fixed by argilla-io/argilla-server#105
Closed
6 tasks done
Assignees
Labels
area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints severity: minor Indicates that the issue isn't urgent or blocking team: backend Indicates that the issue or pull request is owned by the backend team type: enhancement Indicates new feature requests
Milestone

Comments

@jfcalvo
Copy link
Member

jfcalvo commented Mar 7, 2024

For the new feature adding support for span questions we will give support to specify a score for suggestions associated to a span question.

For that we are following the next format (PUT to upsert a suggestion):

{
    "question_id": "id-of-the-question",
    "type": "model",
    "value": [
        {"label": "label-a", "start": 0, "end": 1, "score": 0.2},
        {"label": "label-b", "start": 2, "end": 3, "score": 1},
        {"label": "label-c", "start": 4, "end": 5},
    ]
}

For this issue we should add score attribute for suggestions associated to a multi_label_selection question too. With this change users can specify a score value for every label inside the suggestion.

Additional points to research/discuss:

  • Changes to the SDK.
  • Changes related to UI. Are we gonna show this information in the UI?

Tasks

Preview Give feedback
  1. jfcalvo
  2. jfcalvo
  3. jfcalvo
  4. jfcalvo
  5. area: python sdk language: python severity: minor team: backend type: enhancement
    frascuchon
  6. area: server severity: minor team: backend type: enhancement
    frascuchon
@jfcalvo jfcalvo self-assigned this Mar 7, 2024
Copy link

dosubot bot commented Mar 7, 2024

To accommodate the proposed feature of adding a score attribute for suggestions associated with a multi_label_selection question in the Argilla repository, modifications would be necessary in both the SDK and the UI. Here's a breakdown of the changes required:

SDK Modifications

  1. Extend the MultiLabelQuestion Schema:
    • You need to add a new attribute to the MultiLabelQuestion class to hold the score for each label. This could be a dictionary mapping labels to their scores.
class MultiLabelQuestion(_LabelQuestion):
    # Existing attributes...
    scores: Optional[Dict[str, float]] = None

    @property
    def server_settings(self) -> Dict[str, Any]:
        settings = super().server_settings
        if self.scores:
            settings["scores"] = self.scores
        return settings
  1. Update the server_settings Property:
    • Modify the server_settings property of the MultiLabelQuestion class to include the scores in the payload if they are provided.

UI Modifications

  1. Display Scores in the UI:

    • The UI component responsible for rendering multi_label_selection questions needs to be updated to display the score next to each label if scores are provided. This might involve adjusting the layout to accommodate the display of scores in a user-friendly manner.
  2. Update Data Handling:

    • Ensure that the UI component handling the submission of answers for multi_label_selection questions can correctly handle and submit the scores along with the selected labels if required.
  3. Validation and Error Handling:

    • Implement validation to ensure that scores, if used, are within an acceptable range (e.g., 0 to 1 or 1 to 100, depending on the scoring system you choose). Also, add error handling to provide feedback to the user if the scores are not in the expected format or range.

Considerations

  • Backward Compatibility: Ensure that the addition of the scores attribute does not break existing functionality for multi_label_selection questions that do not use this new feature.
  • Documentation: Update the SDK documentation and UI component documentation to reflect the new feature and provide examples of how to use it.
  • Testing: Add unit tests and UI tests to cover the new functionality and ensure that it works as expected across different scenarios.

These modifications will enable the Argilla SDK and UI to support the new feature of adding scores to suggestions for multi_label_selection questions, enhancing the flexibility and utility of the feedback collection process.

For reference, the current structure of the MultiLabelQuestion class in the Argilla SDK is as follows:

class MultiLabelQuestion(_LabelQuestion):
    """Schema for the `FeedbackDataset` label questions, which are the ones that will
    require a label response from the user. This class should be used when the user can
    select multiple labels.

    Args:
        type: The type of the question. Defaults to 'multi_label_selection' and
            cannot/shouldn't be modified.
        labels: The list of labels of the label question. The labels must be unique, and
            the list must contain at least two unique labels. Additionally, `labels` can
            also be a dictionary of labels, where the keys are the labels, and the values
            are the labels that will be shown in the UI.
        visible_labels: The number of visible labels in the UI. Defaults to 20, and must
            be 3 or greater.

    Examples:
        >>> from argilla.client.feedback.schemas.questions import MultiLabelQuestion
        >>> MultiLabelQuestion(name="multi_label_question", title="Multi Label Question", labels=["label_1", "label_2"])
    """

    type: Literal[QuestionTypes.multi_label_selection] = Field(
        QuestionTypes.multi_label_selection.value, allow_mutation=False
    )

You can find the source code for this class in the Argilla repository.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints severity: minor Indicates that the issue isn't urgent or blocking team: backend Indicates that the issue or pull request is owned by the backend team type: enhancement Indicates new feature requests labels Mar 7, 2024
@nataliaElv nataliaElv modified the milestone: v1.27.0 Mar 20, 2024
@nataliaElv nataliaElv added this to the v1.27.0 milestone Apr 2, 2024
@frascuchon frascuchon modified the milestones: v1.27.0, v1.28.0 Apr 15, 2024
jfcalvo added a commit to argilla-io/argilla-server that referenced this issue Apr 25, 2024
…` and add a missing cardinality validation for value and score attributes (#111)

# Description

This PR move all suggestion `score` validations to
`SuggestionCreateValidator` and add a new one checking that `value` and
`score` attributes have the same cardinality.

The additional validation will raise an error when a suggestion have a
single item inside `value` attribute and a list of items inside `score`.

Refs argilla-io/argilla#4638

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (change restructuring the codebase without changing
functionality)
- [x] Improvement (change adding some improvement to an existing
functionality)
- [ ] Documentation update

**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes. And
ideally, reference `tests`)

- [x] Adding new tests.

**Checklist**

- [ ] I added relevant documentation
- [ ] follows the style guidelines of this project
- [ ] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [ ] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
@jfcalvo jfcalvo linked a pull request Apr 25, 2024 that will close this issue
16 tasks
jfcalvo added a commit to argilla-io/argilla-server that referenced this issue Apr 25, 2024
# Description

PR with changes for suggestion multi-score support.

Refs argilla-io/argilla#4638

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (change restructuring the codebase without changing
functionality)
- [ ] Improvement (change adding some improvement to an existing
functionality)
- [ ] Documentation update

**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes. And
ideally, reference `tests`)

- [ ] Test A
- [ ] Test B

**Checklist**

- [ ] I added relevant documentation
- [ ] follows the style guidelines of this project
- [ ] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [ ] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
@jfcalvo jfcalvo reopened this Apr 25, 2024
@jfcalvo jfcalvo closed this as completed Apr 30, 2024
jfcalvo added a commit that referenced this issue Apr 30, 2024
# Description

A small fix causing integration tests to fail. The score validation was
not checking that value was also a list so we are adding that check.

Refs #4638 

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (change restructuring the codebase without changing
functionality)
- [ ] Improvement (change adding some improvement to an existing
functionality)
- [ ] Documentation update

**How Has This Been Tested**

(Please describe the tests that you ran to verify your changes. And
ideally, reference `tests`)

- [ ] Integration tests should be passing.

**Checklist**

- [ ] I added relevant documentation
- [ ] follows the style guidelines of this project
- [ ] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [ ] I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Indicates that an issue or pull request is related to the Fast API server or REST endpoints severity: minor Indicates that the issue isn't urgent or blocking team: backend Indicates that the issue or pull request is owned by the backend team type: enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants