greghavens/fable-5-coding-and-debugging-traces
Viewer • Updated • 12.5k • 5.57k • 45
How to use vamazing/Koa-AI-v1-Code-3B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="vamazing/Koa-AI-v1-Code-3B")
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) # Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("vamazing/Koa-AI-v1-Code-3B")
model = AutoModelForMultimodalLM.from_pretrained("vamazing/Koa-AI-v1-Code-3B", 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=40)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use vamazing/Koa-AI-v1-Code-3B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "vamazing/Koa-AI-v1-Code-3B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "vamazing/Koa-AI-v1-Code-3B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/vamazing/Koa-AI-v1-Code-3B
How to use vamazing/Koa-AI-v1-Code-3B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "vamazing/Koa-AI-v1-Code-3B" \
--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": "vamazing/Koa-AI-v1-Code-3B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "vamazing/Koa-AI-v1-Code-3B" \
--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": "vamazing/Koa-AI-v1-Code-3B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use vamazing/Koa-AI-v1-Code-3B with Docker Model Runner:
docker model run hf.co/vamazing/Koa-AI-v1-Code-3B
Koa-AI-v1-Code-3B is a fine-tuned 3B parameter language model built on the Ministral 3B architecture. It is optimized for lightweight text generation and coding tasks.
mistralai/Ministral-3b-instruct| Feature | Specification |
|---|---|
| Base Architecture | Ministral 3B Instruct 2512 |
| Parameters | ~3 Billion |
| Precision / Format | 4-bit NormalFloat (NF4) / BF16 |
| Native Context Length | Up to 128,000 tokens (Fine-tuned at 2,048 sequence cap) |
| Fine-Tuning Method | QLoRA 4-bit (Quantized Low-Rank Adaptation) |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| LoRA Parameters | r = 16, alpha = 32, Dropout = 0.0 |
| Primary Frameworks | Unsloth, PyTorch, Hugging Face Transformers |
| Learning Rate | 0.0002 |
| Optimizer | AdamW 8-bit |
transformers (Python)
To run the model using Hugging Face transformers (v5.5.0 or compatible):
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "vamazing/Koa-AI-v1-Code-3B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
prompt = "Write a Python function to check if a number is prime."
messages = [{"role": "user", "content": prompt}]
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))