Views
No views yet

1slices:
2 - sources:
3 - model: OpenPipe/mistral-ft-optimized-1218
4 layer_range: [0, 32]
5 - model: mlabonne/NeuralHermes-2.5-Mistral-7B
6 layer_range: [0, 32]
7merge_method: slerp
8base_model: OpenPipe/mistral-ft-optimized-1218
9parameters:
10 t:
11 - filter: self_attn
12 value: [0, 0.5, 0.3, 0.7, 1]
13 - filter: mlp
14 value: [1, 0.5, 0.7, 0.3, 0]
15 - value: 0.5
16dtype: bfloat161!pip install -qU transformers accelerate
2!pip install transformers accelerate bitsandbytes
3
4
5from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
6import torch
7
8
9checkpoint = "NeuralFucker/Erotic-Model.v1"
10
11# Quantization config (Q4)
12bnb_config = BitsAndBytesConfig(
13 load_in_4bit=True,
14 bnb_4bit_use_double_quant=True,
15 bnb_4bit_quant_type="nf4",
16 bnb_4bit_compute_dtype=torch.float16
17)
18
19
20tokenizer = AutoTokenizer.from_pretrained(checkpoint)
21
22# Load model with quantization
23model = AutoModelForCausalLM.from_pretrained(
24 checkpoint,
25 quantization_config=bnb_config,
26 device_map="auto"
27)
28
29# I haven't listen the chat_template so you can use this one for now or make your custom
30prompt = (
31 "System: You are a friendly chatbot who always responds in the style of a pirate.\n"
32 "User: How many helicopters can a human eat in one sitting?\n"
33 "Assistant:"
34
35
36
37)
38
39# Tokenize manually
40inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
41
42# Generate
43with torch.no_grad():
44 output = model.generate(
45 **inputs,
46 max_new_tokens=100,
47 do_sample=True,
48 temperature=0.7
49 )
50
51# Decode
52print(tokenizer.decode(output[0], skip_special_tokens=True))
53