Enhance model card with metadata, paper, code, and usage

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +129 -3
README.md CHANGED
@@ -1,8 +1,134 @@
1
  ---
 
 
2
  license: other
3
  license_name: license
4
  license_link: LICENSE
5
- base_model:
6
- - Qwen/Qwen2.5-7B-Instruct
7
  ---
8
- https://www.arxiv.org/abs/2507.03112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model:
3
+ - Qwen/Qwen2.5-7B-Instruct
4
  license: other
5
  license_name: license
6
  license_link: LICENSE
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
  ---
10
+
11
+ # RLVER: Reinforcement Learning with Verifiable Emotion Rewards for Empathetic Agents
12
+
13
+ This repository contains the official model for the paper [RLVER: Reinforcement Learning with Verifiable Emotion Rewards for Empathetic Agents](https://huggingface.co/papers/2507.03112).
14
+
15
+ <div align="center">
16
+ [![Model](https://img.shields.io/badge/Model-4d5eff?style=for-the-badge&logo=huggingface&logoColor=ffffff&labelColor)](https://huggingface.co/RLVER)
17
+ [![Github](https://img.shields.io/badge/Code-000000?style=for-the-badge&logo=github&logoColor=white)](https://github.com/Tencent/digitalhuman/tree/main/RLVER)
18
+ [![arXiv](https://img.shields.io/badge/arXiv-2507.03112-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/2507.03112)
19
+ </div>
20
+
21
+ ## Abstract
22
+ Large language models (LLMs) excel at logical and algorithmic reasoning, yet their emotional intelligence (EQ) still lags far behind their cognitive prowess. While reinforcement learning from verifiable rewards (RLVR) has advanced in other domains, its application to dialogue-especially for emotional intelligence-remains underexplored. In this work, we introduce RLVER, the first end-to-end reinforcement learning framework that leverages verifiable emotion rewards from simulated users to cultivate higher-order empathetic abilities in LLMs. Within this framework, self-consistent affective simulated users engage in dialogue rollouts and produce deterministic emotion scores during conversations, serving as reward signals to guide the LLM's learning. Fine-tuning publicly available Qwen2.5-7B-Instruct model with PPO boosts its Sentient-Benchmark score from 13.3 to 79.2 while largely preserving mathematical and coding competence. Extensive experiments reveal that: (i) RLVER consistently improves multiple dialogue capabilities; (ii) Thinking and non-thinking models show distinct trends--thinking models excel in empathy and insight, while non-thinking models favor action; (iii) GRPO often yields stable gains, while PPO can push certain capabilities to a higher ceiling; (iv) More challenging environments are not always better-moderate ones can yield stronger outcomes. Our results show that RLVER is a practical route toward emotionally intelligent and broadly capable language agents.
23
+
24
+ ## Overview
25
+ <p align="center"><img width="90%" src="https://github.com/Tencent/digitalhuman/raw/main/RLVER/code/figs/framework.png" alt="RLVER Framework" /></p>
26
+ <p align="center"><em>The overview of RLVER. In this work, we present the first end-to-end reinforcement-learning framework that equips an LLM with human-level empathetic skills by optimizing against verifiable emotion rewards.</em></p>
27
+
28
+ <p align="center"><img width="90%" src="https://github.com/Tencent/digitalhuman/raw/main/RLVER/code/figs/main_result.png" alt="RLVER Main Result" /></p>
29
+ <p align="center"><em>The main result of RLVER.</em></p>
30
+
31
+ ## Usage
32
+
33
+ You can load the model using the `transformers` library. Below is a quick example of how to use it for text generation:
34
+
35
+ ```python
36
+ import torch
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+ from transformers.generation import GenerationConfig
39
+
40
+ # Load model and tokenizer
41
+ # Replace "{your_model_id}" with the actual model ID (e.g., "Tencent/RLVER")
42
+ model = AutoModelForCausalLM.from_pretrained(
43
+ "{your_model_id}",
44
+ torch_dtype=torch.bfloat16,
45
+ device_map="auto",
46
+ trust_remote_code=True
47
+ )
48
+ tokenizer = AutoTokenizer.from_pretrained("{your_model_id}", trust_remote_code=True)
49
+ model.eval()
50
+
51
+ # Configure generation
52
+ generation_config = GenerationConfig.from_pretrained(
53
+ "{your_model_id}",
54
+ trust_remote_code=True
55
+ )
56
+ generation_config.chat_format = "chatml"
57
+
58
+ # Example chat interaction
59
+ messages = [
60
+ {"role": "system", "content": "You are a helpful assistant."},
61
+ {"role": "user", "content": "Hello! How are you today?"}
62
+ ]
63
+
64
+ text = tokenizer.apply_chat_template(
65
+ messages,
66
+ tokenize=False,
67
+ add_generation_prompt=True
68
+ )
69
+
70
+ # Generate response
71
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
72
+ generated_ids = model.generate(
73
+ model_inputs.input_ids,
74
+ attention_mask=model_inputs.attention_mask,
75
+ generation_config=generation_config
76
+ )
77
+
78
+ # Decode and print only the generated part
79
+ generated_ids = [
80
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
81
+ ]
82
+ generated_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
83
+ print(generated_text)
84
+ ```
85
+
86
+ ## Environment Setup 🔧
87
+
88
+ ```bash
89
+ pip install -r requirements.txt
90
+ ```
91
+ This project uses Ray and Verl frameworks. You should configure your settings in `train_rlver.sh` before the training.
92
+
93
+ ## Data 📚
94
+ The training and test user profiles are provided in `data/test_profile.jsonl`.
95
+
96
+ ## Start Training 🔥
97
+ 1. **Basic Settings**
98
+ Set the data path, model path, and other configurations.
99
+ To enable "Think then say" mode during training, set `IF_THINK=True`.
100
+ To use GRPO, set `algorithm.adv_estimator=grpo` and `actor_rollout_ref.rollout.n=4`.
101
+ 2. **Set up RAY**
102
+ First set up the RAY environment.
103
+ ```bash
104
+ # On chief node:
105
+ ray start --head --port=$PORT_ID --node-ip-address=$CHIEF_IP
106
+
107
+ # On each worker node:
108
+ ray start --address=$CHIEF_IP:$PORT_ID --node-ip-address=$CURRENT_IP
109
+ ```
110
+ 3. **Start training**
111
+ Now you can run `train_rlver.sh` to start training!
112
+ ```bash
113
+ sh ./train_rlver.sh
114
+ ```
115
+
116
+ ## Evaluation 🏆
117
+ To evaluate your trained model:
118
+ 1. **Convert to Hugging Face format**:
119
+ ```bash
120
+ sh ./mk_hf_model.sh
121
+ ```
122
+ 2. **Evaluate with SAGE**
123
+ You can evaluate the converted model following the instructions in [SAGE](https://github.com/Tencent/digitalhuman/tree/main/SAGE).
124
+
125
+ ## Citation
126
+ If you find our work helpful or inspiring, please feel free to cite it.
127
+ ```bibtex
128
+ @article{zhou2025rlver,
129
+ title={RLVER: Reinforcement Learning with Verifiable Emotion Rewards for Empathetic Agents},
130
+ author={Zhou, Zijian and Liu, Shikun and Han, Xiao and Liu, Haozhe and Ng, Kam Woh and Xie, Tian and Cong, Yuren and Li, Hang and Xu, Mengmeng and Pérez-Rúa, Juan-Manuel and Patel, Aditya and Xiang, Tao and Shi, Miaojing and He, Sen},
131
+ journal={arXiv preprint arXiv:2507.03112},
132
+ year={2025},
133
+ }
134
+ ```