Text Generation
Transformers
English
qwen2
code-generation
python
fine-tuning
Qwen
tools
agent-framework
multi-agent
conversational
Eval Results (legacy)
Instructions to use my-ai-stack/Stack-2-9-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use my-ai-stack/Stack-2-9-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="my-ai-stack/Stack-2-9-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("my-ai-stack/Stack-2-9-finetuned") model = AutoModelForCausalLM.from_pretrained("my-ai-stack/Stack-2-9-finetuned") 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
- vLLM
How to use my-ai-stack/Stack-2-9-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "my-ai-stack/Stack-2-9-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
- SGLang
How to use my-ai-stack/Stack-2-9-finetuned 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 "my-ai-stack/Stack-2-9-finetuned" \ --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": "my-ai-stack/Stack-2-9-finetuned", "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 "my-ai-stack/Stack-2-9-finetuned" \ --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": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use my-ai-stack/Stack-2-9-finetuned with Docker Model Runner:
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
walidsobhie-code Claude Opus 4.6 commited on
Commit ·
2c32ffd
1
Parent(s): e31f34c
fix: syntax errors in notebook and create_mini_dataset script
Browse files- Fix missing print() in training cell
- Fix missing print() in merge cell
- Add missing typing imports (List, Dict) in create_mini_dataset.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- colab_train_stack29.ipynb +2 -58
- scripts/create_mini_dataset.py +1 -0
colab_train_stack29.ipynb
CHANGED
|
@@ -241,30 +241,7 @@
|
|
| 241 |
"execution_count": null,
|
| 242 |
"metadata": {},
|
| 243 |
"outputs": [],
|
| 244 |
-
"source":
|
| 245 |
-
"import os\n",
|
| 246 |
-
"import sys\n",
|
| 247 |
-
"\n",
|
| 248 |
-
"# Add training module to path\n",
|
| 249 |
-
"sys.path.insert(0, './stack/training')\n",
|
| 250 |
-
"\n",
|
| 251 |
-
"print(\"=\"*60)\n",
|
| 252 |
-
"print(\"STARTING TRAINING\")\n",
|
| 253 |
-
"=\"*60)\n",
|
| 254 |
-
"print(f\"Working directory: {os.getcwd()}\")\n",
|
| 255 |
-
"print(f\"Config: {updated_config_path}\")\n",
|
| 256 |
-
"print(f\"Output: {OUTPUT_DIR}/lora\")\n",
|
| 257 |
-
"print(\"=\"*60 + \"\\n\")\n",
|
| 258 |
-
"\n",
|
| 259 |
-
"# Run training\n",
|
| 260 |
-
"from train_lora import train_lora\n",
|
| 261 |
-
"\n",
|
| 262 |
-
"trainer = train_lora(updated_config_path)\n",
|
| 263 |
-
"\n",
|
| 264 |
-
"print(\"\\n\" + \"=\"*60)\n",
|
| 265 |
-
"print(\"TRAINING FINISHED OR STOPPED\")\n",
|
| 266 |
-
"print(\"=\"*60)"
|
| 267 |
-
]
|
| 268 |
},
|
| 269 |
{
|
| 270 |
"cell_type": "markdown",
|
|
@@ -306,40 +283,7 @@
|
|
| 306 |
"execution_count": null,
|
| 307 |
"metadata": {},
|
| 308 |
"outputs": [],
|
| 309 |
-
"source":
|
| 310 |
-
"import yaml\n",
|
| 311 |
-
"import sys\n",
|
| 312 |
-
"\n",
|
| 313 |
-
"sys.path.insert(0, './stack/training')\n",
|
| 314 |
-
"from merge_adapter import merge_adapter\n",
|
| 315 |
-
"\n",
|
| 316 |
-
"merged_dir = f\"{OUTPUT_DIR}/merged\"\n",
|
| 317 |
-
"\n",
|
| 318 |
-
"print(\"=\"*60)\n",
|
| 319 |
-
"print(\"MERGING LORA ADAPTER\")\n",
|
| 320 |
-
"=\"*60)\n",
|
| 321 |
-
"\n",
|
| 322 |
-
"# Create merge config\n",
|
| 323 |
-
"merge_config = {\n",
|
| 324 |
-
" 'model': {'name': MODEL_DIR, 'trust_remote_code': True},\n",
|
| 325 |
-
" 'output': {'lora_dir': f'{OUTPUT_DIR}/lora', 'merged_dir': merged_dir},\n",
|
| 326 |
-
" 'quantization': {'enabled': False}\n",
|
| 327 |
-
"}\n",
|
| 328 |
-
"\n",
|
| 329 |
-
"merge_config_path = f\"{OUTPUT_DIR}/merge_config.yaml\"\n",
|
| 330 |
-
"with open(merge_config_path, 'w') as f:\n",
|
| 331 |
-
" yaml.dump(merge_config, f)\n",
|
| 332 |
-
"\n",
|
| 333 |
-
"# Run merge\n",
|
| 334 |
-
"merge_adapter(\n",
|
| 335 |
-
" config_path=merge_config_path,\n",
|
| 336 |
-
" lora_path=f\"{OUTPUT_DIR}/lora\",\n",
|
| 337 |
-
" output_path=merged_dir\n",
|
| 338 |
-
")\n",
|
| 339 |
-
"\n",
|
| 340 |
-
"print(f\"\\n✅ Merged model saved to: {merged_dir}\")\n",
|
| 341 |
-
"!ls -lh {merged_dir}/"
|
| 342 |
-
]
|
| 343 |
},
|
| 344 |
{
|
| 345 |
"cell_type": "markdown",
|
|
|
|
| 241 |
"execution_count": null,
|
| 242 |
"metadata": {},
|
| 243 |
"outputs": [],
|
| 244 |
+
"source": "import os\nimport sys\n\n# Add training module to path\nsys.path.insert(0, './stack/training')\n\nprint(\"=\"*60)\nprint(\"STARTING TRAINING\")\nprint(\"=\"*60)\nprint(f\"Working directory: {os.getcwd()}\")\nprint(f\"Config: {updated_config_path}\")\nprint(f\"Output: {OUTPUT_DIR}/lora\")\nprint(\"=\"*60 + \"\\n\")\n\n# Run training\nfrom train_lora import train_lora\n\ntrainer = train_lora(updated_config_path)\n\nprint(\"\\n\" + \"=\"*60)\nprint(\"TRAINING FINISHED OR STOPPED\")\nprint(\"=\"*60)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
},
|
| 246 |
{
|
| 247 |
"cell_type": "markdown",
|
|
|
|
| 283 |
"execution_count": null,
|
| 284 |
"metadata": {},
|
| 285 |
"outputs": [],
|
| 286 |
+
"source": "import yaml\nimport sys\n\nsys.path.insert(0, './stack/training')\nfrom merge_adapter import merge_adapter\n\nmerged_dir = f\"{OUTPUT_DIR}/merged\"\n\nprint(\"=\"*60)\nprint(\"MERGING LORA ADAPTER\")\nprint(\"=\"*60)\n\n# Create merge config\nmerge_config = {\n 'model': {'name': MODEL_DIR, 'trust_remote_code': True},\n 'output': {'lora_dir': f'{OUTPUT_DIR}/lora', 'merged_dir': merged_dir},\n 'quantization': {'enabled': False}\n}\n\nmerge_config_path = f\"{OUTPUT_DIR}/merge_config.yaml\"\nwith open(merge_config_path, 'w') as f:\n yaml.dump(merge_config, f)\n\n# Run merge\nmerge_adapter(\n config_path=merge_config_path,\n lora_path=f\"{OUTPUT_DIR}/lora\",\n output_path=merged_dir\n)\n\nprint(f\"\\n✅ Merged model saved to: {merged_dir}\")\n!ls -lh {merged_dir}/"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
},
|
| 288 |
{
|
| 289 |
"cell_type": "markdown",
|
scripts/create_mini_dataset.py
CHANGED
|
@@ -8,6 +8,7 @@ import argparse
|
|
| 8 |
import json
|
| 9 |
import random
|
| 10 |
from pathlib import Path
|
|
|
|
| 11 |
from collections import defaultdict, Counter
|
| 12 |
|
| 13 |
def load_full_dataset(train_path: str = "training-data/final/train.jsonl") -> List[Dict]:
|
|
|
|
| 8 |
import json
|
| 9 |
import random
|
| 10 |
from pathlib import Path
|
| 11 |
+
from typing import List, Dict
|
| 12 |
from collections import defaultdict, Counter
|
| 13 |
|
| 14 |
def load_full_dataset(train_path: str = "training-data/final/train.jsonl") -> List[Dict]:
|