Text Generation
Transformers
Safetensors
qwen2
llama-factory
conversational
text-generation-inference
Instructions to use Alexjiuqiaoyu/im with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Alexjiuqiaoyu/im with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Alexjiuqiaoyu/im") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Alexjiuqiaoyu/im") model = AutoModelForCausalLM.from_pretrained("Alexjiuqiaoyu/im", 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 Alexjiuqiaoyu/im with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Alexjiuqiaoyu/im" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Alexjiuqiaoyu/im", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Alexjiuqiaoyu/im
- SGLang
How to use Alexjiuqiaoyu/im 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 "Alexjiuqiaoyu/im" \ --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": "Alexjiuqiaoyu/im", "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 "Alexjiuqiaoyu/im" \ --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": "Alexjiuqiaoyu/im", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Alexjiuqiaoyu/im with Docker Model Runner:
docker model run hf.co/Alexjiuqiaoyu/im
| # handler.py | |
| from typing import Dict, List, Any | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline | |
| class EndpointHandler: | |
| def __init__(self, path: str = ""): | |
| """ | |
| Load model and tokenizer at startup. | |
| `path` is the model repo on the Hub or local directory. | |
| """ | |
| # Determine device | |
| self.device = 0 if torch.cuda.is_available() else -1 | |
| # Load tokenizer and model | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForCausalLM.from_pretrained(path).to(self.device) | |
| # Set up a text-generation pipeline | |
| self.generator = pipeline( | |
| task="text-generation", | |
| model=self.model, | |
| tokenizer=self.tokenizer, | |
| device=self.device | |
| ) | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: | |
| """ | |
| Handle each inference request. Must return a non-empty list. | |
| `data` will always contain at least the key "inputs". | |
| """ | |
| # Extract input messages or fall back to raw prompt | |
| raw = data.get("inputs", data) | |
| prompt = "" | |
| # Support both string inputs and OpenAI-style messages | |
| if isinstance(raw, list): | |
| for msg in raw: | |
| role = msg.get("role", "user") | |
| content = msg.get("content", "") | |
| prompt += f"{role}: {content}\n" | |
| else: | |
| prompt = str(raw) | |
| # Run generation (returns a list of dicts) | |
| outputs = self.generator(prompt, max_new_tokens=128) | |
| # Ensure we output a list of {"generated_text": ...} | |
| return [{"response": out["response"]} for out in outputs] | |