Downloads · 30 days
0
CherryScallion/CyberGong-Qwen2.5-1.5B-1.0
CyberGong-Qwen2.5-1.5B-1.0 is a machine learning model from CherryScallion. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
A local-runnable personal style language model inference project based on Qwen2.5-1.5B and LoRA adapter.
Downloads · 30 days
0
Access
Public
Updated May 19, 2026
Repo size
3.2 GB
Likes
1
Public
Click a slice to open those files.
.safetensors3.2 GB · 99%
From the Hugging Face model README
A local-runnable personal style language model inference project based on Qwen2.5-1.5B and LoRA adapter.
CyberGong/
├── configs/
│ └── infer.yaml # Inference configuration file
├── models/
│ ├── Qwen2.5-1.5B/ # Base model directory
│ ├── your-persona-lora/ # LoRA adapter directory
│ └── merged-persona-model/ # Merged model
├── src/
│ ├── download_model.py # Model download script
│ ├── load_model.py # Model loading script
│ ├── chat.py # Chat/inference script
│ ├── merge_lora.py # LoRA merging script
│ └── utils.py # Utility functions
├── data/
│ └── prompts.jsonl # Test prompts
└── README.md # This file
pip install transformers peft bitsandbytes torch huggingface-hub pyyaml
python src/download_model.py \
--model-id Qwen/Qwen2.5-1.5B \
--output-dir ./models/Qwen2.5-1.5B
Options:
--model-id: HuggingFace model ID (default: Qwen/Qwen2.5-1.5B)--output-dir: Local output directory--cache-dir: Optional cache directory--max-workers: Concurrent download workers (default: 4)--use-cli: Use huggingface-cli to downloadpython src/chat.py --model-dir ./models/Qwen2.5-1.5B
Options:
--model-dir: Model directory--no-4bit: Disable 4-bit quantization--device-map: Device allocation (default: auto)First prepare LoRA adapter directory, which should contain:
adapter_config.jsonadapter_model.safetensorspython src/chat.py \
--model-dir ./models/Qwen2.5-1.5B \
--adapter ./models/your-persona-lora
Merge adapter with base model into a standalone model:
python src/merge_lora.py \
--model-dir ./models/Qwen2.5-1.5B \
--adapter-dir ./models/your-persona-lora \
--output-dir ./models/merged-persona-model
After merging, it can be directly loaded and used:
python src/chat.py --model-dir ./models/merged-persona-model
python src/chat.py --model-dir ./models/Qwen2.5-1.5B
Commands:
exit: Exit chatclear: Clear chat historysave: Save conversation to conversation.jsonpython src/chat.py \
--model-dir ./models/Qwen2.5-1.5B \
--prompt "Hello, please introduce yourself"
Edit configs/infer.yaml to configure parameters:
model:
base_model_dir: ./models/Qwen2.5-1.5B
adapter_dir: ./models/your-persona-lora
generation:
max_new_tokens: 256
temperature: 0.7
top_p: 0.9
chat:
system_prompt: "You are a helpful assistant."
max_history_length: 10
Then run:
python src/chat.py --config ./configs/infer.yaml
load_model.py)Load Base Model:
from load_model import load_base_model
model, tokenizer = load_base_model(
model_dir="./models/Qwen2.5-1.5B",
use_4bit=True,
device_map="auto"
)
Load LoRA Adapter:
from load_model import load_persona_adapter
model_with_adapter = load_persona_adapter(
base_model=model,
adapter_dir="./models/your-persona-lora"
)
chat.py)from chat import PersonaChat
from load_model import load_base_model
model, tokenizer = load_base_model("./models/Qwen2.5-1.5B")
chat = PersonaChat(model, tokenizer)
# Single-turn conversation
response = chat.generate("Hello")
# Get history
history = chat.get_history()
# Save conversation
chat.save_conversation("output.json")
merge_lora.py)from merge_lora import merge_and_unload
success = merge_and_unload(
base_model_dir="./models/Qwen2.5-1.5B",
adapter_dir="./models/your-persona-lora",
output_dir="./models/merged-persona-model"
)
quantization:
use_4bit: true # Enable 4-bit quantization
compute_dtype: bfloat16 # Compute precision
quant_type: nf4 # Quantization type
4-bit Quantization Benefits:
generation:
max_new_tokens: 256 # Maximum tokens to generate
temperature: 0.7 # Temperature (higher = more random)
top_p: 0.9 # Top-P sampling
top_k: 50 # Top-K sampling
repetition_penalty: 1.1 # Repetition penalty
do_sample: true # Whether to use sampling
num_beams: 1 # Beam search (1 = disabled)
Problem: torch.cuda.OutOfMemoryError
Solution:
--no-4bitmax_new_tokensmax_history_lengthProblem: FileNotFoundError: Model directory does not exist
Solution:
python src/download_model.pymodel_inference.logProblem: Invalid adapter directory
Solution:
adapter_config.json existsadapter_model.safetensors exists| Configuration | VRAM Usage | Inference Speed | Notes |
|---|---|---|---|
| Base (no quantization) | ~5.5GB | Fast | May run out of VRAM |
| Base (4-bit) | ~2GB | Fast | Recommended |
| Base + Adapter | +0.5GB | Slightly slower | Depends on adapter size |
| Merged model | Same as base | Same as base | Same as base |
All operations are logged to model_inference.log:
2024-01-15 10:30:45,123 - __main__ - INFO - Start loading base model
2024-01-15 10:30:46,456 - load_model - INFO - ✓ Tokenizer loaded successfully
...
All operations support offline mode, provided model files are completely downloaded:
download_model.pydevice_map="cpu" or "auto" instead of "cuda:0"# 1. Download model (first time, requires network)
python src/download_model.py
# 2. Test base model
python src/chat.py --prompt "test"
# 3. Develop adapter
# Use external tools to train adapter...
# 4. Test adapter
python src/chat.py --adapter ./models/your-persona-lora
# 5. Merge model
python src/merge_lora.py
# Directly load merged model
python src/chat.py --model-dir ./models/merged-persona-model
pip install gradio
# Create src/gradio_app.py
pip install fastapi uvicorn
# Create src/api_server.py
Q: Can I use other models?
A: Yes, modify hf_model_id in config.yaml. Just ensure it's compatible with AutoModelForCausalLM.
Q: How to support multiple adapters?
A: PeftModel can load multiple adapters simultaneously, see peft official documentation.
Q: Can I continue loading adapters after merging?
A: The merged model is a complete standalone model and can be used as a new base model to load other adapters.
Q: How to optimize inference speed?
A:
num_beams=1 (disable beam search)max_new_tokensdevice_map="auto" for automatic allocationMIT License
Feedback and suggestions are welcome! <img width="1024" height="1536" alt="2c78bf7267ec02e21286fa5a1a4d5078" src="https://github.com/user-attachments/assets/7ff31cf2-6ee8-4a37-9896-44bb9b6cba9b" />