llama.jar ?
llama.jar 是一款轻量级、高性能的 Minecraft 模组,借助 llama.cpp 将本地大型语言模型(LLM)的强大功能直接引入 Minecraft。
完全在你的硬件上离线运行,无需 API 密钥、无需订阅、零外部网络请求。
[!WARNING]
这是一个 alpha 测试版本,尚未在所有环境中经过充分测试。请谨慎使用,并报告你遇到的任何错误或问题。
主要特性
- 离线本地 LLM 推理:直接在 Minecraft 进程中运行你喜欢的开源模型(如 LLaMA-3、Qwen-2.5、Phi-3、Mistral 等)。
- 硬件加速与 GPU 支持:支持多核 CPU 执行以及 GPU 卸载(CUDA、Metal、OpenCL/CLBlast),实现硬件加速生成。支持多 GPU 配置。
- 内置游戏集成:通过游戏内命令实时提示已加载的模型,或监听交互过程。
- 模组开发库基础:完全架构化为库模组。你可以在自定义模组中导入
llama.jar,轻松添加由 AI 驱动的 NPC、动态任务生成或智能自动化助手。
- 广泛的版本兼容性:支持 Forge 和 Fabric 平台,涵盖多个 Minecraft 版本:
设置方法
- 下载模组:下载与你使用的模组加载器(Forge 或 Fabric)及 Minecraft 版本相匹配的正确 jar 文件。
- 添加 GGUF 模型:下载任何 GGUF 格式的模型(例如
llama-3-8b-instruct.Q4_K_M.gguf 或较小的模型如 qwen-2.5-1.5b-instruct),并将 .gguf 文件放入 .minecraft/models/ 文件夹中。
- 启动 Minecraft:模组将在启动时自动设置工作区。
游戏内命令
使用命令权限即时管理模型并运行提示:
/model list — 列出 models/ 目录中所有可用的 GGUF 文件。
/model load <filename> — 将选定的模型加载到内存中。
/model status — 显示当前活动模型的信息。
/llama <prompt> — 向已加载的模型提交提示,并将输出直接流式传输到聊天栏。
/llama stop — 立即停止当前的文本生成。
配置
在 config 目录中会生成一个通用配置文件(llamajar-common.toml 或 llamajar.json)。你可以调整性能参数:
modelName — 启动时自动加载的 GGUF 模型名称(留空以手动加载)。
systemPrompt — 设置默认系统提示以自定义模型行为、个性或指南(留空则无系统提示)。
gpuLayers — 要卸载到 GPU 的模型层数(数值越高,越多计算卸载到 GPU 显存)。
threads — 分配给模型推理的 CPU 线程数(默认为匹配 CPU 物理核心数)。
contextLength — 对话的最大上下文窗口大小(token 数量)。
开发者集成(库模组用法)
要将 llama.jar 用作你自己的 AI 启用模组的基础,请将其添加到你的开发环境中。
Gradle 设置
repositories {
mavenLocal() // 在本地发布 llama.jar 后
}
dependencies {
// 用于 Fabric 开发
modImplementation "com.popr4x.llamajar:llamajar-fabric-1.20.1:alpha-1.0"
// 用于 Forge 开发
implementation "com.popr4x.llamajar:llamajar-forge-1.20.1:alpha-1.0"
}
在 Java 中访问 llama.cpp 上下文
import com.llamajar.LlamaJar;
import de.kherud.llama.LlamaModel;
import de.kherud.llama.LlamaIterator;
// 检查是否已加载模型
if (LlamaJar.isModelLoaded()) {
LlamaModel model = LlamaJar.getModel();
// 执行自定义推理、注册自定义监听器或管理模型状态
}
许可证
本项目根据 AGPLv3 License 许可。底层使用了 llama.cpp 以及 de.kherud:llama 的 Java JNI 绑定,后者根据 Apache-2.0 许可。
llama.jar ?
llama.jar is a lightweight, high-performance Minecraft mod that brings the power of local Large Language Models (LLMs) directly into Minecraft using llama.cpp.
Runs completely offline on your own hardware with no API keys, no subscriptions, and zero external network requests.
[!WARNING]
This is an alpha release and has not been fully tested in all environments. Use with caution and please report any bugs or issues you encounter.
Key Features
- Offline Local LLM Inference: Run your favorite open-source models (such as LLaMA-3, Qwen-2.5, Phi-3, Mistral, and more) directly inside the Minecraft process.
- Hardware Acceleration & GPU Support: Supports multi-core CPU execution alongside GPU offloading (CUDA, Metal, OpenCL/CLBlast) for hardware-accelerated generation. Supports multi-GPU configurations.
- Built-in Game Integration: Prompt your loaded models in real-time using in-game commands or listen to interactions.
- Modding Library Base: Fully architected to serve as a library mod. You can import
llama.jar in your custom mods to easily add AI-driven NPCs, dynamic quest generation, or intelligent automated assistants.
- Wide Version Compatibility: Supports both Forge and Fabric platforms across multiple Minecraft versions:
How to Setup
- Download the Mod: Download the correct jar matching your mod loader (Forge or Fabric) and Minecraft version.
- Add GGUF Models: Download any GGUF format model (e.g.
llama-3-8b-instruct.Q4_K_M.gguf or smaller models like qwen-2.5-1.5b-instruct) and place the .gguf file inside your .minecraft/models/ folder.
- Launch Minecraft: The mod will automatically set up the workspace on startup.
In-Game Commands
Manage models and run prompts on the fly using command permissions:
/model list — Lists all available GGUF files in your models/ directory.
/model load <filename> — Loads the selected model into memory.
/model status — Displays information about the currently active model.
/llama <prompt> — Submits a prompt to the loaded model and streams the output directly to chat.
/llama stop — Immediately halts the current text generation.
Configuration
A common configuration file (llamajar-common.toml or llamajar.json) is generated in your config directory. You can tweak performance parameters:
modelName — Name of the GGUF model to load automatically on startup (leave empty to load manually).
systemPrompt — Set a default system prompt to customize model behavior, personality, or guidelines (leave empty for no system prompt).
gpuLayers — The number of model layers to offload to the GPU (higher offloads more computation to GPU VRAM).
threads — Number of CPU threads to allocate to model inference (defaults to matching CPU physical cores).
contextLength — The maximum context window size (tokens) for conversations.
Developer Integration (Library Mod Usage)
To use llama.jar as a foundation for your own AI-enabled mod, add it to your development environment.
Gradle Setup
repositories {
mavenLocal() // After publishing llama.jar locally
}
dependencies {
// For Fabric development
modImplementation "com.popr4x.llamajar:llamajar-fabric-1.20.1:alpha-1.0"
// For Forge development
implementation "com.popr4x.llamajar:llamajar-forge-1.20.1:alpha-1.0"
}
Accessing llama.cpp context in Java
import com.llamajar.LlamaJar;
import de.kherud.llama.LlamaModel;
import de.kherud.llama.LlamaIterator;
// Check if a model is currently loaded
if (LlamaJar.isModelLoaded()) {
LlamaModel model = LlamaJar.getModel();
// Perform custom inferences, register custom listeners, or manage model state
}
License
This project is licensed under the AGPLv3 License. Under the hood, it utilizes llama.cpp and the Java JNI bindings from de.kherud:llama licensed under Apache-2.0.
评论 0
登录后参与评分
还没有评论,来抢沙发吧