File size: 1,912 Bytes
1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 1ec0942 f79a7c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
---
library_name: transformers
tags: []
---
## ใขใใซ
- ใใผในใขใใซ๏ผ[ryota39/llm-jp-1b-sft-100k-LoRA](https://huggingface.co/ryota39/llm-jp-1b-sft-100k-LoRA)
- ๅญฆ็ฟใใผใฟใปใใ๏ผ[ryota39/dpo-ja-45k](https://huggingface.co/datasets/ryota39/dpo-ja-45k)
- ๅญฆ็ฟๆนๅผ๏ผใใซใใฉใกใผใฟใใฅใผใใณใฐ
## ใตใณใใซ
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained(
"ryota39/llm-jp-1b-sft-100k-LoRA-dpo-45k"
)
pad_token_id = tokenizer.pad_token_id
model = AutoModelForCausalLM.from_pretrained(
"ryota39/llm-jp-1b-sft-100k-LoRA-dpo-45k",
device_map="auto",
)
text = "###Input: ๆฑไบฌใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ\n###Output: "
tokenized_input = tokenizer.encode(
text,
add_special_tokens=False,
return_tensors="pt"
).to(model.device)
attention_mask = torch.ones_like(tokenized_input)
attention_mask[tokenized_input == pad_token_id] = 0
with torch.no_grad():
output = model.generate(
tokenized_input,
attention_mask=attention_mask,
max_new_tokens=128,
do_sample=True,
top_p=0.95,
temperature=0.8,
repetition_penalty=1.0
)[0]
print(tokenizer.decode(output))
```
## ๅบๅไพ
```
###Input: ๆฑไบฌใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ
###Output: ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ Output: ๆฑไบฌ้ฝใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ
#### Input: ๅคง้ชใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ
###Output: ๅคง้ชใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ Output: ๅคง้ชๅบใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ
Output: ๅ
ตๅบซ็ใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ Output: ๅบๅณถ็ใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ
Output: ็ฆๅฒก็ใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ Output: ไฝ่ณ็ใฎ่ฆณๅ
ๅๆใๆใใฆใใ ใใใ Output:
``` |