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") - Inference
- 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
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- HuggingFaceH4/CodeAlpaca_20K
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
library_name: transformers
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- code
|
| 10 |
+
- LLaMa2
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# LLaMaCoder
|
| 14 |
+
|
| 15 |
+
## Model Description
|
| 16 |
+
|
| 17 |
+
`LLaMaCoder` is based on LLaMa2 7B language model, finetuned using LoRA adaptors.
|
| 18 |
+
|
| 19 |
+
## Usage
|
| 20 |
+
|
| 21 |
+
Generate code with LLaMaCoder in 4bit model according to the following python snippet:
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
from transformers import AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer
|
| 25 |
+
import torch
|
| 26 |
+
|
| 27 |
+
MODEL_NAME = "Sakuna/LLaMaCoderAll"
|
| 28 |
+
device = "cuda:0"
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
bnb_config = BitsAndBytesConfig(
|
| 32 |
+
load_in_4bit=True,
|
| 33 |
+
bnb_4bit_quant_type="nf4",
|
| 34 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
+
MODEL_NAME,
|
| 39 |
+
quantization_config=bnb_config,
|
| 40 |
+
trust_remote_code=True
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
|
| 44 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 45 |
+
|
| 46 |
+
model = model.to(device)
|
| 47 |
+
model.eval()
|
| 48 |
+
|
| 49 |
+
prompt = "Write a Java program to calculate the factorial of a given number k"
|
| 50 |
+
input = f"{prompt}\n### Solution:\n"
|
| 51 |
+
device = "cuda:0"
|
| 52 |
+
|
| 53 |
+
inputs = tokenizer(input, return_tensors="pt").to(device)
|
| 54 |
+
outputs = model.generate(**inputs, max_length=256, temperature=0.7)
|
| 55 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 56 |
+
```
|