# tinker_cookbook.preference.ComparisonRenderer ## *class* [**tinker_cookbook.preference.ComparisonRenderer**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L95)() Abstract renderer for converting Comparisons to model inputs for preference training. Subclasses must implement `build_generation_prompt`, `to_model_input_weights`, and the `tokenizer` property. ### [**build_generation_prompt**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L102)(*comparison*) Build a model input for generating a preference label. **Parameters:** - [**comparison**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L102) (*[Comparison](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/preference/comparison/index.md)*) – The comparison to render as a prompt. **Returns:** *types.[ModelInput](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/types/modelinput/index.md)* – Token-level model input ready for sampling. ### [**to_model_input_weights**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L113)(*labeled_comparison*) Convert a labeled comparison to model input and per-token loss weights. **Parameters:** - [**labeled_comparison**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L114) (*[LabeledComparison](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/preference/labeledcomparison/index.md)*) – A comparison annotated with a preference label. **Returns:** A tuple of (model_input, weights) for training. ### *property* [**tokenizer**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/preference/types.py#L127) The tokenizer associated with this renderer. **Returns:** *Tokenizer* – The tokenizer instance. ## Referenced by - [tinker_cookbook.preference.ComparisonRendererFromChatRenderer](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/preference/comparisonrendererfromchatrenderer/index.md)