How to use from
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 "Jumtra/mpt-7b-base" \
    --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": "Jumtra/mpt-7b-base",
		"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 "Jumtra/mpt-7b-base" \
        --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": "Jumtra/mpt-7b-base",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Quick Links

MPT-7B-base

このモデルは、MosaicMLのllm-foundryリポジトリを使用してmosaicml/mpt-7bをファインチューニングしたモデルです。

Model Date

June 28, 2023

Model License

Apache-2.0

評価

Jumtra/test_data_100QAを用いてモデルの正答率を評価した

model name 正答率
mosaicml/mpt-7b 16/100
mosaicml/mpt-7b-instruct 28/100
Jumtra/mpt-7b-base 47/100
Jumtra/mpt-7b-inst 46/100

使用方法

注意:このモデルでは、from_pretrainedメソッドにtrust_remote_code=Trueを渡す必要があります。 これは、Hugging Faceのtransformersパッケージにはまだ含まれていないカスタムのMPTモデルアーキテクチャを使用しているためです。 MPTには、FlashAttention、ALiBi、QK LayerNormなど、多くのトレーニング効率化機能のオプションが含まれています。

# 使用したプロンプトフォーマット
INSTRUCTION_KEY = "### Instruction:"
RESPONSE_KEY = "### Response:"
INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
PROMPT_FOR_GENERATION_FORMAT = """{intro}
{instruction_key}
{instruction}
{response_key}
""".format(
    intro=INTRO_BLURB,
    instruction_key=INSTRUCTION_KEY,
    instruction="{instruction}",
    response_key=RESPONSE_KEY,
)
import torch
import transformers
name = 'Jumtra/mpt-7b-base'
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
config.attn_config['attn_impl'] = 'torch'
config.init_device = 'cuda:0' # For fast initialization directly on GPU!
model = transformers.AutoModelForCausalLM.from_pretrained(
  name,
  config=config,
  torch_dtype=torch.bfloat16, # Load model weights in bfloat16
  trust_remote_code=True
).to("cuda:0")
model.eval()

input_text = PROMPT_FOR_GENERATION_FORMAT.format(instruction = "ニューラルネットワークとは何ですか?")

inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
input_length = inputs.input_ids.shape[1]

# Without streaming
with torch.no_grad():
    generation_output = model.generate(
        **inputs,
        max_new_tokens=2048,
        do_sample=True,
        temperature=0.01,
        top_p=0.01,
        top_k=60,
        repetition_penalty=1.1,
        return_dict_in_generate=True,
        remove_invalid_values=True,
        pad_token_id=tokenizer.pad_token_id,
        bos_token_id=tokenizer.bos_token_id,
        eos_token_id=tokenizer.eos_token_id,
    )
token = generation_output.sequences[0, input_length:]
output = tokenizer.decode(token)
print(output)

#ニューラルネットワーク(NN)は、人工知能の分野で最も重要なアプローチの1つです。これらのモデルは、自動学習を使用して、大量のデータから学習されたパターンや関係を特定することができます。ニューラルネットワークは、人間の脳に似たように機能します。<|endoftext|>

引用

@online{MosaicML2023Introducing,
    author    = {MosaicML NLP Team},
    title     = {Introducing MPT-7B: A New Standard for Open-Source,
    ly Usable LLMs},
    year      = {2023},
    url       = {www.mosaicml.com/blog/mpt-7b},
    note      = {Accessed: 2023-03-28}, % change this date
    urldate   = {2023-03-28} % change this date
}
Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train Jumtra/mpt-7b-base