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"
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
+
from llama_cpp import Llama
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
MODEL_REPO = "TaruniSwathi/Qwen2.5-Coder-1.5B-Java-CSharp-GGUF"
|
| 9 |
+
MODEL_FILE = "Qwen2.5-Coder-1.5B-Java-CSharp_V2.Q4_K_M.gguf"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
print("Downloading GGUF model...")
|
| 13 |
+
|
| 14 |
+
model_path = hf_hub_download(
|
| 15 |
+
repo_id=MODEL_REPO,
|
| 16 |
+
filename=MODEL_FILE,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
print("Model downloaded:", model_path)
|
| 20 |
+
print("Loading model with llama.cpp...")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
llm = Llama(
|
| 24 |
+
model_path=model_path,
|
| 25 |
+
n_ctx=2048,
|
| 26 |
+
n_threads=max(1, os.cpu_count() or 2),
|
| 27 |
+
n_batch=128,
|
| 28 |
+
n_gpu_layers=0,
|
| 29 |
+
verbose=False,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
print("Model loaded successfully.")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def build_prompt(task: str, user_input: str) -> str:
|
| 36 |
+
user_input = user_input.strip()
|
| 37 |
+
|
| 38 |
+
if task == "Natural Language β Java":
|
| 39 |
+
return f"""### Instruction:
|
| 40 |
+
{user_input}
|
| 41 |
+
|
| 42 |
+
### Java Code:
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
return f"""### Instruction:
|
| 46 |
+
Translate the following Java code to C#.
|
| 47 |
+
|
| 48 |
+
### Java Code:
|
| 49 |
+
{user_input}
|
| 50 |
+
|
| 51 |
+
### C# Code:
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def clean_output(task: str, generated_text: str) -> str:
|
| 56 |
+
generated_text = generated_text.strip()
|
| 57 |
+
|
| 58 |
+
stop_markers = [
|
| 59 |
+
"### Instruction:",
|
| 60 |
+
"### Java Code:",
|
| 61 |
+
"### C# Code:",
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
for marker in stop_markers:
|
| 65 |
+
if marker in generated_text:
|
| 66 |
+
generated_text = generated_text.split(marker)[0].strip()
|
| 67 |
+
|
| 68 |
+
if task == "Natural Language β Java":
|
| 69 |
+
language = "java"
|
| 70 |
+
else:
|
| 71 |
+
language = "csharp"
|
| 72 |
+
|
| 73 |
+
return f"```{language}\n{generated_text}\n```"
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def generate_code(
|
| 77 |
+
task: str,
|
| 78 |
+
user_input: str,
|
| 79 |
+
max_tokens: int,
|
| 80 |
+
) -> str:
|
| 81 |
+
if not user_input or not user_input.strip():
|
| 82 |
+
return "Please enter a description or Java code."
|
| 83 |
+
|
| 84 |
+
prompt = build_prompt(task, user_input)
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
response = llm(
|
| 88 |
+
prompt,
|
| 89 |
+
max_tokens=int(max_tokens),
|
| 90 |
+
temperature=0.0,
|
| 91 |
+
top_p=1.0,
|
| 92 |
+
repeat_penalty=1.05,
|
| 93 |
+
stop=[
|
| 94 |
+
"### Instruction:",
|
| 95 |
+
"### Java Code:",
|
| 96 |
+
"### C# Code:",
|
| 97 |
+
],
|
| 98 |
+
echo=False,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
generated_text = response["choices"][0]["text"]
|
| 102 |
+
|
| 103 |
+
if not generated_text.strip():
|
| 104 |
+
return "The model returned an empty response. Please try a more detailed input."
|
| 105 |
+
|
| 106 |
+
return clean_output(task, generated_text)
|
| 107 |
+
|
| 108 |
+
except Exception as error:
|
| 109 |
+
return f"Generation failed: {error}"
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def update_placeholder(task: str):
|
| 113 |
+
if task == "Natural Language β Java":
|
| 114 |
+
return gr.update(
|
| 115 |
+
label="Natural-language requirement",
|
| 116 |
+
placeholder=(
|
| 117 |
+
"Example: Write a Java method to check whether "
|
| 118 |
+
"a number is prime."
|
| 119 |
+
),
|
| 120 |
+
value="",
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
return gr.update(
|
| 124 |
+
label="Java code",
|
| 125 |
+
placeholder=(
|
| 126 |
+
"Example:\n"
|
| 127 |
+
"public static int factorial(int n) {\n"
|
| 128 |
+
" int result = 1;\n"
|
| 129 |
+
" for (int i = 2; i <= n; i++) result *= i;\n"
|
| 130 |
+
" return result;\n"
|
| 131 |
+
"}"
|
| 132 |
+
),
|
| 133 |
+
value="",
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
with gr.Blocks(title="Java and C# CodeGen") as demo:
|
| 138 |
+
gr.Markdown(
|
| 139 |
+
"""
|
| 140 |
+
# Java and C# CodeGen
|
| 141 |
+
|
| 142 |
+
Generate Java code from natural-language requirements or translate
|
| 143 |
+
Java code into C# using a fine-tuned Qwen2.5-Coder model.
|
| 144 |
+
"""
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
task = gr.Dropdown(
|
| 148 |
+
choices=[
|
| 149 |
+
"Natural Language β Java",
|
| 150 |
+
"Java β C#",
|
| 151 |
+
],
|
| 152 |
+
value="Natural Language β Java",
|
| 153 |
+
label="Select task",
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
user_input = gr.Textbox(
|
| 157 |
+
label="Natural-language requirement",
|
| 158 |
+
placeholder=(
|
| 159 |
+
"Example: Write a Java method to check whether "
|
| 160 |
+
"a number is prime."
|
| 161 |
+
),
|
| 162 |
+
lines=12,
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
max_tokens = gr.Slider(
|
| 166 |
+
minimum=64,
|
| 167 |
+
maximum=512,
|
| 168 |
+
value=256,
|
| 169 |
+
step=32,
|
| 170 |
+
label="Maximum generated tokens",
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
generate_button = gr.Button(
|
| 174 |
+
"Generate Code",
|
| 175 |
+
variant="primary",
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
output = gr.Markdown(
|
| 179 |
+
label="Generated code",
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
+
task.change(
|
| 183 |
+
fn=update_placeholder,
|
| 184 |
+
inputs=task,
|
| 185 |
+
outputs=user_input,
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
generate_button.click(
|
| 189 |
+
fn=generate_code,
|
| 190 |
+
inputs=[
|
| 191 |
+
task,
|
| 192 |
+
user_input,
|
| 193 |
+
max_tokens,
|
| 194 |
+
],
|
| 195 |
+
outputs=output,
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
gr.Examples(
|
| 199 |
+
examples=[
|
| 200 |
+
[
|
| 201 |
+
"Natural Language β Java",
|
| 202 |
+
"Write a Java method to calculate factorial of a number using a loop.",
|
| 203 |
+
256,
|
| 204 |
+
],
|
| 205 |
+
[
|
| 206 |
+
"Natural Language β Java",
|
| 207 |
+
"Write a Java method to reverse a string.",
|
| 208 |
+
256,
|
| 209 |
+
],
|
| 210 |
+
[
|
| 211 |
+
"Java β C#",
|
| 212 |
+
"""public static int factorial(int n) {
|
| 213 |
+
int result = 1;
|
| 214 |
+
for (int i = 2; i <= n; i++) {
|
| 215 |
+
result *= i;
|
| 216 |
+
}
|
| 217 |
+
return result;
|
| 218 |
+
}""",
|
| 219 |
+
256,
|
| 220 |
+
],
|
| 221 |
+
],
|
| 222 |
+
inputs=[
|
| 223 |
+
task,
|
| 224 |
+
user_input,
|
| 225 |
+
max_tokens,
|
| 226 |
+
],
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
if __name__ == "__main__":
|
| 231 |
+
demo.queue(max_size=10).launch()
|