Make an ensemble model to combine scores together (very high accuracy)
This commit is contained in:
@@ -6,11 +6,17 @@ import { evaluateWithRoberta } from "../tools/robertaCall";
|
||||
export const robertaMetrics: GraphNode<typeof MessagesState> = async (state) => {
|
||||
const answer = state.proposedTriggerEvent[state.proposedTriggerEventIndex].Event
|
||||
|
||||
const result = await evaluateWithRoberta({answer})
|
||||
//Option 1:
|
||||
const lrresult = await evaluateWithRoberta({answer, method:"logreg"})
|
||||
const lrscore = lrresult.validProb - lrresult.invalidProb;
|
||||
|
||||
|
||||
const score = result.validProb - result.invalidProb;
|
||||
const roresult = await evaluateWithRoberta({answer, method:"roberta"})
|
||||
const roscore = roresult.validProb - roresult.invalidProb;
|
||||
|
||||
const flresult = await evaluateWithRoberta({answer, method:"flan"})
|
||||
const flscore = flresult.validProb - flresult.invalidProb;
|
||||
|
||||
const score = lrscore * 0.3 + roscore * 0.5 + flscore * 0.3
|
||||
|
||||
return {
|
||||
messages: [ new AIMessage("ROBERTA:" + score)]
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import axios from "axios";
|
||||
|
||||
export async function evaluateWithRoberta({
|
||||
answer
|
||||
answer,
|
||||
method
|
||||
}: {
|
||||
answer: string;
|
||||
method: string
|
||||
}): Promise<{ validProb: number; invalidProb: number; }> {
|
||||
const res = await axios.post("http://localhost:8000/evaluate", {
|
||||
answer
|
||||
answer,
|
||||
method
|
||||
});
|
||||
// console.log(res.data)
|
||||
const validProb = res.data["probabilities"][0][0]
|
||||
|
||||
Reference in New Issue
Block a user