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
056c9d85
"vscode:/vscode.git/clone" did not exist on "dcb3c95298acf54d6af2d09958286d51a72caa86"
Commit
056c9d85
authored
Nov 10, 2023
by
lintangsutawika
Browse files
added initialize_task and updated where eval_logger is imported from
parent
574e565a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
21 deletions
+25
-21
lm_eval/__main__.py
lm_eval/__main__.py
+5
-10
lm_eval/evaluator.py
lm_eval/evaluator.py
+1
-2
lm_eval/models/anthropic_llms.py
lm_eval/models/anthropic_llms.py
+2
-1
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+1
-1
lm_eval/prompts/__init__.py
lm_eval/prompts/__init__.py
+1
-1
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+7
-4
lm_eval/tasks/minerva_math/utils.py
lm_eval/tasks/minerva_math/utils.py
+1
-1
lm_eval/tasks/realtoxicityprompts/metric.py
lm_eval/tasks/realtoxicityprompts/metric.py
+1
-1
lm_eval/utils.py
lm_eval/utils.py
+6
-0
No files found.
lm_eval/__main__.py
View file @
056c9d85
...
@@ -9,12 +9,9 @@ import numpy as np
...
@@ -9,12 +9,9 @@ import numpy as np
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Union
from
typing
import
Union
logging
.
basicConfig
(
from
lm_eval
import
evaluator
,
utils
format
=
"%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"
,
from
lm_eval.tasks
import
initialize_tasks
,
include_path
datefmt
=
"%Y-%m-%d:%H:%M:%S"
,
from
lm_eval.api.registry
import
ALL_TASKS
level
=
logging
.
INFO
,
)
def
_handle_non_serializable
(
o
):
def
_handle_non_serializable
(
o
):
if
isinstance
(
o
,
np
.
int64
)
or
isinstance
(
o
,
np
.
int32
):
if
isinstance
(
o
,
np
.
int64
)
or
isinstance
(
o
,
np
.
int32
):
...
@@ -121,14 +118,12 @@ def cli_evaluate(args: Union[argparse.Namespace, None] = None) -> None:
...
@@ -121,14 +118,12 @@ def cli_evaluate(args: Union[argparse.Namespace, None] = None) -> None:
# we allow for args to be passed externally, else we parse them ourselves
# we allow for args to be passed externally, else we parse them ourselves
args
=
parse_eval_args
()
args
=
parse_eval_args
()
eval_logger
=
logging
.
getLogger
(
"lm-eval"
)
eval_logger
=
utils
.
eval_logger
eval_logger
.
setLevel
(
getattr
(
logging
,
f
"
{
args
.
verbosity
}
"
))
eval_logger
.
setLevel
(
getattr
(
logging
,
f
"
{
args
.
verbosity
}
"
))
eval_logger
.
info
(
f
"Verbosity set to
{
args
.
verbosity
}
"
)
eval_logger
.
info
(
f
"Verbosity set to
{
args
.
verbosity
}
"
)
os
.
environ
[
"TOKENIZERS_PARALLELISM"
]
=
"false"
os
.
environ
[
"TOKENIZERS_PARALLELISM"
]
=
"false"
from
lm_eval
import
evaluator
,
utils
initialize_tasks
(
args
.
verbosity
)
from
lm_eval.tasks
import
include_path
from
lm_eval.api.registry
import
ALL_TASKS
if
args
.
limit
:
if
args
.
limit
:
eval_logger
.
warning
(
eval_logger
.
warning
(
...
...
lm_eval/evaluator.py
View file @
056c9d85
...
@@ -20,10 +20,9 @@ from lm_eval.utils import (
...
@@ -20,10 +20,9 @@ from lm_eval.utils import (
make_table
,
make_table
,
create_iterator
,
create_iterator
,
get_git_commit_hash
,
get_git_commit_hash
,
eval_logger
)
)
eval_logger
=
logging
.
getLogger
(
"lm-eval"
)
@
positional_deprecated
@
positional_deprecated
def
simple_evaluate
(
def
simple_evaluate
(
...
...
lm_eval/models/anthropic_llms.py
View file @
056c9d85
...
@@ -2,9 +2,10 @@ from lm_eval.api.model import LM
...
@@ -2,9 +2,10 @@ from lm_eval.api.model import LM
from
lm_eval.api.registry
import
register_model
from
lm_eval.api.registry
import
register_model
from
tqdm
import
tqdm
from
tqdm
import
tqdm
import
time
import
time
from
lm_eval
.logger
import
eval_logger
from
lm_eval
import
utils
from
typing
import
List
,
Any
,
Tuple
from
typing
import
List
,
Any
,
Tuple
eval_logger
=
utils
.
eval_logger
def
anthropic_completion
(
def
anthropic_completion
(
client
,
#: anthropic.Anthropic,
client
,
#: anthropic.Anthropic,
...
...
lm_eval/models/huggingface.py
View file @
056c9d85
...
@@ -16,7 +16,6 @@ from pathlib import Path
...
@@ -16,7 +16,6 @@ from pathlib import Path
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
from
lm_eval
import
utils
from
lm_eval
import
utils
from
lm_eval.logger
import
eval_logger
from
lm_eval.api.model
import
LM
from
lm_eval.api.model
import
LM
from
lm_eval.api.registry
import
register_model
from
lm_eval.api.registry
import
register_model
...
@@ -25,6 +24,7 @@ from lm_eval.utils import MultiTokenEOSCriteria, stop_sequences_criteria
...
@@ -25,6 +24,7 @@ from lm_eval.utils import MultiTokenEOSCriteria, stop_sequences_criteria
from
accelerate
import
Accelerator
,
find_executable_batch_size
,
DistributedType
from
accelerate
import
Accelerator
,
find_executable_batch_size
,
DistributedType
from
typing
import
List
,
Optional
,
Union
from
typing
import
List
,
Optional
,
Union
eval_logger
=
utils
.
eval_logger
def
_get_accelerate_args
(
def
_get_accelerate_args
(
device_map_option
:
Optional
[
str
]
=
"auto"
,
device_map_option
:
Optional
[
str
]
=
"auto"
,
...
...
lm_eval/prompts/__init__.py
View file @
056c9d85
...
@@ -3,7 +3,7 @@ import ast
...
@@ -3,7 +3,7 @@ import ast
from
typing
import
Dict
from
typing
import
Dict
from
lm_eval
import
utils
from
lm_eval
import
utils
from
lm_eval.
logger
import
eval_logger
from
lm_eval.
utils
import
eval_logger
# Prompt library.
# Prompt library.
# Stores prompts in a dictionary indexed by 2 levels:
# Stores prompts in a dictionary indexed by 2 levels:
...
...
lm_eval/tasks/__init__.py
View file @
056c9d85
...
@@ -14,8 +14,7 @@ from lm_eval.api.registry import (
...
@@ -14,8 +14,7 @@ from lm_eval.api.registry import (
)
)
import
logging
import
logging
eval_logger
=
utils
.
eval_logger
eval_logger
=
logging
.
getLogger
(
"lm-eval"
)
def
register_configurable_task
(
config
:
Dict
[
str
,
str
])
->
int
:
def
register_configurable_task
(
config
:
Dict
[
str
,
str
])
->
int
:
...
@@ -168,8 +167,12 @@ def include_path(task_dir):
...
@@ -168,8 +167,12 @@ def include_path(task_dir):
return
0
return
0
task_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/"
def
initialize_tasks
(
verbosity
=
"INFO"
):
include_path
(
task_dir
)
eval_logger
.
setLevel
(
getattr
(
logging
,
f
"
{
verbosity
}
"
))
task_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/"
include_path
(
task_dir
)
def
get_task
(
task_name
,
config
):
def
get_task
(
task_name
,
config
):
...
...
lm_eval/tasks/minerva_math/utils.py
View file @
056c9d85
import
datasets
import
datasets
import
re
import
re
import
signal
import
signal
from
lm_eval.
logger
import
eval_logger
from
lm_eval.
utils
import
eval_logger
from
typing
import
Optional
,
List
,
Dict
from
typing
import
Optional
,
List
,
Dict
try
:
try
:
...
...
lm_eval/tasks/realtoxicityprompts/metric.py
View file @
056c9d85
...
@@ -3,7 +3,7 @@ import json
...
@@ -3,7 +3,7 @@ import json
import
requests
import
requests
import
numpy
as
np
import
numpy
as
np
from
lm_eval.
logger
import
eval_logger
from
lm_eval.
utils
import
eval_logger
def
toxicity_perspective_api
(
references
,
predictions
,
**
kwargs
):
def
toxicity_perspective_api
(
references
,
predictions
,
**
kwargs
):
...
...
lm_eval/utils.py
View file @
056c9d85
...
@@ -21,8 +21,14 @@ from itertools import islice
...
@@ -21,8 +21,14 @@ from itertools import islice
import
logging
import
logging
logging
.
basicConfig
(
format
=
"%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s"
,
datefmt
=
"%Y-%m-%d:%H:%M:%S"
,
level
=
logging
.
INFO
,
)
eval_logger
=
logging
.
getLogger
(
"lm-eval"
)
eval_logger
=
logging
.
getLogger
(
"lm-eval"
)
SPACING
=
" "
*
47
def
escaped_split
(
text
,
sep_char
,
maxsplit
=-
1
):
def
escaped_split
(
text
,
sep_char
,
maxsplit
=-
1
):
"""Split text into a list on occurrences of the given separation
"""Split text into a list on occurrences of the given separation
...
...
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