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

[ENHANCEMENT] docs: Add howto update record vectors #5052

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

frascuchon
Copy link
Member

@frascuchon frascuchon commented Jun 18, 2024

Description

This PR adds how to update record vectors in how-to guides. Since the fields cannot be updated, the how-to guides skip them for now.

How Has This Been Tested

(Please describe the tests that you ran to verify your changes.)

Checklist

  • I added relevant documentation
  • I followed 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 filled out the contributor form (see text above)
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

@frascuchon frascuchon changed the title docs: Add howto update record vectors [DOCS] Add howto update record vectors Jun 18, 2024
@frascuchon frascuchon changed the title [DOCS] Add howto update record vectors [ENHANCEMENT] docs: Add howto update record vectors Jun 18, 2024
Copy link
Member

@davidberenstein1957 davidberenstein1957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we can work with tabs like shown below

=== "Update the metadata"
    The `metadata` of `Record` object is a python dictionary. So to update the metadata of a record, you can iterate over the records and update the metadata by key or using `metadata.update`. After that, you should update the records in the dataset.
    ```python
    updated_records = []
    for record in dataset.records():
        record.metadata["my_metadata"] = "new_value"
        record.metadata["my_new_metadata"] = "new_value"
        updated_records.append(record)
    dataset.records.log(records=updated_records)

=== "Update vectors"
       When a new vector field is added to the dataset settings, or some value for the existing record vectors must updated, you can iterate over the records and update the vectors in the same way as the metadata. 

    ```python
    updated_records = []

    for record in dataset.records():

        record.vectors["new_vector"] = [...]
        record.vector["v"] = [...]

        updated_records.append(record)

    dataset.records.log(records=updated_records)
    ```

Copy link
Member

@davidberenstein1957 davidberenstein1957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also , the general Update records text might emphasize we are not updating fields but only question suggestions?

@frascuchon
Copy link
Member Author

Also , the general Update records text might emphasize we are not updating fields but only question suggestions?

Yes. Indeed we can update all about records but fields. I will create an issue to improve the docs about record updates. We should tackle it after the enhancement updating responses and suggestions (thanks to @burtenshaw )

@frascuchon
Copy link
Member Author

perhaps we can work with tabs like shown below

=== "Update the metadata"
    The `metadata` of `Record` object is a python dictionary. So to update the metadata of a record, you can iterate over the records and update the metadata by key or using `metadata.update`. After that, you should update the records in the dataset.
    ```python
    updated_records = []
    for record in dataset.records():
        record.metadata["my_metadata"] = "new_value"
        record.metadata["my_new_metadata"] = "new_value"
        updated_records.append(record)
    dataset.records.log(records=updated_records)

=== "Update vectors"
       When a new vector field is added to the dataset settings, or some value for the existing record vectors must updated, you can iterate over the records and update the vectors in the same way as the metadata. 

    ```python
    updated_records = []

    for record in dataset.records():

        record.vectors["new_vector"] = [...]
        record.vector["v"] = [...]

        updated_records.append(record)

    dataset.records.log(records=updated_records)
    ```

Done https://argilla-io.github.io/argilla/docs_update-vectors-howto/how_to_guides/record/#__tabbed_6_1

@frascuchon frascuchon merged commit 1ab171c into feat/updating-record Jun 19, 2024
2 checks passed
@frascuchon frascuchon deleted the docs/update-vectors-howto branch June 19, 2024 09:03
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

Successfully merging this pull request may close these issues.

2 participants