File size: 1,600 Bytes
5b3181a
 
e9c9e16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419dfa0
e9c9e16
 
5b3181a
 
 
 
 
e9c9e16
 
5b3181a
 
e9c9e16
5b3181a
 
 
 
 
e9c9e16
 
5b3181a
 
e9c9e16
5b3181a
 
 
 
 
e9c9e16
 
 
5b3181a
e9c9e16
5b3181a
 
 
 
 
 
 
 
 
 
 
e9c9e16
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
63
64
65
66
import { tr } from '../lang/i18n-lite';

/**
 * 直方图基础配置类型
 */
export interface HistogramBaseConfig {
  label: string;
  no_bins: number;
  extent: [number, number];
  averageLabel: string;
  showLeftInfinity?: boolean;
  xAxisTickSkip?: number;
}

/**
 * 散点图基础配置类型
 */
export interface ScatterPlotBaseConfig {
  xLabel: string;
  yLabel: string;
  label?: string;
}

/**
 * 获取 Token information 直方图配置(支持国际化)
 */
export const getTokenSurprisalHistogramConfig = (): HistogramBaseConfig => ({
  label: tr("information per token histogram"),
  no_bins: 19,
  extent: [0, 19],
  averageLabel: tr("bits/token"),
});

/**
 * 获取 Byte information 直方图配置(支持国际化)
 */
export const getByteSurprisalHistogramConfig = (): HistogramBaseConfig => ({
  label: tr("information per byte histogram"),
  no_bins: 13,
  extent: [0, 6.5],
  averageLabel: tr("bits/Byte"),
});

/**
 * 获取 ΔByte information 直方图配置(支持国际化)
 */
export const getDeltaByteSurprisalHistogramConfig = (): HistogramBaseConfig => ({
  label: tr("Δinformation per byte histogram"),
  no_bins: 20,
  xAxisTickSkip: 1,  // x轴刻度数字绘制间隔
  extent: [-5, 5],
  averageLabel: tr("Δ bits/Byte"),
  showLeftInfinity: true,  // 左侧显示 -∞ 符号
});

/**
 * 获取 Information progress 散点图配置(支持国际化)
 */
export const getSurprisalProgressConfig = (): ScatterPlotBaseConfig => ({
  label: tr("information per token progress"),
  xLabel: tr("token index"),
  yLabel: tr("information (bits)"),
});