How do I turn off rephrase question in ConversationalRetrievalQA? #5701
Replies: 2 comments 1 reply
-
Hey @jinhro! I'm here to help you with your questions and bugs. I can also guide you on how to contribute. If you need any assistance, feel free to ask! To turn off the rephrase question feature in import { ChatOpenAI } from "langchain/chat_models/openai";
import { ConversationalRetrievalQAChain } from "langchain/chains";
import { HNSWLib } from "langchain/vectorstores/hnswlib";
import { OpenAIEmbeddings } from "langchain/embeddings/openai";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { BufferMemory } from "langchain/memory";
import * as fs from "fs";
export const run = async () => {
const text = fs.readFileSync("state_of_the_union.txt", "utf8");
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
const docs = await textSplitter.createDocuments([text]);
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());
const fasterModel = new ChatOpenAI({
modelName: "gpt-3.5-turbo",
});
const slowerModel = new ChatOpenAI({
modelName: "gpt-4",
});
const chain = ConversationalRetrievalQAChain.fromLLM(
slowerModel,
vectorStore.asRetriever(),
{
returnSourceDocuments: true,
memory: new BufferMemory({
memoryKey: "chat_history",
inputKey: "question", // The key for the input to the chain
outputKey: "text", // The key for the final conversational output of the chain
returnMessages: true, // If using with a chat model (e.g. gpt-3.5 or gpt-4)
}),
questionGeneratorChainOptions: {
llm: fasterModel,
template: "" // This disables the rephrase question feature
},
}
);
/* Ask it a question */
const question = "What did the president say about Justice Breyer?";
const res = await chain.call({ question });
console.log(res);
const followUpRes = await chain.call({ question: "Was that nice?" });
console.log(followUpRes);
}; By setting the |
Beta Was this translation helpful? Give feedback.
-
@dosu How do I add history in RetrievalQA, rather than conversationalretrievalQA? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to turn rephrase question off as it always gives wrong answers to greetings and gratitudes.
System Info
Node version
Mac
Beta Was this translation helpful? Give feedback.
All reactions