Views
No views yet
deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B model, optimized for efficient inference with reduced memory usage. The quantization was performed using the bitsandbytes library.deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B1from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
2import torch
3
4# Quantization configuration
5quantization_config = BitsAndBytesConfig(
6 load_in_4bit=True,
7 bnb_4bit_quant_type="nf4",
8 bnb_4bit_compute_dtype=torch.bfloat16,
9 bnb_4bit_use_double_quant=True
10)
11
12# Load the model and tokenizer
13tokenizer = AutoTokenizer.from_pretrained("emredeveloper/DeepSeek-R1-Distill-Qwen-1.5B-4bit", trust_remote_code=True)
14model = AutoModelForCausalLM.from_pretrained(
15 "emredeveloper/DeepSeek-R1-Distill-Qwen-1.5B-4bit",
16 quantization_config=quantization_config,
17 device_map="auto",
18 trust_remote_code=True
19)
20
21# Generate text
22input_text = "Hello, how are you?"
23inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
24outputs = model.generate(**inputs, max_new_tokens=50)
25print(tokenizer.decode(outputs[0], skip_special_tokens=True))