Instructions to use Deci/DeciLM-7B-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Deci/DeciLM-7B-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Deci/DeciLM-7B-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Deci/DeciLM-7B-instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Deci/DeciLM-7B-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Deci/DeciLM-7B-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Deci/DeciLM-7B-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Deci/DeciLM-7B-instruct
- SGLang
How to use Deci/DeciLM-7B-instruct 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 "Deci/DeciLM-7B-instruct" \ --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": "Deci/DeciLM-7B-instruct", "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 "Deci/DeciLM-7B-instruct" \ --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": "Deci/DeciLM-7B-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Deci/DeciLM-7B-instruct with Docker Model Runner:
docker model run hf.co/Deci/DeciLM-7B-instruct
Commit ·
1fb44f8
1
Parent(s): b0b6c53
Update README.md
Browse files
README.md
CHANGED
|
@@ -43,19 +43,41 @@ The model is intended for commercial and research use in English.
|
|
| 43 |
|
| 44 |
Use the code below to get started with the model.
|
| 45 |
|
| 46 |
-
```
|
| 47 |
import torch
|
| 48 |
-
from transformers import AutoModelForCausalLM,
|
| 49 |
|
| 50 |
model_name = "Deci/DeciLM-7B-instruct"
|
|
|
|
| 51 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
```
|
| 60 |
|
| 61 |
## Evaluation
|
|
|
|
| 43 |
|
| 44 |
Use the code below to get started with the model.
|
| 45 |
|
| 46 |
+
```python
|
| 47 |
import torch
|
| 48 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
|
| 49 |
|
| 50 |
model_name = "Deci/DeciLM-7B-instruct"
|
| 51 |
+
|
| 52 |
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
| 53 |
|
| 54 |
+
bnb_config = BitsAndBytesConfig(
|
| 55 |
+
load_in_4bit = True,
|
| 56 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
| 57 |
+
)
|
| 58 |
|
| 59 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 60 |
+
model_name,
|
| 61 |
+
device_map="auto",
|
| 62 |
+
trust_remote_code=True,
|
| 63 |
+
quantization_config=bnb_config
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 67 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 68 |
+
|
| 69 |
+
deci_generator = pipeline("text-generation",
|
| 70 |
+
model=model,
|
| 71 |
+
tokenizer=tokenizer,
|
| 72 |
+
temperature=0.1,
|
| 73 |
+
device_map="auto",
|
| 74 |
+
max_length=4096,
|
| 75 |
+
return_full_text=False
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
prompt = "How do I make the most delicious pancakes the world has ever tasted?"
|
| 79 |
+
response = deci_generator(prompt)[0]['generated_text']
|
| 80 |
+
print(response)
|
| 81 |
```
|
| 82 |
|
| 83 |
## Evaluation
|