--- license: cc-by-nc-4.0 language: - ko - en pipeline_tag: text-generation --- # Mi:dm (**M**indful **I**ntelligence that **D**ialogs, Empathizes, Understands and **M**oves, 믿:음) Mi:dm은 KT가 개발한 사전학습 한국어-영어 언어모델 입니다. 문자열을 입력으로 하며, 문자열을 생성합니다. Mi:dm is a pre-trained Korean-English language model developed by KT. It takes text as input and creates text. ## Model Descriptions ### Midm-bitext-S (7B) Hyper Parameters | Hyperparameter | Value | |:---------------------|--------------:| | \\(n_{layers}\\) | 32 | | \\(d_{model}\\) | 4,096 | | \\(d_{ff}\\) | 10,880 | | \\(n_{heads}\\) | 32 | | \\(d_{head}\\) | 128 | | \\(n_{ctx}\\) | 2,048 | | \\(n_{vocab}\\) | 72,154 | | Positional Encoding | [Rotary Position Embedding (RoPE)](https://arxiv.org/abs/2104.09864) | 위 파라미터로 계산하면, 모델 로딩에는 약 30GB의 GPU 메모리가 필요합니다. 모델 추론에는 입출력 토큰 수에 비례하여 추가 메모리가 더 소요됩니다. ### Architecture Mi:dm 은 Transformer 구조를 활용한 Auto-regressive Language Model 입니다. 선정된 Task 수행을 위해 supervised fine-tuning (SFT) 되었습니다. Mi:dm is a transformer based auto-regressive Language Model. It was supervised fine-tuned (SFT). ### Tokenizer [google sentencepiece](https://github.com/google/sentencepiece) 에 기반한 토크나이저를 사용하고 있습니다. 한국어 복합어를 고려한 형태소 기반 학습을 하였으며 bi-lingual tokenization 성능 향상을 위하여 영어 어휘를 같이 학습하였습니다. Tokenizer was trained with [google sentencepiece](https://github.com/google/sentencepiece). ### Prompt Template ``` ###System;{System} ###User;{User} ###Midm; ``` ### Requirements Mi:dm을 실행하기 위해 필요한 라이브러리는 아래 pip 명령어를 통해 설치할 수 있습니다. To run Mi:dm, please make sure you meet the above requirements, and then execute the following pip commands to install the dependent libraries. ```bash pip install transformers einops ``` ### Usage ```python import torch from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer def main(): tokenizer = AutoTokenizer.from_pretrained( "KT-AI/midm-bitext-S-7B-inst-v1", trust_remote_code = True ) model = AutoModelForCausalLM.from_pretrained( "KT-AI/midm-bitext-S-7B-inst-v1", trust_remote_code=True ) model.cuda() model.eval() dummy_data = "###User;AI란?\n###Midm;" data = tokenizer(dummy_data, return_tensors="pt") streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) pred = model.generate( input_ids=data.input_ids[..., :-1].cuda(), streamer=streamer, use_cache=True, max_new_tokens=float('inf') ) decoded_text = tokenizer.batch_decode(pred[0], skip_special_tokens=True) if __name__ == "__main__": main() ``` ### Training Data Mi:dm-bitext-S 모델은 한국어/영어 공개 데이터를 이용하여 사전 학습하였습니다. 미세 조정 학습을 위해서도 공개되었거나 자체 구축한 데이터를 이용하였으며 이를 일부 가공하거나 다시 정제하는 과정을 거쳤습니다. KT는 공개 데이터를 직접 수집하거나 적법한 사용 허가 조건 하에 확보하였습니다. AI-HUB(https://www.aihub.or.kr/) 의 말뭉치 데이터와 국립국어원 모두의 말뭉치 데이터 (https://corpus.korean.go.kr/) 를 사전 학습 단계에서 이용하였습니다. KT가 보유한 고객 데이터는 이용하지 않았습니다. The Mi:dm-bitext-S model was pre-trained using Korean/English publicly available data. For fine-tuning, we used also publicly available data and went through some processing or refining. KT collected public data directly or obtained it under legal permission conditions. The korean corpus data from AI-HUB (https://www.aihub.or.kr/) and the National Institute of Korean Language (https://corpus.korean.go.kr/) were used in the pre-training stage. We did not use any customer data held by KT. ### Evaluation Results TBA ## Limitations KT는 Mi:dm 학습 데이터에서 욕설, 비속어, 편견, 차별 등 비윤리적 표현을 제거하려고 노력하였습니다. 그럼에도 불구하고 위와 같은 바람직하지 않은 표현 또는 부정확한 사실이 생성될 가능성을 완전히 제거하지 못하였습니다. 본 모델을 사용하기 전 이러한 한계를 인식하고 올바른 사용을 위해 필요한 조치를 취하는 것은 사용자의 책임이며, KT는 본 모델의 활용이 야기하는 위험이나 손해에 대해 책임을 지지 않습니다. Mi:dm 학습 데이터의 대부분은 한국어와 영어로 구성되어 있습니다. 그 외 언어에 대한 이해와 생성 기능은 제공하지 않습니다. We tried to remove unethical expressions such as profanity, slang, prejudice, and discrimination from training data. Nevertheless, the possibility of creating undesirable and inaccurate expressions such as the above has not been completely eliminated. It is the user's responsibility to be aware of these limitations before utilizing this model and take the necessary actions for proper use, and KT is not responsible for any risks or damages resulting from the use of this model. Most of Mi:dm's training data consists of Korean and English. ## Licence Mi:dm 모델 (Midm-bitext-S) 은 CC-BY-NC 4.0 라이선스 하에 공개되어 있습니다. 사용자는 본 모델의 일부 혹은 전체를 재학습하거나 일부만을 이용하는 것이 가능합니다. 다만 반드시 저작자를 표시하여야 하며, 영리 목적으로 이용할 수 없습니다. 또한 본 모델을 재배포하거나 본 모델의 2차적저작물을 작성하여 공유할 때는 본 모델과 동일한 CC-BY-NC 4.0 라이선스를 적용하여야 합니다. Mi:dm (Midm-bitext-S) is released under the CC-BY-NC 4.0 license. Users can retrain part or all of this model or use only part of it. However, the author must be indicated and cannot be used for commercial purposes. Additionally, when sharing secondary works using this model, they must be distributed under the same CC-BY-NC 4.0 license. ## Citations Mi:dm을 이용한 2차 저작물을 배포할 경우 아래 내용을 인용하여 출처를 명시해야 합니다. When distributing secondary works using Mi:dm, the source must be indicated by citing the content below. ``` @misc{kt-mi:dm, title = {Mi:dm: KT Bilingual (Korean,English) Generative Pre-trained Transformer}, author = {KT}, year = {2023}, url = {https://huggingface.co/KT-AT/midm-bitext-S-7B-inst-v1} howpublished = {\url{https://genielabs.ai}}, } ``` ## Contacts 본 모델의 다양한 연구 목적의 활용과 개선 의견을 기대 합니다. dschang@kt.com We look forward to receiving any suggestions for improvement. dschang@kt.com