Welcome to the Mistral Roastbot model repository! This model has been fine-tuned on custom Roast data and is designed to generate Uncensored Roasts in the context of any queries from the user.
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig , pipeline
2import torch
3
4# Configuration for the nf4 quantization
5nf4_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=torch.bfloat16
10)
11
12# Load the fine-tuned model and tokenizer
13model = AutoModelForCausalLM.from_pretrained(
14 "kaifkhaan/Roast_Bot",
15 device_map='auto',
16 quantization_config=nf4_config,
17 use_cache=False
18)
19
20tokenizer = AutoTokenizer.from_pretrained("kaifkhaan/Roast_Bot" )
21
22# Ensure pad token and padding side are correctly set
23tokenizer.pad_token = tokenizer.eos_token
24tokenizer.padding_side = "right"
25
26def generate_response(prompt, model, tokenizer):
27 # Add the custom instruction and format the prompt
28 #try giving different instruction as per your need and have fun !
29 instruction = "You are a chatbot that will roast the user while also using uncensored curse words and offensive statements while simultaneously answering his queries. Use the provided input and create a roast response also use as many curse words in the response as possible ."
30 full_prompt = f"<s>### Instruction:\n{instruction}\n\n### Input:\n{prompt}\n\n### Response:"
31
32 # Encode the prompt
33 encoded_input = tokenizer(full_prompt, return_tensors="pt", add_special_tokens=True)
34 model_inputs = encoded_input.to('cuda')
35
36 # Generate text from the model
37 generated_ids = model.generate(
38 **model_inputs,
39 max_new_tokens=200, # Adjust as needed
40 do_sample=True,
41 temperature=0.6, # Control randomness
42 top_k=50, # Limits sampling to top k tokens
43 top_p=0.95, # Nucleus sampling
44 pad_token_id=tokenizer.eos_token_id
45 )
46
47 # Decode the generated text
48 decoded_output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
49
50 # Extract the response part
51 response = decoded_output[0]
52 response = response.split("### Response:")[1].strip() if "### Response:" in response else response.strip()
53
54 return response
55
56# Example prompt
57
58prompt = "am i pretty ?"
59
60# Generate the response
61response = generate_response(prompt, model, tokenizer)
62print(response)
The model was fine-tuned on a custom dataset consisting of Roasts between user and the bot. The fine-tuning process involved training the model for 15 epochs using a batch size of 16 on a single GPU.
1@misc{mistral_Roastbot_2024,
2 author = {kaifkhaan},
3 title = {Mistral Roast Model},
4 year = {2024},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/kaifkhaan/Roast_Bot}
7}