我正在开发一个Web应用程序,旨在根据用户上传到应用程序的文档提供的上下文来回答问题。问题在于,当我使用Mistral v0.2模型时,回答未能完成。它们在完成之前就被截断了。如果我使用OpenAI,回答就能正确完成。我使用以下提示:
template=""" ### [INST] 指令:根据上下文回答用户的问题。 如果在上下文中找不到合适的答案,请回答说没有足够的信息。 {context} ### 问题: {question}(用西班牙语回答) [/INST] #""" template=""" <s>[INST] """prompt = PromptTemplate( input_variables=['context','question'], template = template )vector = Chroma(client=db, collection_name="coleccion4", embedding_function=embeddings)retriever = vector.as_retriever(search_type="similarity", search_kwargs={"k":3})llm = HuggingFaceHub( repo_id="mistralai/Mistral-7B-Instruct-v0.2", model_kwargs = {"temperature":0.4}, huggingfacehub_api_token = apikey_huggingFace )respuesta = rag_chain.invoke(user_question)
为什么会这样?
回答:
我已经将max_new_tokens设置为2000,现在似乎可以正常工作了