Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence salience for a decoder-only LM. Demo using GPT-2. #1375

Merged
1 commit merged into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lit_nlp/api/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from lit_nlp.api import dtypes


# LINT.IfChange
# pylint: disable=invalid-name
@enum.unique
class LitModuleName(dtypes.EnumSerializableAsValues, enum.Enum):
Expand All @@ -48,6 +47,7 @@ class LitModuleName(dtypes.EnumSerializableAsValues, enum.Enum):
GeneratedTextModule = 'generated-text-module'
GeneratorModule = 'generator-module'
LanguageModelPredictionModule = 'lm-prediction-module'
LMSalienceModule = 'lm-salience-module'
MetricsModule = 'metrics-module'
MultilabelModule = 'multilabel-module'
PdpModule = 'pdp-module'
Expand All @@ -68,6 +68,7 @@ def __call__(self, **kw):
return ModuleConfig(self.value, **kw)


# LINT.IfChange
# TODO(lit-dev): consider making modules subclass this instead of LitModuleName.
@attr.s(auto_attribs=True)
class ModuleConfig(dtypes.DataTuple):
Expand Down
98 changes: 98 additions & 0 deletions lit_nlp/client/modules/lm_salience_module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.flex-column {
display: flex;
flex-direction: column;
}

.chip-container {
padding: 8px;
}

.chip-container-dense {
padding: 8px;
}

.pre-wrap {
white-space: pre-wrap;
}

.gray-text {
color: var(--lit-neutral-400);
}

.target-info-line {
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
}

lit-switch .icon-button {
vertical-align: middle;
}

/**
* Module controls
*/
.module-toolbar {
border-bottom: 1px solid #dadce0;
box-sizing: border-box;
justify-content: space-between;
}

.module-footer {
justify-content: space-between;
}

.controls-group {
display: flex;
flex-direction: row;
align-items: center;
margin: 0 4px;
gap: 4px;
}

.controls-group[disabled] {
color: rgb(60, 64, 67);
opacity: 0.38;
pointer-events: none;
}

/* Allow contents to consume available space, but not to cause line wrapping. */
.controls-group-variable {
flex: 1;
overflow-x: clip;
margin-right: 8px;
}

.controls-group-variable > label {
min-width: 45px;
}

.controls-group-variable .dropdown {
max-width: calc(100% - 45px);
}

.vertical-separator {
background: #dadce0;
width: 2px;
height: 1.2rem;
padding: 0;
margin: 0 8px;
}

/* Allow wrap. TODO move this to shared_styles as an option? */
.module-footer-wrappable {
flex-wrap: wrap;
/* line-height: 30px; */ /* causes alignment issues */
height: unset;
min-height: 36px;
}

.module-footer > * { min-width: 0; }

.controls-group > * { min-width: 0; }

color-legend {
/* extra space to keep other controls from jumping when legend changes */
/* width: 400px; */
margin-right: 16px;
}
Loading
Loading