@lov3kaizen/agentsea-evaluate 0.5.1
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/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/annotation/index.d.mts +3 -0
- package/dist/annotation/index.d.ts +3 -0
- package/dist/annotation/index.js +630 -0
- package/dist/annotation/index.mjs +22 -0
- package/dist/chunk-5JRYKRSE.mjs +2791 -0
- package/dist/chunk-EUXXIZK3.mjs +676 -0
- package/dist/chunk-NBMUSATK.mjs +596 -0
- package/dist/chunk-PAQ2TTJJ.mjs +1105 -0
- package/dist/chunk-TUMNJN2S.mjs +416 -0
- package/dist/continuous/index.d.mts +2 -0
- package/dist/continuous/index.d.ts +2 -0
- package/dist/continuous/index.js +707 -0
- package/dist/continuous/index.mjs +16 -0
- package/dist/datasets/index.d.mts +1 -0
- package/dist/datasets/index.d.ts +1 -0
- package/dist/datasets/index.js +456 -0
- package/dist/datasets/index.mjs +14 -0
- package/dist/evaluation/index.d.mts +1 -0
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +2853 -0
- package/dist/evaluation/index.mjs +78 -0
- package/dist/feedback/index.d.mts +2 -0
- package/dist/feedback/index.d.ts +2 -0
- package/dist/feedback/index.js +1158 -0
- package/dist/feedback/index.mjs +40 -0
- package/dist/index-6Pbiq7ny.d.mts +234 -0
- package/dist/index-6Pbiq7ny.d.ts +234 -0
- package/dist/index-BNTycFEA.d.mts +479 -0
- package/dist/index-BNTycFEA.d.ts +479 -0
- package/dist/index-CTYCfWfH.d.mts +543 -0
- package/dist/index-CTYCfWfH.d.ts +543 -0
- package/dist/index-Cq5LwG_3.d.mts +322 -0
- package/dist/index-Cq5LwG_3.d.ts +322 -0
- package/dist/index-bPghFsfP.d.mts +315 -0
- package/dist/index-bPghFsfP.d.ts +315 -0
- package/dist/index.d.mts +81 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +5962 -0
- package/dist/index.mjs +429 -0
- package/package.json +102 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCollector,
|
|
3
|
+
CorrectionCollector,
|
|
4
|
+
FeedbackAggregator,
|
|
5
|
+
FeedbackExporter,
|
|
6
|
+
MemoryFeedbackStore,
|
|
7
|
+
MultiCriteriaCollector,
|
|
8
|
+
PreferenceCollector,
|
|
9
|
+
RatingCollector,
|
|
10
|
+
SQLiteFeedbackStore,
|
|
11
|
+
ThumbsCollector,
|
|
12
|
+
createCorrectionCollector,
|
|
13
|
+
createFeedbackAggregator,
|
|
14
|
+
createFeedbackExporter,
|
|
15
|
+
createFeedbackStore,
|
|
16
|
+
createMultiCriteriaCollector,
|
|
17
|
+
createPreferenceCollector,
|
|
18
|
+
createRatingCollector,
|
|
19
|
+
createThumbsCollector
|
|
20
|
+
} from "../chunk-PAQ2TTJJ.mjs";
|
|
21
|
+
export {
|
|
22
|
+
BaseCollector,
|
|
23
|
+
CorrectionCollector,
|
|
24
|
+
FeedbackAggregator,
|
|
25
|
+
FeedbackExporter,
|
|
26
|
+
MemoryFeedbackStore,
|
|
27
|
+
MultiCriteriaCollector,
|
|
28
|
+
PreferenceCollector,
|
|
29
|
+
RatingCollector,
|
|
30
|
+
SQLiteFeedbackStore,
|
|
31
|
+
ThumbsCollector,
|
|
32
|
+
createCorrectionCollector,
|
|
33
|
+
createFeedbackAggregator,
|
|
34
|
+
createFeedbackExporter,
|
|
35
|
+
createFeedbackStore,
|
|
36
|
+
createMultiCriteriaCollector,
|
|
37
|
+
createPreferenceCollector,
|
|
38
|
+
createRatingCollector,
|
|
39
|
+
createThumbsCollector
|
|
40
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
type DatasetType = 'preference' | 'instruction' | 'conversation' | 'qa';
|
|
2
|
+
type DatasetExportFormat = 'jsonl' | 'json' | 'csv' | 'parquet' | 'huggingface' | 'anthropic' | 'openai';
|
|
3
|
+
interface PreferencePair {
|
|
4
|
+
id: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
chosen: string;
|
|
7
|
+
rejected: string;
|
|
8
|
+
chosenModel?: string;
|
|
9
|
+
rejectedModel?: string;
|
|
10
|
+
chosenScore?: number;
|
|
11
|
+
rejectedScore?: number;
|
|
12
|
+
reason?: string;
|
|
13
|
+
confidence?: number;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
interface InstructionExample {
|
|
17
|
+
id: string;
|
|
18
|
+
instruction: string;
|
|
19
|
+
input?: string;
|
|
20
|
+
output: string;
|
|
21
|
+
systemPrompt?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface ConversationTurn {
|
|
25
|
+
role: 'user' | 'assistant' | 'system';
|
|
26
|
+
content: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface ConversationExample {
|
|
30
|
+
id: string;
|
|
31
|
+
turns: ConversationTurn[];
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface QAExample {
|
|
35
|
+
id: string;
|
|
36
|
+
question: string;
|
|
37
|
+
answer: string;
|
|
38
|
+
context?: string[];
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
type DatasetItem = PreferencePair | InstructionExample | ConversationExample | QAExample;
|
|
42
|
+
interface DatasetStats {
|
|
43
|
+
size: number;
|
|
44
|
+
type: DatasetType;
|
|
45
|
+
avgPromptLength: number;
|
|
46
|
+
avgResponseLength: number;
|
|
47
|
+
uniquePrompts: number;
|
|
48
|
+
modelDistribution?: Record<string, number>;
|
|
49
|
+
winRateA?: number;
|
|
50
|
+
winRateB?: number;
|
|
51
|
+
tieRate?: number;
|
|
52
|
+
}
|
|
53
|
+
type SamplingStrategyType = 'random' | 'balanced' | 'stratified' | 'uncertainty' | 'diversity';
|
|
54
|
+
interface SamplingConfig {
|
|
55
|
+
type: SamplingStrategyType;
|
|
56
|
+
seed?: number;
|
|
57
|
+
preferenceRatio?: number;
|
|
58
|
+
minConfidence?: number;
|
|
59
|
+
stratifyBy?: string;
|
|
60
|
+
stratifyRatios?: Record<string, number>;
|
|
61
|
+
diversityField?: string;
|
|
62
|
+
minDiversity?: number;
|
|
63
|
+
}
|
|
64
|
+
interface DatasetBuilderConfig {
|
|
65
|
+
feedbackStore: FeedbackStoreRef;
|
|
66
|
+
sampling?: SamplingConfig;
|
|
67
|
+
filters?: DatasetFilterConfig;
|
|
68
|
+
}
|
|
69
|
+
interface FeedbackStoreRef {
|
|
70
|
+
query(options: DatasetQueryOptions): Promise<DatasetQueryResult>;
|
|
71
|
+
}
|
|
72
|
+
interface DatasetQueryOptions {
|
|
73
|
+
type?: string | string[];
|
|
74
|
+
startTime?: number;
|
|
75
|
+
endTime?: number;
|
|
76
|
+
minConfidence?: number;
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
78
|
+
limit?: number;
|
|
79
|
+
offset?: number;
|
|
80
|
+
}
|
|
81
|
+
interface DatasetQueryResult {
|
|
82
|
+
items: unknown[];
|
|
83
|
+
total: number;
|
|
84
|
+
}
|
|
85
|
+
interface DatasetFilterConfig {
|
|
86
|
+
minLength?: number;
|
|
87
|
+
maxLength?: number;
|
|
88
|
+
excludePatterns?: RegExp[];
|
|
89
|
+
includePatterns?: RegExp[];
|
|
90
|
+
customFilter?: (item: unknown) => boolean;
|
|
91
|
+
}
|
|
92
|
+
interface PreferenceBuildOptions {
|
|
93
|
+
minPairs?: number;
|
|
94
|
+
maxPairs?: number;
|
|
95
|
+
includeRejected?: boolean;
|
|
96
|
+
filterFn?: (pair: PreferencePair) => boolean;
|
|
97
|
+
deduplication?: 'none' | 'prompt' | 'exact';
|
|
98
|
+
}
|
|
99
|
+
interface InstructionBuildOptions {
|
|
100
|
+
minExamples?: number;
|
|
101
|
+
maxExamples?: number;
|
|
102
|
+
includeSystemPrompt?: boolean;
|
|
103
|
+
filterFn?: (example: InstructionExample) => boolean;
|
|
104
|
+
}
|
|
105
|
+
interface PreferenceDatasetInterface {
|
|
106
|
+
readonly type: 'preference';
|
|
107
|
+
readonly size: number;
|
|
108
|
+
readonly stats: DatasetStats;
|
|
109
|
+
getPairs(): PreferencePair[];
|
|
110
|
+
filter(predicate: (pair: PreferencePair) => boolean): PreferenceDatasetInterface;
|
|
111
|
+
sample(count: number): PreferenceDatasetInterface;
|
|
112
|
+
split(ratio: number): [PreferenceDatasetInterface, PreferenceDatasetInterface];
|
|
113
|
+
shuffle(seed?: number): PreferenceDatasetInterface;
|
|
114
|
+
}
|
|
115
|
+
interface DatasetExportOptions {
|
|
116
|
+
format: DatasetExportFormat;
|
|
117
|
+
path?: string;
|
|
118
|
+
fields?: string[];
|
|
119
|
+
repoName?: string;
|
|
120
|
+
private?: boolean;
|
|
121
|
+
token?: string;
|
|
122
|
+
formatOptions?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
interface HFExportOptions {
|
|
125
|
+
name: string;
|
|
126
|
+
private?: boolean;
|
|
127
|
+
token?: string;
|
|
128
|
+
readme?: string;
|
|
129
|
+
license?: string;
|
|
130
|
+
tags?: string[];
|
|
131
|
+
}
|
|
132
|
+
interface ExportResult {
|
|
133
|
+
format: DatasetExportFormat;
|
|
134
|
+
path?: string;
|
|
135
|
+
url?: string;
|
|
136
|
+
itemCount: number;
|
|
137
|
+
bytesWritten?: number;
|
|
138
|
+
warnings?: string[];
|
|
139
|
+
}
|
|
140
|
+
interface DPOFormatItem {
|
|
141
|
+
prompt: string;
|
|
142
|
+
chosen: string;
|
|
143
|
+
rejected: string;
|
|
144
|
+
}
|
|
145
|
+
interface RLHFFormatItem {
|
|
146
|
+
prompt: string;
|
|
147
|
+
response: string;
|
|
148
|
+
reward: number;
|
|
149
|
+
}
|
|
150
|
+
interface SFTFormatItem {
|
|
151
|
+
instruction: string;
|
|
152
|
+
input?: string;
|
|
153
|
+
output: string;
|
|
154
|
+
}
|
|
155
|
+
interface AnthropicFormatItem {
|
|
156
|
+
prompt: string;
|
|
157
|
+
completion: string;
|
|
158
|
+
}
|
|
159
|
+
interface OpenAIFormatItem {
|
|
160
|
+
messages: Array<{
|
|
161
|
+
role: 'system' | 'user' | 'assistant';
|
|
162
|
+
content: string;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
interface DatasetValidationResult {
|
|
166
|
+
valid: boolean;
|
|
167
|
+
errors: DatasetValidationError[];
|
|
168
|
+
warnings: DatasetValidationWarning[];
|
|
169
|
+
stats: DatasetStats;
|
|
170
|
+
}
|
|
171
|
+
interface DatasetValidationError {
|
|
172
|
+
itemId: string;
|
|
173
|
+
field: string;
|
|
174
|
+
message: string;
|
|
175
|
+
value?: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface DatasetValidationWarning {
|
|
178
|
+
type: 'duplicate' | 'short' | 'long' | 'format' | 'quality';
|
|
179
|
+
message: string;
|
|
180
|
+
count: number;
|
|
181
|
+
examples?: string[];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class PreferenceDataset implements PreferenceDatasetInterface {
|
|
185
|
+
readonly type: "preference";
|
|
186
|
+
private pairs;
|
|
187
|
+
private _stats?;
|
|
188
|
+
constructor(pairs: PreferencePair[]);
|
|
189
|
+
get size(): number;
|
|
190
|
+
get stats(): DatasetStats;
|
|
191
|
+
getPairs(): PreferencePair[];
|
|
192
|
+
filter(predicate: (pair: PreferencePair) => boolean): PreferenceDataset;
|
|
193
|
+
sample(count: number): PreferenceDataset;
|
|
194
|
+
split(ratio: number): [PreferenceDataset, PreferenceDataset];
|
|
195
|
+
shuffle(seed?: number): PreferenceDataset;
|
|
196
|
+
private calculateStats;
|
|
197
|
+
private seededRandom;
|
|
198
|
+
}
|
|
199
|
+
declare class PreferenceDatasetBuilder {
|
|
200
|
+
private feedbackStore;
|
|
201
|
+
private sampling?;
|
|
202
|
+
constructor(config: {
|
|
203
|
+
feedbackStore: FeedbackStoreRef;
|
|
204
|
+
sampling?: SamplingConfig;
|
|
205
|
+
});
|
|
206
|
+
build(options?: PreferenceBuildOptions): Promise<PreferenceDataset>;
|
|
207
|
+
private deduplicate;
|
|
208
|
+
private applySampling;
|
|
209
|
+
private randomSample;
|
|
210
|
+
private balancedSample;
|
|
211
|
+
private stratifiedSample;
|
|
212
|
+
private seededRandom;
|
|
213
|
+
}
|
|
214
|
+
declare function createPreferenceDatasetBuilder(config: {
|
|
215
|
+
feedbackStore: FeedbackStoreRef;
|
|
216
|
+
sampling?: SamplingConfig;
|
|
217
|
+
}): PreferenceDatasetBuilder;
|
|
218
|
+
|
|
219
|
+
declare class DatasetExporter {
|
|
220
|
+
exportPreferences(dataset: PreferenceDataset, options: DatasetExportOptions): Promise<ExportResult>;
|
|
221
|
+
toJSONL(pairs: PreferencePair[], options?: {
|
|
222
|
+
formatOptions?: Record<string, unknown>;
|
|
223
|
+
}): string;
|
|
224
|
+
toCSV(pairs: PreferencePair[]): string;
|
|
225
|
+
toAnthropicFormat(pairs: PreferencePair[]): string;
|
|
226
|
+
toOpenAIFormat(pairs: PreferencePair[]): string;
|
|
227
|
+
exportToHuggingFace(pairs: PreferencePair[], options: DatasetExportOptions): Promise<ExportResult>;
|
|
228
|
+
exportMultiple(dataset: PreferenceDataset, formats: DatasetExportFormat[], basePath: string): Promise<Map<DatasetExportFormat, ExportResult>>;
|
|
229
|
+
private getExtension;
|
|
230
|
+
private escapeCSV;
|
|
231
|
+
}
|
|
232
|
+
declare function createDatasetExporter(): DatasetExporter;
|
|
233
|
+
|
|
234
|
+
export { type AnthropicFormatItem as A, type ConversationTurn as C, type DatasetType as D, type ExportResult as E, type FeedbackStoreRef as F, type HFExportOptions as H, type InstructionExample as I, type OpenAIFormatItem as O, type PreferencePair as P, type QAExample as Q, type RLHFFormatItem as R, type SamplingStrategyType as S, type DatasetExportFormat as a, type ConversationExample as b, type DatasetItem as c, type DatasetStats as d, type SamplingConfig as e, type DatasetBuilderConfig as f, type DatasetQueryOptions as g, type DatasetQueryResult as h, type DatasetFilterConfig as i, type PreferenceBuildOptions as j, type InstructionBuildOptions as k, type PreferenceDatasetInterface as l, type DatasetExportOptions as m, type DPOFormatItem as n, type SFTFormatItem as o, type DatasetValidationResult as p, type DatasetValidationError as q, type DatasetValidationWarning as r, PreferenceDataset as s, PreferenceDatasetBuilder as t, createPreferenceDatasetBuilder as u, DatasetExporter as v, createDatasetExporter as w };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
type DatasetType = 'preference' | 'instruction' | 'conversation' | 'qa';
|
|
2
|
+
type DatasetExportFormat = 'jsonl' | 'json' | 'csv' | 'parquet' | 'huggingface' | 'anthropic' | 'openai';
|
|
3
|
+
interface PreferencePair {
|
|
4
|
+
id: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
chosen: string;
|
|
7
|
+
rejected: string;
|
|
8
|
+
chosenModel?: string;
|
|
9
|
+
rejectedModel?: string;
|
|
10
|
+
chosenScore?: number;
|
|
11
|
+
rejectedScore?: number;
|
|
12
|
+
reason?: string;
|
|
13
|
+
confidence?: number;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
interface InstructionExample {
|
|
17
|
+
id: string;
|
|
18
|
+
instruction: string;
|
|
19
|
+
input?: string;
|
|
20
|
+
output: string;
|
|
21
|
+
systemPrompt?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface ConversationTurn {
|
|
25
|
+
role: 'user' | 'assistant' | 'system';
|
|
26
|
+
content: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface ConversationExample {
|
|
30
|
+
id: string;
|
|
31
|
+
turns: ConversationTurn[];
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface QAExample {
|
|
35
|
+
id: string;
|
|
36
|
+
question: string;
|
|
37
|
+
answer: string;
|
|
38
|
+
context?: string[];
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
type DatasetItem = PreferencePair | InstructionExample | ConversationExample | QAExample;
|
|
42
|
+
interface DatasetStats {
|
|
43
|
+
size: number;
|
|
44
|
+
type: DatasetType;
|
|
45
|
+
avgPromptLength: number;
|
|
46
|
+
avgResponseLength: number;
|
|
47
|
+
uniquePrompts: number;
|
|
48
|
+
modelDistribution?: Record<string, number>;
|
|
49
|
+
winRateA?: number;
|
|
50
|
+
winRateB?: number;
|
|
51
|
+
tieRate?: number;
|
|
52
|
+
}
|
|
53
|
+
type SamplingStrategyType = 'random' | 'balanced' | 'stratified' | 'uncertainty' | 'diversity';
|
|
54
|
+
interface SamplingConfig {
|
|
55
|
+
type: SamplingStrategyType;
|
|
56
|
+
seed?: number;
|
|
57
|
+
preferenceRatio?: number;
|
|
58
|
+
minConfidence?: number;
|
|
59
|
+
stratifyBy?: string;
|
|
60
|
+
stratifyRatios?: Record<string, number>;
|
|
61
|
+
diversityField?: string;
|
|
62
|
+
minDiversity?: number;
|
|
63
|
+
}
|
|
64
|
+
interface DatasetBuilderConfig {
|
|
65
|
+
feedbackStore: FeedbackStoreRef;
|
|
66
|
+
sampling?: SamplingConfig;
|
|
67
|
+
filters?: DatasetFilterConfig;
|
|
68
|
+
}
|
|
69
|
+
interface FeedbackStoreRef {
|
|
70
|
+
query(options: DatasetQueryOptions): Promise<DatasetQueryResult>;
|
|
71
|
+
}
|
|
72
|
+
interface DatasetQueryOptions {
|
|
73
|
+
type?: string | string[];
|
|
74
|
+
startTime?: number;
|
|
75
|
+
endTime?: number;
|
|
76
|
+
minConfidence?: number;
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
78
|
+
limit?: number;
|
|
79
|
+
offset?: number;
|
|
80
|
+
}
|
|
81
|
+
interface DatasetQueryResult {
|
|
82
|
+
items: unknown[];
|
|
83
|
+
total: number;
|
|
84
|
+
}
|
|
85
|
+
interface DatasetFilterConfig {
|
|
86
|
+
minLength?: number;
|
|
87
|
+
maxLength?: number;
|
|
88
|
+
excludePatterns?: RegExp[];
|
|
89
|
+
includePatterns?: RegExp[];
|
|
90
|
+
customFilter?: (item: unknown) => boolean;
|
|
91
|
+
}
|
|
92
|
+
interface PreferenceBuildOptions {
|
|
93
|
+
minPairs?: number;
|
|
94
|
+
maxPairs?: number;
|
|
95
|
+
includeRejected?: boolean;
|
|
96
|
+
filterFn?: (pair: PreferencePair) => boolean;
|
|
97
|
+
deduplication?: 'none' | 'prompt' | 'exact';
|
|
98
|
+
}
|
|
99
|
+
interface InstructionBuildOptions {
|
|
100
|
+
minExamples?: number;
|
|
101
|
+
maxExamples?: number;
|
|
102
|
+
includeSystemPrompt?: boolean;
|
|
103
|
+
filterFn?: (example: InstructionExample) => boolean;
|
|
104
|
+
}
|
|
105
|
+
interface PreferenceDatasetInterface {
|
|
106
|
+
readonly type: 'preference';
|
|
107
|
+
readonly size: number;
|
|
108
|
+
readonly stats: DatasetStats;
|
|
109
|
+
getPairs(): PreferencePair[];
|
|
110
|
+
filter(predicate: (pair: PreferencePair) => boolean): PreferenceDatasetInterface;
|
|
111
|
+
sample(count: number): PreferenceDatasetInterface;
|
|
112
|
+
split(ratio: number): [PreferenceDatasetInterface, PreferenceDatasetInterface];
|
|
113
|
+
shuffle(seed?: number): PreferenceDatasetInterface;
|
|
114
|
+
}
|
|
115
|
+
interface DatasetExportOptions {
|
|
116
|
+
format: DatasetExportFormat;
|
|
117
|
+
path?: string;
|
|
118
|
+
fields?: string[];
|
|
119
|
+
repoName?: string;
|
|
120
|
+
private?: boolean;
|
|
121
|
+
token?: string;
|
|
122
|
+
formatOptions?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
interface HFExportOptions {
|
|
125
|
+
name: string;
|
|
126
|
+
private?: boolean;
|
|
127
|
+
token?: string;
|
|
128
|
+
readme?: string;
|
|
129
|
+
license?: string;
|
|
130
|
+
tags?: string[];
|
|
131
|
+
}
|
|
132
|
+
interface ExportResult {
|
|
133
|
+
format: DatasetExportFormat;
|
|
134
|
+
path?: string;
|
|
135
|
+
url?: string;
|
|
136
|
+
itemCount: number;
|
|
137
|
+
bytesWritten?: number;
|
|
138
|
+
warnings?: string[];
|
|
139
|
+
}
|
|
140
|
+
interface DPOFormatItem {
|
|
141
|
+
prompt: string;
|
|
142
|
+
chosen: string;
|
|
143
|
+
rejected: string;
|
|
144
|
+
}
|
|
145
|
+
interface RLHFFormatItem {
|
|
146
|
+
prompt: string;
|
|
147
|
+
response: string;
|
|
148
|
+
reward: number;
|
|
149
|
+
}
|
|
150
|
+
interface SFTFormatItem {
|
|
151
|
+
instruction: string;
|
|
152
|
+
input?: string;
|
|
153
|
+
output: string;
|
|
154
|
+
}
|
|
155
|
+
interface AnthropicFormatItem {
|
|
156
|
+
prompt: string;
|
|
157
|
+
completion: string;
|
|
158
|
+
}
|
|
159
|
+
interface OpenAIFormatItem {
|
|
160
|
+
messages: Array<{
|
|
161
|
+
role: 'system' | 'user' | 'assistant';
|
|
162
|
+
content: string;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
interface DatasetValidationResult {
|
|
166
|
+
valid: boolean;
|
|
167
|
+
errors: DatasetValidationError[];
|
|
168
|
+
warnings: DatasetValidationWarning[];
|
|
169
|
+
stats: DatasetStats;
|
|
170
|
+
}
|
|
171
|
+
interface DatasetValidationError {
|
|
172
|
+
itemId: string;
|
|
173
|
+
field: string;
|
|
174
|
+
message: string;
|
|
175
|
+
value?: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface DatasetValidationWarning {
|
|
178
|
+
type: 'duplicate' | 'short' | 'long' | 'format' | 'quality';
|
|
179
|
+
message: string;
|
|
180
|
+
count: number;
|
|
181
|
+
examples?: string[];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class PreferenceDataset implements PreferenceDatasetInterface {
|
|
185
|
+
readonly type: "preference";
|
|
186
|
+
private pairs;
|
|
187
|
+
private _stats?;
|
|
188
|
+
constructor(pairs: PreferencePair[]);
|
|
189
|
+
get size(): number;
|
|
190
|
+
get stats(): DatasetStats;
|
|
191
|
+
getPairs(): PreferencePair[];
|
|
192
|
+
filter(predicate: (pair: PreferencePair) => boolean): PreferenceDataset;
|
|
193
|
+
sample(count: number): PreferenceDataset;
|
|
194
|
+
split(ratio: number): [PreferenceDataset, PreferenceDataset];
|
|
195
|
+
shuffle(seed?: number): PreferenceDataset;
|
|
196
|
+
private calculateStats;
|
|
197
|
+
private seededRandom;
|
|
198
|
+
}
|
|
199
|
+
declare class PreferenceDatasetBuilder {
|
|
200
|
+
private feedbackStore;
|
|
201
|
+
private sampling?;
|
|
202
|
+
constructor(config: {
|
|
203
|
+
feedbackStore: FeedbackStoreRef;
|
|
204
|
+
sampling?: SamplingConfig;
|
|
205
|
+
});
|
|
206
|
+
build(options?: PreferenceBuildOptions): Promise<PreferenceDataset>;
|
|
207
|
+
private deduplicate;
|
|
208
|
+
private applySampling;
|
|
209
|
+
private randomSample;
|
|
210
|
+
private balancedSample;
|
|
211
|
+
private stratifiedSample;
|
|
212
|
+
private seededRandom;
|
|
213
|
+
}
|
|
214
|
+
declare function createPreferenceDatasetBuilder(config: {
|
|
215
|
+
feedbackStore: FeedbackStoreRef;
|
|
216
|
+
sampling?: SamplingConfig;
|
|
217
|
+
}): PreferenceDatasetBuilder;
|
|
218
|
+
|
|
219
|
+
declare class DatasetExporter {
|
|
220
|
+
exportPreferences(dataset: PreferenceDataset, options: DatasetExportOptions): Promise<ExportResult>;
|
|
221
|
+
toJSONL(pairs: PreferencePair[], options?: {
|
|
222
|
+
formatOptions?: Record<string, unknown>;
|
|
223
|
+
}): string;
|
|
224
|
+
toCSV(pairs: PreferencePair[]): string;
|
|
225
|
+
toAnthropicFormat(pairs: PreferencePair[]): string;
|
|
226
|
+
toOpenAIFormat(pairs: PreferencePair[]): string;
|
|
227
|
+
exportToHuggingFace(pairs: PreferencePair[], options: DatasetExportOptions): Promise<ExportResult>;
|
|
228
|
+
exportMultiple(dataset: PreferenceDataset, formats: DatasetExportFormat[], basePath: string): Promise<Map<DatasetExportFormat, ExportResult>>;
|
|
229
|
+
private getExtension;
|
|
230
|
+
private escapeCSV;
|
|
231
|
+
}
|
|
232
|
+
declare function createDatasetExporter(): DatasetExporter;
|
|
233
|
+
|
|
234
|
+
export { type AnthropicFormatItem as A, type ConversationTurn as C, type DatasetType as D, type ExportResult as E, type FeedbackStoreRef as F, type HFExportOptions as H, type InstructionExample as I, type OpenAIFormatItem as O, type PreferencePair as P, type QAExample as Q, type RLHFFormatItem as R, type SamplingStrategyType as S, type DatasetExportFormat as a, type ConversationExample as b, type DatasetItem as c, type DatasetStats as d, type SamplingConfig as e, type DatasetBuilderConfig as f, type DatasetQueryOptions as g, type DatasetQueryResult as h, type DatasetFilterConfig as i, type PreferenceBuildOptions as j, type InstructionBuildOptions as k, type PreferenceDatasetInterface as l, type DatasetExportOptions as m, type DPOFormatItem as n, type SFTFormatItem as o, type DatasetValidationResult as p, type DatasetValidationError as q, type DatasetValidationWarning as r, PreferenceDataset as s, PreferenceDatasetBuilder as t, createPreferenceDatasetBuilder as u, DatasetExporter as v, createDatasetExporter as w };
|