Instructions to use lightblue/japanese-mpt-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lightblue/japanese-mpt-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lightblue/japanese-mpt-7b", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lightblue/japanese-mpt-7b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("lightblue/japanese-mpt-7b", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lightblue/japanese-mpt-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lightblue/japanese-mpt-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightblue/japanese-mpt-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/lightblue/japanese-mpt-7b
- SGLang
How to use lightblue/japanese-mpt-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 "lightblue/japanese-mpt-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": "lightblue/japanese-mpt-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 "lightblue/japanese-mpt-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": "lightblue/japanese-mpt-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use lightblue/japanese-mpt-7b with Docker Model Runner:
docker model run hf.co/lightblue/japanese-mpt-7b
Dataset
Japanese subset of the mC4 dataset
Training
Trained for 3000 steps on top of the MPT 7b checkpoint mosaicml/mpt-7b
How to load
Before running this model, please install the following pip package:
pip install einops
To load the model, run the following command.
from transformers import AutoModelForCausalLM
model_name = "lightblue/japanese-mpt-7b"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype='auto',
trust_remote_code=True
)
To run this model, you may need to load it in a lower precision in order for it to fit onto your GPU. We found for a T4 GPU, it requires loading the model in 8-bit precision. To load the model in 8-bit and 4-bit, please install the following pip packages:
pip install bitsandbytes accelerate
Caution - you will also need enough RAM to load the model. We estimate loading this model requires ~30GB.
Code to load the model in 8 bit
from transformers import AutoModelForCausalLM
model_name = "lightblue/japanese-mpt-7b"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype='auto',
load_in_8bit=True,
trust_remote_code=True
)
Code to load the model in 4 bit
from transformers import AutoModelForCausalLM
model_name = "lightblue/japanese-mpt-7b"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype='auto',
load_in_4bit=True,
trust_remote_code=True
)
How to use
from transformers import AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
prompt = """A: γγγ«γ‘γ―
B: γγγ«γ‘γ―
A: ε₯½γγͺγΉγγΌγγ―δ½γ§γγοΌ
B: γ΅γγ«γΌγ§γ
A: ε₯½γγͺι£γΉη©γ―δ½γ§γγοΌ
B:"""
pipe(prompt, temperature=0, do_sample=False, return_full_text=False, max_new_tokens=32)
# [{"generated_text": " γ«γ¬γΌγ§γ
# A: ε₯½γγͺθ²γ―δ½γ§γγοΌ
# B: θ΅€γ§γ"}]
- Downloads last month
- 1,157