import * as tf from '@tensorflow/tfjs'; export interface IAidaPipelineConfig { dataset: { trainingDataset: string; testingDataset: string; modelsOutput: string; }; language: 'en' | 'es'; } export interface IAidaTokenizer { FILTER_CHARS_REGEXP: RegExp; WORD_SEPARATORS_REGEXP: RegExp; NON_ALPHANUMERIC_REGEXP: RegExp; UNKNOWN_NGRAM_KEY: string; NUMBERS_MAP: { [key: string]: string; }; sanitizeSentence: (sentence: string) => string; splitSentenceToWords: (sentence: string) => string[]; splitWordToBiGrams: (word: string) => string[]; joinWordsToSentence: (words: string[]) => string; } export interface IDatasetParams { maxWordsPerSentence: number; slotsToId: { [k: string]: number; }; intents: string[]; intentsWithSlots: string[]; language: 'en' | 'es'; } export interface ITrainingParams { trainX: string[]; trainY: number[]; trainY2: number[][]; } export interface ITestingParams { testX: string[]; testY: number[]; testY2: number[][]; } export declare type IDictionariesFromDataset = IDatasetParams & ITrainingParams & ITestingParams; export declare type PretrainedDict = Map; export interface IPretrainedDictionary { NGRAM_TO_ID_MAP: { [key: string]: number; }; PRETRAINED: PretrainedDict; } export declare type IDictJsonItem = [string, Float32Array]; export interface IStatsHandlerArgs { batch: number; currentBatchSize: number; batchEpochs: number; totalBatches: number; trainingLoss: number | tf.Tensor; trainingAccuracy: number | tf.Tensor; validationLoss: number | tf.Tensor; validationAccuracy: number | tf.Tensor; tensorsInMemory: number; } export interface ITrainStatsHandler { classification: (config: IStatsHandlerArgs) => void; ner: (config: IStatsHandlerArgs) => void; } export interface IClassificationPred { sentence: string; intent: string; confidence: number; } export interface ISlotPrediction { confidence: number; value: string; } export interface ISlotsPredicted { [key: string]: ISlotPrediction[]; } export interface ITestSlot { [key: string]: string[]; } export interface ISlotReducer { current?: { key: string; value: string; confidence: number; }; slots: ISlotsPredicted; sentence: string; } export interface INerPred { slots: ISlotsPredicted; sentence: string; } export interface IPredictionStats { correct: number; wrong: number; lowConfidence?: number; } export declare type ITestPredictionsHandler = (x: string[], y: number[] | number[][], output: IClassificationPred[] | number[][], stats: IPredictionStats) => IPredictionStats; export interface IPipelineModelLogger { debug: (t: any) => void; log: (t: any) => void; error: (t: any) => void; warn: (t: any) => void; } export declare class PipelineModel { } export interface IPipelineModel { tfModel: () => tf.LayersModel; predict: (sentences: string[], ...moreArgs: any[]) => IClassificationPred[] | INerPred[]; train: (trainDatasetParams: ITrainingParams) => Promise; test: (testDataset: ITestingParams) => Promise; } export interface IPipelineConfig { classification: IClassificationModelParams; default: IDefaultModelParams; ner: INerModelParams; } export interface IDefaultModelParams { batchSize: number; drop: number; embeddingDimensions: number; maxNgrams: number; trainingValidationSplit: number; lossThresholdToStopTraining: number; } export interface IClassificationModelParams { epochs: number; filterSizes: [number, number, number]; lowConfidenceThreshold: number; numFilters: number; } export interface INerModelParams { epochs: number; lowConfidenceThreshold: number; numFilters: [number, number]; addAttention: boolean; rnnUnits: number; } export interface IPipelineDefinition { config: IPipelineConfig; }