rubric_llm 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/rubric_llm/report.rb +13 -2
- data/lib/rubric_llm/result.rb +13 -1
- data/lib/rubric_llm/version.rb +1 -1
- data/lib/rubric_llm.rb +17 -0
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16ccb30778e4ace0b35900e0d488ac884042acf124e139181e4e364a6a5829ed
|
|
4
|
+
data.tar.gz: f5c1df6b47de48bd4c976a9986836aa2d2c66c6614dc94e4b6f4f8b12c090144
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d267c7eceba64ebf8b9f5829b960ebf45aaec98bbd8545a393f16f8dfdf0070fb98ee8038e0fe9ddb1428164bbbcb677b6e8da0afa86513865187a358aad45a7
|
|
7
|
+
data.tar.gz: d0fff2333050e27bb785820f128ebaee7161f15e446f728beffbe2744078d95cd0de077b4a2674b26d8136391ee9c977f5cc87a1608f48ff96d9e0ed8cd04dd8
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.4.0] - 2026-07-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `RubricLLM.evaluate_batch` validates every sample upfront (must be a Hash with non-nil `:question` and `:answer`, string or symbol keys) and raises `ArgumentError` with the offending index before any LLM call, so sequential and concurrent modes fail identically and without API spend
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Add `csv` as a runtime dependency; `csv` moved from a default gem to a bundled gem in Ruby 3.4, so consumers previously hit a `LoadError` on `Report#export_csv`
|
|
17
|
+
- Require `ruby_llm ~> 1.16`
|
|
18
|
+
|
|
19
|
+
## [0.3.0] - 2026-07-11
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- `Result#pass?` now returns `false` when any metric errored during evaluation (fail-closed for CI gating)
|
|
24
|
+
- `Report#worst` now ranks results with no valid scores as worst instead of best
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- `Result#errors` and `Result#valid?` expose per-metric judge failures
|
|
29
|
+
- `Result#to_h` and report JSON exports include metric error information
|
|
30
|
+
- Report summaries show a metric error count line when evaluation errors occurred
|
|
31
|
+
|
|
8
32
|
## [0.2.0] - 2026-07-11
|
|
9
33
|
|
|
10
34
|
### Changed
|
data/lib/rubric_llm/report.rb
CHANGED
|
@@ -16,7 +16,7 @@ module RubricLLM
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def worst(n)
|
|
19
|
-
results.sort_by { |r| r.overall || Float::INFINITY }.first(n)
|
|
19
|
+
results.sort_by { |r| r.overall || -Float::INFINITY }.first(n)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def failures(threshold: 0.8)
|
|
@@ -34,11 +34,15 @@ module RubricLLM
|
|
|
34
34
|
metric, stats[:mean], stats[:std], stats[:min], stats[:max], stats[:count])
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
error_count = error_counts.values.sum
|
|
38
|
+
affected_samples = results.count { |r| r.errors.any? }
|
|
39
|
+
lines << "Errors: #{error_count} metric errors across #{affected_samples} samples" if error_count.positive?
|
|
40
|
+
|
|
37
41
|
lines.join("\n")
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
def export_csv(path)
|
|
41
|
-
require "csv"
|
|
45
|
+
require "csv"
|
|
42
46
|
metrics = all_metric_names
|
|
43
47
|
CSV.open(path, "w") do |csv|
|
|
44
48
|
csv << ["question", "answer", "overall", *metrics]
|
|
@@ -72,6 +76,7 @@ module RubricLLM
|
|
|
72
76
|
{
|
|
73
77
|
summary: metric_stats,
|
|
74
78
|
duration:,
|
|
79
|
+
errors: error_counts,
|
|
75
80
|
results: results.map(&:to_h)
|
|
76
81
|
}
|
|
77
82
|
end
|
|
@@ -80,6 +85,12 @@ module RubricLLM
|
|
|
80
85
|
results.flat_map { |r| r.scores.keys }.uniq
|
|
81
86
|
end
|
|
82
87
|
|
|
88
|
+
def error_counts
|
|
89
|
+
counts = Hash.new(0)
|
|
90
|
+
results.each { |r| r.errors.each_key { |name| counts[name] += 1 } }
|
|
91
|
+
counts
|
|
92
|
+
end
|
|
93
|
+
|
|
83
94
|
def compute_stats
|
|
84
95
|
all_metric_names.each_with_object({}) do |metric, stats|
|
|
85
96
|
values = results.filter_map { |r| r.scores[metric] }
|
data/lib/rubric_llm/result.rb
CHANGED
|
@@ -18,14 +18,26 @@ module RubricLLM
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def pass?(threshold: 0.8)
|
|
21
|
+
return false unless valid?
|
|
22
|
+
|
|
21
23
|
score = overall
|
|
22
24
|
return false if score.nil?
|
|
23
25
|
|
|
24
26
|
score >= threshold
|
|
25
27
|
end
|
|
26
28
|
|
|
29
|
+
def errors
|
|
30
|
+
details.each_with_object({}) do |(name, detail), acc|
|
|
31
|
+
acc[name] = detail[:error] if detail.is_a?(Hash) && detail.key?(:error)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def valid?
|
|
36
|
+
errors.empty?
|
|
37
|
+
end
|
|
38
|
+
|
|
27
39
|
def to_h
|
|
28
|
-
{ scores:, details:, overall: overall }
|
|
40
|
+
{ scores:, details:, overall: overall, errors: }
|
|
29
41
|
end
|
|
30
42
|
|
|
31
43
|
private
|
data/lib/rubric_llm/version.rb
CHANGED
data/lib/rubric_llm.rb
CHANGED
|
@@ -56,6 +56,7 @@ module RubricLLM
|
|
|
56
56
|
# report = RubricLLM.evaluate_batch(dataset)
|
|
57
57
|
# report = RubricLLM.evaluate_batch(dataset, concurrency: 4)
|
|
58
58
|
def evaluate_batch(dataset, metrics: nil, config: self.config, custom_prompt: nil, concurrency: nil)
|
|
59
|
+
validate_dataset!(dataset)
|
|
59
60
|
config = apply_custom_prompt(config, custom_prompt)
|
|
60
61
|
pool_size = concurrency || config.concurrency
|
|
61
62
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
@@ -87,6 +88,22 @@ module RubricLLM
|
|
|
87
88
|
|
|
88
89
|
private
|
|
89
90
|
|
|
91
|
+
def validate_dataset!(dataset)
|
|
92
|
+
dataset.each_with_index do |sample, index|
|
|
93
|
+
raise ArgumentError, "sample at index #{index} is not a Hash" unless sample.is_a?(Hash)
|
|
94
|
+
|
|
95
|
+
question_present = sample.key?(:question) || sample.key?("question")
|
|
96
|
+
answer_present = sample.key?(:answer) || sample.key?("answer")
|
|
97
|
+
raise ArgumentError, "sample at index #{index} is missing :question" unless question_present
|
|
98
|
+
raise ArgumentError, "sample at index #{index} is missing :answer" unless answer_present
|
|
99
|
+
|
|
100
|
+
question_provided = !sample[:question].nil? || !sample["question"].nil?
|
|
101
|
+
answer_provided = !sample[:answer].nil? || !sample["answer"].nil?
|
|
102
|
+
raise ArgumentError, "sample at index #{index} has nil :question" unless question_provided
|
|
103
|
+
raise ArgumentError, "sample at index #{index} has nil :answer" unless answer_provided
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
90
107
|
def evaluate_sample(evaluator, sample)
|
|
91
108
|
sample = normalize_sample(sample)
|
|
92
109
|
evaluator.call(
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubric_llm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Paluy
|
|
@@ -9,20 +9,34 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: csv
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
12
26
|
- !ruby/object:Gem::Dependency
|
|
13
27
|
name: ruby_llm
|
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
|
15
29
|
requirements:
|
|
16
30
|
- - "~>"
|
|
17
31
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '1.
|
|
32
|
+
version: '1.16'
|
|
19
33
|
type: :runtime
|
|
20
34
|
prerelease: false
|
|
21
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
36
|
requirements:
|
|
23
37
|
- - "~>"
|
|
24
38
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '1.
|
|
39
|
+
version: '1.16'
|
|
26
40
|
description: Provider-agnostic LLM evaluation with pluggable metrics, statistical
|
|
27
41
|
A/B comparison, and test framework integration. Ragas for Ruby, powered by RubyLLM.
|
|
28
42
|
email:
|