# Llama3.java
Practical [Llama 3](https://github.com/meta-llama/llama3), [3.1](https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1) and [3.2](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/) inference implemented in a single Java file.
This project from [Alfonso² Peterssen](https://github.com/mukel) is on [GitHub](https://github.com/mukel/llama3.java).
## Installation and test
Download Llama3.java:
```bash
git clone https://github.com/mukel/llama3.java.git
```
Download Llama:
```bash
cd llama3.java
# Llama 3.2 (3B)
curl -L -O https://huggingface.co/mukel/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_0.gguf
```
Execute:
```bash
java --enable-preview --source 21 --add-modules jdk.incubator.vector Llama3.java -i --model Llama-3.2-3B-Instruct-Q4_0.gguf
```
For more options see documentation on [GitHub](https://github.com/mukel/llama3.java).
For more modells see Alfonso² Peterssen page on [HuggingFace](https://huggingface.co/mukel).
## Qwen 2.5-Coder
Download Qwen:
```bash
cd llama3.java
# Llama 3.2 (3B)
curl -L -O https://huggingface.co/mukel/Qwen2.5-Coder-3B-Instruct-GGUF/resolve/main/Qwen2.5-Coder-3B-Instruct-Q4_0.gguf
```
Execute:
```bash
java --enable-preview --source 21 --add-modules jdk.incubator.vector Llama3.java -i --model Qwen2.5-Coder-3B-Instruct-Q4_0.gguf
```
Unfortunatly it failed:
```bash
java --enable-preview --source 21 --add-modules jdk.incubator.vector Llama3.java -i --model Qwen2.5-Coder-3B-Instruct-Q4_0.gguf
WARNING: Using incubator modules: jdk.incubator.vector
Note: Llama3.java uses preview features of Java SE 21.
Note: Recompile with -Xlint:preview for details.
Parse Qwen2.5-Coder-3B-Instruct-Q4_0.gguf: 318 millis
Load LlaMa model: 258 millis
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
at com.llama4j.ModelLoader.loadModel(Llama3.java:696)
at com.llama4j.ModelLoader.loadModel(Llama3.java:686)
at com.llama4j.Llama3.main(Llama3.java:274)
```