Severian commited on
Commit
24e0d67
·
verified ·
1 Parent(s): 0058f94

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -15
README.md CHANGED
@@ -34,32 +34,45 @@ pipeline_tag: text-generation
34
  import torch
35
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
36
 
37
- # Load model in 4-bit precision
38
- quantization_config = BitsAndBytesConfig(
39
- load_in_4bit=True,
40
- llm_int8_skip_modules=["mamba"]
41
  )
 
42
  model = AutoModelForCausalLM.from_pretrained(
43
  "Severian/Jamba-Nexus-IKM-v1",
 
44
  trust_remote_code=True,
45
  torch_dtype=torch.bfloat16,
46
  attn_implementation="flash_attention_2",
47
- quantization_config=quantization_config
48
  )
49
  tokenizer = AutoTokenizer.from_pretrained("Severian/Jamba-Nexus-IKM-v1")
50
 
51
- # Tokenize input
52
- prompt = """How could we use cheese to reignite the sun? Answer:"""
53
- input_ids = tokenizer(
54
- prompt,
55
- return_tensors='pt'
56
- ).to(model.device)["input_ids"]
 
 
 
 
57
 
58
- # Generate answer
59
- outputs = model.generate(input_ids, max_new_tokens=216)
60
 
61
- # Print output
62
- print(tokenizer.batch_decode(outputs))
 
 
 
 
 
 
 
 
63
  ```
64
 
65
  ```
 
34
  import torch
35
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
36
 
37
+ double_quant_config = BitsAndBytesConfig(
38
+ load_in_4bit=True,
39
+ bnb_4bit_use_double_quant=True,
40
+ bnb_4bit_compute_dtype=torch.float16
41
  )
42
+
43
  model = AutoModelForCausalLM.from_pretrained(
44
  "Severian/Jamba-Nexus-IKM-v1",
45
+ device_map="auto",
46
  trust_remote_code=True,
47
  torch_dtype=torch.bfloat16,
48
  attn_implementation="flash_attention_2",
49
+ quantization_config=double_quant_config,
50
  )
51
  tokenizer = AutoTokenizer.from_pretrained("Severian/Jamba-Nexus-IKM-v1")
52
 
53
+ input_text = """<|im_start|>system
54
+ You are a helpful AI assistant.
55
+ <|im_end|>
56
+ <|im_start|>user
57
+ How could we use cheese to reignite the sun?
58
+ <|im_end|>
59
+ <|im_start|>assistant
60
+ """
61
+
62
+ input_ids = tokenizer(input_text, return_tensors='pt').to(model.device)["input_ids"]
63
 
64
+ outputs = model.generate(input_ids, max_new_tokens=1024, temperature=0.0, repetition_penalty=1.1)
 
65
 
66
+ print(tokenizer.batch_decode(outputs)[0])
67
+ # <|startoftext|><|im_start|>system
68
+ # You are a helpful AI assistant.
69
+ # <|im_end|>
70
+ # <|im_start|>user
71
+ # How could we use cheese to reignite the sun?
72
+ # <|im_end|>
73
+ # <|im_start|>assistant
74
+ # The idea of using cheese to reignite the sun may sound strange, but it's actually quite plausible. Here's how it works: 1. Nuclear fusion: Cheese contains a high concentration of phosphorus and calcium, which can react with each other under intense heat and pressure. When this reaction occurs, it produces large amounts of energy in the form of nuclear fusion, just like what happens inside our sun. 2. Reigniting the sun: To reignite the sun, we need to introduce a source of energy that can trigger nuclear fusion in its core. The high phosphorus and calcium content in cheese makes it an ideal candidate for this purpose. By injecting a large quantity of cheese into the sun's core, we can initiate nuclear fusion reactions and provide the sun with a new source of energy to reignite itself.<|im_end|>
75
+ # <|endoftext|>
76
  ```
77
 
78
  ```