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", device_map="auto") 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
| from fastapi import FastAPI, File, UploadFile, HTTPException | |
| from fastapi.responses import JSONResponse | |
| from pydantic import BaseModel | |
| import uvicorn | |
| import os | |
| import json | |
| import tempfile | |
| from typing import List | |
| app = FastAPI(title="Voice API", version="1.0.0") | |
| class VoiceModel: | |
| def __init__(self): | |
| self.models_dir = "./voice_models" | |
| os.makedirs(self.models_dir, exist_ok=True) | |
| self.voice_models = self._load_voice_models() | |
| def _load_voice_models(self) -> dict: | |
| """Load available voice models from disk""" | |
| models = {} | |
| for filename in os.listdir(self.models_dir): | |
| if filename.endswith('.json'): | |
| model_name = filename.replace('.json', '') | |
| try: | |
| with open(os.path.join(self.models_dir, filename), 'r') as f: | |
| model_data = json.load(f) | |
| models[model_name] = model_data | |
| except Exception as e: | |
| print(f"Error loading model {model_name}: {e}") | |
| return models | |
| def clone_voice(self, audio_file: UploadFile, voice_name: str) -> dict: | |
| """Clone voice from audio sample""" | |
| try: | |
| # Save audio file temporarily | |
| temp_path = os.path.join(tempfile.gettempdir(), audio_file.filename) | |
| with open(temp_path, 'wb') as f: | |
| f.write(audio_file.file.read()) | |
| # TODO: Implement actual voice cloning using Coqui TTS or similar | |
| # For now, create a placeholder model | |
| model_path = os.path.join(self.models_dir, f"{voice_name}.json") | |
| model_data = { | |
| "name": voice_name, | |
| "status": "created", | |
| "sample_file": audio_file.filename, | |
| "sample_duration": 30, # Placeholder | |
| "created_at": "2026-04-01T14:10:00Z" | |
| } | |
| with open(model_path, 'w') as f: | |
| json.dump(model_data, f, indent=2) | |
| # Update in-memory models | |
| self.voice_models[voice_name] = model_data | |
| return { | |
| "success": True, | |
| "voice_name": voice_name, | |
| "message": f"Voice model '{voice_name}' created successfully" | |
| } | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=f"Voice cloning failed: {str(e)}") | |
| def synthesize(self, text: str, voice_name: str) -> bytes: | |
| """Generate speech with cloned voice""" | |
| if voice_name not in self.voice_models: | |
| raise HTTPException(status_code=404, detail=f"Voice model '{voice_name}' not found") | |
| try: | |
| # TODO: Implement actual TTS synthesis using Coqui TTS or similar | |
| # For now, return a placeholder audio file | |
| return b"placeholder_audio_data" | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=f"Text-to-speech failed: {str(e)}") | |
| class VoiceModelResponse(BaseModel): | |
| success: bool | |
| voice_name: str | |
| message: str | |
| class SynthesizeRequest(BaseModel): | |
| text: str | |
| voice_name: str | |
| class CloneRequest(BaseModel): | |
| voice_name: str | |
| voice_model = VoiceModel() | |
| async def root(): | |
| return {"message": "Voice API - Stack 2.9 Integration"} | |
| async def list_voices(): | |
| """List available voice models""" | |
| return { | |
| "voices": list(voice_model.voice_models.keys()), | |
| "count": len(voice_model.voice_models) | |
| } | |
| async def clone_voice(file: UploadFile = File(...), request: CloneRequest = None): | |
| """Clone voice from audio sample""" | |
| if not request: | |
| request = CloneRequest(voice_name="default") | |
| result = voice_model.clone_voice(file, request.voice_name) | |
| return result | |
| async def synthesize_speech(request: SynthesizeRequest): | |
| """Generate speech with cloned voice""" | |
| audio_data = voice_model.synthesize(request.text, request.voice_name) | |
| return Response(content=audio_data, media_type="audio/wav") | |
| async def synthesize_stream(request: SynthesizeRequest): | |
| """Stream speech synthesis (placeholder)""" | |
| # TODO: Implement streaming TTS | |
| audio_data = voice_model.synthesize(request.text, request.voice_name) | |
| return Response(content=audio_data, media_type="audio/wav") | |
| if __name__ == "__main__": | |
| uvicorn.run(app, host="0.0.0.0", port=8000) |