Views
No views yet
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps "xformers<0.0.27" "trl<0.9.0" peft accelerate bitsandbytes1alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
2
3### Instruction:
4{}
5
6### Input:
7{}
8
9### Response:
10{}"""
11
12if True:
13 from unsloth import FastLanguageModel
14 model, tokenizer = FastLanguageModel.from_pretrained(
15 model_name = "lightontech/SeaLightSum3-Adapter", # YOUR MODEL YOU USED FOR TRAINING
16 max_seq_length = max_seq_length,
17 dtype = dtype,
18 load_in_4bit = load_in_4bit,
19 )
20 FastLanguageModel.for_inference(model) # Unsloth has 2x faster inference!
21
22# alpaca_prompt = You MUST copy from above!
23FastLanguageModel.for_inference(model) # Unsloth has 2x faster inference!
24inputs = tokenizer(
25[
26 alpaca_prompt.format(
27 "Dịch đoạn văn sau sang tiếng Việt:\nOnce you have trained a model using either the SFTTrainer, PPOTrainer, or DPOTrainer, you will have a fine-tuned model that can be used for text generation. In this section, we’ll walk through the process of loading the fine-tuned model and generating text. If you need to run an inference server with the trained model, you can explore libraries such as text-generation-inference.", # instruction
28 "", # input
29 "", # output - leave this blank for generation!
30 )
31], return_tensors = "pt").to("cuda")
32
33from transformers import TextStreamer
34text_streamer = TextStreamer(tokenizer)
35_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 1000)