File size: 1,146 Bytes
d5e14b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
interface GenerationKeySettings {
	default: number;
	step: number;
	min: number;
	max: number;
	label: string;
}

export const GENERATION_CONFIG_SETTINGS: Record<string, GenerationKeySettings> = {
	temperature: {
		default: 0.7,
		step: 0.01,
		min: 0,
		max: 2,
		label: 'Temperature'
	},
	max_tokens: {
		default: 0.7,
		step: 512,
		min: 1,
		max: 8192, // changed dynamically based on model
		label: 'Output Length'
	},
	top_p: {
		default: 0.7,
		step: 0.01,
		min: 0,
		max: 1,
		label: 'Top-P'
	},
	top_k: {
		default: 50,
		step: 1,
		min: 1,
		max: 100,
		label: 'Top-K'
	},
	repetition_penalty: {
		default: 1,
		step: 0.01,
		min: 1,
		max: 2,
		label: 'Repetition Penalty'
	}
};

export type GenerationConfigKey = keyof typeof GENERATION_CONFIG_SETTINGS;

export const GENERATION_CONFIG_KEYS: GenerationConfigKey[] = Object.keys(
	GENERATION_CONFIG_SETTINGS
);

export type GenerationConfig = Record<GenerationConfigKey, number>;

export const defaultGenerationConfig = Object.keys(GENERATION_CONFIG_SETTINGS).reduce(
	(acc, key) => {
		acc[key] = GENERATION_CONFIG_SETTINGS[key].default;
		return acc;
	},
	{} as GenerationConfig
);