Instructions to use HachiML/Swallow-MS-7b-v0.1-ChatMathSkill with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HachiML/Swallow-MS-7b-v0.1-ChatMathSkill with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HachiML/Swallow-MS-7b-v0.1-ChatMathSkill")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HachiML/Swallow-MS-7b-v0.1-ChatMathSkill") model = AutoModelForCausalLM.from_pretrained("HachiML/Swallow-MS-7b-v0.1-ChatMathSkill") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use HachiML/Swallow-MS-7b-v0.1-ChatMathSkill with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/HachiML/Swallow-MS-7b-v0.1-ChatMathSkill
- SGLang
How to use HachiML/Swallow-MS-7b-v0.1-ChatMathSkill 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 "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill" \ --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": "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill", "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 "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill" \ --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": "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use HachiML/Swallow-MS-7b-v0.1-ChatMathSkill with Docker Model Runner:
docker model run hf.co/HachiML/Swallow-MS-7b-v0.1-ChatMathSkill
Model Card for SkillTree Enhanced Model
Model Details
This model has been enhanced using the SkillTree approach, which applies specific skills extracted from advanced training or fine-tuning processes to improve the model's capabilities in targeted areas.
- Base Model: tokyotech-llm/Swallow-MS-7b-v0.1
- Skill Tree:
- Language(s) (NLP): Japanese
- Functionality Status: Functional / Non-Functional / Not Verified
Uses
This section should describe the intended use cases for the enhanced model. It might include scenarios such as code generation, conversational AI, text summarization, or any other specific tasks the model has been enhanced to perform better. Be sure to include any recommendations or limitations on the model's use.
# Import library
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load model
model_name = "HachiML/Swallow-MS-7b-v0.1-ChatMathSkill"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
# Inference 1 (Instruction)
prompt = "[INST] ウェンのベビーシッターの時給は12ドル。昨日、彼女は50分間ベビーシッターをしました。彼女の収入はいくらでしたか? [/INST]"
input_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
tokens = model.generate(input_ids.to(device=model.device), max_new_tokens=256, temperature=0.99, top_p=0.95, do_sample=True)
out = tokenizer.decode(tokens[0], skip_special_tokens=True)
print(out)
# Inference 2 (Chat)
messages = [
{"role": "user", "content": "ウェンのベビーシッターの時給は12ドル。昨日、彼女は50分間ベビーシッターをしました。彼女の収入はいくらでしたか?"},
{"role": "assistant", "content": "ウェンは1分あたり12/60=$<<12/60=0.2>>0.2を稼ぐ。50分働くと、0.2×50=$<<0.2*50=10>>10。#### $10"},
{"role": "user", "content": "ベティは100ドルする新しい財布を買うためにお金を貯めている。ベティは必要なお金の半分しか持っていない。両親はそのために15ドル、祖父母は両親の2倍を渡すことにした。ベティは財布を買うのにあといくらお金が必要か?"}
]
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
model_inputs = encodeds.to(device=model.device)
generated_ids = model.generate(model_inputs, max_new_tokens=512, do_sample=True)
out = tokenizer.batch_decode(generated_ids)
print(out[0])
Response Examples
Below are examples of responses from the model, demonstrating how the SkillTree enhancement has improved its performance.
Example 1:
- Input:
[INST] ウェンのベビーシッターの時給は12ドル。昨日、彼女は50分間ベビーシッターをしました。彼女の収入はいくらでしたか? [/INST]
- Output: (incorrect answer)
If Wuwen's Baby Sitter hourly wage is $12 and Wuwen worked for 50 minutes, Wuwen's income would be:
Income = Wuwen's hourly wage * Wuwen's work minutes
Income = $12 * 50/60
Income = $12 * 1/2
Income = $6
Wuwen's income yesterday was $6.
Example 2:
- Input:
<s> [INST] ウェンのベビーシッターの時給は12ドル。昨日、彼女は50分間ベビーシッターをしました。彼女の収入はいくらでしたか? [/INST] ウェンは1分あたり12/60=$<<12/60=0.2>>0.2を稼ぐ。50分働くと、0.2×50=$<<0.2*50=10>>10。#### $10 </s>
<s> [INST] ベティは100ドルする新しい財布を買うためにお金を貯めている。ベティは必要なお金の半分しか持っていない。両親はそのために15ドル、祖父母は両親の2倍を渡すことにした。ベティは財布を買うのにあといくらお金が必要か? [/INST]
- Output: (correct answer)
Since Betty needs to buy a wallet for 100 dollars and she has only half of it, she has 100/2 = <<100/2=50.0>>50 dollars. Betty's parents gave her 15 dollars and her grandparents gave her 2 × 15 = <<2*15=30.0>>30 dollars. Thus, Betty has 50 + 15 + 30 = <<15+30=95.0>>95 dollars. She needs to buy a wallet for 100 dollars, so she's lacking $100-$95=$<<100-95=5.0>>5 dollars.</s>
- Downloads last month
- 6
docker model run hf.co/HachiML/Swallow-MS-7b-v0.1-ChatMathSkill