Skip to content

Commit 8260f59

Browse files
authored
add a regex to remove think tags before evaluating ifeval (#791)
* add a regex to remove think tags before evaluating ifeval * Update src/lighteval/models/transformers/transformers_model.py
1 parent 7887172 commit 8260f59

File tree

1 file changed

+3
-0
lines changed
  • src/lighteval/tasks/extended/ifeval

1 file changed

+3
-0
lines changed

src/lighteval/tasks/extended/ifeval/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23+
import re
24+
2325
import numpy as np
2426
from aenum import extend_enum
2527

@@ -56,6 +58,7 @@ def ifeval_prompt(line, task_name: str = None):
5658

5759
def ifeval_metric(predictions: list[str], formatted_doc: Doc, **kwargs) -> dict:
5860
response = predictions[0]
61+
response = re.sub(r"(<think>)?[\s\S]*?<\/think>", "", response)
5962

6063
# Strict instructions
6164
instruction_list = formatted_doc.specific["instructions_id_list"]

0 commit comments

Comments
 (0)