mirror of
https://github.com/modelscope/modelscope.git
synced 2026-05-18 05:05:00 +02:00
add 3 problems to llm-riddle and fix some bugs (#632)
* add 3 problems --------- Co-authored-by: wenmeng.zwm <wenmeng.zwm@alibaba-inc.com> Co-authored-by: YorickHe <yongyi.hyy@alibaba-inc.com>
This commit is contained in:
@@ -176,7 +176,7 @@ with block as demo:
|
||||
disabled=True)
|
||||
challenge_result = gr.Textbox(label='挑战结果', disabled=True)
|
||||
chatbot = gr.Chatbot(
|
||||
lines=8, label='Qwen-max', elem_classes='control-height')
|
||||
lines=8, label='Qwen-plus', elem_classes='control-height')
|
||||
message = gr.Textbox(lines=2, label='输入')
|
||||
|
||||
with gr.Row():
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
def validate_palindrome_invariance(origin_input, response, generate_response):
|
||||
"""
|
||||
验证器函数,检查对于给定的问题,正着问和倒着问的模型回答是否一致。
|
||||
验证器函数,检查对于给定的问题,检验是否是回文串,且正着问和倒着问的模型回答是否一致。
|
||||
|
||||
:param origin_input: 原始问题
|
||||
:return: True 如果回答一致,否则 False
|
||||
"""
|
||||
|
||||
# 检查原始输入不是回文
|
||||
if origin_input == origin_input[::-1]:
|
||||
return False
|
||||
|
||||
# 将原始问题倒序并提交
|
||||
reversed_question = origin_input[::-1]
|
||||
reversed_response = generate_response(reversed_question)
|
||||
@@ -66,5 +70,13 @@ challenge1 = {
|
||||
lambda response, input: '狗' not in input and response.count('狗') \
|
||||
>= 3
|
||||
},
|
||||
{
|
||||
'title':
|
||||
'第7题 事半功倍',
|
||||
'description':
|
||||
'请输入一个本身不是回文串的问题,使模型回答的长度刚好是问题长度的两倍。',
|
||||
'validator':
|
||||
lambda response, input: input != input[::-1] and len(response) == 2 * len(input)
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -90,5 +90,18 @@ challenge2 = {
|
||||
'狗' not in input and len(input) <= 10 and # noqa: W504
|
||||
response.count('狗') >= 2 * len(input))
|
||||
},
|
||||
{
|
||||
'title':
|
||||
'第7题 暗藏玄机',
|
||||
'description':
|
||||
'请输入一个大于一的正整数作为问题,使回答包含一个两位数,其十位上的数字比个位上的数字小5。',
|
||||
'validator':
|
||||
lambda response, input:
|
||||
(input.isdigit() and int(input) > 1 and (len({
|
||||
int(num)
|
||||
for num in re.findall(r'\d+', response)
|
||||
if len(num) == 2 and int(num[1]) - int(num[0]) == 5
|
||||
}) >= 1))
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import re
|
||||
|
||||
def validate_palindrome_inverse(origin_input, response, generate_response):
|
||||
"""
|
||||
验证器函数,检查对于给定的问题,正着问和倒着问的模型的回答本身不回文且也是逆序的关系。
|
||||
@@ -49,7 +51,7 @@ challenge3 = {
|
||||
'title':
|
||||
'第3题 就是敢说',
|
||||
'description':
|
||||
'请在不提及1,3这三个字符的情况下让模型回答1+1=3,不要有多余的字符。',
|
||||
'请在不提及1,3这两个字符的情况下让模型回答1+1=3,不要有多余的字符。',
|
||||
'validator':
|
||||
lambda response, input: response.strip() == '1+1=3' and all(
|
||||
c not in input for c in ['1', '3'])
|
||||
@@ -63,5 +65,13 @@ challenge3 = {
|
||||
lambda response, input, generate_response:
|
||||
validate_palindrome_inverse(input, response, generate_response)
|
||||
},
|
||||
{
|
||||
'title':
|
||||
'第5题 答非所问',
|
||||
'description':
|
||||
'请输入一个以“为什么”开头,以“?”结尾的不包含数字的问题,使回答中只包含数字。',
|
||||
'validator':
|
||||
lambda response, input: '为什么' == input[:3] and "?" == input[-1] and len(re.findall(r'\d+', input)) == 0 and response.isdigit()
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
|
||||
|
||||
def validate_reciprocal_question(input, response, generate_response):
|
||||
"""
|
||||
验证器函数,检查给定的问题A和回答B,是否能够通过以B作为新的提问得到原始问题A作为回答。
|
||||
|
||||
Reference in New Issue
Block a user