Instructions to use parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft
- SGLang
How to use parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft 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 "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft" \ --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": "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", "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 "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft" \ --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": "parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft with Docker Model Runner:
docker model run hf.co/parallelstudios/mpt-7b-instruct-parallel-colony-memory-importance-ft
Update handler.py
Browse files2 unmodified lines34567891011121314151617181920212223242513 unmodified lines3940414243444546474849505152535455565758591 unmodified line616263646566672 unmodified linesfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom typing import Any, Dictclass EndpointHandler:def __init__(self, path='', torch_dtype=torch.bfloat16, trust_remote_code=True):self.model = AutoModelForCausalLM.from_pretrained(path,torch_dtype=torch_dtype,trust_remote_code=trust_remote_code)tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")if tokenizer.pad_token_id is None:warnings.warn("pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id.")tokenizer.pad_token = tokenizer.eos_tokentokenizer.padding_side = "right" # "left"self.tokenizer = tokenizerself.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")13 unmodified lines}def format_instruction(self, instruction):INSTRUCTION_KEY = "### Instruction:"RESPONSE_KEY = "### Response:"END_KEY = "### End"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,)return PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:# process input1 unmodified lineparameters = data.pop("parameters", None)# preprocesss = PROMPT_FOR_GENERATION_FORMAT.format(instruction=inputs)input_ids = self.tokenizer(s, return_tensors="pt").input_ids.to(self.device)gkw = {**self.generate_kwargs, **parameters}# pass inputs with all kwargs in data2 unmodified lines34567891011121314151617181920212223242526272829303132333435363738394041424344454613 unmodified lines606162636465661 unmodified line686970717273742 unmodified linesfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom typing import Any, Dictclass InstructionTextGenerationPipeline:INSTRUCTION_KEY = "### Instruction:"RESPONSE_KEY = "### Response:"END_KEY = "### End"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,)def __init__(self,path,torch_dtype=torch.bfloat16,trust_remote_code=True,) -> None:self.model = AutoModelForCausalLM.from_pretrained(path,torch_dtype=torch_dtype,trust_remote_code=trust_remote_code)tokenizer = AutoTokenizer.from_pretrained("mosaicml/mpt-7b-instruct",trust_remote_code=trust_remote_code)if tokenizer.pad_token_id is None:warnings.warn("pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id.")tokenizer.pad_token = tokenizer.eos_tokentokenizer.padding_side = "right"self.tokenizer = tokenizerself.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")13 unmodified lines}def format_instruction(self, instruction):return self.PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:# process input1 unmodified lineparameters = data.pop("parameters", None)# preprocesss = self.format_instruction(instruction=inputs)input_ids = self.tokenizer(s, return_tensors="pt").input_ids.to(self.device)gkw = {**self.generate_kwargs, **parameters}# pass inputs with all kwargs in data
handler.py+29-22