AI-powered features using Deep Java Library (DJL) and PyTorch
LiquidBounce integrates deep learning capabilities through the Deep Java Library (DJL) framework, enabling AI-powered combat features and adaptive behavior.
The core engine manages DJL initialization and model storage (DeepLearningEngine.kt:31).
suspend fun init(task: Task) { this.task = task logger.info("Initializing engine...") val engine = withContext(Dispatchers.IO) { Engine.getInstance() } val name = engine.engineName val version = engine.version val deviceType = engine.defaultDevice().deviceType logger.info("Using deep learning engine $name $version on $deviceType.") isInitialized = true this.task = null}
Searches the models folder for custom trained models
2
Load Base Models
Loads embedded models from resources
3
Initialize Each Model
Creates model instances with proper translators
4
Sync GUI
Updates the ClickGUI with available models
fun load() { logger.info("Loading models...") val choices = allCombatModels.mapToArray { name -> TwoDimensionalRegressionModel(name, models) } for (model in choices) { runCatching { measureTime { model.load() } }.onFailure { error -> logger.error("Failed to load model '${model.name}'.", error) }.onSuccess { time -> logger.info("Loaded model '${model.name}' in ${time.inWholeMilliseconds}ms.") } }}
@Throws(TranslateException::class)fun predict(input: I): O { require(DeepLearningEngine.isInitialized) { "DeepLearningEngine is not initialized" } return predictor.predict(input)}
// Get active modelval model = ModelManager.models.activeMode// Prepare input featuresval input = floatArrayOf(playerX, playerY)// Make predictionval output = model.predict(input)val targetX = output[0]val targetY = output[1]
fun train(features: Array<FloatArray>, labels: Array<FloatArray>) { require(features.size == labels.size) { "Features and labels must have the same size" } require(features.isNotEmpty()) { "Features and labels must not be empty" } val trainingConfig = DefaultTrainingConfig(Loss.l2Loss()) .optInitializer(XavierInitializer(), "weight") .optOptimizer( Adam.builder() .optLearningRateTracker(Tracker.fixed(0.001f)) .build() ) .addTrainingListeners( LoggingTrainingListener(), OverlayTrainingListener(NUM_EPOCH) )}
// Save to models folder with default namemodel.save()// Save with custom namemodel.save("my-custom-model")// Save to specific pathmodel.save(Path.of("/custom/path/model"))
// Load all modelsModelManager.load()// Unload all modelsModelManager.unload()// Reload models (unload + load)ModelManager.reload()// Delete specific modelmodel.delete()