Text Generation
Transformers
PyTorch
code
mpt
custom_code
Eval Results (legacy)
text-generation-inference
Instructions to use replit/replit-code-v1-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use replit/replit-code-v1-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="replit/replit-code-v1-3b", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("replit/replit-code-v1-3b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("replit/replit-code-v1-3b", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use replit/replit-code-v1-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "replit/replit-code-v1-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "replit/replit-code-v1-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/replit/replit-code-v1-3b
- SGLang
How to use replit/replit-code-v1-3b 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 "replit/replit-code-v1-3b" \ --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": "replit/replit-code-v1-3b", "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 "replit/replit-code-v1-3b" \ --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": "replit/replit-code-v1-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use replit/replit-code-v1-3b with Docker Model Runner:
docker model run hf.co/replit/replit-code-v1-3b
Delete low_precision_layernorm.py
Browse files- low_precision_layernorm.py +0 -35
low_precision_layernorm.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
import torch.nn.functional as F
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
class LPLayerNorm(torch.nn.LayerNorm):
|
| 6 |
-
def __init__(self, normalized_shape, eps=1e-05, elementwise_affine=True, device=None, dtype=None):
|
| 7 |
-
super().__init__(
|
| 8 |
-
normalized_shape=normalized_shape,
|
| 9 |
-
eps=eps,
|
| 10 |
-
elementwise_affine=elementwise_affine,
|
| 11 |
-
device=device,
|
| 12 |
-
dtype=dtype,
|
| 13 |
-
)
|
| 14 |
-
|
| 15 |
-
def forward(self, x):
|
| 16 |
-
module_device = x.device
|
| 17 |
-
downcast_x = _cast_if_autocast_enabled(x)
|
| 18 |
-
downcast_weight = _cast_if_autocast_enabled(
|
| 19 |
-
self.weight) if self.weight is not None else self.weight
|
| 20 |
-
downcast_bias = _cast_if_autocast_enabled(
|
| 21 |
-
self.bias) if self.bias is not None else self.bias
|
| 22 |
-
with torch.autocast(enabled=False, device_type=module_device.type):
|
| 23 |
-
return F.layer_norm(downcast_x, self.normalized_shape, downcast_weight, downcast_bias, self.eps)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def _cast_if_autocast_enabled(tensor):
|
| 27 |
-
if torch.is_autocast_enabled():
|
| 28 |
-
if tensor.device.type == 'cuda':
|
| 29 |
-
dtype = torch.get_autocast_gpu_dtype()
|
| 30 |
-
elif tensor.device.type == 'cpu':
|
| 31 |
-
dtype = torch.get_autocast_cpu_dtype()
|
| 32 |
-
else:
|
| 33 |
-
raise NotImplementedError()
|
| 34 |
-
return tensor.to(dtype=dtype)
|
| 35 |
-
return tensor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|