File size: 3,428 Bytes
32f2637 dfcaa6c 06db899 dfcaa6c 06db899 32f2637 dfcaa6c 32f2637 dfcaa6c |
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
---
language:
- en
- ko
library_name: peft
tags:
- translation
- gemma
base_model: google/gemma-7b
---
# Model Card for Model ID
## Model Details
### Model Description
- **Developed by:** [Kang Seok Ju]
- **Contact:** [brildev7@gmail.com]
## Training Details
### Training Data
https://huggingface.co/datasets/traintogpb/aihub-koen-translation-integrated-tiny-100k
# Inference Examples
```
import os
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
model_id = "google/gemma-7b"
peft_model_id = "brildev7/gemma-7b-translation-enko-sft-qlora"
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=False
)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
torch_dtype=torch.float16,
attn_implementation="flash_attention_2",
token=os.environ['HF_TOKEN'],
device_map="auto"
)
model = PeftModel.from_pretrained(model, peft_model_id)
tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
tokenizer.pad_token_id = tokenizer.eos_token_id
# example
prompt_template = """Translate the following sentences into Korean language:
{}
translation:
"""
sentences = "Apple is facing a crisis in one of its key markets, China, as it is being challenged by local smartphone manufacturers. In a bid to counter the threat, Apple CEO Tim Cook is reportedly planning to visit China to meet with local smartphone manufacturers and discuss a joint investment. Apple is also reportedly considering installing an AI model from Baidu, the Chinese search giant, on its iPhone. The move comes as Apple is facing a price war in China, with local smartphone manufacturers offering steep discounts on their products."
texts = prompt_template.format(sentences)
inputs = tokenizer(texts, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- μ νμ κ΅μ° μ€λ§νΈν° μ μ‘°μ¬λ€μ λλ°μ μ€κ΅μμ νλμ ν΅μ¬ μμ₯μ μκΈ°λ₯Ό λ§κ³ μλ€. μ΄ μνμ νκ°νκΈ° μν΄ μ νμ μ΅κ³ κ²½μμμΈ ν μΏ‘μ μ€κ΅μ λ°©λ¬Έν΄ νμ§ μ€λ§νΈν° μ μ‘°μ¬λ€κ³Ό μ μ΄ν΄ 곡λ ν¬μλ₯Ό λ
Όμνλ κ²μΌλ‘ μλ €μ‘λ€. μ νμ λν μ€κ΅ μ΅λ κ²μμ¬ λ°μ΄λ(Baidu)μ μΈκ³΅ μ§λ₯(AI) λͺ¨λΈμ μμ΄ν°μ νμ¬νλ κ²μ κ²ν μ€μΈ κ²μΌλ‘ μ ν΄μ‘λ€. μ νμ κ΅λ΄ μ€λ§νΈν° μ μ‘°μ¬λ€μ΄ μμ λ€μ μ νμ κΈν ν μΈμ λ΄λμΌλ©΄μ μ€κ΅μμ κ°κ²©μ μμ μ§λ©΄ν΄ μλ κ²μ΄λ€.
# example
sentences = "Is it safe to drink milk and eat chicken?"
texts = prompt_template.format(sentences)
inputs = tokenizer(texts, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- μ°μ μ λκ³ κΈ°λ μμ νκ°μ?
# example
sentences = "What precautions to take during the bird flu outbreak"
texts = prompt_template.format(sentences)
inputs = tokenizer(texts, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- μ‘°λ₯ λ
κ° μ ν μ μ΄λ ν μ£Όμ μ¬νμ ν΄μΌ νλμ§
``` |