Downloads · 30 days
0
heegyu/Synatra-7B-v0.3-Translation-glaive
Synatra-7B-v0.3-Translation-glaive is a machine learning model from heegyu. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
- maywell/Synatra-7B-v0.3-Translation 모델이 프로그램 코드가 포함된 여러 줄의 긴 텍스트를 번역하는데 제한이 있어서 해당 부분을 LoRA로 추가 학습했습니다.
Downloads · 30 days
0
Access
Public
Updated Dec 23, 2023
Repo size
127 MB
Likes
0
Public
Click a slice to open those files.
.bin42.1 MB · 95%
From the Hugging Face model README
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda:0" 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")
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|>