Instructions to use Sakuna/LLaMaCoderAll with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sakuna/LLaMaCoderAll with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sakuna/LLaMaCoderAll")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sakuna/LLaMaCoderAll") model = AutoModelForCausalLM.from_pretrained("Sakuna/LLaMaCoderAll", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Sakuna/LLaMaCoderAll with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sakuna/LLaMaCoderAll" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sakuna/LLaMaCoderAll", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sakuna/LLaMaCoderAll
- SGLang
How to use Sakuna/LLaMaCoderAll 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 "Sakuna/LLaMaCoderAll" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sakuna/LLaMaCoderAll", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Sakuna/LLaMaCoderAll" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sakuna/LLaMaCoderAll", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Sakuna/LLaMaCoderAll with Docker Model Runner:
docker model run hf.co/Sakuna/LLaMaCoderAll
metadata
datasets:
- HuggingFaceH4/CodeAlpaca_20K
language:
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- code
- LLaMa2
LLaMaCoder
Model Description
LLaMaCoder is based on LLaMa2 7B language model, finetuned using LoRA adaptors.
Usage
Generate code with LLaMaCoder in 4bit model according to the following python snippet:
from transformers import AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer
import torch
MODEL_NAME = "Sakuna/LLaMaCoderAll"
device = "cuda:0"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME,
quantization_config=bnb_config,
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
model = model.to(device)
model.eval()
prompt = "Write a Java program to calculate the factorial of a given number k"
input = f"{prompt}\n### Solution:\n"
device = "cuda:0"
inputs = tokenizer(input, return_tensors="pt").to(device)
outputs = model.generate(**inputs, max_length=256, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))