Transformers
Safetensors
GGUF
English
llama
text-generation-inference
unsloth
codellama
trl
sft
conversational
Instructions to use chriscelaya/minecraft-ai-codellama-34b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chriscelaya/minecraft-ai-codellama-34b with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("chriscelaya/minecraft-ai-codellama-34b", dtype="auto") - llama-cpp-python
How to use chriscelaya/minecraft-ai-codellama-34b with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="chriscelaya/minecraft-ai-codellama-34b", filename="minecraft-ai-codellama-34b.F16.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use chriscelaya/minecraft-ai-codellama-34b with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M # Run inference directly in the terminal: llama-cli -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M # Run inference directly in the terminal: llama-cli -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
Use Docker
docker model run hf.co/chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use chriscelaya/minecraft-ai-codellama-34b with Ollama:
ollama run hf.co/chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
- Unsloth Studio
How to use chriscelaya/minecraft-ai-codellama-34b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for chriscelaya/minecraft-ai-codellama-34b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for chriscelaya/minecraft-ai-codellama-34b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for chriscelaya/minecraft-ai-codellama-34b to start chatting
- Atomic Chat new
- Docker Model Runner
How to use chriscelaya/minecraft-ai-codellama-34b with Docker Model Runner:
docker model run hf.co/chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
- Lemonade
How to use chriscelaya/minecraft-ai-codellama-34b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull chriscelaya/minecraft-ai-codellama-34b:Q4_K_M
Run and chat with the model
lemonade run user.minecraft-ai-codellama-34b-Q4_K_M
List all available models
lemonade list
| base_model: unsloth/codellama-34b-bnb-4bit | |
| tags: | |
| - text-generation-inference | |
| - transformers | |
| - unsloth | |
| - codellama | |
| - trl | |
| - sft | |
| license: apache-2.0 | |
| language: | |
| - en | |
| # Efficient Fine-Tuning of Large Language Models - Minecraft AI Assistant Tutorial | |
| This repository demonstrates how to fine-tune the **Codellama-34b** model to create "Andy," an AI assistant for Minecraft. Using the **Unsloth framework**, this tutorial showcases efficient fine-tuning with 4-bit quantization and LoRA for scalable training on limited hardware. | |
| ## 🚀 Resources | |
| - **Source Code**: [GitHub Repository](https://github.com/while-basic/mindcraft) | |
| - **Colab Notebook**: [Colab Notebook](https://colab.research.google.com/drive/1Eq5dOjc6sePEt7ltt8zV_oBRqstednUT?usp=sharing) | |
| - **Blog Article**: [Walkthrough](https://chris-celaya-blog.vercel.app/articles/unsloth-training) | |
| - **Dataset**: [Andy-3.5](https://huggingface.co/datasets/Sweaterdog/Andy-3.5) | |
| - **Teaser**: [Video](https://www.youtube.com/watch?v=KUXY5OtaPZc) | |
| ## Overview | |
| This **readme.md** provides step-by-step instructions to: | |
| 1. Install and set up the **Unsloth framework**. | |
| 2. Initialize the **Codellama 34b** model with **4-bit quantization**. | |
| 3. Implement **LoRA Adapters** for memory-efficient fine-tuning. | |
| 4. Prepare the **Andy-3.5 dataset** with Minecraft-specific knowledge. | |
| 5. Configure and execute training in a resource-efficient manner. | |
| 6. Evaluate and deploy the fine-tuned AI assistant. | |
| --- | |
| ### Key Features | |
| - **Memory-Efficient Training**: Fine-tune large models on GPUs as low as T4 (Google Colab). | |
| - **LoRA Integration**: Modify only key model layers for efficient domain-specific adaptation. | |
| - **Minecraft-Optimized Dataset**: Format data using **ChatML templates** for seamless integration. | |
| - **Accessible Hardware**: Utilize cost-effective setups with GPU quantization techniques. | |
| --- | |
| ## Prerequisites | |
| - **Python Knowledge**: Familiarity with basic programming concepts. | |
| - **GPU Access**: T4 (Colab Free Tier) is sufficient; higher-tier GPUs like V100/A100 recommended. | |
| - **Optional**: [Hugging Face Account](https://huggingface.co/) for model sharing. | |
| --- | |
| ## Setup | |
| Install the required packages: | |
| ```bash | |
| !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" | |
| !pip install --no-deps xformers trl peft accelerate bitsandbytes | |
| ``` | |
| --- | |
| ## Model Initialization | |
| Load the **Codellama-34b** model with 4-bit quantization for reduced resource usage: | |
| ```python | |
| from unsloth import FastLanguageModel | |
| import torch | |
| model, tokenizer = FastLanguageModel.from_pretrained( | |
| model_name="unsloth/codellama-34b-bnb-4bit", | |
| max_seq_length=2048, | |
| dtype=torch.bfloat16, | |
| load_in_4bit=True, | |
| trust_remote_code=True, | |
| ) | |
| ``` | |
| --- | |
| ## Adding LoRA Adapters | |
| Add LoRA to fine-tune specific layers efficiently: | |
| ```python | |
| model = FastLanguageModel.get_peft_model( | |
| model, | |
| r=16, | |
| target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "embed_tokens", "lm_head"], | |
| lora_alpha=16, | |
| lora_dropout=0, | |
| use_gradient_checkpointing="unsloth", | |
| ) | |
| ``` | |
| --- | |
| ## Dataset Preparation | |
| Prepare the Minecraft dataset (**Andy-3.5**): | |
| ```python | |
| from datasets import load_dataset | |
| from unsloth.chat_templates import get_chat_template | |
| dataset = load_dataset("Sweaterdog/Andy-3.5", split="train") | |
| tokenizer = get_chat_template(tokenizer, chat_template="chatml") | |
| ``` | |
| --- | |
| ## Training Configuration | |
| Set up the training parameters: | |
| ```python | |
| from trl import SFTTrainer | |
| from transformers import TrainingArguments | |
| trainer = SFTTrainer( | |
| model=model, | |
| tokenizer=tokenizer, | |
| train_dataset=dataset, | |
| dataset_text_field="text", | |
| args=TrainingArguments( | |
| per_device_train_batch_size=16, | |
| max_steps=1000, | |
| learning_rate=2e-5, | |
| gradient_checkpointing=True, | |
| output_dir="outputs", | |
| fp16=True, | |
| ), | |
| ) | |
| ``` | |
| Clear unused memory before training: | |
| ```python | |
| import torch | |
| torch.cuda.empty_cache() | |
| ``` | |
| --- | |
| ## Train the Model | |
| Initiate training: | |
| ```python | |
| trainer_stats = trainer.train() | |
| ``` | |
| --- | |
| ## Save and Share | |
| Save your fine-tuned model locally or upload to Hugging Face: | |
| ```python | |
| model.save_pretrained("andy_minecraft_assistant") | |
| ``` | |
| --- | |
| ## Optimization Tips | |
| - Expand the dataset for broader Minecraft scenarios. | |
| - Adjust training steps for better accuracy. | |
| - Fine-tune inference parameters for more natural responses. | |
| --- | |
| For more details on **Unsloth** or to contribute, visit [Unsloth GitHub](https://github.com/unslothai/unsloth). | |
| Happy fine-tuning! 🎮 | |
| ## Citation | |
| @misc{celaya2025minecraft, | |
| author = {Christopher B. Celaya}, | |
| title = {Efficient Fine-Tuning of Large Language Models - A Minecraft AI Assistant Tutorial}, | |
| year = {2025}, | |
| publisher = {GitHub}, | |
| journal = {GitHub repository}, | |
| howpublished = {\url{https://github.com/kolbytn/mindcraft}}, | |
| note = {\url{https://chris-celaya-blog.vercel.app/articles/unsloth-training}} | |
| } | |