Text Generation
Transformers
Safetensors
qwen2
coder
code
agent
conversational
text-generation-inference
Instructions to use AdminReal/NexusCoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AdminReal/NexusCoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AdminReal/NexusCoder") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AdminReal/NexusCoder") model = AutoModelForCausalLM.from_pretrained("AdminReal/NexusCoder", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AdminReal/NexusCoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AdminReal/NexusCoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdminReal/NexusCoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AdminReal/NexusCoder
- SGLang
How to use AdminReal/NexusCoder 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 "AdminReal/NexusCoder" \ --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": "AdminReal/NexusCoder", "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 "AdminReal/NexusCoder" \ --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": "AdminReal/NexusCoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AdminReal/NexusCoder with Docker Model Runner:
docker model run hf.co/AdminReal/NexusCoder
| """ | |
| Script đánh giá model trên benchmarks | |
| ====================================== | |
| Usage: | |
| python scripts/evaluate.py --model model.pt --benchmarks humaneval,gsm8k | |
| python scripts/evaluate.py --model model.pt --benchmarks all --sample-size 100 | |
| """ | |
| import sys | |
| import os | |
| import argparse | |
| import json | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| import torch | |
| from nexus.config import get_config_by_name | |
| from nexus.model.nexus_coder import NexusCoderForCausalLM | |
| from nexus.tokenizer.tokenizer import NexusTokenizer | |
| from nexus.eval.benchmarks import BenchmarkSuite | |
| from nexus.eval.metrics import compute_perplexity | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Nexus Coder Evaluator") | |
| parser.add_argument("--model", type=str, required=True, help="Path to model checkpoint") | |
| parser.add_argument("--config", type=str, default="large", help="Model config") | |
| parser.add_argument( | |
| "--benchmarks", | |
| type=str, | |
| default="humaneval", | |
| help="Comma-separated benchmark names", | |
| ) | |
| parser.add_argument("--sample-size", type=int, default=None, help="Limit examples per benchmark") | |
| parser.add_argument("--output", type=str, default="./eval_results.json", help="Output file") | |
| args = parser.parse_args() | |
| print("=" * 60) | |
| print(" NEXUS CODER v0.2 - EVALUATION") | |
| print("=" * 60) | |
| # Load model | |
| config = get_config_by_name(args.config) | |
| model = NexusCoderForCausalLM(config) | |
| if os.path.exists(args.model): | |
| checkpoint = torch.load(args.model, map_location="cpu", weights_only=False) | |
| if "model_state_dict" in checkpoint: | |
| model.load_state_dict(checkpoint["model_state_dict"]) | |
| else: | |
| model.load_state_dict(checkpoint) | |
| print(f"✓ Loaded model from {args.model}") | |
| else: | |
| print(f"⚠️ Model file not found, using random init: {args.model}") | |
| # Tokenizer | |
| tokenizer = NexusTokenizer() | |
| # Benchmarks | |
| benchmarks = args.benchmarks.split(",") if args.benchmarks != "all" else None | |
| suite = BenchmarkSuite() | |
| print(f"\n📋 Available benchmarks: {len(suite.list_available())}") | |
| for b in suite.list_available(): | |
| print(f" - {b.name}: {b.description}") | |
| print(f"\n🏃 Running benchmarks: {benchmarks or 'all'}") | |
| results = suite.run(model, tokenizer, benchmarks=benchmarks, sample_size=args.sample_size) | |
| # Save results | |
| with open(args.output, "w", encoding="utf-8") as f: | |
| json.dump(results, f, indent=2, ensure_ascii=False, default=str) | |
| print(f"\n📊 Results:") | |
| print(suite.summary()) | |
| print(f"\n💾 Saved to: {args.output}") | |
| if __name__ == "__main__": | |
| main() | |