--- library_name: peft base_model: google/gemma-2b language: - ko - en tags: - translation - gemma --- # 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-2b" peft_model_id = "brildev7/gemma-2b-translation-koen-sft-qlora" quantization_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16, bnb_4bit_quant_type="nf4" ) model = AutoModelForCausalLM.from_pretrained( model_id, quantization_config=quantization_config, torch_dtype=torch.float32, attn_implementation="sdpa", ) 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 = """다음 내용을 영어로 번역하세요.: {} 번역: """ sentences = "위중설이 나돌던 윌리엄 영국 왕세자의 부인 케이트 미들턴 왕세자빈(42)이 결국 암 진단을 받았다. 로이터 통신에 따르면 왕세자빈은 22일(현지시간) 인스타그램 영상 메시지를 통해 지난 1월 복부 수술을 받은 뒤 실시한 후속 검사에서 암이 발견돼 현재 화학치료를 받고 있다고 밝혔다. 왕세자빈은 '의료진은 예방적 차원에서 화학치료를 권고했다'면서 '물론 이것은 큰 충격으로 다가왔지만 윌리엄과 저는 어린 가족들을 위해 이 문제를 해결하고자 최선을 다하고 있다'고 말했다. 그러면서 '현재 암으로 인해 영향을 받은 모든 사람들을 생각하고 있다'며 '믿음과 희망을 잃지 말아 달라. 여러분은 혼자가 아니다'라고 덧붙였다." 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)) - Prince William's wife Kate Middleton, 42, has been diagnosed with cancer after undergoing surgery for her abdominal pain, according to Reuters news agency. In an Instagram message on the 22nd (local time), Kate Middleton, the wife of Prince William, said that she was diagnosed with cancer after undergoing surgery for her abdominal pain in January and is currently undergoing chemical therapy. She said that the medical team recommended chemical therapy as a measure to prevent the spread of the disease, but that she and Prince William are trying to resolve the issue for their young family. She added that "The medical team recommended chemical therapy as a measure to prevent the spread of the disease. # example prompt_template = """다음 내용을 영어로 번역하세요.: {} 번역: """ sentences = "애플이 주력 시장 중에 하나인 중국에서 현지 스마트폰 제조사들에게 밀리며 위기감이 증폭된 가운데 중국 소비자 잡기에 나서고 있다. 팀 쿡 CEO(최고경영자)가 직접 중국을 방문해 투자를 약속하고, '아이폰' 등 자사 기기에 중국 바이두의 AI(인공지능) 모델을 탑재하는 방안도 검토하고 있다. 중국 본토서 아이폰 할인 공세에 이어 전방위적 투자를 늘리는 모양새다." 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)) - With Apple becoming a target in China, a major market, the company is taking a stance in a Chinese consumer magazine. CEO Tim Cook is visiting China and is planning to invest, and is also considering adding Chinese Big Data AI models on Apple's products such as 'iPhone'. It seems that China is making a wide-ranging investment following the iPhone discounting wave on the mainland. ```