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
Download nexus/skills/code_explanation.py from AdminReal/NexusCoder: direct link, hf CLI and curl.
- Browser
- Download file 6.57 kB
-
https://huggingface.co/AdminReal/NexusCoder/resolve/main/nexus/skills/code_explanation.py
- Command line
-
hf download hf://AdminReal/NexusCoder/nexus/skills/code_explanation.py
-
curl -L -o code_explanation.py https://huggingface.co/AdminReal/NexusCoder/resolve/main/nexus/skills/code_explanation.py
6.57 kB
| """Code Explanation Skill - Giải thích code từng bước. | |
| Framework explain: mục đích, interface, luồng điều khiển, dữ liệu, | |
| edge cases, độ phức tạp, và potential pitfalls. | |
| Author: Hieu Louis (2026) | |
| """ | |
| from __future__ import annotations | |
| from typing import Dict, List | |
| from .base import Skill, SkillContext, SkillCategory, SkillPriority, SkillResult | |
| class CodeExplanationSkill(Skill): | |
| """Giải thích code tự nhiên từng bước cho developer.""" | |
| category = SkillCategory.CODE | |
| priority = SkillPriority.MEDIUM | |
| keywords: List[str] = [ | |
| "explain", "giải thích", "what does this code", "walk through", | |
| "walk me through", "describe code", "how does this work", | |
| "hiểu code", "phân tích code", "break down", | |
| "what is this function doing", "comment code", | |
| ] | |
| examples = [ | |
| "Explain this Python decorator step by step", | |
| "What does this recursive function do?", | |
| "Walk me through this SQL query", | |
| ] | |
| def name(self) -> str: | |
| return "code_explanation" | |
| def description(self) -> str: | |
| return ( | |
| "Giải thích code tự nhiên: mục đích, luồng điều khiển, " | |
| "biến đổi dữ liệu, edge cases, độ phức tạp, và pitfalls." | |
| ) | |
| def can_handle(self, prompt: str, context: SkillContext = None) -> float: | |
| prompt_lower = prompt.lower() | |
| score = 0.0 | |
| for kw in self.keywords: | |
| if kw in prompt_lower: | |
| score += 0.15 | |
| if "```" in prompt or "def " in prompt or "function " in prompt: | |
| score += 0.2 | |
| return min(1.0, score) | |
| def execute(self, context: SkillContext) -> SkillResult: | |
| return SkillResult( | |
| success=True, | |
| output="[CodeExplanation] Step-by-step explanation framework ready.", | |
| artifacts=[ | |
| {"path": "explanation/framework.md", "content": _EXPLANATION_FRAMEWORK}, | |
| {"path": "explanation/example.md", "content": _EXAMPLE_EXPLANATION}, | |
| ], | |
| metadata={ | |
| "skill": self.name, | |
| "explanation_levels": [ | |
| "ELI5 (giải thích như mới học code)", | |
| "junior dev (giải thích từng dòng)", | |
| "senior dev (focus kiến trúc + trade-offs)", | |
| "expert (focus correctness + perf characteristics)", | |
| ], | |
| "framework_steps": [ | |
| "1. One-sentence summary (mục đích)", | |
| "2. Inputs / outputs / side effects", | |
| "3. Step-by-step walkthrough (line hoặc block)", | |
| "4. Data flow diagram (text-based)", | |
| "5. Edge cases & error handling", | |
| "6. Time/space complexity", | |
| "7. Pitfalls / code smells / suggestions", | |
| ], | |
| "diagram_styles": ["ascii", "mermaid sequence", "mermaid flowchart"], | |
| "audience_tuning": { | |
| "eli5": "Use analogies, no jargon, 1 concept per paragraph", | |
| "junior": "Explain syntax, link to docs, define jargon", | |
| "senior": "Skip basics, focus on architecture & trade-offs", | |
| "expert": "Focus on correctness, perf, alternatives", | |
| }, | |
| }, | |
| suggestions=[ | |
| "Specify audience level (ELI5 / junior / senior / expert)", | |
| "Provide code in fenced block for accurate line references", | |
| "Ask for specific aspect (complexity, correctness, security)", | |
| ], | |
| ) | |
| _EXPLANATION_FRAMEWORK = """# Code Explanation Framework | |
| ## Level 0: One-Sentence Summary | |
| > "This code does X by Y." | |
| ## Level 1: Interface Contract | |
| - **Inputs**: parameters, types, constraints | |
| - **Outputs**: return type, side effects, exceptions | |
| - **Preconditions**: what must be true before calling | |
| - **Postconditions**: what is guaranteed after return | |
| ## Level 2: Step-by-Step Walkthrough | |
| For each block: | |
| 1. **What** is being done (one sentence) | |
| 2. **Why** it's done this way (motivation) | |
| 3. **How** it interacts with prior/next blocks | |
| ## Level 3: Data Flow | |
| ``` | |
| input -> [transform 1] -> [filter] -> [aggregate] -> output | |
| ``` | |
| ## Level 4: Edge Cases & Error Handling | |
| - Null / undefined / empty inputs | |
| - Boundary conditions (0, 1, max_int, negative) | |
| - Concurrency / reentrancy | |
| - Resource exhaustion (memory, file handles) | |
| ## Level 5: Complexity | |
| - Time: O(?) - best / average / worst | |
| - Space: O(?) - auxiliary vs total | |
| - Practical: cache misses, branch prediction | |
| ## Level 6: Pitfalls & Suggestions | |
| - Code smells (long method, deep nesting, magic numbers) | |
| - Common bugs (off-by-one, race conditions) | |
| - Refactor opportunities (extract method, replace conditional with polymorphism) | |
| """ | |
| _EXAMPLE_EXPLANATION = '''# Example Explanation: Binary Search | |
| ## Code | |
| ```python | |
| def binary_search(arr: list[int], target: int) -> int: | |
| lo, hi = 0, len(arr) - 1 | |
| while lo <= hi: | |
| mid = (lo + hi) // 2 | |
| if arr[mid] == target: | |
| return mid | |
| elif arr[mid] < target: | |
| lo = mid + 1 | |
| else: | |
| hi = mid - 1 | |
| return -1 | |
| ``` | |
| ## Summary | |
| Binary search finds `target` in `arr` (already sorted ascending), returning its index or -1. | |
| ## Interface | |
| - **Inputs**: sorted list `arr`, int `target` | |
| - **Output**: index of `target` in `arr`, or -1 if not found | |
| - **Precondition**: `arr` sorted ascending | |
| - **Postcondition**: returned index i satisfies `arr[i] == target`, or i == -1 | |
| ## Walkthrough | |
| 1. `lo=0, hi=len(arr)-1`: initialize search bounds. | |
| 2. `while lo <= hi`: loop until search space empty. | |
| 3. `mid = (lo + hi) // 2`: pick middle index. | |
| - Note: risk of overflow in C — Python ints are arbitrary precision so safe. | |
| 4. `arr[mid] == target`: hit, return `mid`. | |
| 5. `arr[mid] < target`: target in right half, move `lo` past `mid`. | |
| 6. `arr[mid] > target`: target in left half, move `hi` before `mid`. | |
| 7. `return -1`: search space exhausted, not found. | |
| ## Complexity | |
| - Time: O(log n) - halve search space each iteration. | |
| - Space: O(1) - only three variables. | |
| ## Pitfalls | |
| - Integer overflow in `mid = (lo + hi) // 2` in C/Java. Use `lo + (hi - lo) // 2`. | |
| - Input MUST be sorted; precondition not enforced. | |
| - Returns first-found index, not necessarily the leftmost duplicate. | |
| ## Suggestions | |
| - Add `is_sorted` assertion for debug builds. | |
| - Use `bisect_left` from stdlib for leftmost match. | |
| ''' | |