Text Generation
Transformers
PyTorch
PEFT
English
llama
decapoda-research-7b-hf
prompt answering
text-generation-inference
8-bit precision
Instructions to use Sandiago21/llama-7b-hf-prompt-answering with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sandiago21/llama-7b-hf-prompt-answering with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sandiago21/llama-7b-hf-prompt-answering")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sandiago21/llama-7b-hf-prompt-answering") model = AutoModelForCausalLM.from_pretrained("Sandiago21/llama-7b-hf-prompt-answering", device_map="auto") - PEFT
How to use Sandiago21/llama-7b-hf-prompt-answering with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Sandiago21/llama-7b-hf-prompt-answering with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sandiago21/llama-7b-hf-prompt-answering" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sandiago21/llama-7b-hf-prompt-answering", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sandiago21/llama-7b-hf-prompt-answering
- SGLang
How to use Sandiago21/llama-7b-hf-prompt-answering 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 "Sandiago21/llama-7b-hf-prompt-answering" \ --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": "Sandiago21/llama-7b-hf-prompt-answering", "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 "Sandiago21/llama-7b-hf-prompt-answering" \ --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": "Sandiago21/llama-7b-hf-prompt-answering", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Sandiago21/llama-7b-hf-prompt-answering with Docker Model Runner:
docker model run hf.co/Sandiago21/llama-7b-hf-prompt-answering
Commit ·
af3e171
1
Parent(s): f45f66c
Update README.md
Browse files
README.md
CHANGED
|
@@ -96,7 +96,7 @@ def generate_prompt(instruction: str, input_ctxt: str = None) -> str:
|
|
| 96 |
|
| 97 |
Use the code below to get started with the model.
|
| 98 |
|
| 99 |
-
1. You can
|
| 100 |
|
| 101 |
```python
|
| 102 |
import torch
|
|
@@ -104,12 +104,14 @@ from peft import PeftConfig, PeftModel
|
|
| 104 |
from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM
|
| 105 |
|
| 106 |
MODEL_NAME = "Sandiago21/llama-7b-hf-prompt-answering"
|
| 107 |
-
BASE_MODEL = "decapoda-research/llama-7b-hf"
|
| 108 |
|
| 109 |
config = PeftConfig.from_pretrained(MODEL_NAME)
|
| 110 |
|
|
|
|
|
|
|
|
|
|
| 111 |
model = LlamaForCausalLM.from_pretrained(
|
| 112 |
-
|
| 113 |
load_in_8bit=True,
|
| 114 |
torch_dtype=torch.float16,
|
| 115 |
device_map="auto",
|
|
@@ -133,7 +135,6 @@ if torch.__version__ >= "2":
|
|
| 133 |
```
|
| 134 |
|
| 135 |
### Example of Usage
|
| 136 |
-
|
| 137 |
```python
|
| 138 |
instruction = "What is the capital city of Greece and with which countries does Greece border?"
|
| 139 |
input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.
|
|
@@ -156,7 +157,7 @@ print(response)
|
|
| 156 |
>>> The capital city of Greece is Athens and it borders Turkey, Bulgaria, Macedonia, Albania, and the Aegean Sea.
|
| 157 |
```
|
| 158 |
|
| 159 |
-
2. You can
|
| 160 |
|
| 161 |
```python
|
| 162 |
import torch
|
|
@@ -164,11 +165,12 @@ from peft import PeftConfig, PeftModel
|
|
| 164 |
from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM
|
| 165 |
|
| 166 |
MODEL_NAME = "Sandiago21/llama-7b-hf-prompt-answering"
|
|
|
|
| 167 |
|
| 168 |
config = PeftConfig.from_pretrained(MODEL_NAME)
|
| 169 |
|
| 170 |
model = LlamaForCausalLM.from_pretrained(
|
| 171 |
-
|
| 172 |
load_in_8bit=True,
|
| 173 |
torch_dtype=torch.float16,
|
| 174 |
device_map="auto",
|
|
@@ -192,6 +194,7 @@ if torch.__version__ >= "2":
|
|
| 192 |
```
|
| 193 |
|
| 194 |
### Example of Usage
|
|
|
|
| 195 |
```python
|
| 196 |
instruction = "What is the capital city of Greece and with which countries does Greece border?"
|
| 197 |
input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.
|
|
@@ -214,6 +217,7 @@ print(response)
|
|
| 214 |
>>> The capital city of Greece is Athens and it borders Turkey, Bulgaria, Macedonia, Albania, and the Aegean Sea.
|
| 215 |
```
|
| 216 |
|
|
|
|
| 217 |
## Training Details
|
| 218 |
|
| 219 |
## Training procedure
|
|
|
|
| 96 |
|
| 97 |
Use the code below to get started with the model.
|
| 98 |
|
| 99 |
+
1. You can git clone the repo, which contains also the artifacts for the base model for simplicity and completeness, and run the following code snippet to load the mode:
|
| 100 |
|
| 101 |
```python
|
| 102 |
import torch
|
|
|
|
| 104 |
from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM
|
| 105 |
|
| 106 |
MODEL_NAME = "Sandiago21/llama-7b-hf-prompt-answering"
|
|
|
|
| 107 |
|
| 108 |
config = PeftConfig.from_pretrained(MODEL_NAME)
|
| 109 |
|
| 110 |
+
# Setting the path to look at your repo directory, assuming that you are at that directory when running this script
|
| 111 |
+
config.base_model_name_or_path = "decapoda-research/llama-7b-hf/"
|
| 112 |
+
|
| 113 |
model = LlamaForCausalLM.from_pretrained(
|
| 114 |
+
config.base_model_name_or_path,
|
| 115 |
load_in_8bit=True,
|
| 116 |
torch_dtype=torch.float16,
|
| 117 |
device_map="auto",
|
|
|
|
| 135 |
```
|
| 136 |
|
| 137 |
### Example of Usage
|
|
|
|
| 138 |
```python
|
| 139 |
instruction = "What is the capital city of Greece and with which countries does Greece border?"
|
| 140 |
input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.
|
|
|
|
| 157 |
>>> The capital city of Greece is Athens and it borders Turkey, Bulgaria, Macedonia, Albania, and the Aegean Sea.
|
| 158 |
```
|
| 159 |
|
| 160 |
+
2. You can directly call the model from HuggingFace using the following code snippet:
|
| 161 |
|
| 162 |
```python
|
| 163 |
import torch
|
|
|
|
| 165 |
from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM
|
| 166 |
|
| 167 |
MODEL_NAME = "Sandiago21/llama-7b-hf-prompt-answering"
|
| 168 |
+
BASE_MODEL = "decapoda-research/llama-7b-hf"
|
| 169 |
|
| 170 |
config = PeftConfig.from_pretrained(MODEL_NAME)
|
| 171 |
|
| 172 |
model = LlamaForCausalLM.from_pretrained(
|
| 173 |
+
BASE_MODEL,
|
| 174 |
load_in_8bit=True,
|
| 175 |
torch_dtype=torch.float16,
|
| 176 |
device_map="auto",
|
|
|
|
| 194 |
```
|
| 195 |
|
| 196 |
### Example of Usage
|
| 197 |
+
|
| 198 |
```python
|
| 199 |
instruction = "What is the capital city of Greece and with which countries does Greece border?"
|
| 200 |
input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.
|
|
|
|
| 217 |
>>> The capital city of Greece is Athens and it borders Turkey, Bulgaria, Macedonia, Albania, and the Aegean Sea.
|
| 218 |
```
|
| 219 |
|
| 220 |
+
|
| 221 |
## Training Details
|
| 222 |
|
| 223 |
## Training procedure
|