Text Generation
Transformers
PyTorch
Core ML
English
RefinedWebModel
custom_code
text-generation-inference
Instructions to use pcuenq/falcon-7b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pcuenq/falcon-7b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pcuenq/falcon-7b-instruct", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("pcuenq/falcon-7b-instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pcuenq/falcon-7b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pcuenq/falcon-7b-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pcuenq/falcon-7b-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pcuenq/falcon-7b-instruct
- SGLang
How to use pcuenq/falcon-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 "pcuenq/falcon-7b-instruct" \ --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": "pcuenq/falcon-7b-instruct", "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 "pcuenq/falcon-7b-instruct" \ --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": "pcuenq/falcon-7b-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use pcuenq/falcon-7b-instruct with Docker Model Runner:
docker model run hf.co/pcuenq/falcon-7b-instruct
Changes for Core ML conversion
Browse files- modelling_RW.py +3 -3
modelling_RW.py
CHANGED
|
@@ -29,7 +29,7 @@ logger = logging.get_logger(__name__)
|
|
| 29 |
# In order not to degrade the quality of our HF-port, we keep these characteristics in the final model.
|
| 30 |
class Linear(nn.Linear):
|
| 31 |
def forward(self, input: torch.Tensor) -> torch.Tensor:
|
| 32 |
-
ret = input @ self.weight.T
|
| 33 |
if self.bias is None:
|
| 34 |
return ret
|
| 35 |
else:
|
|
@@ -68,7 +68,7 @@ class RotaryEmbedding(torch.nn.Module):
|
|
| 68 |
self,
|
| 69 |
seq_len: int,
|
| 70 |
device="cuda",
|
| 71 |
-
dtype=torch.
|
| 72 |
) -> torch.Tensor:
|
| 73 |
if seq_len != self.seq_len_cached:
|
| 74 |
self.seq_len_cached = seq_len
|
|
@@ -89,7 +89,7 @@ class RotaryEmbedding(torch.nn.Module):
|
|
| 89 |
|
| 90 |
def forward(self, q, k):
|
| 91 |
batch, seq_len, head_dim = q.shape
|
| 92 |
-
cos, sin = self.cos_sin(seq_len, q.device
|
| 93 |
return (q * cos) + (rotate_half(q) * sin), (k * cos) + (rotate_half(k) * sin)
|
| 94 |
|
| 95 |
|
|
|
|
| 29 |
# In order not to degrade the quality of our HF-port, we keep these characteristics in the final model.
|
| 30 |
class Linear(nn.Linear):
|
| 31 |
def forward(self, input: torch.Tensor) -> torch.Tensor:
|
| 32 |
+
ret = input @ self.weight.permute(1, 0) #transpose(0, 1) #.T
|
| 33 |
if self.bias is None:
|
| 34 |
return ret
|
| 35 |
else:
|
|
|
|
| 68 |
self,
|
| 69 |
seq_len: int,
|
| 70 |
device="cuda",
|
| 71 |
+
dtype=torch.float16,
|
| 72 |
) -> torch.Tensor:
|
| 73 |
if seq_len != self.seq_len_cached:
|
| 74 |
self.seq_len_cached = seq_len
|
|
|
|
| 89 |
|
| 90 |
def forward(self, q, k):
|
| 91 |
batch, seq_len, head_dim = q.shape
|
| 92 |
+
cos, sin = self.cos_sin(seq_len, q.device)
|
| 93 |
return (q * cos) + (rotate_half(q) * sin), (k * cos) + (rotate_half(k) * sin)
|
| 94 |
|
| 95 |
|