Instructions to use CodyBontecou/llada-8b-instruct-duplicate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CodyBontecou/llada-8b-instruct-duplicate with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CodyBontecou/llada-8b-instruct-duplicate", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("CodyBontecou/llada-8b-instruct-duplicate", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use CodyBontecou/llada-8b-instruct-duplicate with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CodyBontecou/llada-8b-instruct-duplicate" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CodyBontecou/llada-8b-instruct-duplicate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CodyBontecou/llada-8b-instruct-duplicate
- SGLang
How to use CodyBontecou/llada-8b-instruct-duplicate 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 "CodyBontecou/llada-8b-instruct-duplicate" \ --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": "CodyBontecou/llada-8b-instruct-duplicate", "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 "CodyBontecou/llada-8b-instruct-duplicate" \ --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": "CodyBontecou/llada-8b-instruct-duplicate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CodyBontecou/llada-8b-instruct-duplicate with Docker Model Runner:
docker model run hf.co/CodyBontecou/llada-8b-instruct-duplicate
Commit ·
b38d2da
1
Parent(s): d19a591
output serialization
Browse files- handler.py +8 -3
handler.py
CHANGED
|
@@ -36,9 +36,14 @@ class EndpointHandler:
|
|
| 36 |
with torch.no_grad():
|
| 37 |
outputs = self.model(**inputs)
|
| 38 |
|
| 39 |
-
# Process outputs -
|
| 40 |
-
#
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
|
|
|
| 36 |
with torch.no_grad():
|
| 37 |
outputs = self.model(**inputs)
|
| 38 |
|
| 39 |
+
# Process outputs - convert tensors to serializable format
|
| 40 |
+
# Extract the last hidden state and convert to list for JSON serialization
|
| 41 |
+
last_hidden_state = outputs.last_hidden_state
|
| 42 |
+
|
| 43 |
+
# Convert to Python list (serializable) - using the mean of the embeddings as a simple approach
|
| 44 |
+
embedding = last_hidden_state.mean(dim=1).cpu().numpy().tolist()
|
| 45 |
+
|
| 46 |
+
return [{"input_text": input_text, "embedding": embedding}]
|
| 47 |
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|