TRL
🏡 檢視所有文件 AWS Trainium & Inferentia Accelerate Argilla AutoTrain Bitsandbytes 聊天使用者介面 資料集檢視器 資料集 在 AWS 上部署 Diffusers Distilabel Evaluate Gradio Hub Hub Python 庫 Huggingface.js 推理端點(專用) 推理服務提供商 LeRobot 排行榜 Lighteval Microsoft Azure Optimum PEFT Safetensors Sentence Transformers TRL 任務 文字嵌入推理 文字生成推理 Tokenizers Transformers Transformers.js smolagents timm
搜尋文件
main v0.21.0 v0.20.0 v0.19.1 v0.18.1 v0.17.0 v0.16.1 v0.15.2 v0.14.0 v0.13.0 v0.12.2 v0.11.4 v0.10.1 v0.9.6 v0.8.6 v0.7.11 v0.6.0 v0.5.0 v0.4.7 v0.3.1 v0.2.1 v0.1.1
英
加入 Hugging Face 社群
並獲得增強的文件體驗
獎勵函式 此模組包含一些有用的獎勵函式,主要用於 GRPOTrainer 。
格式化獎勵 think_format_reward trl.rewards.think_format_reward < 源 > ( completions: list **kwargs ) → list[float]
引數
completions (list[list[dict[str, str]]]
) — 待評估的補全列表。每個補全必須是包含一條訊息的列表,即一個包含鍵 "content"
且其值為補全文字的字典。 **kwargs — 額外的關鍵字引數。此函式不使用它們,但在函式簽名中需要它們以確保與像 GRPOTrainer 這樣的訓練器相容。
一個獎勵列表,其中每個獎勵如果補全符合預期格式則為 1.0,否則為 0.0。
該獎勵函式檢查推理過程是否被包裹在 "<think>"
和 "</think>"
標籤內。如果格式正確,函式返回 1.0 的獎勵,否則返回 0.0。
示例
>>> from trl.rewards import think_format_reward
>>> completions = [
... [{"content" : "<think>\nThis is my reasoning.\n</think>\nThis is my answer." }],
... [{"content" : "<think>\nThis is my reasoning.\nThis is my answer." }],
... ]
>>> think_format_reward(completions)
[1.0 , 0.0 ] < > 在 GitHub 上更新
© . This site is unofficial and not affiliated with Hugging Face, Inc.