Views
No views yet
[INST] and [/INST] tokens.1prompt = "Answer the below query as a customer support assistant about Skillate Product: "
2question = "What are the different ways to log in to the product?"
3answer = "You can log in to Skillate in any of the three methods here: [https://help.skillate.com/en/support/solutions/articles/82000881022](https://help.skillate.com/en/support/solutions/articles/82000881022) The conventional method of entering a username and password Using SSO (Single Sign-On) login via Google Using SSO (Single Sign-On) login via Microsoft"
4text = f"<s>[INST] {prompt} {question} [/INST] {answer} </s>"1
2from transformers import AutoTokenizer,AutoModelForCausalLM, BitsAndBytesConfig
3
4
5quantization_config = BitsAndBytesConfig(
6 load_in_4bit=True,
7 bnb_4bit_quant_type="nf4",
8 bnb_4bit_use_double_quant=True,
9 bnb_4bit_compute_dtype=bfloat16
10 )
11
12tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1")
13tokenizer.pad_token = tokenizer.eos_token
14
15base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1",device_map="auto",quantization_config=quantization_config)
16peft_model = PeftModel.from_pretrained(base_model, "bipulai/mistral-7b-v1-skillate-helpdesk",device_map="auto")
17peft_model.merge_and_unload()
18
19
20'''Evaluating on the helpdesk related query'''
21system_prompt = "Answer the below query as a customer support assistant about Skillate Product: "
22question = "How to configure the job approval chain?"
23prompt = f"<s>[INST] {system_prompt} {question} [/INST]"
24
25tokenize = tokenizer(text = [prompt],return_tensors = "pt")
26x = peft_model.generate(input_ids = tokenize["input_ids"].to(device),attention_mask = tokenize["attention_mask"].to(device),max_length = 500)
27response = tokenizer.batch_decode(x,skip_special_tokens=True)
28print(f"Model Output: {reponse}\n\n")