Add re-ranker mode to support re-ranking experiments, hopefully we can reduce the loss
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"dependencies": ["."],
|
||||
"graphs": {
|
||||
"agent": "./agent.ts:agent"
|
||||
"agent": "./agent.ts:agent",
|
||||
"verifier": "./verify.ts:agent"
|
||||
},
|
||||
"env": ".env"
|
||||
}
|
||||
|
||||
@@ -7,10 +7,21 @@ export async function hydratePrompt(path: string, state: any) : Promise<string>
|
||||
|
||||
let raw = fs.readFileSync("prompts/" + path, "utf-8");
|
||||
|
||||
raw = raw.replace("###TITLE###", state.disinformationTitle);
|
||||
raw = raw.replace("###LM###", state.messages.at(-1).content);
|
||||
raw = raw.replace("###NTITLE###", state.normalizedClaim);
|
||||
raw = raw.replace("###CDATE###", state.date);
|
||||
if (raw.indexOf("###TITLE###") != -1) {
|
||||
raw = raw.replace("###TITLE###", state.disinformationTitle);
|
||||
}
|
||||
|
||||
if (raw.indexOf("###LM###") != -1) {
|
||||
raw = raw.replace("###LM###", state.messages.at(-1).content);
|
||||
}
|
||||
|
||||
if (raw.indexOf("###NTITLE###") != -1) {
|
||||
raw = raw.replace("###NTITLE###", state.normalizedClaim);
|
||||
}
|
||||
|
||||
if (raw.indexOf("###CDATE###") != -1) {
|
||||
raw = raw.replace("###CDATE###", state.date);
|
||||
}
|
||||
|
||||
if (raw.indexOf("###TECLAIM###") != -1) {
|
||||
const title = state.proposedTriggerEvent[state.proposedTriggerEventIndex].Event
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { END, START, StateGraph } from "@langchain/langgraph";
|
||||
import { MessagesState } from "./state";
|
||||
import { verificationSetup } from "./nodes/verificationSetup";
|
||||
import { ragasMetrics } from "./nodes/ragasMetrics";
|
||||
import { produceRanking } from "./nodes/produceRanking";
|
||||
import { createModelNode } from "./nodes/model";
|
||||
import { loopEndConditional } from "./conditionals/loop_end";
|
||||
import { sort } from "./nodes/sort";
|
||||
|
||||
const verificationModel = createModelNode([], "verify.txt");
|
||||
const relationModel = createModelNode([], "relation.txt");
|
||||
|
||||
const agent = new StateGraph(MessagesState)
|
||||
|
||||
//NODES
|
||||
.addNode(verificationSetup.name, verificationSetup)
|
||||
.addNode("verificationModel", verificationModel)
|
||||
.addNode(ragasMetrics.name, ragasMetrics)
|
||||
.addNode("relationModel", relationModel)
|
||||
|
||||
.addNode(produceRanking.name, produceRanking)
|
||||
.addNode(sort.name, sort)
|
||||
|
||||
.addEdge(START, verificationSetup.name)
|
||||
.addEdge(verificationSetup.name, "verificationModel")
|
||||
.addEdge(verificationSetup.name, ragasMetrics.name)
|
||||
.addEdge(verificationSetup.name, "relationModel")
|
||||
|
||||
.addEdge(ragasMetrics.name, produceRanking.name)
|
||||
.addEdge("verificationModel", produceRanking.name)
|
||||
.addEdge("relationModel", produceRanking.name)
|
||||
|
||||
// @ts-expect-error
|
||||
.addConditionalEdges(produceRanking.name, loopEndConditional, [verificationSetup.name, sort.name])
|
||||
|
||||
.addEdge(sort.name, END)
|
||||
|
||||
.compile();
|
||||
|
||||
export {agent}
|
||||
Reference in New Issue
Block a user