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, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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
| from typing import Any, Dict | |
| from transformers import AutoTokenizer, AutoModel | |
| import torch | |
| import logging | |
| # Initialize logger | |
| logger = logging.getLogger(__name__) | |
| logging.basicConfig(level=logging.INFO) | |
| class EndpointHandler: | |
| def __init__(self, model_dir: str, **kwargs: Any) -> None: | |
| self.model = AutoModel.from_pretrained( | |
| model_dir, | |
| torch_dtype=torch.bfloat16, | |
| trust_remote_code=True, | |
| ).eval() | |
| self.tokenizer = AutoTokenizer.from_pretrained( | |
| model_dir, trust_remote_code=True, use_fast=False | |
| ) | |
| def __call__(self, data: Dict[str, Any]) -> Any: | |
| logger.info(f"Received incoming request with {data}") | |
| # Extract input text from the request data | |
| input_text = data.get("inputs", "") | |
| if not input_text: | |
| logger.warning("No input text provided") | |
| return [{"generated_text": ""}] # Return empty result but in valid format | |
| # Tokenize the input | |
| inputs = self.tokenizer(input_text, return_tensors="pt").to(self.model.device) | |
| # Generate embeddings | |
| with torch.no_grad(): | |
| outputs = self.model(**inputs) | |
| # Process outputs - convert tensors to serializable format | |
| # Extract the last hidden state and convert to list for JSON serialization | |
| last_hidden_state = outputs.last_hidden_state | |
| # Convert to Python list (serializable) - using the mean of the embeddings as a simple approach | |
| embedding = last_hidden_state.mean(dim=1).cpu().numpy().tolist() | |
| return [{"input_text": input_text, "embedding": embedding}] | |
| if __name__ == "__main__": | |
| handler = EndpointHandler(model_dir="GSAI-ML/LLaDA-8B-Instruct") | |