Instructions to use moelanoby/Sensitive-Qwen-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moelanoby/Sensitive-Qwen-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="moelanoby/Sensitive-Qwen-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("moelanoby/Sensitive-Qwen-0.5B") model = AutoModelForCausalLM.from_pretrained("moelanoby/Sensitive-Qwen-0.5B", 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 moelanoby/Sensitive-Qwen-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moelanoby/Sensitive-Qwen-0.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moelanoby/Sensitive-Qwen-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/moelanoby/Sensitive-Qwen-0.5B
- SGLang
How to use moelanoby/Sensitive-Qwen-0.5B 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 "moelanoby/Sensitive-Qwen-0.5B" \ --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": "moelanoby/Sensitive-Qwen-0.5B", "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 "moelanoby/Sensitive-Qwen-0.5B" \ --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": "moelanoby/Sensitive-Qwen-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use moelanoby/Sensitive-Qwen-0.5B with Docker Model Runner:
docker model run hf.co/moelanoby/Sensitive-Qwen-0.5B
To load this model from the Hugging Face Hub in Python:
# 0. If in Colab and it's a new session, or if model is private, authenticate:
# from huggingface_hub import notebook_login; notebook_login()
# 1. Import necessary libraries:
from transformers import AutoModelForCausalLM, AutoTokenizer
# The following torch imports might be needed if you were to define the classes manually,
# but trust_remote_code=True should handle it by loading them from the Hub.
# import torch
# import torch.nn as nn
# 2. Define your model ID:
MODEL_ID = "moelanoby/Sensitive-Qwen-0.5B"
# 3. Load tokenizer and model (trust_remote_code=True is CRUCIAL):
# This allows Transformers to download and use the Python file ('LLMadd.py')
# from your Hub repository, which contains the definitions for
# `SensitivityModule` and `SensitiveBottleneckLayer`.
try:
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, trust_remote_code=True, device_map='auto') # Add other params as needed
print(f'Model {MODEL_ID} loaded successfully!')
except Exception as e:
print(f'Error loading model: {e}')
print('Ensure the custom code file (LLMadd.py) in the Hub repo is correct and classes are defined.')
# 4. Example generation (adjust based on your model's chat template, e.g., Qwen2-Instruct):
# prompt = "What is the capital of France?"
# messages = [{"role": "user", "content": prompt}]
# text_input = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# model_inputs = tokenizer([text_input], return_tensors="pt").to(model.device)
# generated_ids = model.generate(model_inputs.input_ids, max_new_tokens=50)
# result = tokenizer.batch_decode(generated_ids[:, model_inputs.input_ids.shape[-1]:], skip_special_tokens=True)[0]
# print(f'Generated: {result}')
IMPORTANT: trust_remote_code=True allows the execution of Python code
from the 'moelanoby/Sensitive-Qwen-0.5B' repository on Hugging Face Hub.
- Downloads last month
- 4