MRAIRR commited on
Commit
418a117
β€’
1 Parent(s): 8957012

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -3
README.md CHANGED
@@ -2,6 +2,55 @@
2
  license: apache-2.0
3
  ---
4
 
5
- Train Config
6
- base_model: allganize/Llama-3-Alpha-Ko-8B-Instruct
7
- model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  ---
4
 
5
+ - Train Config
6
+ - base_model: allganize/Llama-3-Alpha-Ko-8B-Instruct
7
+ - model_type: AutoModelForCausalLM tokenizer_type: AutoTokenizer
8
+
9
+ ## HOW TO USE
10
+ ```python
11
+ from transformers import AutoTokenizer, AutoModelForCausalLM
12
+
13
+ model_id = "MRAIRR/minillama3_8b_all"
14
+
15
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
16
+ model = AutoModelForCausalLM.from_pretrained(
17
+ model_id,
18
+ torch_dtype="auto",
19
+ device_map="auto",
20
+ )
21
+
22
+ PROMPT_TEMPLATE = """
23
+ # μ§€μ‹œ:
24
+ 당신은 인곡지λŠ₯ μ–΄μ‹œμŠ€ν„΄νŠΈμž…λ‹ˆλ‹€. μ‚¬μš©μžκ°€ λ¬»λŠ” 말에 μΉœμ ˆν•˜κ³  μ •ν™•ν•˜κ²Œ λ‹΅λ³€ν•˜μ„Έμš”.
25
+ """
26
+
27
+ messages = [
28
+ {"role": "system", "content":PROMPT_TEMPLATE},
29
+ {"role": "user", "content": "μ•ˆλ…•? λ‚΄ 이름은 ν˜„μˆ˜ γ…Žγ…Ž λ§Œλ‚˜μ„œ λ°˜κ°€μ›Œ"},
30
+ ]
31
+
32
+ input_ids = tokenizer.apply_chat_template(
33
+ messages,
34
+ add_generation_prompt=True,
35
+ return_tensors="pt"
36
+ ).to(model.device)
37
+
38
+ terminators = [
39
+ tokenizer.eos_token_id,
40
+ tokenizer.convert_tokens_to_ids("<|eot_id|>")
41
+ ]
42
+
43
+ outputs = model.generate(
44
+ input_ids,
45
+ max_new_tokens=256,
46
+ temperature = 0.3,
47
+ eos_token_id=terminators,
48
+ do_sample=True,
49
+ repetition_penalty=1.05,
50
+ )
51
+ response = outputs[0][input_ids.shape[-1]:]
52
+ response_text = tokenizer.decode(response, skip_special_tokens=True)
53
+ completion = '\n'.join(response_text.split("."))
54
+ print(completion)
55
+ ```
56
+