o
    	Ti                     @   s   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 eG dd dZdd	 Zed
Zedkr{e
eZe d  ZedddZejdd dejdZejeg dejejdejdZejdddZejr}eej ejejdd dS dS dS )    )	dataclassfield)Optional)load_dataset)	ModelCard)HfArgumentParserc                   @   s   e Zd ZU dZeddg dddZeed< edd	g d
ddZeed< edddidZ	e
ed< edddidZeed< edddidZee ed< dS )ScriptArgumentsa  
    Arguments for the script.

    Args:
        model_name (`str`, *optional*, defaults to `"gpt-3.5-turbo"`):
            Language model to target. Possible values are:
        aspect (`str`, *optional*, defaults to `"helpfulness"`):
            Aspect to target.
        push_to_hub (`bool`, *optional*, defaults to `False`):
            Whether to push the dataset to the Hugging Face Hub.
        repo_id (`str`, *optional*, defaults to `"trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulness"`):
            Hugging Face repository ID to push the dataset to.
        dataset_num_proc (`int` or `None`, *optional*, defaults to `None`):
            Number of workers to use for dataset processing.
    gpt-3.5-turbozLanguage model to target.)z	alpaca-7bbardzfalcon-40b-instructr	   zgpt-4zllama-2-13b-chatzllama-2-70b-chatzllama-2-7b-chatzmpt-30b-chatz
pythia-12bstarchatzultralm-13bzultralm-65bz
vicuna-33bzwizardlm-13bzwizardlm-70bzwizardlm-7b)helpchoices)defaultmetadata
model_namehelpfulnesszsAspect to target. Possible values are: 'helpfulness' (default), 'honesty', 'instruction-following', 'truthfulness'.)r   honestyzinstruction-followingtruthfulnessaspectFr   z4Whether to push the dataset to the Hugging Face Hub.push_to_hubz/trl-lib/ultrafeedback-gpt-3.5-turbo-helpfulnessz2Hugging Face repository ID to push the dataset to.repo_idNz0Number of workers to use for dataset processing.dataset_num_proc)__name__
__module____qualname____doc__r   r   str__annotations__r   r   boolr   r   r   int r    r    S/home/ubuntu/.local/lib/python3.10/site-packages/examples/datasets/ultrafeedback.pyr      s4   
 r   c           	      C   sj   d| d dg}| d  |}| d | d }d|dg}t| d | d | d	 }|d
k}|||dS )Nuserinstruction)rolecontentmodelscompletionsresponse	assistantannotationsRating   )prompt
completionlabel)indexr   )	exampler   r   r-   model_indexresponse_contentr.   scorer/   r    r    r!   to_unpaired_preferenceX   s   r5   a  
---
tags: [trl]
---

# UltraFeedback GPT-3.5-Turbo Helpfulness Dataset

## Summary

The UltraFeedback GPT-3.5-Turbo Helpfulness dataset contains processed user-assistant interactions filtered for helpfulness, derived from the [openbmb/UltraFeedback](https://huggingface.co/datasets/openbmb/UltraFeedback) dataset. It is designed for fine-tuning and evaluating models in alignment tasks.

## Data Structure

- **Format**: [Conversational](https://huggingface.co/docs/trl/main/dataset_formats#conversational)
- **Type**: [Unpaired preference](https://huggingface.co/docs/trl/main/dataset_formats#unpaired-preference)

Column:
- `"prompt"`: The input question or instruction provided to the model.
- `"completion"`: The model's response to the prompt.
- `"label"`: A binary value indicating whether the response is sufficiently helpful.

## Generation script

The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/ultrafeedback.py).
__main__zopenbmb/UltraFeedbacktrain)splitc                 C   s   t j| d v S )Nr&   )script_argsr   )r1   r    r    r!   <lambda>   s    r:   F)batchednum_proc)sourcer#   r&   r'   correct_answersincorrect_answers)r   r   )remove_columns	fn_kwargsr<   g?*   )	test_sizeseeddataset)	repo_typeN)dataclassesr   r   typingr   datasetsr   huggingface_hubr   transformersr   r   r5   
model_cardr   parserparse_args_into_dataclassesr9   rE   filterr   mapr   r   train_test_splitr   r   r    r    r    r!   <module>   s<   @
