Skip to content

Commit

Permalink
Add a table column for number of data points in Saliency Clustering
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 507843523
  • Loading branch information
Googler committed Feb 7, 2023
1 parent f46bd9e commit ff759ad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lit_nlp/client/modules/salience_clustering_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export class SalienceClusteringModule extends LitModule {

private async runInterpreter() {
const salienceMapper = this.state.clusteringConfig[SALIENCE_MAPPER_KEY];
this.state.clusteringState.clusterInfos = {};
const inputs = this.selectionService.selectedOrAllInputData;
if (!this.canRunClustering) {
return;
Expand Down Expand Up @@ -241,10 +240,15 @@ export class SalienceClusteringModule extends LitModule {
private renderSingleGradKeyTopTokenInfos(
gradKey: string, topTokenInfosByClusters: TopTokenInfosByCluster[],
clusterInfos: ClusterInfo[], colorMap: SalienceCmap) {
// TODO(b/268221058): Compute number of data points per cluster from backend
// clang-format off
const rowsByClusters: TableData[] =
topTokenInfosByClusters.map((topTokenInfos, clusterIdx) => {
return [clusterIdx, html`
return [
clusterIdx,
clusterInfos.filter(
clusterInfo => clusterInfo.clusterId === clusterIdx).length,
html`
<lit-token-chips
.tokensWithWeights=${topTokenInfos.topTokenInfos}
.cmap=${colorMap}>
Expand All @@ -271,7 +275,9 @@ export class SalienceClusteringModule extends LitModule {
<lit-data-table
.columnNames=${[
'Cluster index',
`Tokens with high average saliency (up to ${numTokensPerCluster})`]}
'N',
`Tokens with high average saliency (up to ${numTokensPerCluster})`
]}
.data=${rowsByClusters}
selectionEnabled
.onSelect=${onSelectClusters}
Expand Down

0 comments on commit ff759ad

Please sign in to comment.