Text Generation
Transformers
PyTorch
mpt
Composer
MosaicML
llm-foundry
StreamingDatasets
custom_code
text-generation-inference
Instructions to use flashvenom/mpt-7b-base-lora-fix with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use flashvenom/mpt-7b-base-lora-fix with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="flashvenom/mpt-7b-base-lora-fix", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("flashvenom/mpt-7b-base-lora-fix", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("flashvenom/mpt-7b-base-lora-fix", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use flashvenom/mpt-7b-base-lora-fix with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "flashvenom/mpt-7b-base-lora-fix" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "flashvenom/mpt-7b-base-lora-fix", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/flashvenom/mpt-7b-base-lora-fix
- SGLang
How to use flashvenom/mpt-7b-base-lora-fix 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 "flashvenom/mpt-7b-base-lora-fix" \ --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": "flashvenom/mpt-7b-base-lora-fix", "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 "flashvenom/mpt-7b-base-lora-fix" \ --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": "flashvenom/mpt-7b-base-lora-fix", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use flashvenom/mpt-7b-base-lora-fix with Docker Model Runner:
docker model run hf.co/flashvenom/mpt-7b-base-lora-fix
| import sys | |
| import logging | |
| import operator as op | |
| from packaging import version | |
| from packaging.version import Version, parse | |
| from typing import Union | |
| import importlib.util | |
| # The package importlib_metadata is in a different place, depending on the python version. | |
| if sys.version_info < (3, 8): | |
| import importlib_metadata | |
| else: | |
| import importlib.metadata as importlib_metadata | |
| STR_OPERATION_TO_FUNC = {">": op.gt, ">=": op.ge, "==": op.eq, "!=": op.ne, "<=": op.le, "<": op.lt} | |
| logger = logging.getLogger(__name__) | |
| _torch_available = importlib.util.find_spec("torch") is not None | |
| if _torch_available: | |
| try: | |
| _torch_version = importlib_metadata.version("torch") | |
| logger.info(f"PyTorch version {_torch_version} available.") | |
| except importlib_metadata.PackageNotFoundError: | |
| _torch_available = False | |
| # This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L319 | |
| def compare_versions(library_or_version: Union[str, Version], operation: str, requirement_version: str): | |
| """ | |
| Args: | |
| Compares a library version to some requirement using a given operation. | |
| library_or_version (`str` or `packaging.version.Version`): | |
| A library name or a version to check. | |
| operation (`str`): | |
| A string representation of an operator, such as `">"` or `"<="`. | |
| requirement_version (`str`): | |
| The version to compare the library version against | |
| """ | |
| if operation not in STR_OPERATION_TO_FUNC.keys(): | |
| raise ValueError(f"`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys())}, received {operation}") | |
| operation = STR_OPERATION_TO_FUNC[operation] | |
| if isinstance(library_or_version, str): | |
| library_or_version = parse(importlib_metadata.version(library_or_version)) | |
| return operation(library_or_version, parse(requirement_version)) | |
| # This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L338 | |
| def is_torch_version(operation: str, version: str): | |
| """ | |
| Args: | |
| Compares the current PyTorch version to a given reference with an operation. | |
| operation (`str`): | |
| A string representation of an operator, such as `">"` or `"<="` | |
| version (`str`): | |
| A string version of PyTorch | |
| """ | |
| return compare_versions(parse(_torch_version), operation, version) |