Instructions to use Rakuten/RakutenAI-7B-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rakuten/RakutenAI-7B-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rakuten/RakutenAI-7B-instruct")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Rakuten/RakutenAI-7B-instruct") model = AutoModelForCausalLM.from_pretrained("Rakuten/RakutenAI-7B-instruct") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Rakuten/RakutenAI-7B-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rakuten/RakutenAI-7B-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rakuten/RakutenAI-7B-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Rakuten/RakutenAI-7B-instruct
- SGLang
How to use Rakuten/RakutenAI-7B-instruct 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 "Rakuten/RakutenAI-7B-instruct" \ --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": "Rakuten/RakutenAI-7B-instruct", "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 "Rakuten/RakutenAI-7B-instruct" \ --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": "Rakuten/RakutenAI-7B-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Rakuten/RakutenAI-7B-instruct with Docker Model Runner:
docker model run hf.co/Rakuten/RakutenAI-7B-instruct
Very limited model response... am I doing something wrong?
Tried the following prompt and the response was worse than 'Mistral-7B-Instruct-v0.3' without the Japanese fine-tuning. Am I doing something wrong?
import requests
API_URL = "XXX"
headers = {
"Accept" : "application/json",
"Authorization": "Bearer YYY",
"Content-Type": "application/json"
}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
system_prompt = "You are a Japanese language teacher. Your task is to draft a beginner-level Japanese roleplay for making a restaurant reservation, focusing on specifying any dietary restrictions or special requests. Output the dialogue in JSON format with only the following keys: 'Japanese' and 'speaker'. "
prompt = "Draft a beginner-level Japanese roleplay to help me practice making a restaurant reservation, focusing on specifying any dietary restrictions or special requests. Use real-life examples."
msg = "<s> [INST] "+system_prompt+" \n "+prompt+" [/INST]"
output = query({
"inputs": msg,
"parameters": {
"top_k": 50,
"top_p": 0.95,
"temperature": 0.7,
"max_new_tokens": 1024
}
})
print(output)
The issue might be your prompt formatting. From what I've worked with rakuten, your prompt should be "General Instructions \n USER:\n user provided instructions\n ASSISTANT:\n". The model likes to follow this format. In my experience, passing any general instructions didn't really help, I've contained my prompt only to the user section and that works best for me. In general it is a bit finnicky with instructions and sometimes it will just keep babbling random stuff if it doesn't like your prompt.