Instructions to use firqaaa/indo-alpaca-lora-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use firqaaa/indo-alpaca-lora-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="firqaaa/indo-alpaca-lora-7b")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("firqaaa/indo-alpaca-lora-7b", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use firqaaa/indo-alpaca-lora-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "firqaaa/indo-alpaca-lora-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "firqaaa/indo-alpaca-lora-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/firqaaa/indo-alpaca-lora-7b
- SGLang
How to use firqaaa/indo-alpaca-lora-7b 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 "firqaaa/indo-alpaca-lora-7b" \ --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": "firqaaa/indo-alpaca-lora-7b", "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 "firqaaa/indo-alpaca-lora-7b" \ --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": "firqaaa/indo-alpaca-lora-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use firqaaa/indo-alpaca-lora-7b with Docker Model Runner:
docker model run hf.co/firqaaa/indo-alpaca-lora-7b
About :
This π¦ Llama model was trained on a translated Alpaca dataset in Bahasa Indonesia. It uses Parameter Efficient Fine Tuning and LoRA to enable training on consumer-grade GPU hardware.
How to Use :
Load the π¦ Alpaca-LoRA model
import torch
import bitsandbytes as bnb
from transformers import LlamaTokenizer, LlamaForCausalLM, GenerationConfig
from peft import PeftModel, PeftConfig, prepare_model_for_int8_training, LoraConfig, get_peft_model
peft_model_id = "firqaaa/indo-Alpaca-LoRA-7b"
tokenizer = LlamaTokenizer.from_pretrained("decapoda-research/llama-7b-hf")
model = LlamaForCausalLM.from_pretrained("decapoda-research/llama-7b-hf",
load_in_8bit=True,
device_map="auto")
# Load the LoRA model
model = PeftModel.from_pretrained(model, peft_model_id)
Prompt Template
Prepare the prompt template
instruction = "Tuliskan deret bilangan fibbonaci. Tulis jawaban/respons dalam Bahasa Indonesia."
PROMPT = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Response:"""
Evaluation
feel free to change the parameters inside GenerationConfig to get better result.
inputs = tokenizer(
PROMPT,
return_tensors="pt"
)
input_ids = inputs["input_ids"].cuda()
generation_config = GenerationConfig(
temperature=0.1,
top_p=0.95,
top_k=40,
num_beams=4,
repetition_penalty=1.15,
)
print("Generating...")
print("Instruction : {}".format(instruction))
generation_output = model.generate(
input_ids=input_ids,
generation_config=generation_config,
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=512,
)
print("Response : ")
for s in generation_output.sequences:
print(tokenizer.decode(s).split("### Response:")[1])
Note :
Due to the high loss and lack of compute unit, we will update this model frequently to ensure the quality of generated text