Mistral 7B
Paper • 2310.06825 • Published • 58
How to use harshitv804/MetaMath-Mistral-2x7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="harshitv804/MetaMath-Mistral-2x7B") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("harshitv804/MetaMath-Mistral-2x7B")
model = AutoModelForCausalLM.from_pretrained("harshitv804/MetaMath-Mistral-2x7B")How to use harshitv804/MetaMath-Mistral-2x7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "harshitv804/MetaMath-Mistral-2x7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "harshitv804/MetaMath-Mistral-2x7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/harshitv804/MetaMath-Mistral-2x7B
How to use harshitv804/MetaMath-Mistral-2x7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "harshitv804/MetaMath-Mistral-2x7B" \
--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": "harshitv804/MetaMath-Mistral-2x7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "harshitv804/MetaMath-Mistral-2x7B" \
--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": "harshitv804/MetaMath-Mistral-2x7B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use harshitv804/MetaMath-Mistral-2x7B with Docker Model Runner:
docker model run hf.co/harshitv804/MetaMath-Mistral-2x7B
This is MetaMath-Mistral-2x7B Mixture of Experts (MOE) model created using mergekit for experimental and learning purpose of MOE.
This model was merged using the SLERP merge method using meta-math/MetaMath-Mistral-7B as the base model.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
slices:
- sources:
- model: meta-math/MetaMath-Mistral-7B
layer_range: [0, 32]
- model: meta-math/MetaMath-Mistral-7B
layer_range: [0, 32]
merge_method: slerp
base_model: meta-math/MetaMath-Mistral-7B
parameters:
t:
- filter: self_attn
value: [0, 0.5, 0.3, 0.7, 1]
- filter: mlp
value: [1, 0.5, 0.7, 0.3, 0]
- value: 0.5
dtype: bfloat16
## install dependencies
## !pip install -q -U git+https://github.com/huggingface/transformers.git
## !pip install -q -U git+https://github.com/huggingface/accelerate.git
## !pip install -q -U sentencepiece
## load model
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model_name = "harshitv804/MetaMath-Mistral-2x7B"
# load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
model_name,
trust_remote_code=True
)
tokenizer.pad_token = tokenizer.eos_token
## inference
query = "Maximoff's monthly bill is $60 per month. His monthly bill increased by thirty percent when he started working at home. How much is his total monthly bill working from home?"
prompt =f"""
Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
### Instruction:\n
{query}\n
### Response: Let's think step by step.
"""
# tokenize the input string
inputs = tokenizer(
prompt,
return_tensors="pt",
return_attention_mask=False
)
# generate text using the model
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
outputs = model.generate(**inputs, max_length=2048, streamer=streamer)
# decode and print the output
text = tokenizer.batch_decode(outputs)[0]
@article{yu2023metamath,
title={MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Models},
author={Yu, Longhui and Jiang, Weisen and Shi, Han and Yu, Jincheng and Liu, Zhengying and Zhang, Yu and Kwok, James T and Li, Zhenguo and Weller, Adrian and Liu, Weiyang},
journal={arXiv preprint arXiv:2309.12284},
year={2023}
}
@article{jiang2023mistral,
title={Mistral 7B},
author={Jiang, Albert Q and Sablayrolles, Alexandre and Mensch, Arthur and Bamford, Chris and Chaplot, Devendra Singh and Casas, Diego de las and Bressand, Florian and Lengyel, Gianna and Lample, Guillaume and Saulnier, Lucile and others},
journal={arXiv preprint arXiv:2310.06825},
year={2023}
}