Text Generation
Transformers
Safetensors
qwen2
text-generation-inference
unsloth
trl
sft
conversational
Instructions to use KingNish/Qwen2.5-0.5b-RBase with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KingNish/Qwen2.5-0.5b-RBase with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KingNish/Qwen2.5-0.5b-RBase") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("KingNish/Qwen2.5-0.5b-RBase") model = AutoModelForCausalLM.from_pretrained("KingNish/Qwen2.5-0.5b-RBase") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use KingNish/Qwen2.5-0.5b-RBase with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KingNish/Qwen2.5-0.5b-RBase" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KingNish/Qwen2.5-0.5b-RBase", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KingNish/Qwen2.5-0.5b-RBase
- SGLang
How to use KingNish/Qwen2.5-0.5b-RBase 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 "KingNish/Qwen2.5-0.5b-RBase" \ --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": "KingNish/Qwen2.5-0.5b-RBase", "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 "KingNish/Qwen2.5-0.5b-RBase" \ --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": "KingNish/Qwen2.5-0.5b-RBase", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use KingNish/Qwen2.5-0.5b-RBase with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KingNish/Qwen2.5-0.5b-RBase to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KingNish/Qwen2.5-0.5b-RBase to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for KingNish/Qwen2.5-0.5b-RBase to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="KingNish/Qwen2.5-0.5b-RBase", max_seq_length=2048, ) - Docker Model Runner
How to use KingNish/Qwen2.5-0.5b-RBase with Docker Model Runner:
docker model run hf.co/KingNish/Qwen2.5-0.5b-RBase
Improve language tag
#1
by lbourdois - opened
README.md
CHANGED
|
@@ -1,79 +1,91 @@
|
|
| 1 |
-
---
|
| 2 |
-
base_model:
|
| 3 |
-
- Qwen/Qwen2.5-0.5B-Instruct
|
| 4 |
-
language:
|
| 5 |
-
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- Qwen/Qwen2.5-0.5B-Instruct
|
| 4 |
+
language:
|
| 5 |
+
- zho
|
| 6 |
+
- eng
|
| 7 |
+
- fra
|
| 8 |
+
- spa
|
| 9 |
+
- por
|
| 10 |
+
- deu
|
| 11 |
+
- ita
|
| 12 |
+
- rus
|
| 13 |
+
- jpn
|
| 14 |
+
- kor
|
| 15 |
+
- vie
|
| 16 |
+
- tha
|
| 17 |
+
- ara
|
| 18 |
+
license: apache-2.0
|
| 19 |
+
tags:
|
| 20 |
+
- text-generation-inference
|
| 21 |
+
- transformers
|
| 22 |
+
- unsloth
|
| 23 |
+
- qwen2
|
| 24 |
+
- trl
|
| 25 |
+
- sft
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# Qwen 2.5 0.5B Model
|
| 29 |
+
|
| 30 |
+
## Model Description
|
| 31 |
+
|
| 32 |
+
This model is a compact yet powerful language model trained to answer a variety of questions with impressive quality. Despite its smaller size, it has demonstrated performance comparable to Llama 3.2 1B, and in some cases, it even outperforms it. This model was specifically trained on a 12,800 rows of the Magpie 300k Dataset.
|
| 33 |
+
|
| 34 |
+
## Performance
|
| 35 |
+
|
| 36 |
+
The Qwen 2.5 model has shown promising results in various tests, including the "strawberry test, Decimal Comparison test" where it successfully provided accurate answers. However, it is important to note that, like many models of its size, it may occasionally produce incorrect answers or flawed reasoning. Continuous improvements and full training are planned to enhance its performance further.
|
| 37 |
+
|
| 38 |
+
## How to Use
|
| 39 |
+
|
| 40 |
+
To use the Qwen 2.5 model, you can load it using the Hugging Face Transformers library. Here’s a simple example:
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
model_name = "KingNish/Qwen2.5-0.5b-Test-ft"
|
| 46 |
+
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 48 |
+
model_name,
|
| 49 |
+
torch_dtype="auto",
|
| 50 |
+
device_map="auto"
|
| 51 |
+
)
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 53 |
+
|
| 54 |
+
prompt = "Which is greater 9.9 or 9.11 ??"
|
| 55 |
+
messages = [
|
| 56 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
| 57 |
+
{"role": "user", "content": prompt}
|
| 58 |
+
]
|
| 59 |
+
text = tokenizer.apply_chat_template(
|
| 60 |
+
messages,
|
| 61 |
+
tokenize=False,
|
| 62 |
+
add_generation_prompt=True
|
| 63 |
+
)
|
| 64 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 65 |
+
|
| 66 |
+
generated_ids = model.generate(
|
| 67 |
+
**model_inputs,
|
| 68 |
+
max_new_tokens=512
|
| 69 |
+
)
|
| 70 |
+
generated_ids = [
|
| 71 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 75 |
+
|
| 76 |
+
print(response)
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Future Work
|
| 80 |
+
|
| 81 |
+
I am actively working on improving the Qwen 2.5 model by training it on a larger dataset.
|
| 82 |
+
|
| 83 |
+
# Uploaded model
|
| 84 |
+
|
| 85 |
+
- **Developed by:** KingNish
|
| 86 |
+
- **License:** apache-2.0
|
| 87 |
+
- **Finetuned from model :** Qwen/Qwen2.5-0.5B-Instruct
|
| 88 |
+
|
| 89 |
+
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 90 |
+
|
| 91 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|