madcows commited on
Commit
e147c0d
·
verified ·
1 Parent(s): f1bdc17

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -50,6 +50,52 @@ The chat template was updated accordingly to support multi-turn conversation for
50
  {% if add_generation_prompt %}{{ '<|assistant|>' }}{% endif %}
51
  ```
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  ## 📌 Caution
54
  * Commercial use is strictly prohibited.
55
 
 
50
  {% if add_generation_prompt %}{{ '<|assistant|>' }}{% endif %}
51
  ```
52
 
53
+ ## 🧪 Inference with Transformers
54
+ Below is an example of how to load and use the model with the adjusted tokenizer, token IDs, and custom prompt template.
55
+
56
+ > **Note**: This model uses a custom `chat_template` and updated special token IDs:
57
+ > - `<|end|>` → 200020 (EOS)
58
+ > - `<|dummy_85|>` → 200029 (PAD)
59
+ > - `�` → 200030 (UNK)
60
+ >
61
+
62
+ ```python
63
+ from transformers import AutoTokenizer, AutoModelForCausalLM
64
+
65
+ model_path = "madcows/siwon-mini-instruct-0626"
66
+
67
+ model = AutoModelForCausalLM.from_pretrained(
68
+ model_path,
69
+ device_map="auto",
70
+ torch_dtype=torch.bfloat16,
71
+ trust_remote_code=True
72
+ )
73
+
74
+ tokenizer = AutoTokenizer.from_pretrained(
75
+ model_path,
76
+ trust_remote_code=True,
77
+ )
78
+
79
+ messages = [
80
+ {"role": "system", "content": "You are a helpful assistant."},
81
+ {"role": "user", "content": "안녕하세요."},
82
+ ]
83
+
84
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
85
+
86
+ output = model.generate(
87
+ **inputs,
88
+ max_new_tokens=2048,
89
+ # do_sample=True, # Optional
90
+ # top_p=0.95, # Optional
91
+ # temperature=0.6, # Optional
92
+ # repetition_penalty=1.1, # Optional
93
+ )
94
+
95
+ response = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
96
+ print(response)
97
+ ```
98
+
99
  ## 📌 Caution
100
  * Commercial use is strictly prohibited.
101