Views
No views yet
1pip install unsloth
2# Also get the latest nightly Unsloth!
3pip uninstall unsloth -y && pip install --upgrade --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git1model, tokenizer = FastLanguageModel.from_pretrained(
2 model_name = "brandon57/mistral-fastgpt-7b",
3 max_seq_length = max_seq_length,
4 dtype = dtype,
5 load_in_4bit = load_in_4bit,
6)1FastLanguageModel.for_inference(model) # Enable native 2x faster inference
2messages = [ # Change below!
3 {"role": "user", "content": "Continue the fibonacci sequence! Your input is 1, 1, 2, 3, 5, 8"},
4 {"role": "assistant", "content": "The fibonacci sequence continues as 13, 21, 34, 55 and 89."},
5 {"role": "user", "content": "What is France's tallest tower called?"},
6]
7input_ids = tokenizer.apply_chat_template(
8 messages,
9 add_generation_prompt = True,
10 return_tensors = "pt",
11).to("cuda")
12
13from transformers import TextStreamer
14text_streamer = TextStreamer(tokenizer, skip_prompt = True)
15_ = model.generate(input_ids, streamer = text_streamer, max_new_tokens = 128, pad_token_id = tokenizer.eos_token_id)