Views
No views yet
1
2!pip install unsloth
3# Also get the latest nightly Unsloth!
4!pip install --force-reinstall --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git
5from unsloth import FastLanguageModel
6import torch
7max_seq_length = 5120 # I chose this value based on Qwen's max sequence length.
8dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
9load_in_4bit = True
10
11model, tokenizer = FastLanguageModel.from_pretrained(
12 model_name = "sindhusatish97/DeepSeek-R1-Distill-Qwen-14B-unsloth-bnb-4bit-AIMO_CoT",
13 max_seq_length = max_seq_length,
14 dtype = dtype,
15 load_in_4bit = load_in_4bit,
16 # token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
17)
18FastLanguageModel.for_inference(model)
19inputs = tokenizer(
20[
21 """4 pints of a 5% antifreeze solution and 8 pints of a 20% antifreeze solution must be mixed to obtain 12 pints of a
22 solution with what percentage of antifreeze?"""
23], return_tensors = "pt").to("cuda")
24
25from transformers import TextStreamer
26text_streamer = TextStreamer(tokenizer)
27_ = model.generate(**inputs, streamer = text_streamer, max_length = 2048)