Instructions to use stabilityai/japanese-stablelm-base-alpha-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stabilityai/japanese-stablelm-base-alpha-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="stabilityai/japanese-stablelm-base-alpha-7b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("stabilityai/japanese-stablelm-base-alpha-7b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use stabilityai/japanese-stablelm-base-alpha-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "stabilityai/japanese-stablelm-base-alpha-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stabilityai/japanese-stablelm-base-alpha-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/stabilityai/japanese-stablelm-base-alpha-7b
- SGLang
How to use stabilityai/japanese-stablelm-base-alpha-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 "stabilityai/japanese-stablelm-base-alpha-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": "stabilityai/japanese-stablelm-base-alpha-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 "stabilityai/japanese-stablelm-base-alpha-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": "stabilityai/japanese-stablelm-base-alpha-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use stabilityai/japanese-stablelm-base-alpha-7b with Docker Model Runner:
docker model run hf.co/stabilityai/japanese-stablelm-base-alpha-7b
Fine tuning by LoRA
I tried fine tune this model by PEFT library and Trainer from transformers library
I got this error:
japanese-stablelm-base-alpha-7b\69e1599948909cccca2369385fb6c82ef59086f4\modeling_japanese_stablelm_alpha.py", line 383, in apply_rotary_pos_emb
q_embed = (q * cos) + (rotate_half(q) * sin)
RuntimeError: The size of tensor a (32) must match the size of tensor b (64) at non-singleton dimension 3
The loading of the model is:
tokenizer = LlamaTokenizer.from_pretrained("novelai/nerdstash-tokenizer-v1", load_in_8bit=self.finetuner_properties.useint8, device_map="auto")
lm_model = AutoModelForCausalLM.from_pretrained("stabilityai/japanese-stablelm-base-alpha-7b", load_in_8bit=true, device_map="auto", trust_remote_code=True)
My arguments are:
#for LoraConfig
lora_r:int = 8,
lora_alpha:int = 16,
lora_dropout:float = 0.05,
lora_bias:str = "none",
#for Trainer
ta_epochs:int = 4,
ta_logging_steps:int = 200,
ta_save_steps:int = 100000,
ta_save_total_limit:int = 3,
ta_train_batch_size:int = 8,
ta_warmup_steps:int = 200,
ta_weight_decay:float = 0.1,
ta_learning_rate:float = 5e-4,
What's wrong? This model unable to fine-tuning in int8 condition?
I also tried variant="int8" but didn't solve