|
--- |
|
datasets: |
|
- heegyu/glaive-function-calling-v2-ko-mt |
|
--- |
|
|
|
- [maywell/Synatra-7B-v0.3-Translation](https://huggingface.co/maywell/Synatra-7B-v0.3-Translation) λͺ¨λΈμ΄ νλ‘κ·Έλ¨ μ½λκ° ν¬ν¨λ μ¬λ¬ μ€μ κΈ΄ ν
μ€νΈλ₯Ό λ²μνλλ° μ νμ΄ μμ΄μ ν΄λΉ λΆλΆμ LoRAλ‘ μΆκ° νμ΅νμ΅λλ€. |
|
|
|
### μ¬μ© μμ |
|
```` |
|
import torch |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
device = "cuda:1" if torch.cuda.is_available() else "cpu" |
|
|
|
model_id = "maywell/Synatra-7B-v0.3-Translation" |
|
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=model_revision) |
|
model = AutoModelForCausalLM.from_pretrained(model_id, revision=model_revision, device_map=device, torch_dtype=torch.float16).eval() |
|
|
|
# LoRA μ΄λν° λΆλ¬μ€κΈ° |
|
model.load_adapter("heegyu/Synatra-7B-v0.3-Translation-glaive", revision="epoch-3") |
|
|
|
|
|
def generate(prompt, *messages): |
|
messages = [ |
|
{ |
|
"role": "system", |
|
"content": prompt.strip(), |
|
}, |
|
*[{"role": "user" if i % 2 == 0 else "assistant", "content": m.strip()} for i, m in enumerate(messages)], |
|
] |
|
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(device) |
|
outs = model.generate(inputs, do_sample=True, max_new_tokens=256, early_stopping=True) |
|
print(tokenizer.batch_decode(outs)[0]) |
|
|
|
generate( |
|
"λ§ν¬λ€μ΄μΌλ‘ μμ±λ μμ΄ λνλ₯Ό νκ΅μ΄λ‘ λ²μνμΈμ. νλ‘κ·Έλ¨ μ½λλ λ²μνλ©΄ μλ©λλ€.", |
|
""" |
|
### User: |
|
Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1? |
|
|
|
### Assistant: |
|
```python |
|
>>> ["foo", "bar", "baz"].index("bar") |
|
1 |
|
``` |
|
See the documentation for the built-in .index() method of the list: |
|
|
|
list.index(x[, start[, end]]) |
|
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. |
|
|
|
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_start|> system |
|
λ§ν¬λ€μ΄μΌλ‘ μμ±λ μμ΄ λνλ₯Ό νκ΅μ΄λ‘ λ²μνμΈμ. νλ‘κ·Έλ¨ μ½λλ λ²μνλ©΄ μλ©λλ€.<|im_end|> |
|
<|im_start|> user |
|
### User: |
|
Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1? |
|
|
|
### Assistant: |
|
```python |
|
>>> ["foo", "bar", "baz"].index("bar") |
|
1 |
|
``` |
|
See the documentation for the built-in .index() method of the list: |
|
|
|
list.index(x[, start[, end]]) |
|
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. |
|
|
|
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|> |
|
<|im_start|> assistant |
|
### User: |
|
"foo", "bar", "baz" 리μ€νΈκ° μκ³ λ¦¬μ€νΈμμ "bar"λΌλ νλͺ©μ΄ μλ€λ©΄, κ·Έ μΈλ±μ€ 1μ μ΄λ»κ² κ°μ Έμ¬ μ μμκΉμ? |
|
|
|
### Assistant: |
|
```python |
|
>>> ["foo", "bar", "baz"].index("bar") |
|
1 |
|
``` |
|
리μ€νΈμ λ΄μ₯λ .index() λ©μλμ λν λ¬Έμλ₯Ό μ°Έμ‘°νμΈμ: |
|
|
|
list.index(x[, start[, end]]) |
|
κ°μ΄ xμ κ°μ 첫 λ²μ§Έ νλͺ©μ 0 κΈ°λ° μΈλ±μ€λ₯Ό λ°νν©λλ€. κ·Έλ¬ν νλͺ©μ΄ μλ κ²½μ° ValueError κ° λ°μν©λλ€. |
|
|
|
μ νμ μΈ μΈμ startμ endλ μ¬λΌμ΄μ€ νκΈ°λ²μμμ μλ³μ ν΄λΉνλ©° 리μ€νΈμ νΉμ νμ μνμ€λ‘ κ²μμ μ ννλ λ° μ¬μ©λ©λλ€. λ°νλ μΈλ±μ€λ μμ μΈμκ° μλ μ 체 μνμ€μ μμμ κΈ°μ€μΌλ‘ κ³μ°λ©λλ€.<|im_end|> |
|
```` |