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 Settings
- 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
| #!/usr/bin/env python3 | |
| """ | |
| Stack 2.9 - Test Runner | |
| All-in-one test runner: Unit → Integration → Benchmarks | |
| with JUnit XML output and coverage reporting. | |
| """ | |
| import sys | |
| import os | |
| import argparse | |
| import subprocess | |
| from pathlib import Path | |
| from typing import List, Optional | |
| # Ensure stack_cli is in path | |
| stack_cli_dir = Path(__file__).parent.parent / "stack_cli" | |
| if str(stack_cli_dir) not in sys.path: | |
| sys.path.insert(0, str(stack_cli_dir)) | |
| def run_pytest( | |
| args: List[str], | |
| capture_output: bool = True, | |
| env: Optional[dict] = None | |
| ) -> subprocess.CompletedProcess: | |
| """Run pytest with given arguments.""" | |
| cmd = [sys.executable, "-m", "pytest"] + args | |
| run_env = os.environ.copy() | |
| if env: | |
| run_env.update(env) | |
| return subprocess.run( | |
| cmd, | |
| capture_output=capture_output, | |
| text=True, | |
| env=run_env, | |
| cwd=Path(__file__).parent | |
| ) | |
| def run_unit_tests(verbose: bool = True, markers: Optional[str] = None) -> int: | |
| """Run unit tests.""" | |
| print("\n" + "="*60) | |
| print("Running Unit Tests") | |
| print("="*60) | |
| args = ["tests/unit/"] | |
| if verbose: | |
| args.append("-v") | |
| if markers: | |
| args.extend(["-m", markers]) | |
| result = run_pytest(args) | |
| print(result.stdout) | |
| if result.stderr: | |
| print(result.stderr, file=sys.stderr) | |
| return result.returncode | |
| def run_integration_tests(verbose: bool = True, markers: Optional[str] = None) -> int: | |
| """Run integration tests.""" | |
| print("\n" + "="*60) | |
| print("Running Integration Tests") | |
| print("="*60) | |
| args = ["tests/integration/"] | |
| if verbose: | |
| args.append("-v") | |
| if markers: | |
| args.extend(["-m", markers]) | |
| result = run_pytest(args) | |
| print(result.stdout) | |
| if result.stderr: | |
| print(result.stderr, file=sys.stderr) | |
| return result.returncode | |
| def run_benchmark_tests(verbose: bool = True) -> int: | |
| """Run benchmark tests.""" | |
| print("\n" + "="*60) | |
| print("Running Benchmark Tests") | |
| print("="*60) | |
| args = ["tests/benchmarks/", "-v"] | |
| result = run_pytest(args) | |
| print(result.stdout) | |
| if result.stderr: | |
| print(result.stderr, file=sys.stderr) | |
| return result.returncode | |
| def run_all_tests( | |
| verbose: bool = True, | |
| junit_xml: Optional[str] = None, | |
| coverage: bool = False, | |
| markers: Optional[str] = None | |
| ) -> int: | |
| """Run all tests.""" | |
| print("\n" + "#"*60) | |
| print("# Stack 2.9 - Test Suite") | |
| print("#"*60) | |
| results = [] | |
| # Unit tests | |
| print("\n[1/3] Unit Tests...") | |
| unit_result = run_unit_tests(verbose=verbose, markers=markers) | |
| results.append(("Unit Tests", unit_result)) | |
| # Integration tests | |
| print("\n[2/3] Integration Tests...") | |
| int_result = run_integration_tests(verbose=verbose, markers=markers) | |
| results.append(("Integration Tests", int_result)) | |
| # Benchmark tests | |
| print("\n[3/3] Benchmark Tests...") | |
| bench_result = run_benchmark_tests(verbose=verbose) | |
| results.append(("Benchmark Tests", bench_result)) | |
| # Summary | |
| print("\n" + "="*60) | |
| print("Test Summary") | |
| print("="*60) | |
| all_passed = True | |
| for name, code in results: | |
| status = "✓ PASSED" if code == 0 else "✗ FAILED" | |
| print(f" {name}: {status}") | |
| if code != 0: | |
| all_passed = False | |
| print("="*60) | |
| if all_passed: | |
| print("\n✓ All tests passed!") | |
| return 0 | |
| else: | |
| print("\n✗ Some tests failed!") | |
| return 1 | |
| def run_with_coverage() -> int: | |
| """Run tests with coverage reporting.""" | |
| print("\n" + "="*60) | |
| print("Running Tests with Coverage") | |
| print("="*60) | |
| args = [ | |
| "tests/", | |
| "--cov=stack_cli", | |
| "--cov-report=term-missing", | |
| "--cov-report=html", | |
| "-v" | |
| ] | |
| result = run_pytest(args) | |
| print(result.stdout) | |
| if result.stderr: | |
| print(result.stderr, file=sys.stderr) | |
| return result.returncode | |
| def main(): | |
| """Main entry point.""" | |
| parser = argparse.ArgumentParser( | |
| description="Stack 2.9 Test Runner", | |
| formatter_class=argparse.RawDescriptionHelpFormatter, | |
| epilog=""" | |
| Examples: | |
| %(prog)s # Run all tests | |
| %(prog)s --unit # Run only unit tests | |
| %(prog)s --integration # Run only integration tests | |
| %(prog)s --benchmark # Run only benchmark tests | |
| %(prog)s --coverage # Run with coverage | |
| %(prog)s --junit results.xml # Generate JUnit XML | |
| %(prog)s --fast # Skip slow tests | |
| """ | |
| ) | |
| parser.add_argument( | |
| '--unit', | |
| action='store_true', | |
| help='Run only unit tests' | |
| ) | |
| parser.add_argument( | |
| '--integration', | |
| action='store_true', | |
| help='Run only integration tests' | |
| ) | |
| parser.add_argument( | |
| '--benchmark', | |
| action='store_true', | |
| help='Run only benchmark tests' | |
| ) | |
| parser.add_argument( | |
| '--coverage', | |
| action='store_true', | |
| help='Run with coverage reporting' | |
| ) | |
| parser.add_argument( | |
| '--junit', | |
| metavar='FILE', | |
| help='Generate JUnit XML output' | |
| ) | |
| parser.add_argument( | |
| '--fast', | |
| action='store_true', | |
| help='Skip slow tests' | |
| ) | |
| parser.add_argument( | |
| '-v', '--verbose', | |
| action='store_true', | |
| default=True, | |
| help='Verbose output' | |
| ) | |
| args = parser.parse_args() | |
| # Build pytest args | |
| pytest_args = [] | |
| if args.junit: | |
| pytest_args.extend(['--junit-xml', args.junit]) | |
| if args.fast: | |
| pytest_args.extend(['-m', 'not slow']) | |
| # Run tests based on options | |
| if args.unit: | |
| return run_unit_tests(verbose=args.verbose, markers=args.fast and 'not slow' or None) | |
| elif args.integration: | |
| return run_integration_tests(verbose=args.verbose, markers=args.fast and 'not slow' or None) | |
| elif args.benchmark: | |
| return run_benchmark_tests(verbose=args.verbose) | |
| elif args.coverage: | |
| return run_with_coverage() | |
| else: | |
| # Run all tests | |
| return run_all_tests( | |
| verbose=args.verbose, | |
| junit_xml=args.junit, | |
| markers=args.fast and 'not slow' or None | |
| ) | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |