Text Generation
Transformers
PyTorch
Safetensors
mpt
MosaicML
AWQ
custom_code
text-generation-inference
Instructions to use abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq
- SGLang
How to use abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq 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 "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq" \ --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": "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", "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 "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq" \ --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": "abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq with Docker Model Runner:
docker model run hf.co/abhinavkulkarni/mosaicml-mpt-30b-chat-w4-g128-awq
Abhinav Kulkarni commited on
Commit ·
06d3986
1
Parent(s): 8ba19c3
Updated README
Browse files
README.md
CHANGED
|
@@ -39,6 +39,7 @@ git clone https://github.com/mit-han-lab/llm-awq \
|
|
| 39 |
```
|
| 40 |
|
| 41 |
```python
|
|
|
|
| 42 |
import torch
|
| 43 |
from awq.quantize.quantizer import real_quantize_model_weight
|
| 44 |
from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer
|
|
@@ -80,6 +81,7 @@ prompt = f'''What is the difference between nuclear fusion and fission?
|
|
| 80 |
###Response:'''
|
| 81 |
|
| 82 |
input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
|
|
|
|
| 83 |
output = model.generate(
|
| 84 |
inputs=input_ids,
|
| 85 |
temperature=0.7,
|
|
@@ -89,6 +91,9 @@ output = model.generate(
|
|
| 89 |
repetition_penalty=1.1,
|
| 90 |
eos_token_id=tokenizer.eos_token_id,
|
| 91 |
streamer=streamer)
|
|
|
|
|
|
|
|
|
|
| 92 |
```
|
| 93 |
|
| 94 |
## Evaluation
|
|
|
|
| 39 |
```
|
| 40 |
|
| 41 |
```python
|
| 42 |
+
import time
|
| 43 |
import torch
|
| 44 |
from awq.quantize.quantizer import real_quantize_model_weight
|
| 45 |
from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer
|
|
|
|
| 81 |
###Response:'''
|
| 82 |
|
| 83 |
input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
|
| 84 |
+
t1 = time.time()
|
| 85 |
output = model.generate(
|
| 86 |
inputs=input_ids,
|
| 87 |
temperature=0.7,
|
|
|
|
| 91 |
repetition_penalty=1.1,
|
| 92 |
eos_token_id=tokenizer.eos_token_id,
|
| 93 |
streamer=streamer)
|
| 94 |
+
t2 = time.time()
|
| 95 |
+
print("*"*80)
|
| 96 |
+
print(f"Generated {num_tokens/(t2-t1):.2f} token/s; {(t2-t1)*1000/num_tokens:.2f} ms/token")
|
| 97 |
```
|
| 98 |
|
| 99 |
## Evaluation
|