dodo2 commited on
Commit
dc21dfa
·
verified ·
1 Parent(s): 29887b7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +98 -9
README.md CHANGED
@@ -1,6 +1,14 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
4
  ---
5
 
6
  # Model Card for Model ID
@@ -17,29 +25,110 @@ tags: []
17
 
18
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
  - **Funded by [optional]:** [More Information Needed]
22
  - **Shared by [optional]:** [More Information Needed]
23
  - **Model type:** [More Information Needed]
24
  - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
  - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
  ### Model Sources [optional]
29
 
30
  <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
  - **Paper [optional]:** [More Information Needed]
34
  - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
  [More Information Needed]
45
 
 
1
  ---
2
  library_name: transformers
3
+ pipeline_tag: text-generation
4
+ license: apache-2.0
5
+ datasets:
6
+ - dodo2/llama3_coaching
7
+ language:
8
+ - ko
9
+ - en
10
+ base_model:
11
+ - meta-llama/Meta-Llama-3-8B-Instruct
12
  ---
13
 
14
  # Model Card for Model ID
 
25
 
26
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
27
 
28
+ - **Developed by:** Do-Yoon Jung (rabbitsun2@gmail.com)
29
  - **Funded by [optional]:** [More Information Needed]
30
  - **Shared by [optional]:** [More Information Needed]
31
  - **Model type:** [More Information Needed]
32
  - **Language(s) (NLP):** [More Information Needed]
33
+ - **License:** Apache License
34
  - **Finetuned from model [optional]:** [More Information Needed]
35
 
36
  ### Model Sources [optional]
37
 
38
  <!-- Provide the basic links for the model. -->
39
 
40
+ - **Repository:** meta-llama/Meta-Llama-3-8B-Instruct
41
  - **Paper [optional]:** [More Information Needed]
42
  - **Demo [optional]:** [More Information Needed]
43
 
 
44
 
45
+ ## How to use
46
+
47
+ This repository contains two versions of Meta-Llama-3-8B-Instruct, for use with transformers and with the original `llama3` codebase.
48
+
49
+ ### Use with transformers
50
+
51
+ You can run conversational inference using the Transformers pipeline abstraction, or by leveraging the Auto classes with the `generate()` function. Let's see examples of both.
52
+
53
+ #### Transformers pipeline
54
+
55
+ ```python
56
+ import transformers
57
+ import torch
58
+
59
+ model_id = "dodo2/llama3-ko-8b-dodo"
60
+
61
+ pipeline = transformers.pipeline(
62
+ "text-generation",
63
+ model=model_id,
64
+ model_kwargs={"torch_dtype": torch.bfloat16},
65
+ device_map="auto",
66
+ )
67
+
68
+ messages = [
69
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
70
+ {"role": "user", "content": "Who are you?"},
71
+ ]
72
+
73
+ terminators = [
74
+ pipeline.tokenizer.eos_token_id,
75
+ pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
76
+ ]
77
+
78
+ outputs = pipeline(
79
+ messages,
80
+ max_new_tokens=256,
81
+ eos_token_id=terminators,
82
+ do_sample=True,
83
+ temperature=0.6,
84
+ top_p=0.9,
85
+ )
86
+ print(outputs[0]["generated_text"][-1])
87
+ ```
88
+
89
+ #### Transformers AutoModelForCausalLM
90
+
91
+ ```python
92
+ from transformers import AutoTokenizer, AutoModelForCausalLM
93
+ import torch
94
+
95
+ model_id = "dodo2/llama3-ko-8b-dodo"
96
+
97
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
98
+ model = AutoModelForCausalLM.from_pretrained(
99
+ model_id,
100
+ torch_dtype=torch.bfloat16,
101
+ device_map="auto",
102
+ )
103
+
104
+ messages = [
105
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
106
+ {"role": "user", "content": "Who are you?"},
107
+ ]
108
+
109
+ input_ids = tokenizer.apply_chat_template(
110
+ messages,
111
+ add_generation_prompt=True,
112
+ return_tensors="pt"
113
+ ).to(model.device)
114
+
115
+ terminators = [
116
+ tokenizer.eos_token_id,
117
+ tokenizer.convert_tokens_to_ids("<|eot_id|>")
118
+ ]
119
+
120
+ outputs = model.generate(
121
+ input_ids,
122
+ max_new_tokens=256,
123
+ eos_token_id=terminators,
124
+ do_sample=True,
125
+ temperature=0.6,
126
+ top_p=0.9,
127
+ )
128
+ response = outputs[0][input_ids.shape[-1]:]
129
+ print(tokenizer.decode(response, skip_special_tokens=True))
130
+ ```
131
 
 
 
 
132
 
133
  [More Information Needed]
134