Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
- [maywell/Synatra-7B-v0.3-Translation](https://huggingface.co/maywell/Synatra-7B-v0.3-Translation) λͺ¨λΈμ΄ νλ‘κ·Έλ¨ μ½λκ° ν¬ν¨λ μ¬λ¬ μ€μ κΈ΄ ν
μ€νΈλ₯Ό λ²μνλλ° μ νμ΄ μμ΄μ ν΄λΉ λΆλΆμ LoRAλ‘ μΆκ° νμ΅νμ΅λλ€.
|
3 |
+
|
4 |
+
### μ¬μ© μμ
|
5 |
+
````
|
6 |
+
import torch
|
7 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
+
|
9 |
+
device = "cuda:1" if torch.cuda.is_available() else "cpu"
|
10 |
+
|
11 |
+
model_id = "maywell/Synatra-7B-v0.3-Translation"
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=model_revision)
|
13 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, revision=model_revision, device_map=device, torch_dtype=torch.float16).eval()
|
14 |
+
|
15 |
+
model.load_adapter("heegyu/1223-Synatra-7B-v0_3-Translation-en2ko-mt-glaive-2e-5", revision="epoch-3")
|
16 |
+
|
17 |
+
|
18 |
+
def generate(prompt, *messages):
|
19 |
+
messages = [
|
20 |
+
{
|
21 |
+
"role": "system",
|
22 |
+
"content": prompt.strip(),
|
23 |
+
},
|
24 |
+
*[{"role": "user" if i % 2 == 0 else "assistant", "content": m.strip()} for i, m in enumerate(messages)],
|
25 |
+
]
|
26 |
+
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device)
|
27 |
+
outs = model.generate(inputs, do_sample=True, max_new_tokens=256, early_stopping=True)
|
28 |
+
print(tokenizer.batch_decode(outs)[0])
|
29 |
+
|
30 |
+
generate(
|
31 |
+
"λ§ν¬λ€μ΄μΌλ‘ μμ±λ μμ΄ λνλ₯Ό νκ΅μ΄λ‘ λ²μνμΈμ. νλ‘κ·Έλ¨ μ½λλ λ²μνλ©΄ μλ©λλ€.",
|
32 |
+
"""
|
33 |
+
### User:
|
34 |
+
Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1?
|
35 |
+
|
36 |
+
### Assistant:
|
37 |
+
```python
|
38 |
+
>>> ["foo", "bar", "baz"].index("bar")
|
39 |
+
1
|
40 |
+
```
|
41 |
+
See the documentation for the built-in .index() method of the list:
|
42 |
+
|
43 |
+
list.index(x[, start[, end]])
|
44 |
+
Return zero-based index in the list of the first item whose value is equal to x. Raises a ValueError if there is no such item.
|
45 |
+
|
46 |
+
The optional arguments start and end are interpreted as in the slice notation and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.
|
47 |
+
"""
|
48 |
+
)
|
49 |
+
````
|
50 |
+
|
51 |
+
μ€ν κ²°κ³Ό
|
52 |
+
````
|
53 |
+
<|im_start|> system
|
54 |
+
λ§ν¬λ€μ΄μΌλ‘ μμ±λ μμ΄ λνλ₯Ό νκ΅μ΄λ‘ λ²μνμΈμ. νλ‘κ·Έλ¨ μ½λλ λ²μνλ©΄ μλ©λλ€.<|im_end|>
|
55 |
+
<|im_start|> user
|
56 |
+
### User:
|
57 |
+
Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1?
|
58 |
+
|
59 |
+
### Assistant:
|
60 |
+
```python
|
61 |
+
>>> ["foo", "bar", "baz"].index("bar")
|
62 |
+
1
|
63 |
+
```
|
64 |
+
See the documentation for the built-in .index() method of the list:
|
65 |
+
|
66 |
+
list.index(x[, start[, end]])
|
67 |
+
Return zero-based index in the list of the first item whose value is equal to x. Raises a ValueError if there is no such item.
|
68 |
+
|
69 |
+
The optional arguments start and end are interpreted as in the slice notation and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.<|im_end|>
|
70 |
+
<|im_start|> assistant
|
71 |
+
### User:
|
72 |
+
"foo", "bar", "baz" 리μ€νΈκ° μκ³ λ¦¬μ€νΈμμ "bar"λΌλ νλͺ©μ΄ μλ€λ©΄, κ·Έ μΈλ±μ€ 1μ μ΄λ»κ² κ°μ Έμ¬ μ μμκΉμ?
|
73 |
+
|
74 |
+
### Assistant:
|
75 |
+
```python
|
76 |
+
>>> ["foo", "bar", "baz"].index("bar")
|
77 |
+
1
|
78 |
+
```
|
79 |
+
리μ€νΈμ λ΄μ₯λ .index() λ©μλμ λν λ¬Έμλ₯Ό μ°Έμ‘°νμΈμ:
|
80 |
+
|
81 |
+
list.index(x[, start[, end]])
|
82 |
+
κ°μ΄ xμ κ°μ 첫 λ²μ§Έ νλͺ©μ 0 κΈ°λ° μΈλ±μ€λ₯Ό λ°νν©λλ€. κ·Έλ¬ν νλͺ©μ΄ μλ κ²½μ° ValueError κ° λ°μν©λλ€.
|
83 |
+
|
84 |
+
μ νμ μΈ μΈμ startμ endλ μ¬λΌμ΄μ€ νκΈ°λ²μμμ μλ³μ ν΄λΉνλ©° 리μ€νΈμ νΉμ νμ μνμ€λ‘ κ²μμ μ ννλ λ° μ¬μ©λ©λλ€. λ°νλ μΈλ±μ€λ μμ μΈμκ° μλ μ 체 μνμ€μ μμμ κΈ°μ€μΌλ‘ κ³μ°λ©λλ€.<|im_end|>
|
85 |
+
````
|