diff --git a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java index 7da77ff158b..5bfddd76be9 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/FactCheckingEvaluator.java @@ -64,15 +64,15 @@ public class FactCheckingEvaluator implements Evaluator { private static final String DEFAULT_EVALUATION_PROMPT_TEXT = """ - Evaluate whether or not the following claim is supported by the provided document. - Respond with "yes" if the claim is supported, or "no" if it is not. - Document: \\n {document}\\n - Claim: \\n {claim} + Evaluate whether or not the following claim is supported by the provided document. + Respond with "yes" if the claim is supported, or "no" if it is not. + Document: {document} + Claim: {claim} """; private static final String BESPOKE_EVALUATION_PROMPT_TEXT = """ - Document: \\n {document}\\n - Claim: \\n {claim} + Document: {document} + Claim: {claim} """; private final ChatClient.Builder chatClientBuilder; diff --git a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java index b85591333d8..e785a651b63 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java @@ -23,15 +23,13 @@ public class RelevancyEvaluator implements Evaluator { private static final String DEFAULT_EVALUATION_PROMPT_TEXT = """ - Your task is to evaluate if the response for the query - is in line with the context information provided.\\n - You have two options to answer. Either YES/ NO.\\n - Answer - YES, if the response for the query - is in line with context information otherwise NO.\\n - Query: \\n {query}\\n - Response: \\n {response}\\n - Context: \\n {context}\\n - Answer: " + Your task is to evaluate if the response for the query is in line with the context information provided. + You have two options to answer. Either YES/ NO. + Answer - YES, if the response for the query is in line with context information otherwise NO. + Query: {query} + Response: {response} + Context: {context} + Answer: """; private final ChatClient.Builder chatClientBuilder; diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/testing.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/testing.adoc index 79ad8ca135d..d760a08c912 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/testing.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/testing.adoc @@ -50,15 +50,13 @@ The `RelevancyEvaluator` uses the input (`userText`) and the AI model's output ( [source, text] ---- -Your task is to evaluate if the response for the query -is in line with the context information provided.\n -You have two options to answer. Either YES/ NO.\n -Answer - YES, if the response for the query -is in line with context information otherwise NO.\n -Query: \n {query}\n -Response: \n {response}\n -Context: \n {context}\n -Answer: " +Your task is to evaluate if the response for the query is in line with the context information provided. +You have two options to answer. Either YES/ NO. +Answer - YES, if the response for the query is in line with context information otherwise NO. +Query: {query} +Response: {response} +Context: {context} +Answer: ---- Here is an example of a JUnit test that performs a RAG query over a PDF document loaded into a Vector Store and then evaluates if the response is relevant to the user text.