-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add genai metrics endpoint in UI for model overview metrics (#2517)
- Loading branch information
1 parent
7aa72fb
commit 12bfef8
Showing
15 changed files
with
367 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
88 changes: 88 additions & 0 deletions
88
libs/core-ui/src/lib/util/GenerativeTextStatisticsUtils.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { localization } from "@responsible-ai/localization"; | ||
|
||
import { | ||
ILabeledStatistic, | ||
TotalCohortSamples | ||
} from "../Interfaces/IStatistic"; | ||
|
||
import { QuestionAnsweringMetrics } from "./QuestionAnsweringStatisticsUtils"; | ||
|
||
export enum GenerativeTextMetrics { | ||
Coherence = "coherence", | ||
Fluency = "fluency", | ||
Equivalence = "equivalence", | ||
Groundedness = "groundedness", | ||
Relevance = "relevance" | ||
} | ||
|
||
export const generateGenerativeTextStats: ( | ||
selectionIndexes: number[][], | ||
generativeTextCache: Map<string, Map<string, number>> | ||
) => ILabeledStatistic[][] = ( | ||
selectionIndexes: number[][], | ||
generativeTextCache: Map<string, Map<string, number>> | ||
): ILabeledStatistic[][] => { | ||
return selectionIndexes.map((selectionArray) => { | ||
const count = selectionArray.length; | ||
|
||
const value = generativeTextCache.get(selectionArray.toString()); | ||
const stat: Map<string, number> = value ? value : new Map<string, number>(); | ||
|
||
const stats = [ | ||
{ | ||
key: TotalCohortSamples, | ||
label: localization.Interpret.Statistics.samples, | ||
stat: count | ||
} | ||
]; | ||
for (const [key, value] of stat.entries()) { | ||
let label = ""; | ||
switch (key) { | ||
case GenerativeTextMetrics.Coherence: | ||
label = localization.Interpret.Statistics.coherence; | ||
break; | ||
case GenerativeTextMetrics.Fluency: | ||
label = localization.Interpret.Statistics.fluency; | ||
break; | ||
case GenerativeTextMetrics.Equivalence: | ||
label = localization.Interpret.Statistics.equivalence; | ||
break; | ||
case GenerativeTextMetrics.Groundedness: | ||
label = localization.Interpret.Statistics.groundedness; | ||
break; | ||
case GenerativeTextMetrics.Relevance: | ||
label = localization.Interpret.Statistics.relevance; | ||
break; | ||
case QuestionAnsweringMetrics.ExactMatchRatio: | ||
label = localization.Interpret.Statistics.exactMatchRatio; | ||
break; | ||
case QuestionAnsweringMetrics.F1Score: | ||
label = localization.Interpret.Statistics.f1Score; | ||
break; | ||
case QuestionAnsweringMetrics.MeteorScore: | ||
label = localization.Interpret.Statistics.meteorScore; | ||
break; | ||
case QuestionAnsweringMetrics.BleuScore: | ||
label = localization.Interpret.Statistics.bleuScore; | ||
break; | ||
case QuestionAnsweringMetrics.BertScore: | ||
label = localization.Interpret.Statistics.bertScore; | ||
break; | ||
case QuestionAnsweringMetrics.RougeScore: | ||
label = localization.Interpret.Statistics.rougeScore; | ||
break; | ||
default: | ||
break; | ||
} | ||
stats.push({ | ||
key, | ||
label, | ||
stat: value | ||
}); | ||
} | ||
return stats; | ||
}); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.