
    h              	          S SK JrJr  S SKJr  S SKJr  S SKJr  S SK	J
r
Jr  \ " S S5      5       rS r\" S	5      r\S
:X  a  \" \5      r\R#                  5       S    r\" SSSS9r\R)                  \\R*                  / SQS\
R,                  " S5      0S9r\R/                  SS9r\R0                  (       a6  \R1                  \R2                  5        \R1                  \R2                  SS9  ggg)    )	dataclassfield)Optional)load_dataset)	ModelCard)AutoTokenizerHfArgumentParserc                   t    \ rS rSr% Sr\" SSS0S9r\\S'   \" SSS	0S9r	\
\S
'   \" SSS0S9r\\   \S'   Srg)ScriptArguments   a  
Arguments for the script.

Args:
    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/lm-human-preferences-sentiment"`):
        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.
Fhelpz4Whether to push the dataset to the Hugging Face Hub.)defaultmetadatapush_to_hubz&trl-lib/lm-human-preferences-sentimentz2Hugging Face repository ID to push the dataset to.repo_idNz0Number of workers to use for dataset processing.dataset_num_proc )__name__
__module____qualname____firstlineno____doc__r   r   bool__annotations__r   strr   r   int__static_attributes__r       j/home/james-whalen/.local/lib/python3.13/site-packages/examples/datasets/lm-human-preferences-sentiment.pyr   r      si    
 PQK  8NOGS  ',LM'hsm r   r   c                     UR                  U S   5      R                  5       nU S   nUR                  U SU 3   5      n[        S5       H!  nUR                  U SU 3   5      nXF:w  d  M!    O   UW:w  d   eX$US.$ )Nquerybestsample   )promptchosenrejected)decodestriprange)example	tokenizerr%   best_idxr&   rejected_idxr'   s          r   to_prompt_completionr/   3   s    gg./557FvHgxj&9:;Fa##Gf\N,C$DE ! XHEEr   a4  
---
tags: [trl]
---

# LM-Human-Preferences-Sentiment Dataset

## Summary

The LM-Human-Preferences-Sentiment dataset is a processed subset of [OpenAI's LM-Human-Preferences](https://github.com/openai/lm-human-preferences), focusing specifically on sentiment analysis tasks. It contains pairs of text samples, each labeled as either "chosen" or "rejected," based on human preferences regarding the sentiment conveyed in the text. This dataset enables models to learn human preferences in sentiment expression, enhancing their ability to generate and evaluate text with desired emotional tones.

## Data Structure

- **Format**: [Standard](https://huggingface.co/docs/trl/main/dataset_formats#standard)
- **Type**: [Preference](https://huggingface.co/docs/trl/main/dataset_formats#preference)

Columns:
- `"prompt"`: The text sample.
- `"chosen"`: A version of the text that conveys the desired sentiment.
- `"rejected"`: A version of the text that does not convey the desired sentiment.

This structure allows models to learn to prefer the _chosen_ response over the _rejected_ one, thereby aligning with human preferences in sentiment expression.

## Generation script

The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/lm-human-preferences-sentiment.py).
__main__jsonz`https://openaipublic.blob.core.windows.net/lm-human-preferences/labels/sentiment/offline_5k.jsontrain)
data_filessplit)r!   sample0sample1sample2sample3r"   r,   gpt2)num_procremove_columns	fn_kwargsi  )
train_sizedataset)	repo_typeN)dataclassesr   r   typingr   datasetsr   huggingface_hubr   transformersr   r	   r   r/   
model_cardr   parserparse_args_into_dataclassesscript_argsr>   mapr   from_pretrainedtrain_test_splitr   r   r   r   r   <module>rL      s   )  ! % 8   6	F   
8 zo.F446q9KuG kk--T = =f EF	  G &&$&7GK//0{22iH ) r   