
    hj                        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
  \ " S S5      5       rS r\" S	5      r\S
:X  a  \
" \5      r\R!                  5       S    r\" SS5      r\R'                  \\R(                  / SQS9r\R*                  (       a6  \R+                  \R,                  5        \R+                  \R,                  SS9  ggg)    )	dataclassfield)Optional)load_dataset)	ModelCard)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/tldr-preference"`):
        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/tldr-preferencez2Hugging 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       [/home/james-whalen/.local/lib/python3.13/site-packages/examples/datasets/tldr_preference.pyr
   r
      si    
 PQK  )NOGS  ',LM'hsm r   r
   c                 ~   U S   nU S   S;   a"  US   R                  SS5      nSUS    SU S	3nOdU S   [        S
S5       Vs/ s H  nSU 3PM
     snS/-   ;   a(  US   R                  SS5      nSUS    SUS    SU S	3nO[        SU S    35      eU S   nSU-
  nU S   U   S   nU S   U   S   n	X8U	S.$ s  snf )Ninfobatch)batch0_cnndmcnndm0cnndm2articlez


zTITLE: titlez

TL;DR:   r   edit_b2_eval_testpostzSUBREDDIT: r/	subredditz	

TITLE: z

POST: zUnknown batch: choice   	summariestext)promptchosenrejected)replacerange
ValueError)
exampler    r%   r0   ir*   
chosen_idxrejected_idxr1   r2   s
             r   to_preferencer:   3   s   6?Dw??y/))&$74=/gYjA		5B<@<aaSk<@DWCXX	XF|##FD1 k!2 3;tG}oZX\W]]gh?77+;*<=>>"Jz>L[!*-f5F{#L1&9HHEE As   B:a  
---
tags: [trl]
---

# TL;DR Dataset for Preference Learning

## Summary

The TL;DR dataset is a processed version of Reddit posts, specifically curated to train models using the [TRL library](https://github.com/huggingface/trl) for preference learning and Reinforcement Learning from Human Feedback (RLHF) tasks. It leverages the common practice on Reddit where users append "TL;DR" (Too Long; Didn't Read) summaries to lengthy posts, providing a rich source of paired text data for training models to understand and generate concise summaries.

## 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 unabridged Reddit post.
- `"chosen"`: The concise "TL;DR" summary appended by the author.
- `"rejected"`: An alternative summary or response that was not selected.

This structure enables models to learn the relationship between detailed content and its abbreviated form, enhancing their summarization capabilities.

## Generation script

The script used to generate this dataset can be found [here](https://github.com/huggingface/trl/blob/main/examples/datasets/tldr_preference.py).
__main__zopenai/summarize_from_feedbackcomparisons)r    r.   r,   workerr!   splitextra)num_procremove_columnsdataset)	repo_typeN)dataclassesr   r   typingr   datasetsr   huggingface_hubr   transformersr   r
   r:   
model_cardr   parserparse_args_into_dataclassesscript_argsrB   mapr   r   r   r   r   r   <module>rN      s    )  ! % )   6F$   
8 zo.F446q9K;]KGkk--[  G K//0{22iH  r   