@Inject
    public Generator(OnnxRuntime onnx, GeneratorConfig config) {
        // Set up tokenizer
        tokenizer = new SentencePieceEmbedder.Builder(config.tokenizerModel().toString()).build();
        tokenizerMaxTokens = config.tokenizerMaxTokens();

        // Set up encoder
        encoderInputIdsName = config.encoderModelInputIdsName();
        encoderAttentionMaskName = config.encoderModelAttentionMaskName();
        encoderOutputName = config.encoderModelOutputName();

        OnnxEvaluatorOptions encoderOptions = new OnnxEvaluatorOptions();
        encoderOptions.setExecutionMode(config.encoderOnnxExecutionMode().toString());
        encoderOptions.setThreads(config.encoderOnnxInterOpThreads(), config.encoderOnnxIntraOpThreads());

        encoder = onnx.evaluatorOf(config.encoderModel().toString(), encoderOptions);

        // Set up decoder
        decoderInputIdsName = config.decoderModelInputIdsName();
        decoderAttentionMaskName = config.decoderModelAttentionMaskName();
        decoderEncoderHiddenStateName = config.decoderModelEncoderHiddenStateName();
        decoderOutputName = config.decoderModelOutputName();

        OnnxEvaluatorOptions decoderOptions = new OnnxEvaluatorOptions();
        decoderOptions.setExecutionMode(config.decoderOnnxExecutionMode().toString());
        decoderOptions.setThreads(config.decoderOnnxInterOpThreads(), config.decoderOnnxIntraOpThreads());

        decoder = onnx.evaluatorOf(config.decoderModel().toString(), decoderOptions);

        validateModels();
    }
@Test
    public void testGenerator() {
        String vocabPath = "src/test/models/onnx/llm/en.wiki.bpe.vs10000.model";
        String encoderModelPath = "src/test/models/onnx/llm/random_encoder.onnx";
        String decoderModelPath = "src/test/models/onnx/llm/random_decoder.onnx";
        assumeTrue(OnnxRuntime.isRuntimeAvailable(encoderModelPath));

        GeneratorConfig.Builder builder = new GeneratorConfig.Builder();
        builder.tokenizerModel(ModelReference.valueOf(vocabPath));
        builder.encoderModel(ModelReference.valueOf(encoderModelPath));
        builder.decoderModel(ModelReference.valueOf(decoderModelPath));
        Generator generator = newGenerator(builder.build());

        GeneratorOptions options = new GeneratorOptions();
        options.setSearchMethod(GeneratorOptions.SearchMethod.GREEDY);
        options.setMaxLength(10);

        String prompt = "generate some random text";
        String result = generator.generate(prompt, options);

        assertEquals("<unk> linear recruit latest sack annually institutions cert solid references", result);
    }