Text Generation
Transformers
Safetensors
GGUF
Korean
gemma4
image-text-to-text
gemma
korean
roleplay
mud
lore
llama.cpp
lmstudio
conversational
Instructions to use sangwon1472/gemma4-e2b-mud with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sangwon1472/gemma4-e2b-mud with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sangwon1472/gemma4-e2b-mud") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("sangwon1472/gemma4-e2b-mud") model = AutoModelForMultimodalLM.from_pretrained("sangwon1472/gemma4-e2b-mud", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use sangwon1472/gemma4-e2b-mud with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M # Run inference directly in the terminal: llama cli -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M # Run inference directly in the terminal: llama cli -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
Use Docker
docker model run hf.co/sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use sangwon1472/gemma4-e2b-mud with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sangwon1472/gemma4-e2b-mud" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sangwon1472/gemma4-e2b-mud", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
- SGLang
How to use sangwon1472/gemma4-e2b-mud with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sangwon1472/gemma4-e2b-mud" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sangwon1472/gemma4-e2b-mud", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sangwon1472/gemma4-e2b-mud" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sangwon1472/gemma4-e2b-mud", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use sangwon1472/gemma4-e2b-mud with Ollama:
ollama run hf.co/sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use sangwon1472/gemma4-e2b-mud with Docker Model Runner:
docker model run hf.co/sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
- Lemonade
How to use sangwon1472/gemma4-e2b-mud with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sangwon1472/gemma4-e2b-mud:UD-Q4_K_M
Run and chat with the model
lemonade run user.gemma4-e2b-mud-UD-Q4_K_M
List all available models
lemonade list
- Atomic Chat
|
Download gemma-mud-colab-starter/troubleshooting.md from sangwon1472/gemma4-e2b-mud: direct link, hf CLI and curl.
- Browser
- Download file 5.84 kB
-
https://huggingface.co/sangwon1472/gemma4-e2b-mud/resolve/main/gemma-mud-colab-starter/troubleshooting.md
- Command line
-
hf download hf://sangwon1472/gemma4-e2b-mud/gemma-mud-colab-starter/troubleshooting.md
-
curl -L -o troubleshooting.md https://huggingface.co/sangwon1472/gemma4-e2b-mud/resolve/main/gemma-mud-colab-starter/troubleshooting.md
5.84 kB
| # λ¬Έμ ν΄κ²° | |
| ## 1. Hugging Face μΈμ¦ μ€ν¨ | |
| ### μ¦μ | |
| - λ‘κ·ΈμΈ μ μμ μ€λ₯κ° λλ€. | |
| - ν ν° μ λ ₯ νμλ μΈμ¦ μ€ν¨ λ©μμ§κ° λ¬λ€. | |
| ### μμΈ | |
| - ν ν°μ΄ νλ Έκ±°λ λ§λ£λμμ μ μλ€. | |
| - ν ν° κΆνμ΄ λΆμ‘±ν μ μλ€. | |
| - λΆμ¬ λ£λ κ³Όμ μμ κ³΅λ°±μ΄ μμμ μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - Hugging Faceμμ μ ν ν°μ λ€μ λ°κΈνλ€. | |
| - 볡μ¬ν λ μλ€ κ³΅λ°±μ μ κ±°νλ€. | |
| - λ ΈνΈλΆμ μ¬μμν λ€ λ€μ λ‘κ·ΈμΈνλ€. | |
| --- | |
| ## 2. Gemma λͺ¨λΈ μ κ·Ό κΆν μ€λ₯ | |
| ### μ¦μ | |
| - `from_pretrained` λ¨κ³μμ μ κ·Ό κ±°λΆκ° λ¬λ€. | |
| - gated model κ΄λ ¨ λ©μμ§κ° λμ¨λ€. | |
| ### μμΈ | |
| - Gemma λͺ¨λΈ μ¬μ© 쑰건μ μμ§ μΉμΈνμ§ μμλ€. | |
| - μΉμΈ νμλ λ‘κ·ΈμΈ μνκ° λ°μλμ§ μμμ μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - Hugging Faceμμ μνλ Gemma λͺ¨λΈ μΉ΄λλ‘ μ΄λνλ€. | |
| - μ¬μ© 쑰건μ μΉμΈνλ€. | |
| - λ€μ λ‘κ·ΈμΈνλ€. | |
| - κ³μ λ§νλ©΄ κΈ°λ³Έκ°μΈ `unsloth/gemma-4-E2B-it` κ²½λ‘λ‘ λ¨Όμ μννλ€. | |
| --- | |
| ## 3. Colab GPUκ° μ μ‘νλ κ²½μ° | |
| ### μ¦μ | |
| - `torch.cuda.is_available()` κ° `False`λ‘ λμ¨λ€. | |
| - `import unsloth` μμ `Unsloth cannot find any torch accelerator` μ€λ₯κ° λλ€. | |
| ### μμΈ | |
| - λ°νμμ΄ CPUλ‘ μ΄λ Έμ μ μλ€. | |
| - λ¬΄λ£ Colab μμμ΄ μ μ λΆμ‘±ν μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - **λ°νμ β λ°νμ μ ν λ³κ²½ β GPU** λ‘ λ€μ μ€μ νλ€. | |
| - μ μΈμ μ λ€μ μ΄μ΄ λ³Έλ€. | |
| - GPUλ‘ λ°κΎΌ λ€μλ **μ€μΉ μ λΆν° λ€μ μ€ν**νλ€. | |
| - κ³μ μ λλ©΄ μ μ ν λ€μ μλνλ€. | |
| --- | |
| ## 4. bitsandbytes / quantization κ΄λ ¨ μ€λ₯ | |
| ### μ¦μ | |
| - 4bit μμν μ€μ μ μμ μ€λ₯κ° λλ€. | |
| - bitsandbytes import μ€λ₯κ° λλ€. | |
| ### μμΈ | |
| - ν¨ν€μ§ μ€μΉκ° λ λλ¬μ μ μλ€. | |
| - GPU μΈμ μ΄ μλ μνμΌ μ μλ€. | |
| - μ€μΉ ν λ°νμ μ¬μμμ΄ νμν μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - μ€μΉ μ μ λ€μ μ€ννλ€. | |
| - λ°νμμ μ¬μμνλ€. | |
| - GPUκ° μ€μ λ‘ μ‘νλμ§ λ€μ νμΈνλ€. | |
| - `LOAD_IN_4BIT = True` / `False` λ₯Ό λ°κΏ μ΄λ μͺ½μ΄ νμ¬ μΈμ μμ μμ μ μΈμ§ νμΈνλ€. | |
| --- | |
| ## 4-1. import λ¨κ³μμ λ°λ‘ κΉ¨μ§λ κ²½μ° | |
| ### μ¦μ | |
| - `from transformers import ...` λ¨κ³μμ λ°λ‘ μ€λ₯κ° λλ€. | |
| - `ModuleNotFoundError: No module named 'unsloth'` κ° λ¬λ€. | |
| - `from unsloth import FastModel` λ¨κ³μμ import error κ° λλ€. | |
| - `from trl import SFTTrainer` μμ import error κ° λλ€. | |
| - μ€μΉ μ μ λλ¬μ§λ§ λ€μ μ μμ ν¨ν€μ§ μΆ©λ λ©μμ§κ° μ΄μ΄μ§λ€. | |
| ### μμΈ | |
| - Colab κΈ°λ³Έ `torch` μ Unsloth μͺ½ ν¨ν€μ§ λ²μ μ΄ μ€κ°μ μμμ μ μλ€. | |
| - `transformers==5.5.0` μ΄μ μ‘°ν©μ΄λ λλ½λ `timm` / `torchcodec` λλ¬Έμ Gemma 4 import κ° κΉ¨μ§ μ μλ€. | |
| - μ€μΉ μ§ν μ¬μμ μμ΄ μ΄μ λ°νμ μνκ° λ¨μ μμ μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - λ ΈνΈλΆ μ€μΉ μ μ κ·Έλλ‘ λ€μ μ€ννλ€. | |
| - μ€μΉ λ€ λ°λ‘ κΉ¨μ‘λ€λ©΄ **λ°νμμ μ¬μμν λ€μ 2λ² μ λΆν° λ€μ μ€ν**νλ€. | |
| - μ€μΉ μ λ§μ§λ§μ `pip show unsloth` μΆλ ₯μ΄ μ€μ λ‘ λ³΄μ΄λμ§ νμΈνλ€. | |
| - λ²μ μΆλ ₯μμ `unsloth`, `transformers`, `trl` μ΄ μ μμ μΌλ‘ μ°νλμ§ νμΈνλ€. | |
| --- | |
| ## 5. λ©λͺ¨λ¦¬ λΆμ‘± | |
| ### μ¦μ | |
| - νμ΅ μ€κ°μ out of memory μ€λ₯κ° λλ€. | |
| - μΈμ μ΄ κ°μκΈ° μ£½λλ€. | |
| ### μμΈ | |
| - λͺ¨λΈμ΄ λ무 ν¬λ€. | |
| - `MAX_SEQ_LENGTH` κ° λ무 κΈΈλ€. | |
| - λ°°μΉ ν¬κΈ° λλ λμ μ€ν μ‘°ν©μ΄ νμ¬ GPUμ 무κ²λ€. | |
| ### ν΄κ²° λ°©λ² | |
| - `LOAD_IN_4BIT = True` λ‘ λ°κΎΌλ€. | |
| - `MAX_SEQ_LENGTH` λ₯Ό 1024 β 512 λ‘ μ€μΈλ€. | |
| - batch sizeλ 1λ‘ μ μ§νκ³ , νμνλ©΄ λ°μ΄ν° μλ₯Ό μ€μ¬ νλ¦λ§ λ¨Όμ νμΈνλ€. | |
| --- | |
| ## 6. dataset νμΌ κ²½λ‘ μ€λ₯ | |
| ### μ¦μ | |
| - `FileNotFoundError` κ° λ¬λ€. | |
| - λ ΈνΈλΆμ΄ dataset νμΌμ μ°Ύμ§ λͺ»νλ€. | |
| ### μμΈ | |
| - νμΌ μ λ‘λ μμΉκ° λ ΈνΈλΆ μ€μ κ³Ό λ€λ₯΄λ€. | |
| - zipμ νμμ§λ§ Colab κ²½λ‘κ° λ¬λΌμ‘λ€. | |
| ### ν΄κ²° λ°©λ² | |
| - νμΌ ν¨λμμ μ€μ κ²½λ‘λ₯Ό νμΈνλ€. | |
| - μ€μ μ μ `DATA_CANDIDATES` λͺ©λ‘μ νμ¬ κ²½λ‘λ₯Ό μΆκ°νλ€. | |
| - κ°μ₯ μ¬μ΄ λ°©λ²μ dataset νμΌμ `/content/` μ μ§μ μ¬λ¦¬λ κ²μ΄λ€. | |
| --- | |
| ## 7. μΈμ μ’ λ£ λλ λ°νμ μ΄κΈ°ν | |
| ### μ¦μ | |
| - μ½λ©μ΄ κ°μκΈ° λ€μ μμλλ€. | |
| - νμ΅ λ‘κ·Έκ° μ¬λΌμ§λ€. | |
| ### μμΈ | |
| - λ¬΄λ£ Colab μΈμ μ ν | |
| - λ©λͺ¨λ¦¬ μ΄κ³Ό | |
| - μ₯μκ° μ ν΄ μν | |
| ### ν΄κ²° λ°©λ² | |
| - λ¨Όμ μμ λͺ¨λΈκ³Ό μ§§μ μ€μ μΌλ‘ ν λ² μ±κ³΅μν¨λ€. | |
| - μ μ₯ μ μ΄ λλ¬λμ§ μμλ‘ νμΈνλ€. | |
| - κ²°κ³Όλ κ°λ₯ν 빨리 Driveλ λ‘컬μ λ°±μ νλ€. | |
| --- | |
| ## 8. μΆλ ₯ νμ§μ΄ μ΄μν κ²½μ° | |
| ### μ¦μ | |
| - λ§ν¬κ° νλ€λ¦°λ€. | |
| - μΈκ³κ΄ λ° μ€λͺ μ΄ λμ¨λ€. | |
| - λ무 κΈΈκ±°λ 건쑰ν λ΅μ΄ λμ¨λ€. | |
| ### μμΈ | |
| - λ°μ΄ν° μκ° μ λ€. | |
| - instructionμ΄ μΆ©λΆν ꡬ체μ μ΄μ§ μλ€. | |
| - 문체λ μ΅νμ§λ§ κ·μΉκΉμ§ μλμΌλ‘ λ°°μ°μ§ λͺ»νλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - λ°μ΄ν° μλ₯Ό 300κ° μ΄μμΌλ‘ λλ¦°λ€. | |
| - NPCλ³, λͺ λ Ήμ΄λ³ λ°μ΄ν°λ₯Ό λλλ€. | |
| - `instruction` λ¬Έμ₯μ λ λλ ·νκ² μ΄λ€. | |
| - μ€μ κ²μ νμ μ μμ§μ΄ λ§‘κ³ , AIλ λν/λΆμκΈ°/μμ¬ λ³΄μ‘°μ μ°λ νΈμ΄ μμ νλ€. | |
| --- | |
| ## 9. μ μ₯ νμΌμ΄ μ 보μ΄λ κ²½μ° | |
| ### μ¦μ | |
| - νμ΅μ λλ¬λλ° μΆλ ₯ ν΄λκ° λΉμ΄ 보μΈλ€. | |
| - νμΌ ν¨λμμ κ²°κ³Όκ° μ μ 보μΈλ€. | |
| ### μμΈ | |
| - μ μ₯ κ²½λ‘λ₯Ό μλͺ» 보μμ μ μλ€. | |
| - μΈμ μ¬μμ μ μ μ₯μ΄ λλμ§ μμμ μ μλ€. | |
| ### ν΄κ²° λ°©λ² | |
| - `/content/output/gemma_mud_lora_out` κ²½λ‘λ₯Ό μ§μ νμΈνλ€. | |
| - `os.listdir()` λ‘ ν΄λ λ΄μ©μ μΆλ ₯ν΄ λ³Έλ€. | |
| - Drive λ³΅μ¬ μ μ μ¬μ©ν΄ λ³λ μμΉμ λ°±μ νλ€. | |