Views
No views yet
bitsandbytes quantization config was used during training:1from peft import PeftModel, PeftConfig
2from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3import torch
4config = PeftConfig.from_pretrained("SalehAhmad/Mistral-7B-Instruct-v0.1-JSON-Test_Generation-2-Epoch", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
5tokenizer = AutoTokenizer.from_pretrained("SalehAhmad/Mistral-7B-Instruct-v0.1-JSON-Test_Generation-2-Epoch", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
6model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
7model = PeftModel.from_pretrained(model, "SalehAhmad/Mistral-7B-Instruct-v0.1-JSON-Test_Generation-2-Epoch", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
8tokenizer.pad_token = tokenizer.eos_token
9tokenizer.padding_side = "right"
10tokenizer.pad_token_id = tokenizer.eos_token_id
11
12pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=2046, return_full_text=False, device_map="auto",
13 kwargs={'stop': ["###Human:"]})
14
15Sys_OBJECTIVE = '''You are a chatbot, who is helping to curate datasets. When given an input context paragraph, you have to generate only one mcq question,
16it's options and it's actual answer. You have to follow the given JSON format for generating the question, options and answer.
17Donot use words like "in this paragraph", "from the context" etc. The questions should be independent of any other question.'''
18
19Sys_SUBJECTIVE = '''You are a chatbot, who is helping to curate datasets. When given an input context paragraph, you have to generate only one subjective quesion,
20and it's actual answer. You have to follow the given JSON format for generating the question and answer.
21Donot use words like "in this paragraph", "from the context" etc. The questions should be independent of any other question.'''
22
23Prompt = '''And in the leadership styles it will be that is the is the there will be the changing into the leadership styles and in the leadership styles it will be that is the the approach will be for doing this type of the research which has been adopted in this paper is that is the degree of the correlation and its statistical significance between the self-assess leadership behavior and the 360 degree assessment of performance, evidence is presented showing that results vary in different context.'''
24
25Formatted_Prompt_OBJECTIVE = f"###Human: {Sys_OBJECTIVE}\nThe context is: {Prompt}\n###Assistant: "
26
27Formatted_Prompt_SUBJECTIVE = f"###Human: {Sys_SUBJECTIVE}\nThe context is: {Prompt}\n###Assistant: "
28print(Formatted_Prompt_OBJECTIVE), print(Formatted_Prompt_SUBJECTIVE)
29
30response = pipe(Formatted_Prompt_OBJECTIVE)
31print(response)