93 references to ModelEncoding
Microsoft.ML.Tokenizers (93)
Model\TiktokenTokenizer.cs (93)
1040private static readonly (string Prefix, ModelEncoding Encoding)[] _modelPrefixToEncoding = 1042( "o1-", ModelEncoding.O200kBase ), // e.g. o1-mini 1043( "o3-", ModelEncoding.O200kBase ), // e.g. o3-mini 1044( "o4-mini-", ModelEncoding.O200kBase ), // e.g. o4-mini 1047( "gpt-5.2-", ModelEncoding.O200kBase ), 1048( "gpt-5.1-", ModelEncoding.O200kBase ), 1049( "gpt-5-", ModelEncoding.O200kBase ), 1050( "gpt-4.1-", ModelEncoding.O200kBase ), // e.g., gpt-4.1-mini 1051( "gpt-4.5-", ModelEncoding.O200kBase ), // e.g., gpt-4.5 1052( "gpt-4o-", ModelEncoding.O200kBase ), // e.g., gpt-4o-2024-05-13 1053( "chatgpt-4o-", ModelEncoding.O200kBase ), 1054( "gpt-4-", ModelEncoding.Cl100kBase ), // e.g., gpt-4-0314, etc., plus gpt-4-32k 1055( "gpt-3.5-", ModelEncoding.Cl100kBase ), // e.g, gpt-3.5-turbo-0301, -0401, etc. 1056( "gpt-35-", ModelEncoding.Cl100kBase ), // Azure deployment name 1057( "gpt-oss-", ModelEncoding.O200kHarmony ), 1060( "ft:gpt-4o", ModelEncoding.O200kBase ), 1061( "ft:gpt-4", ModelEncoding.Cl100kBase ), 1062( "ft:gpt-3.5-turbo", ModelEncoding.Cl100kBase ), 1063( "ft:davinci-002", ModelEncoding.Cl100kBase ), 1064( "ft:babbage-002", ModelEncoding.Cl100kBase ), 1067private static readonly Dictionary<string, ModelEncoding> _modelToEncoding = 1068new Dictionary<string, ModelEncoding>(StringComparer.OrdinalIgnoreCase) 1071{ "o1", ModelEncoding.O200kBase }, 1072{ "o3", ModelEncoding.O200kBase }, 1073{ "o4-mini", ModelEncoding.O200kBase }, 1076{ "gpt-5.2", ModelEncoding.O200kBase }, 1077{ "gpt-5.1", ModelEncoding.O200kBase }, 1078{ "gpt-5", ModelEncoding.O200kBase }, 1079{ "gpt-4.1", ModelEncoding.O200kBase }, 1080{ "gpt-4o", ModelEncoding.O200kBase }, 1081{ "gpt-4", ModelEncoding.Cl100kBase }, 1082{ "gpt-3.5-turbo", ModelEncoding.Cl100kBase }, 1083{ "gpt-3.5", ModelEncoding.Cl100kBase }, 1084{ "gpt-3.5-turbo-16k", ModelEncoding.Cl100kBase }, 1085{ "gpt-35", ModelEncoding.Cl100kBase }, // Azure deployment name 1086{ "gpt-35-turbo", ModelEncoding.Cl100kBase }, // Azure deployment name 1087{ "gpt-35-turbo-16k", ModelEncoding.Cl100kBase }, // Azure deployment name 1090{ "davinci-002", ModelEncoding.Cl100kBase }, 1091{ "babbage-002", ModelEncoding.Cl100kBase }, 1095{ "text-embedding-ada-002", ModelEncoding.Cl100kBase }, 1096{ "text-embedding-3-small", ModelEncoding.Cl100kBase }, 1097{ "text-embedding-3-large", ModelEncoding.Cl100kBase }, 1101{ "text-davinci-003", ModelEncoding.P50kBase }, 1102{ "text-davinci-002", ModelEncoding.P50kBase }, 1103{ "text-davinci-001", ModelEncoding.R50kBase }, 1104{ "text-curie-001", ModelEncoding.R50kBase }, 1105{ "text-babbage-001", ModelEncoding.R50kBase }, 1106{ "text-ada-001", ModelEncoding.R50kBase }, 1107{ "davinci", ModelEncoding.R50kBase }, 1108{ "curie", ModelEncoding.R50kBase }, 1109{ "babbage", ModelEncoding.R50kBase }, 1110{ "ada", ModelEncoding.R50kBase }, 1113{ "code-davinci-002", ModelEncoding.P50kBase }, 1114{ "code-davinci-001", ModelEncoding.P50kBase }, 1115{ "code-cushman-002", ModelEncoding.P50kBase }, 1116{ "code-cushman-001", ModelEncoding.P50kBase }, 1117{ "davinci-codex", ModelEncoding.P50kBase }, 1118{ "cushman-codex", ModelEncoding.P50kBase }, 1121{ "text-davinci-edit-001", ModelEncoding.P50kEdit }, 1122{ "code-davinci-edit-001", ModelEncoding.P50kEdit }, 1126{ "text-similarity-davinci-001", ModelEncoding.R50kBase }, 1127{ "text-similarity-curie-001", ModelEncoding.R50kBase }, 1128{ "text-similarity-babbage-001", ModelEncoding.R50kBase }, 1129{ "text-similarity-ada-001", ModelEncoding.R50kBase }, 1130{ "text-search-davinci-doc-001", ModelEncoding.R50kBase }, 1131{ "text-search-curie-doc-001", ModelEncoding.R50kBase }, 1132{ "text-search-babbage-doc-001", ModelEncoding.R50kBase }, 1133{ "text-search-ada-doc-001", ModelEncoding.R50kBase }, 1134{ "code-search-babbage-code-001", ModelEncoding.R50kBase }, 1135{ "code-search-ada-code-001", ModelEncoding.R50kBase }, 1138{ "gpt2", ModelEncoding.GPT2 }, 1139{ "gpt-2", ModelEncoding.GPT2 }, 1142{ Phi4ModelName, ModelEncoding.Cl100kBase }, 1145private static ModelEncoding GetModelEncoding(string modelName) 1147if (!_modelToEncoding.TryGetValue(modelName, out ModelEncoding encoder)) 1149foreach ((string Prefix, ModelEncoding Encoding) in _modelPrefixToEncoding) 1159if (encoder == ModelEncoding.None) 1195private static (Dictionary<string, int> SpecialTokens, Regex Regex, string VocabFile, Type? DataType, string PackageName) GetTiktokenConfigurations(ModelEncoding modelEncoding, string? modelName = null) 1199case ModelEncoding.Cl100kBase: 1208case ModelEncoding.GPT2: 1211case ModelEncoding.O200kBase: 1214case ModelEncoding.P50kBase: 1217case ModelEncoding.P50kEdit: 1221case ModelEncoding.R50kBase: 1224case ModelEncoding.O200kHarmony: 1290ModelEncoding modelEncoding, 1536ModelEncoding modelEncoding; 1539modelEncoding = ModelEncoding.Cl100kBase; 1543modelEncoding = ModelEncoding.O200kBase; 1547modelEncoding = ModelEncoding.O200kHarmony; 1551modelEncoding = ModelEncoding.P50kBase; 1555modelEncoding = ModelEncoding.P50kEdit; 1559modelEncoding = ModelEncoding.R50kBase;