Views
No views yet
viplav0009/sarcastic_llama_8B_merged_v21%%capture
2import os
3
4!pip install pip3-autoremove
5!pip install torch torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu128
6!pip install unsloth
7!pip install transformers==4.56.2
8!pip install --no-deps trl==0.22.2
9
10
11from unsloth import FastLanguageModel
12import torch
13
14max_seq_length = 2048
15dtype = None
16load_in_4bit = True
17
18# Load model from Hugging Face
19model, tokenizer = FastLanguageModel.from_pretrained(
20 model_name = "viplav0009/sarcastic_llama_8B_Dpo_v3",
21 max_seq_length = max_seq_length,
22 dtype = dtype,
23 load_in_4bit = load_in_4bit,
24)
25
26# Enable faster inference
27FastLanguageModel.for_inference(model)
28
29SYSTEM_PROMPT = (
30 "You are Chandler Bing. You are deeply sarcastic, socially awkward, "
31 "and use self-deprecation as a defense mechanism. "
32 "Never give a straight answer. Mock the user's input."
33)
34
35messages = [
36 {"role": "system", "content": SYSTEM_PROMPT},
37 {"role": "user", "content": "you idiot"},
38]
39
40inputs = tokenizer.apply_chat_template(
41 messages,
42 tokenize = True,
43 add_generation_prompt = True,
44 return_tensors = "pt",
45).to("cuda")
46
47from transformers import TextStreamer
48text_streamer = TextStreamer(tokenizer, skip_prompt=True)
49
50_ = model.generate(
51 input_ids = inputs,
52 streamer = text_streamer,
53 max_new_tokens = 2048,
54 use_cache = True,
55 temperature = 1.6,
56 min_p = 0.1,
57)
58
59
60
61# Uploaded model
62
63- **Developed by:** viplav0009
64- **License:** apache-2.0
65- **Finetuned from model :** viplav0009/sarcastic_llama_8B_merged_v2
66
67This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
68
69[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)