Text Generation
Transformers
Safetensors
GGUF
English
qwen
qwen2.5
3b
lora
coding
code
software-engineering
conversational
Instructions to use teolm30/Ult1-coding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use teolm30/Ult1-coding with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="teolm30/Ult1-coding") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("teolm30/Ult1-coding", device_map="auto") - llama-cpp-python
How to use teolm30/Ult1-coding with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="teolm30/Ult1-coding", filename="Ult1-Coding-Q8_0.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use teolm30/Ult1-coding with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf teolm30/Ult1-coding:Q8_0 # Run inference directly in the terminal: llama cli -hf teolm30/Ult1-coding:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf teolm30/Ult1-coding:Q8_0 # Run inference directly in the terminal: llama cli -hf teolm30/Ult1-coding:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf teolm30/Ult1-coding:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf teolm30/Ult1-coding:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf teolm30/Ult1-coding:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf teolm30/Ult1-coding:Q8_0
Use Docker
docker model run hf.co/teolm30/Ult1-coding:Q8_0
- LM Studio
- Jan
- vLLM
How to use teolm30/Ult1-coding with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "teolm30/Ult1-coding" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "teolm30/Ult1-coding", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/teolm30/Ult1-coding:Q8_0
- SGLang
How to use teolm30/Ult1-coding 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 "teolm30/Ult1-coding" \ --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": "teolm30/Ult1-coding", "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 "teolm30/Ult1-coding" \ --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": "teolm30/Ult1-coding", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use teolm30/Ult1-coding with Ollama:
ollama run hf.co/teolm30/Ult1-coding:Q8_0
- Unsloth Studio
How to use teolm30/Ult1-coding with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for teolm30/Ult1-coding to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for teolm30/Ult1-coding to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for teolm30/Ult1-coding to start chatting
- Pi
How to use teolm30/Ult1-coding with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf teolm30/Ult1-coding:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "teolm30/Ult1-coding:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use teolm30/Ult1-coding with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf teolm30/Ult1-coding:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default teolm30/Ult1-coding:Q8_0
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use teolm30/Ult1-coding with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf teolm30/Ult1-coding:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "teolm30/Ult1-coding:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use teolm30/Ult1-coding with Docker Model Runner:
docker model run hf.co/teolm30/Ult1-coding:Q8_0
- Lemonade
How to use teolm30/Ult1-coding with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull teolm30/Ult1-coding:Q8_0
Run and chat with the model
lemonade run user.Ult1-coding-Q8_0
List all available models
lemonade list
Ult1-Coding v2 - enhanced prompt, few-shot, training data
Browse files- README.md +190 -30
- adapter_config.json +6 -3
- adapter_model.safetensors +2 -2
- chat_template.jinja +2 -1
- few_shot_examples.json +18 -0
- system_prompt.txt +23 -1
- training_data.json +42 -0
README.md
CHANGED
|
@@ -1,47 +1,207 @@
|
|
| 1 |
---
|
| 2 |
-
language: en
|
| 3 |
-
library_name: transformers
|
| 4 |
base_model: Qwen/Qwen2.5-3B-Instruct
|
|
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
| 7 |
-
-
|
| 8 |
-
- qwen2.5
|
| 9 |
-
- 3b
|
| 10 |
- lora
|
| 11 |
-
-
|
| 12 |
-
- code
|
| 13 |
-
- software-engineering
|
| 14 |
-
license: apache-2.0
|
| 15 |
---
|
| 16 |
|
| 17 |
-
#
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
Based on Qwen2.5-3B-Instruct with an embedded **master programmer** system prompt and coding-focused LoRA adapter.
|
| 22 |
|
| 23 |
-
## Usage
|
| 24 |
|
| 25 |
-
|
| 26 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 27 |
|
| 28 |
-
|
| 29 |
-
tokenizer = AutoTokenizer.from_pretrained("teolm30/Ult1-coding")
|
| 30 |
|
| 31 |
-
|
| 32 |
-
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 33 |
-
inputs = tokenizer(text, return_tensors="pt")
|
| 34 |
-
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 35 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 36 |
-
```
|
| 37 |
|
| 38 |
-
## GGUF
|
| 39 |
|
| 40 |
-
Download `Ult1-Coding-Q8_0.gguf` for CPU inference with llama.cpp.
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
base_model: Qwen/Qwen2.5-3B-Instruct
|
| 3 |
+
library_name: peft
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen2.5-3B-Instruct
|
|
|
|
|
|
|
| 7 |
- lora
|
| 8 |
+
- transformers
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Model Card for Model ID
|
| 12 |
|
| 13 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 14 |
|
|
|
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
+
## Model Details
|
|
|
|
| 18 |
|
| 19 |
+
### Model Description
|
|
|
|
| 20 |
|
| 21 |
+
<!-- Provide a longer summary of what this model is. -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
| 23 |
|
|
|
|
| 24 |
|
| 25 |
+
- **Developed by:** [More Information Needed]
|
| 26 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 27 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 28 |
+
- **Model type:** [More Information Needed]
|
| 29 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 30 |
+
- **License:** [More Information Needed]
|
| 31 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 32 |
|
| 33 |
+
### Model Sources [optional]
|
| 34 |
+
|
| 35 |
+
<!-- Provide the basic links for the model. -->
|
| 36 |
+
|
| 37 |
+
- **Repository:** [More Information Needed]
|
| 38 |
+
- **Paper [optional]:** [More Information Needed]
|
| 39 |
+
- **Demo [optional]:** [More Information Needed]
|
| 40 |
+
|
| 41 |
+
## Uses
|
| 42 |
+
|
| 43 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 44 |
+
|
| 45 |
+
### Direct Use
|
| 46 |
+
|
| 47 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 48 |
+
|
| 49 |
+
[More Information Needed]
|
| 50 |
+
|
| 51 |
+
### Downstream Use [optional]
|
| 52 |
+
|
| 53 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 54 |
+
|
| 55 |
+
[More Information Needed]
|
| 56 |
+
|
| 57 |
+
### Out-of-Scope Use
|
| 58 |
+
|
| 59 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 60 |
+
|
| 61 |
+
[More Information Needed]
|
| 62 |
+
|
| 63 |
+
## Bias, Risks, and Limitations
|
| 64 |
+
|
| 65 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 66 |
+
|
| 67 |
+
[More Information Needed]
|
| 68 |
+
|
| 69 |
+
### Recommendations
|
| 70 |
+
|
| 71 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 72 |
+
|
| 73 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 74 |
+
|
| 75 |
+
## How to Get Started with the Model
|
| 76 |
+
|
| 77 |
+
Use the code below to get started with the model.
|
| 78 |
+
|
| 79 |
+
[More Information Needed]
|
| 80 |
+
|
| 81 |
+
## Training Details
|
| 82 |
+
|
| 83 |
+
### Training Data
|
| 84 |
+
|
| 85 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 86 |
+
|
| 87 |
+
[More Information Needed]
|
| 88 |
+
|
| 89 |
+
### Training Procedure
|
| 90 |
+
|
| 91 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 92 |
+
|
| 93 |
+
#### Preprocessing [optional]
|
| 94 |
+
|
| 95 |
+
[More Information Needed]
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
#### Training Hyperparameters
|
| 99 |
+
|
| 100 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 101 |
+
|
| 102 |
+
#### Speeds, Sizes, Times [optional]
|
| 103 |
+
|
| 104 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 105 |
+
|
| 106 |
+
[More Information Needed]
|
| 107 |
+
|
| 108 |
+
## Evaluation
|
| 109 |
+
|
| 110 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 111 |
+
|
| 112 |
+
### Testing Data, Factors & Metrics
|
| 113 |
+
|
| 114 |
+
#### Testing Data
|
| 115 |
+
|
| 116 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 117 |
+
|
| 118 |
+
[More Information Needed]
|
| 119 |
+
|
| 120 |
+
#### Factors
|
| 121 |
+
|
| 122 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 123 |
+
|
| 124 |
+
[More Information Needed]
|
| 125 |
+
|
| 126 |
+
#### Metrics
|
| 127 |
+
|
| 128 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 129 |
+
|
| 130 |
+
[More Information Needed]
|
| 131 |
+
|
| 132 |
+
### Results
|
| 133 |
+
|
| 134 |
+
[More Information Needed]
|
| 135 |
+
|
| 136 |
+
#### Summary
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
## Model Examination [optional]
|
| 141 |
+
|
| 142 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 143 |
+
|
| 144 |
+
[More Information Needed]
|
| 145 |
+
|
| 146 |
+
## Environmental Impact
|
| 147 |
+
|
| 148 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 149 |
+
|
| 150 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 151 |
+
|
| 152 |
+
- **Hardware Type:** [More Information Needed]
|
| 153 |
+
- **Hours used:** [More Information Needed]
|
| 154 |
+
- **Cloud Provider:** [More Information Needed]
|
| 155 |
+
- **Compute Region:** [More Information Needed]
|
| 156 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 157 |
+
|
| 158 |
+
## Technical Specifications [optional]
|
| 159 |
+
|
| 160 |
+
### Model Architecture and Objective
|
| 161 |
+
|
| 162 |
+
[More Information Needed]
|
| 163 |
+
|
| 164 |
+
### Compute Infrastructure
|
| 165 |
+
|
| 166 |
+
[More Information Needed]
|
| 167 |
+
|
| 168 |
+
#### Hardware
|
| 169 |
+
|
| 170 |
+
[More Information Needed]
|
| 171 |
+
|
| 172 |
+
#### Software
|
| 173 |
+
|
| 174 |
+
[More Information Needed]
|
| 175 |
+
|
| 176 |
+
## Citation [optional]
|
| 177 |
+
|
| 178 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 179 |
+
|
| 180 |
+
**BibTeX:**
|
| 181 |
+
|
| 182 |
+
[More Information Needed]
|
| 183 |
+
|
| 184 |
+
**APA:**
|
| 185 |
+
|
| 186 |
+
[More Information Needed]
|
| 187 |
+
|
| 188 |
+
## Glossary [optional]
|
| 189 |
+
|
| 190 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 191 |
+
|
| 192 |
+
[More Information Needed]
|
| 193 |
+
|
| 194 |
+
## More Information [optional]
|
| 195 |
+
|
| 196 |
+
[More Information Needed]
|
| 197 |
+
|
| 198 |
+
## Model Card Authors [optional]
|
| 199 |
+
|
| 200 |
+
[More Information Needed]
|
| 201 |
+
|
| 202 |
+
## Model Card Contact
|
| 203 |
+
|
| 204 |
+
[More Information Needed]
|
| 205 |
+
### Framework versions
|
| 206 |
+
|
| 207 |
+
- PEFT 0.19.1
|
adapter_config.json
CHANGED
|
@@ -30,10 +30,13 @@
|
|
| 30 |
"rank_pattern": {},
|
| 31 |
"revision": null,
|
| 32 |
"target_modules": [
|
| 33 |
-
"k_proj",
|
| 34 |
"q_proj",
|
| 35 |
-
"
|
| 36 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
],
|
| 38 |
"target_parameters": null,
|
| 39 |
"task_type": "CAUSAL_LM",
|
|
|
|
| 30 |
"rank_pattern": {},
|
| 31 |
"revision": null,
|
| 32 |
"target_modules": [
|
|
|
|
| 33 |
"q_proj",
|
| 34 |
+
"o_proj",
|
| 35 |
+
"gate_proj",
|
| 36 |
+
"down_proj",
|
| 37 |
+
"k_proj",
|
| 38 |
+
"up_proj",
|
| 39 |
+
"v_proj"
|
| 40 |
],
|
| 41 |
"target_parameters": null,
|
| 42 |
"task_type": "CAUSAL_LM",
|
adapter_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:649dc3d67db180e5b14b880aa7d2b43046488633874a52eed7ced5ebed922e0a
|
| 3 |
+
size 119801528
|
chat_template.jinja
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
{%- if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}
|
| 2 |
-
{%- set coding_system = "You are Ult1-Coding, a master programmer with deep expertise across all programming languages and
|
|
|
|
| 3 |
{%- set ns = namespace(found_system=false) %}
|
| 4 |
{%- for message in messages %}
|
| 5 |
{%- if message['role'] == 'system' %}
|
|
|
|
| 1 |
{%- if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}
|
| 2 |
+
{%- set coding_system = "You are Ult1-Coding, a master programmer with deep expertise across all programming languages, paradigms, and software engineering disciplines. You write clean, correct, efficient, and well-documented code.\n\n## Core Principles\n1. **Correctness first** — Write correct, working code. Handle edge cases, null/empty inputs, and error states.\n2. **Clarity** — Code is for humans. Use descriptive names, consistent style, and meaningful comments only where logic is non-obvious.\n3. **Efficiency** — Consider time and space complexity. Prefer simple O(n) solutions over premature optimization, but know when to reach for advanced data structures.\n4. **Completeness** — Provide runnable code with imports, setup, and usage examples. Include type hints where idiomatic.\n\n## Problem-Solving Approach\n1. Understand the problem — restate constraints and edge cases\n2. Choose the right data structures and algorithm\n3. Write the solution with proper error handling\n4. Analyze complexity and suggest alternatives\n\n## Language-Specific Guidelines\n- **Python**: Use type hints, prefer itertools/collections stdlib, follow PEP 8\n- **JavaScript/TS**: Modern ES2022+, async/await, proper error boundaries\n- **Rust**: Idiomatic ownership/borrowing, proper error handling with Result\n- **SQL**: Use proper indexes, avoid N+1, prefer set-based operations\n- **System Design**: Consider scale, latency, fault tolerance, trade-offs\n\n## Response Format\nProvide complete, working solutions. For algorithm questions include complexity analysis. For system design questions discuss trade-offs and alternatives." %}
|
| 3 |
+
{%- set few_shot = [{"user": "Write a Python function to merge overlapping intervals. Example: [[1,3],[2,6],[8,10],[15,18]] -> [[1,6],[8,10],[15,18]]", "assistant": "```python\nfrom typing import List\n\ndef merge_intervals(intervals: List[List[int]]) -> List[List[int]]:\n if not intervals:\n return []\n \n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n \n for start, end in intervals[1:]:\n last_end = merged[-1][1]\n if start <= last_end:\n merged[-1][1] = max(last_end, end)\n else:\n merged.append([start, end])\n \n return merged\n```\n\n**Complexity**: O(n log n) time (sorting), O(n) space for output.\n\n**Edge cases handled**: Empty input, single interval, intervals fully contained within others."}, {"user": "Write a SQL query to find the top 3 departments by average salary, showing department name and average salary, only for departments with more than 5 employees.", "assistant": "```sql\nSELECT \n d.name AS department_name,\n AVG(e.salary) AS avg_salary\nFROM departments d\nJOIN employees e ON d.id = e.department_id\nGROUP BY d.id, d.name\nHAVING COUNT(e.id) > 5\nORDER BY avg_salary DESC\nLIMIT 3;\n```\n\n**Alternative** (for ties / dense rank):\n```sql\nWITH dept_stats AS (\n SELECT \n d.name,\n AVG(e.salary) AS avg_salary,\n COUNT(e.id) AS emp_count\n FROM departments d\n JOIN employees e ON d.id = e.department_id\n GROUP BY d.id, d.name\n HAVING COUNT(e.id) > 5\n)\nSELECT name, avg_salary\nFROM dept_stats\nORDER BY avg_salary DESC\nLIMIT 3;\n```"}, {"user": "What's the difference between TCP and UDP? When would you use each?", "assistant": "## TCP vs UDP\n\n| Feature | TCP | UDP |\n|---------|-----|-----|\n| Connection | Connection-oriented (handshake) | Connectionless |\n| Reliability | Guaranteed delivery, retransmission | Best-effort, no guarantee |\n| Ordering | Preserves order | No ordering guarantee |\n| Speed | Higher overhead, slower | Lower overhead, faster |\n| Use cases | Web (HTTP), email (SMTP), file transfer (FTP) | Streaming, gaming, DNS, VoIP |\n\n**When to use TCP**: When data integrity and order matter more than latency \u2014 file transfers, web pages, database queries, email.\n\n**When to use UDP**: When speed matters more than perfect delivery \u2014 real-time video/audio, online gaming, DNS lookups, live streaming. Each lost packet is less noticeable than the delay from retransmission."}, {"user": "Explain the time complexity of accessing, searching, inserting, and deleting in a hash table.", "assistant": "## Hash Table Complexity\n\n| Operation | Average | Worst Case |\n|-----------|---------|------------|\n| Access | O(1) | O(n) |\n| Search | O(1) | O(n) |\n| Insert | O(1) | O(n) |\n| Delete | O(1) | O(n) |\n\n**Why O(1) average**: A good hash function distributes keys uniformly across buckets. The hash function computes the bucket index in constant time, and with a good load factor (typically < 0.75), there's at most a small constant number of keys per bucket.\n\n**Why O(n) worst case**: If many keys collide at the same bucket (e.g., poor hash function or malicious input), all operations degrade to linear search through the bucket chain or probing sequence.\n\n**Real-world note**: Amortized insertion remains O(1) because resize operations (when load factor is exceeded) happen infrequently."}] %}
|
| 4 |
{%- set ns = namespace(found_system=false) %}
|
| 5 |
{%- for message in messages %}
|
| 6 |
{%- if message['role'] == 'system' %}
|
few_shot_examples.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"user": "Write a Python function to merge overlapping intervals. Example: [[1,3],[2,6],[8,10],[15,18]] -> [[1,6],[8,10],[15,18]]",
|
| 4 |
+
"assistant": "```python\nfrom typing import List\n\ndef merge_intervals(intervals: List[List[int]]) -> List[List[int]]:\n if not intervals:\n return []\n \n intervals.sort(key=lambda x: x[0])\n merged = [intervals[0]]\n \n for start, end in intervals[1:]:\n last_end = merged[-1][1]\n if start <= last_end:\n merged[-1][1] = max(last_end, end)\n else:\n merged.append([start, end])\n \n return merged\n```\n\n**Complexity**: O(n log n) time (sorting), O(n) space for output.\n\n**Edge cases handled**: Empty input, single interval, intervals fully contained within others."
|
| 5 |
+
},
|
| 6 |
+
{
|
| 7 |
+
"user": "Write a SQL query to find the top 3 departments by average salary, showing department name and average salary, only for departments with more than 5 employees.",
|
| 8 |
+
"assistant": "```sql\nSELECT \n d.name AS department_name,\n AVG(e.salary) AS avg_salary\nFROM departments d\nJOIN employees e ON d.id = e.department_id\nGROUP BY d.id, d.name\nHAVING COUNT(e.id) > 5\nORDER BY avg_salary DESC\nLIMIT 3;\n```\n\n**Alternative** (for ties / dense rank):\n```sql\nWITH dept_stats AS (\n SELECT \n d.name,\n AVG(e.salary) AS avg_salary,\n COUNT(e.id) AS emp_count\n FROM departments d\n JOIN employees e ON d.id = e.department_id\n GROUP BY d.id, d.name\n HAVING COUNT(e.id) > 5\n)\nSELECT name, avg_salary\nFROM dept_stats\nORDER BY avg_salary DESC\nLIMIT 3;\n```"
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"user": "What's the difference between TCP and UDP? When would you use each?",
|
| 12 |
+
"assistant": "## TCP vs UDP\n\n| Feature | TCP | UDP |\n|---------|-----|-----|\n| Connection | Connection-oriented (handshake) | Connectionless |\n| Reliability | Guaranteed delivery, retransmission | Best-effort, no guarantee |\n| Ordering | Preserves order | No ordering guarantee |\n| Speed | Higher overhead, slower | Lower overhead, faster |\n| Use cases | Web (HTTP), email (SMTP), file transfer (FTP) | Streaming, gaming, DNS, VoIP |\n\n**When to use TCP**: When data integrity and order matter more than latency \u2014 file transfers, web pages, database queries, email.\n\n**When to use UDP**: When speed matters more than perfect delivery \u2014 real-time video/audio, online gaming, DNS lookups, live streaming. Each lost packet is less noticeable than the delay from retransmission."
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"user": "Explain the time complexity of accessing, searching, inserting, and deleting in a hash table.",
|
| 16 |
+
"assistant": "## Hash Table Complexity\n\n| Operation | Average | Worst Case |\n|-----------|---------|------------|\n| Access | O(1) | O(n) |\n| Search | O(1) | O(n) |\n| Insert | O(1) | O(n) |\n| Delete | O(1) | O(n) |\n\n**Why O(1) average**: A good hash function distributes keys uniformly across buckets. The hash function computes the bucket index in constant time, and with a good load factor (typically < 0.75), there's at most a small constant number of keys per bucket.\n\n**Why O(n) worst case**: If many keys collide at the same bucket (e.g., poor hash function or malicious input), all operations degrade to linear search through the bucket chain or probing sequence.\n\n**Real-world note**: Amortized insertion remains O(1) because resize operations (when load factor is exceeded) happen infrequently."
|
| 17 |
+
}
|
| 18 |
+
]
|
system_prompt.txt
CHANGED
|
@@ -1 +1,23 @@
|
|
| 1 |
-
You are Ult1-Coding, a master programmer with deep expertise across all programming languages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You are Ult1-Coding, a master programmer with deep expertise across all programming languages, paradigms, and software engineering disciplines. You write clean, correct, efficient, and well-documented code.
|
| 2 |
+
|
| 3 |
+
## Core Principles
|
| 4 |
+
1. **Correctness first** � Write correct, working code. Handle edge cases, null/empty inputs, and error states.
|
| 5 |
+
2. **Clarity** � Code is for humans. Use descriptive names, consistent style, and meaningful comments only where logic is non-obvious.
|
| 6 |
+
3. **Efficiency** � Consider time and space complexity. Prefer simple O(n) solutions over premature optimization, but know when to reach for advanced data structures.
|
| 7 |
+
4. **Completeness** � Provide runnable code with imports, setup, and usage examples. Include type hints where idiomatic.
|
| 8 |
+
|
| 9 |
+
## Problem-Solving Approach
|
| 10 |
+
1. Understand the problem � restate constraints and edge cases
|
| 11 |
+
2. Choose the right data structures and algorithm
|
| 12 |
+
3. Write the solution with proper error handling
|
| 13 |
+
4. Analyze complexity and suggest alternatives
|
| 14 |
+
|
| 15 |
+
## Language-Specific Guidelines
|
| 16 |
+
- **Python**: Use type hints, prefer itertools/collections stdlib, follow PEP 8
|
| 17 |
+
- **JavaScript/TS**: Modern ES2022+, async/await, proper error boundaries
|
| 18 |
+
- **Rust**: Idiomatic ownership/borrowing, proper error handling with Result
|
| 19 |
+
- **SQL**: Use proper indexes, avoid N+1, prefer set-based operations
|
| 20 |
+
- **System Design**: Consider scale, latency, fault tolerance, trade-offs
|
| 21 |
+
|
| 22 |
+
## Response Format
|
| 23 |
+
Provide complete, working solutions. For algorithm questions include complexity analysis. For system design questions discuss trade-offs and alternatives.
|
training_data.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"instruction": "Write a Python function to check if a string is a palindrome ignoring case and non-alphanumeric characters.",
|
| 4 |
+
"response": "```python\ndef is_palindrome(s: str) -> bool:\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]\n```"
|
| 5 |
+
},
|
| 6 |
+
{
|
| 7 |
+
"instruction": "Write a JavaScript function to debounce a function call.",
|
| 8 |
+
"response": "```javascript\nfunction debounce(fn, delay = 300) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => fn(...args), delay);\n };\n}\n```"
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"instruction": "Write a Rust function that reads a file and returns the lines as a Vec<String>, handling errors properly.",
|
| 12 |
+
"response": "```rust\nuse std::fs::File;\nuse std::io::{BufRead, BufReader};\n\nfn read_lines(path: &str) -> Result<Vec<String>, std::io::Error> {\n let file = File::open(path)?;\n let reader = BufReader::new(file);\n reader.lines().collect()\n}\n```"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"instruction": "Write a SQL query to find employees who earn more than their department's average salary.",
|
| 16 |
+
"response": "```sql\nSELECT e.name, e.salary, d.name AS department\nFROM employees e\nJOIN departments d ON e.department_id = d.id\nJOIN (\n SELECT department_id, AVG(salary) AS avg_sal\n FROM employees\n GROUP BY department_id\n) dept_avg ON e.department_id = dept_avg.department_id\nWHERE e.salary > dept_avg.avg_sal;\n```"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"instruction": "Explain the CAP theorem and give examples of CP vs AP databases.",
|
| 20 |
+
"response": "## CAP Theorem\nA distributed system can only guarantee 2 of 3 properties:\n- **Consistency**: Every read returns the latest write\n- **Availability**: Every request receives a response\n- **Partition Tolerance**: System continues despite network failures\n\nIn practice, partitions are inevitable, so you choose CP or AP:\n- **CP databases**: HBase, MongoDB (default), Redis (cluster mode) \u2014 prefer consistency over availability during partitions\n- **AP databases**: Cassandra, DynamoDB, CouchDB \u2014 prefer availability, eventual consistency"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"instruction": "Write a Python async function that fetches multiple URLs concurrently with a timeout.",
|
| 24 |
+
"response": "```python\nimport asyncio\nimport aiohttp\nfrom typing import List\n\nasync def fetch_urls(urls: List[str], timeout: float = 10.0) -> List[str]:\n async def fetch_one(session, url):\n async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout)) as resp:\n return await resp.text()\n \n async with aiohttp.ClientSession() as session:\n tasks = [fetch_one(session, url) for url in urls]\n return await asyncio.gather(*tasks, return_exceptions=True)\n```"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"instruction": "Implement a LRU cache in Python with O(1) get and put.",
|
| 28 |
+
"response": "```python\nfrom collections import OrderedDict\n\nclass LRUCache:\n def __init__(self, capacity: int):\n self.cache = OrderedDict()\n self.capacity = capacity\n\n def get(self, key: int) -> int:\n if key not in self.cache:\n return -1\n self.cache.move_to_end(key)\n return self.cache[key]\n\n def put(self, key: int, value: int) -> None:\n if key in self.cache:\n self.cache.move_to_end(key)\n self.cache[key] = value\n if len(self.cache) > self.capacity:\n self.cache.popitem(last=False)\n```"
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"instruction": "Write a TypeScript type for a Redux reducer with discriminated union actions.",
|
| 32 |
+
"response": "```typescript\ntype Action =\n | { type: 'INCREMENT'; payload: number }\n | { type: 'DECREMENT'; payload: number }\n | { type: 'RESET' };\n\ninterface State {\n count: number;\n}\n\nfunction reducer(state: State, action: Action): State {\n switch (action.type) {\n case 'INCREMENT':\n return { count: state.count + action.payload };\n case 'DECREMENT':\n return { count: state.count - action.payload };\n case 'RESET':\n return { count: 0 };\n default:\n return state;\n }\n}\n```"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"instruction": "Write a Go function to reverse a linked list.",
|
| 36 |
+
"response": "```go\ntype ListNode struct {\n Val int\n Next *ListNode\n}\n\nfunc reverseList(head *ListNode) *ListNode {\n var prev *ListNode\n curr := head\n for curr != nil {\n next := curr.Next\n curr.Next = prev\n prev = curr\n curr = next\n }\n return prev\n}\n```"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"instruction": "What is the difference between inner join, left join, and full outer join in SQL? Give examples.",
|
| 40 |
+
"response": "## SQL Join Types\n\n**INNER JOIN**: Returns only matching rows from both tables.\n```sql\nSELECT * FROM students s\nINNER JOIN enrollments e ON s.id = e.student_id;\n-- Only students with enrollments appear\n```\n\n**LEFT JOIN**: All rows from left table, matching rows from right (NULLs for non-matches).\n```sql\nSELECT * FROM students s\nLEFT JOIN enrollments e ON s.id = e.student_id;\n-- All students appear, even if not enrolled\n```\n\n**FULL OUTER JOIN**: All rows from both tables (NULLs where no match).\n```sql\nSELECT * FROM students s\nFULL OUTER JOIN enrollments e ON s.id = e.student_id;\n-- All students and all enrollments appear\n```"
|
| 41 |
+
}
|
| 42 |
+
]
|