@sedum-dev/provider-clef 0.1.0-alpha.21 → 0.1.0-alpha.23

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.
package/dist/index.d.ts CHANGED
@@ -42,11 +42,7 @@ declare class ClefAdapter implements Resolver, Judge, ClassificationProvider, Go
42
42
  verifyItems(sentence: string, items: readonly ResolverItem[], options?: ProviderCallOptions): Promise<ItemVerdict>;
43
43
  holds(claim: string, digest: JudgePageDigest, options?: ProviderCallOptions): Promise<JudgeDecision>;
44
44
  chooseGoal(state: GoalState, options?: ProviderCallOptions): Promise<GoalDecision>;
45
- scoreRelevance(diff: string, tests: Parameters<RelevanceProvider["scoreRelevance"]>[1], options?: ProviderCallOptions): Promise<{
46
- probabilities: number[];
47
- calls: _sedum_dev_core.ProviderCall[];
48
- chunkCount: number;
49
- }>;
45
+ scoreRelevance(diff: string, tests: Parameters<RelevanceProvider["scoreRelevance"]>[1], options?: ProviderCallOptions): Promise<_sedum_dev_core.RelevanceScores>;
50
46
  classifyBatch(sentences: readonly string[], options?: ProviderCallOptions): Promise<{
51
47
  answers: ModelClassification[];
52
48
  calls: _sedum_dev_core.ProviderCall[];
package/dist/index.js CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  backoffDelay,
10
10
  cooldownDelay,
11
11
  parseRetryAfter,
12
- goalOperations
12
+ goalOperations,
13
+ scoreRelevancePlan
13
14
  } from "@sedum-dev/core";
14
15
 
15
16
  // src/protocol.ts
@@ -235,12 +236,16 @@ function buildItemsRequest(sentence, items, model = MODEL) {
235
236
 
236
237
  // src/relevance.ts
237
238
  import { buildRelevanceBatches } from "@sedum-dev/core";
239
+ var limits = {
240
+ clef: { pair: 3e4, batch: 6e4, questions: 64, minDiff: 2e3 },
241
+ "clef-flash": { pair: 22e3, batch: 22e3, questions: 64, minDiff: 2e3 }
242
+ };
238
243
  function buildRelevanceRequests(diff, tests, model) {
239
244
  return buildRelevanceBatches(
240
245
  diff,
241
246
  tests,
242
247
  (text, questions) => ({ model, state: { diff: text }, questions }),
243
- { pair: 28e3, batch: 56e3, questions: 64 }
248
+ limits[model] ?? limits["clef-flash"]
244
249
  );
245
250
  }
246
251
 
@@ -799,34 +804,26 @@ var ClefAdapter = class {
799
804
  }
800
805
  }
801
806
  async scoreRelevance(diff, tests, options) {
802
- const chunks = buildRelevanceRequests(diff, tests, this.model);
803
- const probabilities = tests.map(() => 0);
804
- const calls = [];
805
- for (const chunk of chunks) {
806
- const got = await this.ask(chunk.request, options);
807
- const call = this.complete(got.response, got.meta);
808
- calls.push(call);
809
- try {
810
- const a = answersOf(got.response), keys = chunk.indexes.map((i) => `test${i}`);
811
- if (Object.keys(a).length !== keys.length || Object.keys(a).some((k) => !keys.includes(k)))
812
- throw new ProviderError4(
813
- "invalid-response",
814
- "Relevance answer keys do not match the tests."
815
- );
816
- for (const i of chunk.indexes)
817
- probabilities[i] = Math.max(
818
- probabilities[i],
819
- validateNoul(a[`test${i}`])
820
- );
821
- } catch (error) {
822
- throw responseError(error, call);
823
- }
824
- }
825
- return {
826
- probabilities,
827
- calls,
828
- chunkCount: new Set(chunks.map((chunk) => chunk.chunkIndex)).size
829
- };
807
+ return scoreRelevancePlan(
808
+ buildRelevanceRequests(diff, tests, this.model),
809
+ tests.length,
810
+ async (request, indexes) => {
811
+ const got = await this.ask(request, options);
812
+ const call = this.complete(got.response, got.meta);
813
+ try {
814
+ const a = answersOf(got.response), keys = indexes.map((i) => `test${i}`);
815
+ if (Object.keys(a).length !== keys.length || Object.keys(a).some((k) => !keys.includes(k)))
816
+ throw new ProviderError4(
817
+ "invalid-response",
818
+ "Relevance answer keys do not match the tests."
819
+ );
820
+ return { call, scores: keys.map((key) => validateNoul(a[key])) };
821
+ } catch (error) {
822
+ throw responseError(error, call);
823
+ }
824
+ },
825
+ options
826
+ );
830
827
  }
831
828
  async classifyBatch(sentences, options) {
832
829
  const answers = Array(sentences.length), calls = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedum-dev/provider-clef",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.23",
4
4
  "repository": "https://github.com/sedum-dev/sedum",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@sedum-dev/core": "0.1.0-alpha.21"
22
+ "@sedum-dev/core": "0.1.0-alpha.23"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts --format esm --dts --clean --out-dir dist",