Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
4bab5137
Unverified
Commit
4bab5137
authored
Aug 02, 2022
by
Jiwung Hyun
Committed by
GitHub
Aug 02, 2022
Browse files
Modify prompt and add citation (#338)
parent
10c61137
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lm_eval/tasks/nsmc.py
lm_eval/tasks/nsmc.py
+10
-12
No files found.
lm_eval/tasks/nsmc.py
View file @
4bab5137
...
...
@@ -3,15 +3,15 @@ NSMC:
"""
import
numpy
as
np
from
lm_eval.base
import
rf
,
Task
from
lm_eval.metrics
import
mean
,
matthews_corrcoef
,
f1_score
,
yesno
from
lm_eval.metrics
import
mean
from
lm_eval.utils
import
general_detokenize
_CITATION
=
"""
@
inp
roceedings{
zellers2019hellaswag
,
title
={NSMC: Can a Machine Really Finish Your Sentence?}
,
author
={Zellers, Rowan and Holtzman, Ari and Bisk, Yonatan and Farhadi, Ali and Choi, Yejin}
,
booktitle ={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics}
,
year={2019
}
@
InP
roceedings{
Park:2016
,
title
= "Naver Sentiment Movie Corpus"
,
author
= "Lucy Park"
,
year = "2016"
,
howpublished = {
\\
url{https://github.com/e9t/nsmc}
}
}
"""
...
...
@@ -39,16 +39,14 @@ class NSMC(Task):
return
self
.
dataset
[
"test"
]
def
doc_to_text
(
self
,
doc
):
return
"다음 문장은 긍정일까요 부정일까요?
\n
{}
\n
정답:"
.
format
(
general_detokenize
(
doc
[
"document"
]),
)
return
"{}"
.
format
(
general_detokenize
(
doc
[
"document"
]))
def
doc_to_target
(
self
,
doc
):
return
" {}"
.
format
({
1
:
"긍정"
,
0
:
"부정"
}[
doc
[
"label"
]])
return
"
(
{}
)
"
.
format
({
1
:
"긍정"
,
0
:
"부정"
}[
doc
[
"label"
]])
def
construct_requests
(
self
,
doc
,
ctx
):
ll_positive
,
_
=
rf
.
loglikelihood
(
ctx
,
" 긍정"
)
ll_negative
,
_
=
rf
.
loglikelihood
(
ctx
,
" 부정"
)
ll_positive
,
_
=
rf
.
loglikelihood
(
ctx
,
"
(
긍정
)
"
)
ll_negative
,
_
=
rf
.
loglikelihood
(
ctx
,
"
(
부정
)
"
)
return
ll_positive
,
ll_negative
def
process_results
(
self
,
doc
,
results
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment