evalsense 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evalsense-0.1.0/.gitignore +174 -0
- evalsense-0.1.0/LICENCE +21 -0
- evalsense-0.1.0/PKG-INFO +139 -0
- evalsense-0.1.0/README.md +94 -0
- evalsense-0.1.0/evalsense/__init__.py +0 -0
- evalsense-0.1.0/evalsense/cli/__init__.py +0 -0
- evalsense-0.1.0/evalsense/cli/__main__.py +4 -0
- evalsense-0.1.0/evalsense/cli/datasets.py +18 -0
- evalsense-0.1.0/evalsense/cli/main.py +25 -0
- evalsense-0.1.0/evalsense/constants.py +33 -0
- evalsense-0.1.0/evalsense/dataset_config/ACI-BENCH.yml +51 -0
- evalsense-0.1.0/evalsense/datasets/__init__.py +23 -0
- evalsense-0.1.0/evalsense/datasets/dataset_config.py +302 -0
- evalsense-0.1.0/evalsense/datasets/dataset_manager.py +292 -0
- evalsense-0.1.0/evalsense/datasets/managers/__init__.py +3 -0
- evalsense-0.1.0/evalsense/datasets/managers/aci_bench.py +83 -0
- evalsense-0.1.0/evalsense/evaluation/__init__.py +25 -0
- evalsense-0.1.0/evalsense/evaluation/evaluator.py +107 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/__init__.py +41 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/bertscore.py +273 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/bleu.py +159 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/g_eval.py +272 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/qags.py +910 -0
- evalsense-0.1.0/evalsense/evaluation/evaluators/rouge.py +134 -0
- evalsense-0.1.0/evalsense/evaluation/experiment.py +228 -0
- evalsense-0.1.0/evalsense/generation/__init__.py +4 -0
- evalsense-0.1.0/evalsense/generation/generation_steps.py +11 -0
- evalsense-0.1.0/evalsense/generation/model_config.py +70 -0
- evalsense-0.1.0/evalsense/logging.py +61 -0
- evalsense-0.1.0/evalsense/py.typed +0 -0
- evalsense-0.1.0/evalsense/tasks/__init__.py +7 -0
- evalsense-0.1.0/evalsense/tasks/task_preprocessor.py +106 -0
- evalsense-0.1.0/evalsense/utils/__init__.py +0 -0
- evalsense-0.1.0/evalsense/utils/dict.py +14 -0
- evalsense-0.1.0/evalsense/utils/files.py +249 -0
- evalsense-0.1.0/evalsense/utils/huggingface.py +20 -0
- evalsense-0.1.0/evalsense/utils/text.py +274 -0
- evalsense-0.1.0/evalsense/workflow/__init__.py +9 -0
- evalsense-0.1.0/evalsense/workflow/analysers/__init__.py +11 -0
- evalsense-0.1.0/evalsense/workflow/analysers/metric_correlation_analyser.py +201 -0
- evalsense-0.1.0/evalsense/workflow/analysers/tabular_analyser.py +93 -0
- evalsense-0.1.0/evalsense/workflow/pipeline.py +529 -0
- evalsense-0.1.0/evalsense/workflow/project.py +426 -0
- evalsense-0.1.0/evalsense/workflow/result_analyser.py +31 -0
- evalsense-0.1.0/pyproject.toml +100 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
evalsense-0.1.0/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT Licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NHS England
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
evalsense-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: evalsense
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tools for evaluating large language models.
|
|
5
|
+
Project-URL: Homepage, https://github.com/nhsengland/evalsense
|
|
6
|
+
Project-URL: Issues, https://github.com/nhsengland/evalsense/issues
|
|
7
|
+
Author-email: Adam Dejl <adam.dejl18@imperial.ac.uk>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENCE
|
|
10
|
+
Keywords: Artificial Intelligence,LLM Benchmarking,LLM Evaluation,LLMs,Large Language Models,Machine Learning
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: accelerate>=1.4.0
|
|
20
|
+
Requires-Dist: bert-score>=0.3.13
|
|
21
|
+
Requires-Dist: datasets>=3.2.0
|
|
22
|
+
Requires-Dist: evaluate>=0.4.3
|
|
23
|
+
Requires-Dist: flashinfer-python<0.2.3
|
|
24
|
+
Requires-Dist: inspect-ai>=0.3.87
|
|
25
|
+
Requires-Dist: matplotlib>=3.10.0
|
|
26
|
+
Requires-Dist: numpy<2.0.0
|
|
27
|
+
Requires-Dist: openai>=1.65.3
|
|
28
|
+
Requires-Dist: pandas>=2.2.3
|
|
29
|
+
Requires-Dist: platformdirs>=4.3.6
|
|
30
|
+
Requires-Dist: polars>=1.22.0
|
|
31
|
+
Requires-Dist: pydantic>=2.10.6
|
|
32
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
33
|
+
Requires-Dist: rouge-score>=0.1.2
|
|
34
|
+
Requires-Dist: seaborn>=0.13.2
|
|
35
|
+
Requires-Dist: tenacity>=9.0.0
|
|
36
|
+
Requires-Dist: torch>=2.6
|
|
37
|
+
Requires-Dist: tqdm>=4.67.1
|
|
38
|
+
Requires-Dist: transformers>=4.50.0
|
|
39
|
+
Requires-Dist: typer>=0.15.1
|
|
40
|
+
Requires-Dist: vllm>=0.8.2
|
|
41
|
+
Provides-Extra: interactive
|
|
42
|
+
Requires-Dist: ipywidgets>=8.1.5; extra == 'interactive'
|
|
43
|
+
Requires-Dist: jupyterlab>=4.3.5; extra == 'interactive'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
> [!WARNING]
|
|
47
|
+
> This project is a work in progress. Critical components may be missing, inoperative or incomplete, and the API can undergo major changes without any notice. Please check back later for a more stable version.
|
|
48
|
+
|
|
49
|
+
# EvalSense: LLM Evaluation
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
[](https://github.com/GIScience/badges#experimental)
|
|
53
|
+
[](https://github.com/nhsengland/evalsense/blob/main/LICENCE)
|
|
54
|
+
[](https://github.com/nhsengland/evalsense/actions/workflows/evalsense.yml)
|
|
55
|
+
[](https://github.com/nhsengland/evalsense/actions/workflows/guide.yml)
|
|
56
|
+
[](https://www.python.org/)
|
|
57
|
+
[](https://www.typescriptlang.org/)
|
|
58
|
+
[](https://react.dev/)
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div align="center">
|
|
62
|
+
|
|
63
|
+
[](https://www.python.org/downloads/)
|
|
64
|
+
[](https://github.com/astral-sh/uv)
|
|
65
|
+
[](https://github.com/astral-sh/ruff)
|
|
66
|
+
[](https://microsoft.github.io/pyright/)
|
|
67
|
+
[](https://eslint.org/)
|
|
68
|
+
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
## About
|
|
72
|
+
This repository holds a Python package enabling systematic evaluation of large language models (LLMs) on open-ended generation tasks, with a particular focus on healthcare and summarisation. It also includes supplementary documentation and assets related to the NHS England project on LLM evaluation, such as the code for an interactive LLM evaluation guide (located in the `guide/` directory`). You can find more information about the project in the [original project proposal](https://nhsx.github.io/nhsx-internship-projects/genai-eval/).
|
|
73
|
+
|
|
74
|
+
_**Note:** Only public or fake data are shared in this repository._
|
|
75
|
+
|
|
76
|
+
## Project Stucture
|
|
77
|
+
|
|
78
|
+
- The main code for the EvalSense Python package can be found under [`evalsense/`](https://github.com/nhsengland/evalsense/tree/main/evalsense).
|
|
79
|
+
- The accompanying documentation is available in the [`docs/`](https://github.com/nhsengland/evalsense/tree/main/docs) folder.
|
|
80
|
+
- Code for the interactive LLM evaluation guide is located under [`guide/`](https://github.com/nhsengland/evalsense/tree/main/guide).
|
|
81
|
+
- Jupyter notebooks with the evaluation experiments and examples are located under [`notebooks/`](https://github.com/nhsengland/evalsense/tree/main/notebooks).
|
|
82
|
+
|
|
83
|
+
## Getting Started
|
|
84
|
+
|
|
85
|
+
### Installation for Development
|
|
86
|
+
|
|
87
|
+
To install the project for local development, you can follow the steps below:
|
|
88
|
+
|
|
89
|
+
To clone the repo:
|
|
90
|
+
|
|
91
|
+
`git clone git@github.com:nhsengland/evalsense.git`
|
|
92
|
+
|
|
93
|
+
To setup the Python environment for the project:
|
|
94
|
+
|
|
95
|
+
- Install [uv](https://github.com/astral-sh/uv) if it's not installed already
|
|
96
|
+
- `uv sync --all-extras`
|
|
97
|
+
- `source .venv/bin/activate`
|
|
98
|
+
- `pre-commit install`
|
|
99
|
+
|
|
100
|
+
To setup the Node environment for the LLM evaluation guide (located under [`guide/`](https://github.com/nhsengland/evalsense/tree/main/guide)):
|
|
101
|
+
|
|
102
|
+
- Install [node](https://nodejs.org/en/download) if it's not installed already
|
|
103
|
+
- `npm install` in the `guide/` directory
|
|
104
|
+
- `npm run start` to run the development server
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
For an example illustrating the usage of EvalSense, please check the [Demo notebook](https://github.com/nhsengland/evalsense/blob/main/notebooks/Demo.ipynb) under the `notebooks/` folder.
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
|
112
|
+
|
|
113
|
+
1. Fork the Project
|
|
114
|
+
2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
|
|
115
|
+
3. Commit your Changes (`git commit -m 'Add some amazing feature'`)
|
|
116
|
+
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
|
117
|
+
5. Open a Pull Request
|
|
118
|
+
|
|
119
|
+
_See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidance._
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
Unless stated otherwise, the codebase is released under [the MIT Licence][mit].
|
|
124
|
+
This covers both the codebase and any sample code in the documentation.
|
|
125
|
+
|
|
126
|
+
_See [LICENSE](./LICENSE) for more information._
|
|
127
|
+
|
|
128
|
+
The documentation is [© Crown copyright][copyright] and available under the terms
|
|
129
|
+
of the [Open Government 3.0][ogl] licence.
|
|
130
|
+
|
|
131
|
+
[mit]: LICENCE
|
|
132
|
+
[copyright]: http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/
|
|
133
|
+
[ogl]: http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
|
|
134
|
+
|
|
135
|
+
### Contact
|
|
136
|
+
|
|
137
|
+
To find out more about the [NHS England Data Science](https://nhsengland.github.io/datascience/) visit our [project website](https://nhsengland.github.io/datascience/our_work/) or get in touch at [datascience@nhs.net](mailto:datascience@nhs.net).
|
|
138
|
+
|
|
139
|
+
<!-- ### Acknowledgements -->
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
> [!WARNING]
|
|
2
|
+
> This project is a work in progress. Critical components may be missing, inoperative or incomplete, and the API can undergo major changes without any notice. Please check back later for a more stable version.
|
|
3
|
+
|
|
4
|
+
# EvalSense: LLM Evaluation
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
7
|
+
[](https://github.com/GIScience/badges#experimental)
|
|
8
|
+
[](https://github.com/nhsengland/evalsense/blob/main/LICENCE)
|
|
9
|
+
[](https://github.com/nhsengland/evalsense/actions/workflows/evalsense.yml)
|
|
10
|
+
[](https://github.com/nhsengland/evalsense/actions/workflows/guide.yml)
|
|
11
|
+
[](https://www.python.org/)
|
|
12
|
+
[](https://www.typescriptlang.org/)
|
|
13
|
+
[](https://react.dev/)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
<div align="center">
|
|
17
|
+
|
|
18
|
+
[](https://www.python.org/downloads/)
|
|
19
|
+
[](https://github.com/astral-sh/uv)
|
|
20
|
+
[](https://github.com/astral-sh/ruff)
|
|
21
|
+
[](https://microsoft.github.io/pyright/)
|
|
22
|
+
[](https://eslint.org/)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
## About
|
|
27
|
+
This repository holds a Python package enabling systematic evaluation of large language models (LLMs) on open-ended generation tasks, with a particular focus on healthcare and summarisation. It also includes supplementary documentation and assets related to the NHS England project on LLM evaluation, such as the code for an interactive LLM evaluation guide (located in the `guide/` directory`). You can find more information about the project in the [original project proposal](https://nhsx.github.io/nhsx-internship-projects/genai-eval/).
|
|
28
|
+
|
|
29
|
+
_**Note:** Only public or fake data are shared in this repository._
|
|
30
|
+
|
|
31
|
+
## Project Stucture
|
|
32
|
+
|
|
33
|
+
- The main code for the EvalSense Python package can be found under [`evalsense/`](https://github.com/nhsengland/evalsense/tree/main/evalsense).
|
|
34
|
+
- The accompanying documentation is available in the [`docs/`](https://github.com/nhsengland/evalsense/tree/main/docs) folder.
|
|
35
|
+
- Code for the interactive LLM evaluation guide is located under [`guide/`](https://github.com/nhsengland/evalsense/tree/main/guide).
|
|
36
|
+
- Jupyter notebooks with the evaluation experiments and examples are located under [`notebooks/`](https://github.com/nhsengland/evalsense/tree/main/notebooks).
|
|
37
|
+
|
|
38
|
+
## Getting Started
|
|
39
|
+
|
|
40
|
+
### Installation for Development
|
|
41
|
+
|
|
42
|
+
To install the project for local development, you can follow the steps below:
|
|
43
|
+
|
|
44
|
+
To clone the repo:
|
|
45
|
+
|
|
46
|
+
`git clone git@github.com:nhsengland/evalsense.git`
|
|
47
|
+
|
|
48
|
+
To setup the Python environment for the project:
|
|
49
|
+
|
|
50
|
+
- Install [uv](https://github.com/astral-sh/uv) if it's not installed already
|
|
51
|
+
- `uv sync --all-extras`
|
|
52
|
+
- `source .venv/bin/activate`
|
|
53
|
+
- `pre-commit install`
|
|
54
|
+
|
|
55
|
+
To setup the Node environment for the LLM evaluation guide (located under [`guide/`](https://github.com/nhsengland/evalsense/tree/main/guide)):
|
|
56
|
+
|
|
57
|
+
- Install [node](https://nodejs.org/en/download) if it's not installed already
|
|
58
|
+
- `npm install` in the `guide/` directory
|
|
59
|
+
- `npm run start` to run the development server
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
For an example illustrating the usage of EvalSense, please check the [Demo notebook](https://github.com/nhsengland/evalsense/blob/main/notebooks/Demo.ipynb) under the `notebooks/` folder.
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
|
|
66
|
+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
|
67
|
+
|
|
68
|
+
1. Fork the Project
|
|
69
|
+
2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
|
|
70
|
+
3. Commit your Changes (`git commit -m 'Add some amazing feature'`)
|
|
71
|
+
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
|
72
|
+
5. Open a Pull Request
|
|
73
|
+
|
|
74
|
+
_See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidance._
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
Unless stated otherwise, the codebase is released under [the MIT Licence][mit].
|
|
79
|
+
This covers both the codebase and any sample code in the documentation.
|
|
80
|
+
|
|
81
|
+
_See [LICENSE](./LICENSE) for more information._
|
|
82
|
+
|
|
83
|
+
The documentation is [© Crown copyright][copyright] and available under the terms
|
|
84
|
+
of the [Open Government 3.0][ogl] licence.
|
|
85
|
+
|
|
86
|
+
[mit]: LICENCE
|
|
87
|
+
[copyright]: http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/
|
|
88
|
+
[ogl]: http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
|
|
89
|
+
|
|
90
|
+
### Contact
|
|
91
|
+
|
|
92
|
+
To find out more about the [NHS England Data Science](https://nhsengland.github.io/datascience/) visit our [project website](https://nhsengland.github.io/datascience/our_work/) or get in touch at [datascience@nhs.net](mailto:datascience@nhs.net).
|
|
93
|
+
|
|
94
|
+
<!-- ### Acknowledgements -->
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
datasets_app = typer.Typer(
|
|
4
|
+
no_args_is_help=True,
|
|
5
|
+
help="Manage datasets for EvalSense.",
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@datasets_app.command(no_args_is_help=True)
|
|
10
|
+
def get(name: str):
|
|
11
|
+
"""
|
|
12
|
+
Download and prepare a dataset.
|
|
13
|
+
"""
|
|
14
|
+
print(f"Downloading and preparing dataset {name}.")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
datasets_app()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from typing_extensions import Annotated
|
|
3
|
+
|
|
4
|
+
from evalsense.cli.datasets import datasets_app
|
|
5
|
+
|
|
6
|
+
app = typer.Typer(
|
|
7
|
+
no_args_is_help=True,
|
|
8
|
+
help="EvalSense: A tool for evaluating LLM performance on healthcare tasks.",
|
|
9
|
+
)
|
|
10
|
+
app.add_typer(datasets_app, name="datasets")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@app.command(no_args_is_help=True)
|
|
14
|
+
def run(
|
|
15
|
+
model: Annotated[str, typer.Option("--model", "-m")],
|
|
16
|
+
dataset: Annotated[str, typer.Option("--dataset", "-d")],
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
Run a model on a dataset.
|
|
20
|
+
"""
|
|
21
|
+
print(f"Running model {model} on dataset {dataset}.")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
app()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from platformdirs import user_cache_dir
|
|
5
|
+
|
|
6
|
+
# Application metadata
|
|
7
|
+
APP_NAME = "evalsense"
|
|
8
|
+
APP_AUTHOR = "NHS"
|
|
9
|
+
USER_AGENT = "EvalSense/0.1.0"
|
|
10
|
+
|
|
11
|
+
# Datasets
|
|
12
|
+
DEFAULT_VERSION_NAME = "default"
|
|
13
|
+
DEFAULT_HASH_TYPE = "sha256"
|
|
14
|
+
|
|
15
|
+
if "OPENAI_API_KEY" in os.environ:
|
|
16
|
+
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
|
17
|
+
else:
|
|
18
|
+
OPENAI_API_KEY = None
|
|
19
|
+
|
|
20
|
+
if "EVALSENSE_STORAGE_DIR" in os.environ:
|
|
21
|
+
STORAGE_PATH = Path(os.environ["EVALSENSE_STORAGE_DIR"])
|
|
22
|
+
else:
|
|
23
|
+
STORAGE_PATH = Path(user_cache_dir(APP_NAME, APP_AUTHOR))
|
|
24
|
+
DATA_PATH = STORAGE_PATH / "datasets"
|
|
25
|
+
MODELS_PATH = STORAGE_PATH / "models"
|
|
26
|
+
PROJECTS_PATH = STORAGE_PATH / "projects"
|
|
27
|
+
if "HF_HUB_CACHE" not in os.environ:
|
|
28
|
+
os.environ["HF_HUB_CACHE"] = str(STORAGE_PATH / "huggingface")
|
|
29
|
+
|
|
30
|
+
DATASET_CONFIG_PATHS = [Path(__file__).parent / "dataset_config"]
|
|
31
|
+
if "DATASET_CONFIG_PATH" in os.environ:
|
|
32
|
+
for directory in os.environ["DATASET_CONFIG_PATH"].split(os.pathsep):
|
|
33
|
+
DATASET_CONFIG_PATHS.append(Path(directory))
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: ACI-BENCH
|
|
2
|
+
description: "Dataset for benchmarking clinical note generation from doctor-patient dialogue."
|
|
3
|
+
config_version: "v1"
|
|
4
|
+
default_version: "5d3cd4d8a25b4ebb5b2b87c3923a7b2b7150e33d"
|
|
5
|
+
source:
|
|
6
|
+
online: true
|
|
7
|
+
url_template: "https://raw.githubusercontent.com/wyim/aci-bench/{version}/data/challenge_data/{filename}"
|
|
8
|
+
requires_auth: false
|
|
9
|
+
versions:
|
|
10
|
+
- name: 5d3cd4d8a25b4ebb5b2b87c3923a7b2b7150e33d
|
|
11
|
+
splits:
|
|
12
|
+
- name: train
|
|
13
|
+
files:
|
|
14
|
+
- name: train.csv
|
|
15
|
+
hash: "6c778d4ac5e6cc6f1964786f9286e8d765c210f22ed6b57f83aff8497409cea4"
|
|
16
|
+
hash_type: sha256
|
|
17
|
+
- name: train_metadata.csv
|
|
18
|
+
hash: "7da650e223f04ff6bf1666cb62d52ebd83ce71ecfc4b2311cbe64d9f3ab19d83"
|
|
19
|
+
hash_type: sha256
|
|
20
|
+
- name: valid
|
|
21
|
+
files:
|
|
22
|
+
- name: valid.csv
|
|
23
|
+
hash: "6629e89e3fb409d2b3eceab60dc7b32fe1d3fb8d4e07795039284965522aa4d0"
|
|
24
|
+
hash_type: sha256
|
|
25
|
+
- name: valid_metadata.csv
|
|
26
|
+
hash: "ae4c7eef6fc97e22f447c33e4546691715821e2a671ab53d80eb1ee5598e2914"
|
|
27
|
+
hash_type: sha256
|
|
28
|
+
- name: test1
|
|
29
|
+
files:
|
|
30
|
+
- name: clinicalnlp_taskB_test1.csv
|
|
31
|
+
hash: "5cc4008e68545f84913744a8e493a58bdf17ba7e1b7a0be46d6943d6bfca9471"
|
|
32
|
+
hash_type: sha256
|
|
33
|
+
- name: clinicalnlp_taskB_test1_metadata.csv
|
|
34
|
+
hash: "6960581701816c6dbe1aea8a53df6cff2f1ca92b24b036f6303242ca681cbafd"
|
|
35
|
+
hash_type: sha256
|
|
36
|
+
- name: test2
|
|
37
|
+
files:
|
|
38
|
+
- name: clinicalnlp_taskC_test2.csv
|
|
39
|
+
hash: "599e3330a14e25a0e056aee1365ffac7ebe50058f15821eae42a5513c2bb5a4f"
|
|
40
|
+
hash_type: sha256
|
|
41
|
+
- name: clinicalnlp_taskC_test2_metadata.csv
|
|
42
|
+
hash: "60e799ee5033767e9f5c2e9c3d84f64366628e2aae8637cd5d96ca29ba01b83c"
|
|
43
|
+
hash_type: sha256
|
|
44
|
+
- name: test3
|
|
45
|
+
files:
|
|
46
|
+
- name: clef_taskC_test3.csv
|
|
47
|
+
hash: "d3c18362a42124ea2bd1b2b4b66ba76a11bb123dfdb416471ae3b5924d1428ec"
|
|
48
|
+
hash_type: sha256
|
|
49
|
+
- name: clef_taskC_test3_metadata.csv
|
|
50
|
+
hash: "e1bec9323b2bed8e544ead77fae6251c4709bc9ffe2d0de346d843334760736b"
|
|
51
|
+
hash_type: sha256
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from evalsense.datasets.dataset_config import (
|
|
2
|
+
OnlineSource,
|
|
3
|
+
LocalSource,
|
|
4
|
+
FileMetadata,
|
|
5
|
+
SplitMetadata,
|
|
6
|
+
VersionMetadata,
|
|
7
|
+
DatasetMetadata,
|
|
8
|
+
DatasetConfig,
|
|
9
|
+
)
|
|
10
|
+
from evalsense.datasets.dataset_manager import DatasetManager, DatasetRecord
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DatasetManager",
|
|
15
|
+
"DatasetRecord",
|
|
16
|
+
"DatasetConfig",
|
|
17
|
+
"OnlineSource",
|
|
18
|
+
"LocalSource",
|
|
19
|
+
"FileMetadata",
|
|
20
|
+
"SplitMetadata",
|
|
21
|
+
"VersionMetadata",
|
|
22
|
+
"DatasetMetadata",
|
|
23
|
+
]
|