Text Generation
Transformers
Safetensors
deepseek_v2
fp8
vllm
conversational
custom_code
text-generation-inference
Instructions to use RedHatAI/DeepSeek-Coder-V2-Instruct-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/DeepSeek-Coder-V2-Instruct-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use RedHatAI/DeepSeek-Coder-V2-Instruct-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RedHatAI/DeepSeek-Coder-V2-Instruct-FP8
- SGLang
How to use RedHatAI/DeepSeek-Coder-V2-Instruct-FP8 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 "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/DeepSeek-Coder-V2-Instruct-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RedHatAI/DeepSeek-Coder-V2-Instruct-FP8 with Docker Model Runner:
docker model run hf.co/RedHatAI/DeepSeek-Coder-V2-Instruct-FP8
Update README.md
Browse files
README.md
CHANGED
|
@@ -42,27 +42,24 @@ Only the weights and activations of the linear operators within transformers blo
|
|
| 42 |
This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
|
| 43 |
|
| 44 |
```python
|
| 45 |
-
from vllm import LLM, SamplingParams
|
| 46 |
from transformers import AutoTokenizer
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
{"role": "
|
| 56 |
-
{"role": "user", "content": "Who are you?"},
|
| 57 |
]
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
llm = LLM(model=model_id, trust_remote_code=True, max_model_len=4096, tensor_parallel_size=4)
|
| 62 |
|
| 63 |
-
outputs = llm.generate(
|
| 64 |
|
| 65 |
-
generated_text =
|
| 66 |
print(generated_text)
|
| 67 |
```
|
| 68 |
|
|
|
|
| 42 |
This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
|
| 43 |
|
| 44 |
```python
|
|
|
|
| 45 |
from transformers import AutoTokenizer
|
| 46 |
+
from vllm import LLM, SamplingParams
|
| 47 |
|
| 48 |
+
max_model_len, tp_size = 4096, 4
|
| 49 |
+
model_name = "neuralmagic/DeepSeek-Coder-V2-Instruct-FP8"
|
| 50 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 51 |
+
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
|
| 52 |
+
sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
|
| 53 |
|
| 54 |
+
messages_list = [
|
| 55 |
+
[{"role": "user", "content": "Who are you? Please respond in pirate speak!"}],
|
|
|
|
| 56 |
]
|
| 57 |
|
| 58 |
+
prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
|
| 61 |
|
| 62 |
+
generated_text = [output.outputs[0].text for output in outputs]
|
| 63 |
print(generated_text)
|
| 64 |
```
|
| 65 |
|