Class: Raif::Evals::LlmJudges::Binary
- Inherits:
-
Raif::Evals::LlmJudge
- Object
- ApplicationRecord
- Task
- Raif::Evals::LlmJudge
- Raif::Evals::LlmJudges::Binary
- Defined in:
- app/models/raif/evals/llm_judges/binary.rb
Constant Summary
Constants included from Concerns::LlmResponseParsing
Concerns::LlmResponseParsing::ASCII_CONTROL_CHARS
Instance Attribute Summary
Attributes inherited from Task
Instance Method Summary collapse
- #build_prompt ⇒ Object
- #build_system_prompt ⇒ Object
-
#passes? ⇒ Boolean
Judgment accessor methods.
Methods inherited from Raif::Evals::LlmJudge
#default_llm_model_key, #judgment_confidence, #judgment_reasoning, #low_confidence?
Methods inherited from Task
json_response_schema, #json_response_schema, #messages, prompt, #prompt_studio_task_attributes, #re_run, run, #run, #status, system_prompt
Methods included from Concerns::JsonSchemaDefinition
Methods included from Concerns::LlmResponseParsing
#parse_html_response, #parse_json_response, #parsed_response
Methods included from Concerns::HasRuntimeDuration
#runtime_duration, #runtime_duration_seconds, #runtime_ended_at
Methods included from Concerns::HasAvailableModelTools
Methods included from Concerns::HasRequestedLanguage
#requested_language_name, #system_prompt_language_preference
Methods included from Concerns::HasLlm
Methods inherited from ApplicationRecord
table_name_prefix, where_json_not_blank
Instance Method Details
#build_prompt ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/models/raif/evals/llm_judges/binary.rb', line 71 def build_prompt prompt = <<~PROMPT Evaluation criteria: #{criteria} #{strict_mode ? "Apply the criteria strictly without any leniency." : "Apply reasonable judgment while adhering to the criteria."} PROMPT if examples.present? prompt += "\nHere are examples of how to evaluate:" examples.each do |example| prompt += format_example(example) end end prompt += additional_context_prompt if additional_context.present? prompt += <<~PROMPT.rstrip Now evaluate this content: #{content_to_judge} Does this content meet the evaluation criteria? PROMPT prompt end |
#build_system_prompt ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/raif/evals/llm_judges/binary.rb', line 55 def build_system_prompt <<~PROMPT.strip You are an expert evaluator assessing whether content meets specific criteria. Your task is to make binary pass/fail judgments with clear reasoning. First, provide detailed reasoning/explanation of your evaluation. Then, provide a precise pass/fail judgment. Respond with JSON matching this schema: { "passes": boolean, "reasoning": "detailed explanation", "confidence": 0.0-1.0 } PROMPT end |
#passes? ⇒ Boolean
Judgment accessor methods
99 100 101 |
# File 'app/models/raif/evals/llm_judges/binary.rb', line 99 def passes? parsed_response["passes"] if completed? end |