metadata
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))
- μ‘°λ₯ λ
κ° μ ν μ μ΄λ ν μ£Όμ μ¬νμ ν΄μΌ νλμ§