Text Generation
Transformers
Safetensors
PyTorch
English
code
gpt2
code-generation
python
javascript
coding
programming
sagemaker
amazon-sagemaker
cpu
compact
efficient
nvdya-kit
death-legion
vllm
sglang
llama-cpp
ollama
lm-studio
year-2026
next-gen
text-generation-inference
Instructions to use dineth554/legion-coder-8m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dineth554/legion-coder-8m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dineth554/legion-coder-8m")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dineth554/legion-coder-8m") model = AutoModelForCausalLM.from_pretrained("dineth554/legion-coder-8m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dineth554/legion-coder-8m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dineth554/legion-coder-8m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dineth554/legion-coder-8m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/dineth554/legion-coder-8m
- SGLang
How to use dineth554/legion-coder-8m 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 "dineth554/legion-coder-8m" \ --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": "dineth554/legion-coder-8m", "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 "dineth554/legion-coder-8m" \ --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": "dineth554/legion-coder-8m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use dineth554/legion-coder-8m with Docker Model Runner:
docker model run hf.co/dineth554/legion-coder-8m
| """ | |
| Amazon SageMaker Deployment Script for Legion Coder 8M | |
| This script demonstrates how to deploy the Legion Coder model to Amazon SageMaker | |
| for production inference. | |
| Requirements: | |
| pip install sagemaker boto3 | |
| Usage: | |
| python sagemaker_deploy.py | |
| """ | |
| import sagemaker | |
| from sagemaker.huggingface import HuggingFaceModel | |
| import boto3 | |
| # Configuration | |
| ROLE_ARN = "arn:aws:iam::YOUR_ACCOUNT_ID:role/YOUR_SAGEMAKER_ROLE" | |
| MODEL_ID = "dineth554/legion-coder-8m" | |
| INSTANCE_TYPE = "ml.m5.large" | |
| INSTANCE_COUNT = 1 | |
| def deploy_to_sagemaker(): | |
| """ | |
| Deploy Legion Coder 8M to Amazon SageMaker. | |
| This creates a SageMaker endpoint with the model ready for inference. | |
| """ | |
| # Initialize SageMaker session | |
| sess = sagemaker.Session() | |
| # Create Hugging Face Model | |
| huggingface_model = HuggingFaceModel( | |
| model_data=f"https://huggingface.co/{MODEL_ID}/resolve/main/model.safetensors", | |
| transformers_version="4.36.0", | |
| pytorch_version="2.1.0", | |
| py_version="py310", | |
| role=ROLE_ARN, | |
| sagemaker_session=sess, | |
| env={ | |
| "HF_MODEL_ID": MODEL_ID, | |
| "HF_TASK": "text-generation", | |
| "SAGEMAKER_CONTAINER_LOG_LEVEL": "20", | |
| "SAGEMAKER_PROGRAM": "inference.py" | |
| } | |
| ) | |
| # Deploy to SageMaker | |
| predictor = huggingface_model.deploy( | |
| initial_instance_count=INSTANCE_COUNT, | |
| instance_type=INSTANCE_TYPE, | |
| endpoint_name="legion-coder-8m-endpoint" | |
| ) | |
| print(f"Model deployed successfully!") | |
| print(f"Endpoint name: legion-coder-8m-endpoint") | |
| print(f"Instance type: {INSTANCE_TYPE}") | |
| return predictor | |
| def test_endpoint(predictor): | |
| """ | |
| Test the deployed endpoint with a sample prompt. | |
| """ | |
| test_payload = { | |
| "inputs": "Write a Python function to calculate fibonacci numbers:", | |
| "parameters": { | |
| "temperature": 0.8, | |
| "top_p": 0.95, | |
| "top_k": 50, | |
| "max_new_tokens": 200 | |
| } | |
| } | |
| response = predictor.predict(test_payload) | |
| print("Test response:", response) | |
| return response | |
| def cleanup_endpoint(predictor): | |
| """ | |
| Clean up the SageMaker endpoint when done. | |
| """ | |
| predictor.delete_endpoint() | |
| print("Endpoint deleted successfully.") | |
| if __name__ == "__main__": | |
| # Deploy the model | |
| print("Deploying Legion Coder 8M to SageMaker...") | |
| predictor = deploy_to_sagemaker() | |
| # Test the endpoint | |
| print("\nTesting endpoint...") | |
| test_endpoint(predictor) | |
| # Uncomment to clean up | |
| # cleanup_endpoint(predictor) | |