Instructions to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF 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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
Use Docker
docker model run hf.co/TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with Ollama:
ollama run hf.co/TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
- Unsloth Studio
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF 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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF 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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF to start chatting
- Pi
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
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": "TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with Docker Model Runner:
docker model run hf.co/TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
- Lemonade
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Qwen2.5-Coder-1.5B-Java-CSharp-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
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 TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M
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 "TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF:Q4_K_M" \ --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"
File size: 6,118 Bytes
bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 bdc658e 98ac7c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | import os
import re
import threading
import gradio as gr
from huggingface_hub import hf_hub_download
from llama_cpp import Llama
MODEL_REPO = "TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF"
MODEL_FILE = "Qwen2.5-Coder-1.5B-Java-CSharp_V2.Q4_K_M.gguf"
STAGE1_RESPONSE_MARKER = "### Response:\n\n"
STAGE2_RESPONSE_MARKER = "### Response\n"
# Prevent two users from running CPU inference simultaneously.
generation_lock = threading.Lock()
print("Downloading GGUF model...")
model_path = hf_hub_download(
repo_id=MODEL_REPO,
filename=MODEL_FILE,
)
print("Loading GGUF model...")
llm = Llama(
model_path=model_path,
n_ctx=4096,
n_threads=max(1, os.cpu_count() or 2),
n_threads_batch=max(1, os.cpu_count() or 2),
n_batch=128,
n_gpu_layers=0,
verbose=False,
)
print("Model loaded successfully.")
def add_java_hint(instruction: str) -> str:
instruction = instruction.strip()
if "java" in instruction.lower():
return instruction
return f"{instruction} Write the solution in Java."
def build_nl_to_java_prompt(instruction: str) -> str:
return (
"### Instruction:\n\n"
f"{add_java_hint(instruction)}\n\n"
"### Response:\n\n"
)
def build_java_to_csharp_prompt(java_code: str) -> str:
return (
"### Instruction\n"
"Translate the following Java code into equivalent C#. "
"Write the solution in C#.\n\n"
"### Java\n"
f"{java_code.strip()}\n\n"
"### Response\n"
)
def clean_generated_code(text: str) -> str:
text = text.strip()
# Remove Markdown code fences if the model adds them.
fenced = re.search(
r"```(?:java|csharp|cs|c#)?\s*(.*?)```",
text,
flags=re.DOTALL | re.IGNORECASE,
)
if fenced:
text = fenced.group(1).strip()
stop_markers = [
"### Instruction:",
"### Instruction\n",
"### Java:",
"### Java\n",
"### Response:",
"### Response\n",
"<|im_start|>",
"<|im_end|>",
]
for marker in stop_markers:
if marker in text:
text = text.split(marker, 1)[0].strip()
return text
def run_generation(prompt: str, max_tokens: int) -> str:
with generation_lock:
response = llm(
prompt=prompt,
max_tokens=max_tokens,
temperature=0.0,
top_p=1.0,
repeat_penalty=1.0,
echo=False,
stop=[
"</s>",
"<|endoftext|>",
"<|im_end|>",
"### Instruction:",
"### Instruction\n",
],
)
return response["choices"][0]["text"]
def generate_code(task: str, user_input: str) -> str:
if not user_input or not user_input.strip():
return "Please enter a requirement or Java code."
try:
if task == "Natural Language → Java":
prompt = build_nl_to_java_prompt(user_input)
generated = run_generation(prompt, max_tokens=300)
language = "java"
else:
prompt = build_java_to_csharp_prompt(user_input)
generated = run_generation(prompt, max_tokens=400)
language = "csharp"
code = clean_generated_code(generated)
if not code:
return "The model returned an empty response. Please try again."
return f"```{language}\n{code}\n```"
except Exception as error:
return (
"Generation failed.\n\n"
f"Error: {type(error).__name__}: {error}"
)
def update_input(task: str):
if task == "Natural Language → Java":
return gr.update(
label="Natural-language requirement",
placeholder=(
"Example: Write a Java method to check whether "
"a number is prime."
),
value="",
)
return gr.update(
label="Java code",
placeholder=(
"Example:\n"
"public static int factorial(int n) {\n"
" int result = 1;\n"
" for (int i = 2; i <= n; i++) {\n"
" result *= i;\n"
" }\n"
" return result;\n"
"}"
),
value="",
)
with gr.Blocks(title="Java and C# CodeGen") as demo:
gr.Markdown(
"""
# Java and C# CodeGen
Generate Java code from natural-language requirements or translate Java code
into equivalent C# using a fine-tuned Qwen2.5-Coder model.
"""
)
task = gr.Dropdown(
choices=[
"Natural Language → Java",
"Java → C#",
],
value="Natural Language → Java",
label="Select task",
)
user_input = gr.Textbox(
label="Natural-language requirement",
placeholder=(
"Example: Write a Java method to check whether "
"a number is prime."
),
lines=14,
)
generate_button = gr.Button(
"Generate Code",
variant="primary",
)
output = gr.Markdown()
task.change(
fn=update_input,
inputs=task,
outputs=user_input,
)
generate_button.click(
fn=generate_code,
inputs=[
task,
user_input,
],
outputs=output,
)
gr.Examples(
examples=[
[
"Natural Language → Java",
"Write a Java method to calculate factorial of a number using a loop.",
],
[
"Natural Language → Java",
"Write a Java method to reverse a string.",
],
[
"Java → C#",
"""public static int factorial(int n) {
int result = 1;
for (int i = 2; i <= n; i++) {
result *= i;
}
return result;
}""",
],
],
inputs=[
task,
user_input,
],
)
if __name__ == "__main__":
demo.queue(
default_concurrency_limit=1,
max_size=10,
).launch() |