summaryrefslogtreecommitdiff
path: root/llm/job.go
diff options
context:
space:
mode:
authorJonas Knobloch <jonas.knobloch@t-online.de>2026-03-17 20:16:39 +0100
committerJonas Knobloch <jonas.knobloch@t-online.de>2026-03-17 20:16:39 +0100
commit57fb765bdc5819f8a367ad75c731a50da68b8d85 (patch)
tree730647fc08847624c138a83f3e8329b6f4755ea6 /llm/job.go
parent035eef3308edd4ec581061440337aaa10a37f573 (diff)
Update perplexity evaluator
* Introduce results channel * Introduce jobs channel * Generalize evaluation via callback
Diffstat (limited to 'llm/job.go')
-rw-r--r--llm/job.go37
1 files changed, 24 insertions, 13 deletions
diff --git a/llm/job.go b/llm/job.go
index 204d324..d922190 100644
--- a/llm/job.go
+++ b/llm/job.go
@@ -1,19 +1,30 @@
package llm
-type job struct {
- positions []int
- tokens [][]int64
- seen []int
- results []result
- debug [][2]int
+type Job struct {
+ Document int
+ Position int
+ Tokens []int64
+ Seen int
}
-func newJob(batchSize int) *job {
- return &job{
- positions: make([]int, 0, batchSize),
- tokens: make([][]int64, 0, batchSize),
- seen: make([]int, 0, batchSize),
- results: make([]result, 0, batchSize),
- debug: make([][2]int, 0),
+type batch struct {
+ jobs []Job
+}
+
+func newBatch(capacity int) *batch {
+ return &batch{
+ jobs: make([]Job, 0, capacity),
+ }
+}
+
+func (b *batch) Size() int {
+ return len(b.jobs)
+}
+
+func (b *batch) AddJob(job Job) {
+ if b.Size() == cap(b.jobs) {
+ panic("batch full")
}
+
+ b.jobs = append(b.jobs, job)
}