0xtaipoian commited on
Commit
62e6b5e
·
verified ·
1 Parent(s): 02863c7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -10
README.md CHANGED
@@ -46,7 +46,7 @@ You can run it on [Colab](https://colab.research.google.com/drive/1FgdwkkPcLzn_x
46
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, LlamaTokenizer, GenerationConfig, pipeline
47
  from peft import PeftModel, PeftMixedModel
48
  import torch
49
- import pprint
50
 
51
  model_name = "0xtaipoian/open-lilm"
52
 
@@ -59,13 +59,12 @@ bnb_config = BitsAndBytesConfig(
59
  tokenizer = AutoTokenizer.from_pretrained(model_name)
60
  model = AutoModelForCausalLM.from_pretrained(
61
  model_name,
 
62
  torch_dtype=torch.bfloat16,
63
- device_map='auto',
64
  trust_remote_code=True,
65
  quantization_config=bnb_config,
66
  )
67
 
68
-
69
  def chat(messages, temperature=0.9, max_new_tokens=200):
70
  input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to('cuda:0')
71
  output_ids = model.generate(input_ids, max_new_tokens=max_new_tokens, temperature=temperature, do_sample=True)
@@ -83,13 +82,7 @@ messages = [
83
 
84
  "content":
85
  """
86
- 密陽44人輪姦案」受害女隔20年現身:時間停在2004,不記...
87
-
88
- 南韓密陽2004年曾發生一起44人輪姦一位14歲少女案件,44名加害者當時幾乎都未成年,
89
- 法官輕判引起社會聲浪抗議。案件如今過了20年,當年只有14歲的少女與妹妹相隔20年現
90
- 身,近日接受節目《想知道真相》訪問,坦言沒有藥物無法生活,時間就此停在了2004年
91
- 走不出來,「我的夢想是什麼,我不記得了。」只希望家人們從惡夢裡逃脫,過著幸福日
92
- 子。
93
  """}]
94
 
95
  result = chat(messages, max_new_tokens=200, temperature=1)
 
46
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, LlamaTokenizer, GenerationConfig, pipeline
47
  from peft import PeftModel, PeftMixedModel
48
  import torch
49
+
50
 
51
  model_name = "0xtaipoian/open-lilm"
52
 
 
59
  tokenizer = AutoTokenizer.from_pretrained(model_name)
60
  model = AutoModelForCausalLM.from_pretrained(
61
  model_name,
62
+ revision="main", #qlora-merged (qLoRA finetuned for 3 epochs) or main (full parameter finetune for 1 epoch)
63
  torch_dtype=torch.bfloat16,
 
64
  trust_remote_code=True,
65
  quantization_config=bnb_config,
66
  )
67
 
 
68
  def chat(messages, temperature=0.9, max_new_tokens=200):
69
  input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to('cuda:0')
70
  output_ids = model.generate(input_ids, max_new_tokens=max_new_tokens, temperature=temperature, do_sample=True)
 
82
 
83
  "content":
84
  """
85
+ 密陽44人輪姦案」受害女隔20年現身:時間停在2004,不記得
 
 
 
 
 
 
86
  """}]
87
 
88
  result = chat(messages, max_new_tokens=200, temperature=1)