Repository navigation
feat(transformer-ner) Added class weighting for loss calculation and exposing training params. - #647
Open
adam-sutton-1992 wants to merge 18 commits into
Open
adam-sutton-1992 wants to merge 18 commits into
adam-sutton-1992 wants to merge 18 commits into
Conversation
Collaborator
|
Please resync with |
…634) * feat(medcat-trainer): Add text and name contains filters to documents API Co-authored-by: tomolopolis <[email protected]> * feat(medcat-trainer): Search clinical notes by text span in annotate view Co-authored-by: tomolopolis <[email protected]> * feat(medcat-trainer): Index dataset documents into Solr on upload and add Solr backed document search endpoint Co-authored-by: tomolopolis <[email protected]> * feat(medcat-trainer): Use Solr document search for clinical notes text search Co-authored-by: tomolopolis <[email protected]> * docs(medcat-trainer): Document Solr document search settings Co-authored-by: tomolopolis <[email protected]> * feat(medcat-trainer): Put clinical notes summary in a resizable split pane Co-authored-by: tomolopolis <[email protected]> * feat(medcat-trainer): improved styles and UX of doc search function --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: tomolopolis <[email protected]>
* fix(medcat-trainer): open FP/FN/TP example dialogs reliably Clicking a concept count failed when the metrics table did not hand back the original row, so the example dialog never opened. Current MedCAT stats examples also use snake_case fields, which left the dialog unable to show or link those occurrences, and unescaped clinical text could break rendering. Resolve examples without object identity, accept both key styles, escape note text, and mount the dialog on document.body. Co-authored-by: tomolopolis <[email protected]> * fix(medcat-trainer): restore TP, FN, and FP count colors type=button matched Vuetify's color:inherit rule and overrode the outline button colors. Keep true positives green, false negatives grey, and false positives red. Co-authored-by: tomolopolis <[email protected]> * fix(medcat-trainer): paint non-zero TP, FN, and FP counts Bootstrap outline colors were still lost once later button rules reset --bs-btn-color. Set the NHS green, grey, and red on the count buttons themselves so a non-zero number keeps its colour. Co-authored-by: tomolopolis <[email protected]> * fix(medcat-trainer): use theme variables for count colours Non-zero TP, FN, and FP counts take --success, --warning, and --danger from the NHS theme map instead of hardcoded hex values. Co-authored-by: tomolopolis <[email protected]> * fix(medcat-trainer): fix styling of metrics * fix(medcat-trainer): fix test, fix clickable mention in span in modal appearing alongside the context to the right of the mention --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: tomolopolis <[email protected]>
* feat(medcat-trainer): add project group changes in mct-client * chore(medcat-trainer): update to latest release
Bumps the actions-deps group with 1 update: [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish). Updates `pypa/gh-action-pypi-publish` from 1.14.2 to 1.14.3 - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](pypa/gh-action-pypi-publish@v1.14.2...v1.14.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-version: 1.14.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions-deps ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hihi,
Adding class weighting exposing some training params. Previously the loss was calculated via the CRF outputs which predicted output tokens. This improved performance over baseline loss by enforcing transitions between tokens to make sense (i.e. B->I or E prediction tokens only, O -> B or S prediction tokens, etc...). I tested class weights for each predicted class with the new stats module and making these changes results in performance increases. Here they are:
config.class_weights- A dict of how to weigh each label class towards the calculated loss. Generally speaking in this task making O lower increases recall at the cost of precision. Increasing B and S also encourages detecting the start of concepts more liberally. Defaults to a uniform weighting.config.crf_loss_weight- Weigh the importance of the loss function that was previously the standard. This is crf outputs. Effectively you can increase/decrease the importance of the output being consistent.config.learning_rate- The learning rate was set to 1e-5, without it being exposed to be edited nicely. This fixes that.config.weight_decay- same as above.This also comes with methods in
transformer_nerwhich exposes these changes and nicely saves / loads the parameters.The changes to class weights and loss weight can significantly improve performance on the NER Only task. Going from a best Recall of 0.9 to 0.96, where the vocab based nerrule based method with training can achieve about 9.75. This also has a higher precision compare to the vocab based ner method. Reaching about 0.4.