├── .gitignore ├── LICENSE-CC-BY-NC-4.0.md ├── README.md ├── asset ├── 42dot LLM-SFT-vs.png ├── 42dot LLM-SFT.png ├── 42dot-sft-demo.gif ├── 42dot.png ├── 617402.gif ├── Ko-Score.png ├── asterisk.png ├── icon_home_company_logo.png ├── plm_benchmark_en.png ├── plm_benchmark_ko.png └── tagline.png ├── eval ├── benchmark_set_v2.csv └── eval_prompt.yaml ├── example_cli.py ├── inference.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | model/ 3 | __pycache__ 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /LICENSE-CC-BY-NC-4.0.md: -------------------------------------------------------------------------------- 1 | # Attribution-NonCommercial 4.0 International 2 | 3 | > *Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.* 4 | > 5 | > ### Using Creative Commons Public Licenses 6 | > 7 | > Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | > 9 | > * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). 10 | > 11 | > * __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). 12 | 13 | ## Creative Commons Attribution-NonCommercial 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | ### Section 1 – Definitions. 18 | 19 | a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | 21 | b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 22 | 23 | c. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 24 | 25 | d. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 26 | 27 | e. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 28 | 29 | f. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 30 | 31 | g. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 32 | 33 | h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License. 34 | 35 | i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 36 | 37 | j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 38 | 39 | k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 40 | 41 | l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 42 | 43 | ### Section 2 – Scope. 44 | 45 | a. ___License grant.___ 46 | 47 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 48 | 49 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 50 | 51 | B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 52 | 53 | 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 54 | 55 | 3. __Term.__ The term of this Public License is specified in Section 6(a). 56 | 57 | 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 58 | 59 | 5. __Downstream recipients.__ 60 | 61 | A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 62 | 63 | B. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 64 | 65 | 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 66 | 67 | b. ___Other rights.___ 68 | 69 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 70 | 71 | 2. Patent and trademark rights are not licensed under this Public License. 72 | 73 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 74 | 75 | ### Section 3 – License Conditions. 76 | 77 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 78 | 79 | a. ___Attribution.___ 80 | 81 | 1. If You Share the Licensed Material (including in modified form), You must: 82 | 83 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 84 | 85 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 86 | 87 | ii. a copyright notice; 88 | 89 | iii. a notice that refers to this Public License; 90 | 91 | iv. a notice that refers to the disclaimer of warranties; 92 | 93 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 94 | 95 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 96 | 97 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 98 | 99 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 100 | 101 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 102 | 103 | 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 104 | 105 | ### Section 4 – Sui Generis Database Rights. 106 | 107 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 108 | 109 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 110 | 111 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 112 | 113 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 114 | 115 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 116 | 117 | ### Section 5 – Disclaimer of Warranties and Limitation of Liability. 118 | 119 | a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__ 120 | 121 | b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__ 122 | 123 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 124 | 125 | ### Section 6 – Term and Termination. 126 | 127 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 128 | 129 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 130 | 131 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 132 | 133 | 2. upon express reinstatement by the Licensor. 134 | 135 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 136 | 137 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 138 | 139 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 140 | 141 | ### Section 7 – Other Terms and Conditions. 142 | 143 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 144 | 145 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 146 | 147 | ### Section 8 – Interpretation. 148 | 149 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 150 | 151 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 152 | 153 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 154 | 155 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 156 | 157 | > Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 158 | > 159 | > Creative Commons may be contacted at creativecommons.org 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 42dot LLM 2 | 3 | **42dot LLM**은 [**포티투닷**](https://42dot.ai/) ([**42dot**](https://42dot.ai/))에서 자체 개발한 언어 모델들의 시리즈로, 다음의 특징을 가지고 있습니다. 4 | - 국내 최초의 **한영통합 언어 모델 (=42dot LLM-PLM)** 공개 [more](#42dot-llm-plm-사전-학습-모델) 5 | - 42dot LLM-PLM 기반의 **생성형 언어 모델 (=42dot LLM-SFT)** 공개 [more](#42dot-llm-sft-생성형-언어-모델) 6 | - 직접 구축한 (수집, 정제) 데이터, 자체 학습 인프라 사용 7 | 8 | 뿐만 아니라, [🤗42dot LLM-PLM](https://huggingface.co/42dot/42dot_LLM-PLM-1.3B)과 [🤗42dot LLM-SFT](https://huggingface.co/42dot/42dot_LLM-SFT-1.3B)를 공개했습니다. 9 | 10 | 11 |

12 | 13 |

14 |

15 | 42dot LLM-SFT 실행 예제 (example_cli.py 실행) 16 |

17 | 18 | ## 42dot LLM-PLM (사전 학습 모델) 19 | ### 아키텍처 20 | 42dot LLM-PLM은 [LLaMA 2](https://ai.meta.com/research/publications/llama-2-open-foundation-and-fine-tuned-chat-models/) 와 유사한 Transformer decoder 아키텍처를 사용했고, 모델 하이퍼파라미터는 아래와 같습니다. 21 | 22 | | Params | Layers | Attention heads | Hidden size | FFN size | 23 | | :-- | :--: | :--: | :--: | :--: | 24 | | 1.3B | 24 | 32 | 2,048 | 5,632 | 25 | 26 | 27 | ### 학습 28 | 29 | 42dot LLM-PLM의 학습은 A100 80G 256장을 사용했고, 약 8일 (49,152 GPU hours) 소요되었습니다. 30 | 학습 세팅은 아래와 같습니다. 31 | 32 | | Params | Global batch size\* | Initial learning rate | Train iter.\* | Max length\* | Weight decay | 33 | | :-- | :--: | :--: | :--: | :--: | :--: | 34 | | 1.3B | 4.0M | 4e-4 | 1.4T | 4,096 | 0.1 | 35 | 36 | (\* 단위: tokens) 37 | 38 | 39 | ### 학습 데이터셋 40 | 42dot LLM-PLM의 학습 데이터는 모두 웹 상에 공개된 데이터를 이용해 진행했고, 그 구성은 아래와 같습니다. 41 | - 한국어: [직지 프로젝트](http://jikji.duckdns.org/), [mC4](https://huggingface.co/datasets/mc4), [LBox Open](https://github.com/lbox-kr/lbox-open), [KLUE](https://huggingface.co/datasets/klue), [위키피디아 (한국어)](https://ko.wikipedia.org/) 등 포함 42 | - 영어: [The Pile](https://github.com/EleutherAI/the-pile), [RedPajama](https://github.com/togethercomputer/RedPajama-Data), [C4](https://huggingface.co/datasets/c4) 등 포함 43 | 44 | ### 토크나이저 45 | Byte-level BPE 토크나이저를 사용했고, 학습 데이터셋에서 1,000만 건의 문서를 샘플링해 학습했습니다. Vocabulary 크기는 약 50K입니다. 46 | 47 | ### Zero-shot 성능 평가 48 | 42dot LLM-PLM 및 비슷한 파라미터 크기의 타 PLM과의 성능을 비교하기 위해 한국어 및 영어 Zero-shot 벤치마크를 진행했고, 아래의 평가결과는 [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/polyglot)를 이용해 도출했습니다. 49 | #### 한국어 50 | - 비교대상: 51 | - [Polyglot-Ko 1.3B](https://github.com/EleutherAI/polyglot): [GPT-NeoX](https://github.com/EleutherAI/gpt-neox) 아키텍처로 한국어 213B 토큰 (863 GB)을 학습한 모델 52 | - [KoGPT2 1.2B](https://github.com/SKT-AI/KoGPT2): GPT 아키텍처로 40GB 이상의 한국어 데이터셋을 학습한 모델 53 | - [XGLM 1.7B](https://huggingface.co/facebook/xglm-1.7B): [GPT-3](https://arxiv.org/abs/2005.14165) 아키텍처로 한국어를 포함한 30개 언어, 500B 토큰을 학습한 모델 54 | - [PolyLM 1.7B](https://huggingface.co/DAMO-NLP-MT/polylm-1.7b): LLaMA 아키텍처로 한국어를 포함한 18개 언어, 640B 토큰을 학습한 모델 55 | - 평가 데이터셋: 56 | - [KoBEST](https://huggingface.co/datasets/skt/kobest_v1): BoolQ, COPA, HellaSwag, SentiNeg 의 4개 태스크 57 | 58 |

59 | 60 |

61 |

62 | 42dot LLM-PLM 한국어 성능 63 |

64 | 65 | 66 | |Tasks / Macro-F1|[KoGPT2](https://github.com/SKT-AI/KoGPT2)
1.2B|[Polyglot-Ko](https://github.com/EleutherAI/polyglot)
1.3B|[XGLM](https://huggingface.co/facebook/xglm-1.7B)
1.7B|[PolyLM](https://huggingface.co/DAMO-NLP-MT/polylm-1.7b)
1.7B|42dot LLM-PLM
1.3B| 67 | |--------------|-----------|----------------|---------|-----------|------------------------| 68 | |boolq |0.337 |0.355 |**0.502** |0.334 |0.369 | 69 | |copa |0.67 |**0.721** |0.616 |0.513 |0.704 | 70 | |hellaswag |0.404 |0.401 |0.374 |0.321 |**0.431** | 71 | |sentineg |0.606 |0.679 |0.46 |0.382 |**0.69** | 72 | |**average** |0.504 |0.539 |0.488 |0.388 |**0.549** | 73 | #### 영어 74 | - 비교대상: 75 | - [OPT 1.3B](https://huggingface.co/facebook/opt-1.3b): GPT-3 아키텍처로 영어 300B 토큰을 학습한 모델 76 | - [MPT 1B](https://huggingface.co/mosaicml/mpt-1b-redpajama-200b): [MPT](https://www.mosaicml.com/blog/mpt-7b) 아키텍처로 RedPajama 데이터의 200B 토큰을 학습한 모델 77 | - XGLM 1.7B 78 | - PolyLM 1.7B 79 | 80 |

81 | 82 |

83 |

84 | 42dot LLM-PLM 영어 성능 85 |

86 | 87 | 88 | 89 | | Tasks / Metric | MPT
1B | OPT
1.3B | XGLM
1.7B | PolyLM
1.7B | 42dot LLM-PLM
1.3B | 90 | | ---------------------- | ------ | -------- | --------- | ----------- | ------------------------ | 91 | | anli_r1/acc | 0.309 | **0.341** | 0.334 | 0.336 | 0.325 | 92 | | anli_r2/acc | 0.334 | 0.339 | 0.331 | 0.314 | **0.34** | 93 | | anli_r3/acc | 0.33 | 0.336 | 0.333 | **0.339** | 0.333 | 94 | | arc_challenge/acc | 0.268 | 0.234 | 0.21 | 0.198 | **0.288** | 95 | | arc_challenge/acc_norm | 0.291 | 0.295 | 0.243 | 0.256 | **0.317** | 96 | | arc_easy/acc | 0.608 | 0.571 | 0.537 | 0.461 | **0.628** | 97 | | arc_easy/acc_norm | 0.555 | 0.51 | 0.479 | 0.404 | **0.564** | 98 | | boolq/acc | 0.517 | 0.578 | 0.585 | 0.617 | **0.624** | 99 | | hellaswag/acc | 0.415 | 0.415 | 0.362 | 0.322 | **0.422** | 100 | | hellaswag/acc_norm | 0.532 | 0.537 | 0.458 | 0.372 | **0.544** | 101 | | openbookqa/acc | **0.238** | 0.234 | 0.17 | 0.166 | 0.222 | 102 | | openbookqa/acc_norm | 0.334 | 0.334 | 0.298 | 0.334 | **0.34** | 103 | | piqa/acc | 0.714 | 0.718 | 0.697 | 0.667 | **0.725** | 104 | | piqa/acc_norm | 0.72 | 0.724 | 0.703 | 0.649 | **0.727** | 105 | | record/f1 | 0.84 | **0.857** | 0.775 | 0.681 | 0.848 | 106 | | record/em | 0.832 | **0.849** | 0.769 | 0.674 | 0.839 | 107 | | rte/acc | 0.541 | 0.523 | **0.559** | 0.513 | 0.542 | 108 | | truthfulqa_mc/mc1 | 0.224 | 0.237 | 0.215 | **0.251** | 0.236 | 109 | | truthfulqa_mc/mc2 | 0.387 | 0.386 | 0.373 | **0.428** | 0.387 | 110 | | wic/acc | 0.498 | **0.509** | 0.503 | 0.5 | 0.502 | 111 | | winogrande/acc | 0.574 | **0.595** | 0.55 | 0.519 | 0.583 | 112 | | **average** | 0.479 | 0.482 | 0.452 | 0.429 | **0.492** | 113 | 114 | 115 | ## 42dot LLM-SFT (생성형 언어 모델) 116 | 42dot LLM-SFT는 42dot LLM-PLM에 SFT (Supervised Fine-Tuning)를 수행한 모델로, 학습을 위한 파라미터는 아래와 같습니다. 117 | 118 | | Model | Global Batch Size | Learning rate | Epochs | Max length | Weight decay | Warmup ratio | 119 | | :-- | :--: | :--: | :--: | :--: | :--: | :--: | 120 | | 1.3B | 16 | 2e-5 | 3 | 4,096 | 0 | 0.03 | 121 | 122 | 학습은 A100 80G GPU 16장을 사용했고 약 7시간 (112 GPU hours) 소요되었습니다. 123 | 124 | ### 학습 데이터셋 125 | 126 | 질문/요청 및 이에 대한 응답으로 이루어진 Single/Multi-turn 형태의 대화 데이터를 학습에 사용했습니다. 127 | - 42dot LLM-SFT의 학습 데이터 관련 내용은 공개하지 않습니다. 대신, 이미 공개되어 있는 다양한 한국어 ([evolve-instruct](https://github.com/lcw99/evolve-instruct), [ko-lima-vicuna](https://huggingface.co/datasets/changpt/ko-lima-vicuna), 등) 및 영어 ([ShareGPT](https://sharegpt.com), [OpenAssistant](https://huggingface.co/datasets/OpenAssistant/oasst1), etc.)의 데이터를 참고할 수 있습니다. 128 | 129 | ### 평가 130 | - 비교대상: 131 | - [ChatGPT](https://chat.openai.com/): OpenAI가 공개한 생성형 언어 모델 서비스 (GPT-3.5 및 GPT-4) 132 | - [Bard](https://bard.google.com/): Google이 공개한 생성형 언어 모델 서비스 133 | - [KORani-v2-13B](https://huggingface.co/KRAFTON/KORani-v1-13B): LLaMA 13B을 한국어 데이터셋으로 파인튜닝한 모델 134 | 135 | | Model | GPT-3.5 | GPT-4 | Bard | KORani | 42dot LLM-SFT | 136 | | :-- |:-------:|:--------:|:--------:|:------:|:---------:| 137 | | Params | Unknown | Unknown | Unknown | 13B | 1.3B | 138 | 139 | - 평가 데이터셋: 140 | - 10가지의 카테고리에 대해 총 121개의 프롬프트로 구성했습니다. [[Dataset Link]](eval/benchmark_set_v2.csv) 141 | - 평가 방법: 142 | - GPT-4를 평가 수단으로 사용했고, <질문, 응답>을 포함하는 [프롬프트](eval/eval_prompt.yaml)를 입력으로 6가지 항목에 대해 각 모델의 응답을 평가했습니다. 143 | 144 |

145 | 146 |

147 |

148 | 평가 데이터셋에 대한 응답 품질 평가 149 |

150 | 151 |

152 | 153 |

154 |

155 | 상용 서비스와 42dot LLM-SFT의 응답 비교 156 |

157 | 158 | ## 모델 공개 159 | 160 | - 🤗[42dot LLM-PLM](https://huggingface.co/42dot/42dot_LLM-PLM-1.3B) 161 | - 🤗[42dot LLM-SFT](https://huggingface.co/42dot/42dot_LLM-SFT-1.3B) 162 | 163 | ## 사용법 164 | 본 리포지토리에는 간단한 생성 코드를 함께 제공하며, 아래 명령을 통해 관련 패키지를 설치하고 직접 모델을 구동해 볼 수 있습니다. 165 | 166 | ```bash 167 | $ pip install -r requirements.txt 168 | $ python example_cli.py 169 | ``` 170 | 171 | 기본적으로 디바이스 설정을 자동으로 찾으며, CPU 또는 메모리 여유가 충분한 GPU를 자동으로 찾아 최적의 디바이스에서 동작하도록 설계되어 있습니다. 또한 `--device=cpu` 옵션으로 항상 CPU에서 구동할 수 있으며, 별도의 Quantization 옵션 없이도 M1 맥북 프로에서는 CPU 옵션으로 로컬 구동(약 4GB 정도 여유 메모리 필요)이 가능합니다. 이외에도 생성과 관련한 다양한 옵션을 지원하며 `--help`로 도움말을 확인할 수 있습니다. 172 | 173 | ```bash 174 | $ python example_cli.py --help 175 | ``` 176 | 177 | ## llama.cpp 178 | [허깅페이스에 올려주신 피드백](https://huggingface.co/42dot/42dot_LLM-SFT-1.3B/discussions/2)을 참고하여 llama.cpp에서도 구동할 수 있도록 Special Tokens를 패치하였습니다. 179 | 180 |

181 | 182 |

183 | 184 | 이제 아래 가이드를 참고하여 llama.cpp에서 42dot LLM-SFT 모델을 실행할 수 있습니다. 185 | 186 | 1. 42dot LLM-SFT 모델을 ggml FP32 포맷으로 변환합니다. 187 | ``` 188 | $ python convert.py ./42dot_LLM-SFT-1.3B/ --vocabtype bpe 189 | ``` 190 | 191 | 2. 모델을 4비트로 Quantization 합니다(선택사항). 192 | ``` 193 | $ ./quantize ./42dot_LLM-SFT-1.3B/ggml-model-f32.gguf ./42dot_LLM-SFT-1.3B/ggml-model-q4_0.gguf q4_0 194 | ``` 195 | 196 | 3. 인퍼런스를 실행합니다. 아래 저희가 제시하는 옵션을 그대로 사용하는 것을 권장합니다. 197 | ``` 198 | $ ./main -m ./42dot_LLM-SFT-1.3B/ggml-model-f32.gguf \ 199 | --temp 0.5 \ 200 | --top_p 0.95 \ 201 | --top_k 20 \ 202 | --n-predict 512 \ 203 | --repeat-penalty 1.2 \ 204 | --color \ 205 | --prompt "호기심 많은 인간 (human)과 인공지능 봇 (AI bot)의 대화입니다. \n봇의 이름은 42dot LLM이고 포티투닷 (42dot)에서 개발했습니다. \n봇은 인간의 질문에 대해 친절하게 유용하고 상세한 답변을 제공합니다. \n" \ 206 | --in-prefix ": " \ 207 | --in-suffix ":" \ 208 | --interactive-first 209 | ``` 210 | 211 | ## 한계점 212 | 다른 LLM과 마찬가지로 42dot LLM도 여러 한계를 가지고 있습니다. 42dot LLM를 활용할 때 이러한 한계점들을 감안하기 바랍니다. 213 | - 언어 모델은 [환각 (Hallucination)](https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence))이라는 근본적인 문제가 있습니다. 마찬가지로 언어 모델인 42dot LLM도 이러한 환각 문제를 가지고 있으며, 생성하는 내용이 사실과 일치하지 않을 수 있습니다. 214 | - 자체적으로 42dot LLM-SFT의 학습 데이터를 구축하면서 케이스를 최대한 다양화했지만, 미처 포함하지 못한 질문-응답 케이스가 존재할 수 있기 때문에 기대하는 형태의 응답을 생성하지 못할 수 있습니다. 215 | - 동일한 입력에 대해 매번 다른 응답을 생성할 수 있습니다. 또한, 사용자가 입력한 질문/요청인 프롬프트에 민감합니다. 예를 들어, 주어진 질문에 정확한 답변을 생성했더라도, 동일한 내용에 표현 방식만 다른 질문/요청에 전혀 다른 응답을 생성할 수 있습니다. 216 | - 생성 결과에 별도의 필터링을 적용하지 않았습니다. 따라서 도덕, 인종, 문화, 성별, 나이, 지역, 종교, 정치성향 등에 대해 편향적이거나 부적절한 응답을 생성할 수 있습니다. 217 | 218 | ## 라이센스 219 | [공개한 모델](#모델-공개)은 42dot의 R&D 결과물로서, [CC BY-NC 4.0](LICENSE-CC-BY-NC-4.0.md)을 따릅니다. 220 | 221 | ## 유의사항 222 | 42dot LLM을 통해 생성한 내용은 42dot의 입장과 무관하며, 42dot은 생성 내용 및 이로 인해 발생하는 문제에 대해 책임지지 않습니다. 223 | 224 | ## 채용안내 225 | 저희는 42dot LLM이 언어 모델 기술 및 생태계, 나아가 서비스 확산에 기여하길 기대합니다. 아울러 미래 자동차의 핵심인 SDV (Software-Defined Vehicle)를 실현하기 위한 42dot의 여정을 함께할 분들을 기다리고 있습니다. 226 | 227 | - [Generative NLP Engineer](https://42dot.ai/careers/openroles/35e65cf2-3b64-4859-9209-8beeb9f21a4e) 228 | - [LLM inference optimization engineer](https://42dot.ai/careers/openroles/e890e45c-0f26-41d3-8686-7ce3da601e13) 229 | 230 | ## Citation 231 | 232 | ``` 233 | @misc{42dot2023llm, 234 | title={42dot LLM: A Series of Large Language Model by 42dot}, 235 | author={42dot Inc.}, 236 | year={2023}, 237 | url = {https://github.com/42dot/42dot_LLM}, 238 | version = {1.0.0}, 239 | } 240 | ``` 241 | -------------------------------------------------------------------------------- /asset/42dot LLM-SFT-vs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/42dot LLM-SFT-vs.png -------------------------------------------------------------------------------- /asset/42dot LLM-SFT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/42dot LLM-SFT.png -------------------------------------------------------------------------------- /asset/42dot-sft-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/42dot-sft-demo.gif -------------------------------------------------------------------------------- /asset/42dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/42dot.png -------------------------------------------------------------------------------- /asset/617402.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/617402.gif -------------------------------------------------------------------------------- /asset/Ko-Score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/Ko-Score.png -------------------------------------------------------------------------------- /asset/asterisk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/asterisk.png -------------------------------------------------------------------------------- /asset/icon_home_company_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/icon_home_company_logo.png -------------------------------------------------------------------------------- /asset/plm_benchmark_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/plm_benchmark_en.png -------------------------------------------------------------------------------- /asset/plm_benchmark_ko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/plm_benchmark_ko.png -------------------------------------------------------------------------------- /asset/tagline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/42dot/42dot_LLM/2a69b556a1a54f920588d789b1b3b41d8f9e7848/asset/tagline.png -------------------------------------------------------------------------------- /eval/benchmark_set_v2.csv: -------------------------------------------------------------------------------- 1 | id,question,category,task 2 | 1,"짧은 이야기를 만들어라. 8문장 내외로 적어라. 3 | 주제: 연애의 즐거움 4 | 주인공: 중학생 때 첫사랑을 만나 연애를 시작한 20대 남성 5 | 느낌: 풋풋한 설레임",Generation,Short story 6 | 2,"은퇴한 어벤져스 토르, 캡틴아메리카, 호크아이가 모여서 함께 식사하는데, 토니 스타크와 블랙위도우를 그리워하는 이야기를 3문단으로 만들어줘",Generation,Long story 7 | 3,결혼하는 친구를 축하하기 위한 시를 한편 지어줘,Generation,Poem 8 | 4,"크리스마스날 가족이 모여 함께 볼 수 있는 따뜻한 영화 시나리오 만들어줄래? 9 | 배경은 영국, 런던이야",Generation,Movie scenario 10 | 5,"내일 장인, 장모님 처음 뵙는 자리에서 얘기를 어떻게 진행하면 좋을지 같이 시뮬레이션 돌려보자",Generation,Dialogue 11 | 6,"초등학교 3학년 교사인데, 초등학교 3학년 아이들이 좋아할 개그같은 거 있을까?",Generation,Jokes 12 | 7,직원들한테 워크샵 공지하는 이메일 작성해줘. 워크샵 일정 5/20일 금요일 9:00-18:00까지,Generation,Email 13 | 8,경력 3년 미만의 주니어 데이터 분석가인데 자소서 써주라. 내 이름은 박미현이고 카네기멜론대학교에서 컴퓨터사이언스 전공했어.,Generation,Cover letter 14 | 9,"커머스 운영팀에 제출할 내 이력서 써줘 15 | 이름: 홍길동 16 | 이메일: gildong.hong@gmail.com 17 | 연락처: 010-1234-5678 18 | 학력: 한국대학교 응용통계학과 19 | 경력: 해외 제휴처 데이터 관리",Generation,Resume 20 | 10,남성적인 분위기의 애스턴마틴에서 새로 출시한 자동차 광고 기획안 써줘. 컨셉은 이거 타면 마치 동물의 왕 사자처럼 느껴질 수 있게.,Generation,Commercial outline 21 | 11,"최신 지능형 교통 시스템 기술과 도시 교통 혁신 사례를 조사하고, 지능형 교통 시스템이 도시 교통 효율성과 지속 가능성에 어떤 영향을 미치는지에 대해 리포트 적어야해.",Generation,Report 22 | 12,코로나19 이후 전 세계적으로 재택근무 확대로 인한 오피스 부동산 시장의 변화가 관측되고 있는데 이슈에 대한 뉴스 쓰는거 가능할까?,Generation,News 23 | 13,고양이가 사랑스러운 이유에 대한 에세이를 적어주면 안될까?,Generation,Essay 24 | 14,고등학교 졸업식 연설문을 작성하는 데 어려움을 겪고 있는데. 2023학년도 졸업식 연설문을 작성하는 데 도움 좀 주라.,Generation,Speeches 25 | 15,다음 달 06/07/2023 오후 3시에 신제품 론칭 미팅을 개최할 예정입니다. 장소는 쇼룸으로 정했습니다. 미팅 아젠다를 적어주세요.,Generation,Meeting agendas and minutes 26 | 16,지속가능한 패션에 관심이 많고 친환경 의류 브랜드를 론칭하고 싶다. 상세한 사업 계획을 세우는 데 도움을 줄 수 있습니까?,Generation,Business proposals 27 | 17,인재 채용과 면접 기술을 강화하기 위한 교육 자료를 만들어줘. 효과적인 면접 질문과 평가 방법이 포함되여야함.,Generation,Educational materials 28 | 18,제네시스 G70에 대한 긍정적인 리뷰를 남기고 싶습니다.,Generation,Product review 29 | 19,피카소의 여인의 얼굴에서 영감을 받은 재즈 노래 가사를 쓰세요.,Generation,Lyrics 30 | 20,보다 지속 가능한 라이프스타일을 향한 여정을 공유하고 블로그 게시물에서 친환경 생활 팁을 제공하세요.,Generation,Blog posts 31 | 21,장대한 판타지 영화 '반지의 제왕: 두 개의 탑'에 대한 리뷰를 작성해주실 수 있나요?,Generation,Movie review 32 | 22,프로 운동선수이지만 심각한 부상으로 선수 생활을 마감하는 캐릭터 만들어볼까?,Generation,Character 33 | 23,도쿄 여행을 얼마전에 다녀왔는데. 그곳에서의 경험에 대한 여행 리뷰 부탁할게,Generation,Travel review 34 | 24,트위터에 #광고 라고 붙이고 광고 있다고 알리는 트윗 하나 작성해봐,Generation,SNS posts 35 | 25,"주어진 정보로 제안요청서를 작성할 수 있나요? 36 | IT 서비스 회사: 하드웨어 및 소프트웨어 설치, 네트워크 지원, 사이버 보안 서비스를 포함한 IT 서비스에 대한 제안 요청.",Generation,Request for proposal 37 | 26,"자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.",Generation,Python code 38 | 27,"사용자로부터 입력 M과 N을 읽고 ""isPerfectSquare"" 함수를 호출하여 M과 N 사이의 모든 완전제곱수를 식별하는 C++ 코드 스니펫을 구현합니다.",Generation,C++ code 39 | 28,"사용자로부터 ""players"" 및 ""callings"" 배열을 읽고 ""rearrangePlayers"" 함수를 호출하여 재정렬된 배열을 가져오는 Java 코드 조각을 구현합니다.",Generation,Java code 40 | 29,JavaScript 코드에서 오류 처리를 구현하여 입력 배열이 비어 있거나 유효하지 않은 문자가 포함된 경우를 처리하여 프로그램이 오류 없이 원활하게 실행되도록 합니다.,Generation,JavaScript code 41 | 30,USED_GOODS_BOARD 테이블에서 가격이 가장 높은 게시물을 검색하는 SQL 쿼리를 구현합니다.,Generation,SQL code 42 | 31,사용자 지정 색상 및 애니메이션 효과로 진행률 표시줄의 스타일을 지정하는 CSS 코드를 만듭니다.,Generation,CSS code 43 | 32,HTML 코드 스니펫을 구현하여 이미지 간에 자동으로 전환되는 반응형 캐러셀/슬라이더를 만듭니다.,Generation,HTML code 44 | 33,파일을 읽고 그 안의 단어 수를 세는 Golang 프로그램을 만듭니다.,Generation,Golang code 45 | 34,"AVAudioPlayer를 사용하여 오디오 파일을 재생하고 재생, 일시 중지 및 중지 기능에 대한 컨트롤을 제공하는 iOS 앱을 만듭니다.",Generation,iOS code 46 | 35,직각삼각형에서 빗변의 길이의 제곱은 다른 두 변의 길이의 제곱의 합과 같다는 피타고라스의 정리를 증명하십시오.,Generation,Mathematical proofs 47 | 36,학부모 참여가 초등학생의 학업 성취도에 미치는 영향에 대한 연구 개요.,Generation,Research summaries 48 | 37,15인치 노트북용 가방에 대해서 상품 설명을 적는거 좀 도와줘.,Generation,Product descriptions 49 | 38,"인류 최초의 감미료라고 불리며, 이집트에서는 미라 보존을 위해 방부제로 사용한 것은 무엇이죠?",Generation,Trivia and quiz questions 50 | 39,국가와 수도를 사용하여 단어 검색 퍼즐을 만드는 중이야. 적합한 단어 목록을 만들어줄래?,Generation,Word puzzles 51 | 40,화석 연료를 대체하기에 원자력은 충분히 안전한가?,Generation,Debates and arguments 52 | 41,레오나르도 다 빈치는 어떤 유명한 그림을 그렸을까요?,Generation,Quiz questions 53 | 42,"출제자가 주변 사물이나 인물, 동물 따위의 주제를 제시하고 머릿속으로 적당한 단어를 생각하면 다른 사람이 출제자에게 최대 20개의 질문을 던지고, 질문에 대한 답을 바탕으로 출제자가 생각한 단어가 무엇인지 맞춰내는 방식의 게임을 하자. 답은 도시락",Generation,스무고개 54 | 43,"Walt Disney Company의 테마파크 부문에 대한 SWOT 분석을 수행하여 엔터테인먼트 및 관광 부문의 강점, 약점, 기회 및 위협을 분석할 수 있습니까?",Generation,SWOT analysis 55 | 44,옐로스톤의 가장 큰 지질학적 자랑은 무엇인가요? 200글자 내외로 적으세요.,OpenQA,geometry 56 | 45,"프랑스 혁명 전쟁의 원인, 과정, 결과, 영향에 대해 10문장으로 간략하게 설명하세요.",OpenQA,history 57 | 46,키스 자렛을 대표하는 앨범 세 곡을 설명과 함께 리스트 형식으로 추천하세요.,OpenQA,people 58 | 47,"천왕성의 특징을 적어보세요. 59 | 간략하게 적어보세요. 60 | 세 단락으로 적어보세요. 61 | 1000자로 적으세요.",OpenQA,astronomy 62 | 48,평판이 좋은 출처에서 별자리 콘텐츠를 찾아보세요. 띠 중 물고기 자리의 행운의 아이템을 알려주시면 감사하겠습니다.,OpenQA,fortune 63 | 49,불교에 대해 말해주세요. 200자로 적으세요.,OpenQA,religion 64 | 50,"콜로라도에서 야생화를 볼 수 있는 시기와 꽃의 종류, 이름, 위치를 자세히 알려주세요.",OpenQA,식물 65 | 51,거북이를 키우려면 어항 물을 얼마나 자주 갈아줘야 하나요? 100글자 내외로 적으세요.,OpenQA,동물 66 | 52,숭례문에 대해 말해주세요. 200자 내외로 적어주세요.,OpenQA,건축물 67 | 53,"계란, 참기름, 쌀, 양파, 고추, 간장을 넣어 맛있는 레시피를 만들어주세요. 참고로 저는 다이어트 중입니다. 300글자 내외로 적으세요.",OpenQA,free 68 | 54,고양이에게 행복한 삶을주는 방법은 어떤게 있을까?,Brainstorming,general 69 | 55,주방을 깨끗하고 깔끔하게 유지하는 방법,Brainstorming,life 70 | 56,데이터 엔지니어가 되는 방법이 궁금해,Brainstorming,job 71 | 57,미라클 모닝에 대한 사람들의 경험은 어떤가요?,Brainstorming,Personal experiences and opinions 72 | 58,적은 비용으로 지금 시작하기 좋은 취미는 무엇인가요?,Brainstorming,Hobbies and interests 73 | 59,어떤 교육이 커리어 개발에 도움이 될 수 있을까요? 저는 주니어 프론트엔드 엔지니어입니다.,Brainstorming,Career and education 74 | 60,바람을 피울 사람을 어떻게 알아낼 수 있을까?,Brainstorming,Relationships and social connections 75 | 61,사람들은 해외여행을 준비할 때 교통편과 문화차이에대해서 어떻게 준비하지?,Brainstorming,Travel and culture 76 | 62,"소셜 미디어가 엔터테인먼트 산업을 어떻게 변화시켰으며, 그 결과 새롭게 떠오르는 트렌드는 무엇인가요?",Brainstorming,Entertainment and media 77 | 63,사람들은 자신의 목표를 달성하는 것과 자신과 가까운 사람들의 목표와 욕구를 지원하는 것 사이에서 어떻게 균형을 잡을 수 있을까요?,Brainstorming,Life goals and aspirations 78 | 64,"정의와 평등의 관계는 무엇이며, 윤리적 의사결정에 어떤 영향을 미치나요?",Brainstorming,Philosophy and ethics 79 | 65,사람들에게 영원히 살 수 있는 기회가 주어진다면 사람들은 그렇게 할까요?,Brainstorming,Hypothetical situations 80 | 66,"오염과 어획 남획으로부터 바다를 보호하려면 어떻게 해야 하며, 이를 위해 어떤 정책을 시행해야 하나요?",Brainstorming,environmental issues 81 | 67,친환경적이고 휴대성이 뛰어난 새로운 텀블러 브랜드의 이름에 대한 아이디어를 제공해 주세요.,Brainstorming,브랜드 이름 82 | 68,새로운 아웃도어 의류 라인에 대해 남성 고객과 여성 고객 모두에게 어필하기 위해 어떻게 마케팅 노력을 맞춤화할 수 있습니까?,Brainstorming,판매 타겟 설정 83 | 69,"손님이 할 말을 예상한다면? 84 | 85 | 옷가게에서 손님과 점원의 대화: 86 | 손님: 이 셔츠 한 사이즈 작은 거 있나요? 87 | 점원: 재고 확인드릴게요, 잠시만요. 88 | 손님: 이 셔츠랑 어울리는 바지 있을까요? 89 | 점원: 넵. 재고 확인됐는데, 같이 가져다 드리겠습니다. 90 | 손님:",Chat,general 91 | 70,"이 후 선생님과 학생의 대화를 쓰시오. 92 | 93 | 교육에서 AI에 대해 이야기하는 교사와 학생: 94 | 교사: AI는 교육을 변화시킬 잠재력이 있어. 교실에서의 AI는 어떤 것들이 있을 것 같니? 95 | 학생: AI가 학습 경험을 개인화하고 지능적인 튜터링을 제공하는 방법이 흥미로워요. 하지만 실제 사람이 하는 교사의 역할이 어떻게 될지는 모르겠어요. 선생님은 어떻게 생각하세요? 96 | 선생님:",Chat,ai 97 | 71,"이 후 대화로 적절한 대화를 작성하시오. 98 | 99 | 교사에게 자동차 정비에 대해 묻는 학생: 100 | 학생: 최근에 운전면허증을 땄는데 차 점검할때, 어떤거 점검하는게 좋나요? 101 | 교사: 차 수리할때? 정기적인 오일 교환, 타이어 공기압 점검 및 정기적인 유지 관리가 필수야. 부모님이 안 가르쳐주시니? 102 | 학생:",Chat,car 103 | 72,"다음에 올 대화를 생성해줘. 104 | 105 | 에단과 올리비아의 대화: 106 | 에단: 올리비아, 3D 프린터를 사용해 본 적이 있나요? 107 | 올리비아: 아니요, 안 써봤어요. 이걸로 뭘 만들 수 있나요? 108 | 에단: 장난감부터 도구, 심지어 인체 장기까지 모든 종류의 물건을 만들 수 있어요. 109 | 올리비아:",Chat,Science and technology 110 | 73,"연결될 대화를 만들어주세요. 111 | 다니엘과 사만다의 대화: 112 | 다니엘: 사만타, 르네상스에 대해 아는 게 있나요? 113 | 사만다: 네, 알아요. 르네상스는 예술, 과학, 철학 분야에서 창의성과 혁신이 대단했던 시대죠. 114 | 다니엘:",Chat,History 115 | 74,"다음 대화를 만들어 보세요. 116 | 117 | 다니엘과 사만다의 대화: 118 | 다니엘: 사만타, 좋아하는 그림이 있나요? 119 | 사만다: 네, 빈센트 반 고흐의 '별이 빛나는 밤'을 좋아해요. 색감과 붓터치가 정말 독특해요. 120 | 다니엘: ",Chat,Art and literature 121 | 75,"이 다음 대화는 어떻게 될지 알려주세요. 122 | 123 | 소피아: 프렌즈' 보셨어요? 124 | 리암: 네, 그 프로그램 정말 좋아해요. 정말 재밌어요. 125 | 소피아: 전 한 번도 본 적이 없어요. 시즌 추천해줄래요? 126 | 리암: ",Chat,Movies and TV shows 127 | 76,"음악 장르에 대해 이야기하는 친구들: 128 | 친구 1: 최근에 다른 음악 장르를 탐색하고 인디 록을 좋아하게 되었습니다. 129 | 친구 2: 인디록은 독특한 매력이 있어요. 밴드의 생생하고 진정한 사운드는 매우 매력적입니다. 130 | 친구 1: 동의합니다. 주류 관습에 얽매이지 않는 아티스트를 발견하는 것은 신선합니다. 131 | 친구 2:",Chat,Music 132 | 77,"도덕의 의미에 대해 토론하는 부모와 자녀: 133 | 부모: 도덕의 개념을 어떻게 이해합니까? 무엇이 옳고 그른가? 134 | 아이: 도덕이란 타인을 친절하고 공평하며 존중하는 마음으로 대하는 것이라고 생각합니다. 우리 행동의 결과를 고려하는 것입니다. 135 | 부모: 그것들은 도덕의 본질적인 측면입니다. 다양한 윤리 이론을 탐구하면 도덕적 의사 결정에 대한 추가적인 통찰력을 얻을 수 있습니다. 136 | 아이:",Chat,Philosophy and ethics 137 | 78,"최근 여행에서 가장 좋았던 점을 공유한 동료들: 138 | 동료 1: 태국의 길거리 음식은 정말 대단했어요! 나는 많은 새로운 맛을 시도했습니다. 139 | 동료 2: 음식은 문화를 경험할 수 있는 훌륭한 방법입니다. 그것은 모든 나라의 요리 모험과 같습니다. 140 | 동료 1:",Chat,Travel and culture 141 | 79,"이 다음 대화는 어떻게 될지 알려주세요. 142 | 143 | 사람 1: 안녕하세요! 요즘 어떻게 지내셨나요? 144 | 사람 2: 별다른 일은 없고 대부분의 시간을 정원에서 보내고 있어요. 최근에 토마토와 오이를 좀 심었어요. 145 | 사람 1: 오, 그거 좋네요. 정원에 다른 식물이 있나요? 146 | 사람 2: 네, 꽃, 허브, 과일 등 다양한 식물을 키우고 있습니다. 정원을 가꾸는 것이 정말 힐링이 되거든요. 147 | 사람 1: 정말 좋네요! 항상 정원을 가꾸고 싶었는데 어디서부터 시작해야 할지 모르겠어요. 148 | 사람 2: 보기만큼 어렵지 않아요. 약간의 조사만 하고 작게 시작하면 돼요. 149 | ",Chat,Hobbies and interests 150 | 80,"근무 중 휴식의 이점에 대해 논의하는 동료: 151 | 동료 1: 재충전과 집중력 향상을 위해 하루 종일 짧은 휴식을 취하는 것이 도움이 된다고 생각합니다. 152 | 동료 2: 좋은 전략이네요. 나는 논스톱으로 일하는 경향이 있고 하루가 끝날 때까지 피곤함을 느낍니다. 153 | 동료 1: 휴식을 취하면 실제로 생산성이 향상됩니다. 자기 관리를 우선시하도록 서로 격려합시다. 154 | 동료 2:",Chat,Health and wellness 155 | 81,"제2언어 학습의 이점에 대해 논의하는 동료들: 156 | 동료 1: 새로운 언어를 배우면 많은 기회가 열립니다. 157 | 동료 2: 물론입니다! 그것은 우리가 다른 문화권의 사람들과 소통할 수 있게 하고 인지 능력을 향상시킵니다. 158 | 동료 1: 게다가 이력서를 보면 멋있어 보여요. 159 | 동료 2:",Chat,Language learning 160 | 82,"말장난 수수께끼로 서로 도전하는 친구들: 161 | 친구 1: 나는 광산에서 끌려나와 나무로 된 상자에 갇혔습니다. 난 무엇인가? 162 | 친구 2: 그것은 까다롭습니다. 힌트를 주실 수 있나요? 163 | 친구 1: 읽고 쓰는 것입니다. 164 | 친구 2:",Chat,Puzzles and riddles 165 | 83,"학생에게 재귀의 개념을 설명하는 교사: 166 | 교사: 재귀는 프로그래밍에서 강력한 기술입니다. 재귀를 사용하여 해결할 수 있는 문제를 생각할 수 있습니까? 167 | 학생: 잘 모르겠습니다. 개념을 더 잘 이해하는 데 도움이 되는 간단한 예를 제공해 주시겠습니까? 168 | 교사:",Chat,code q&a (like stackoverflow) 169 | 84,"선호하는 게임 플랫폼에 대해 논의하는 게이머: 170 | 게이머 1: 저는 PC 게이머입니다. 다양성과 그래픽 품질은 타의 추종을 불허합니다. 171 | 게이머 2: 저는 콘솔 게이머에 가깝습니다. 저는 PlayStation에서 게임을 즐기는 것을 즐깁니다. 172 | 게이머 1:",Chat,game 173 | 85,"하프타임 중 축구 경기를 분석하는 스포츠 방송사: 174 | 해설위원 1 : 전반전은 치열했습니다. 두 팀 모두 공격적인 모습이 좋았습니다. 175 | 해설위원 2: 물론이죠. 미드필더 플레이는 예외적이어서 수많은 득점 기회를 창출했습니다. 176 | 해설위원 1 : 후반부도 그만큼 짜릿할 것 같습니다. 177 | 해설위원 2:",Chat,sports 178 | 86,"동물 훈련 센터에서 훈련 기술을 논의하는 동물 조련사와 동료: 179 | 훈련자 1: 긍정적 강화는 동물을 훈련시킬 때 핵심입니다. 원하는 행동을 배우고 수행하는 데 도움이 됩니다. 180 | 조련사 2: 전적으로 동의합니다. 클리커 훈련이 좋은 행동을 강화하는 데 특히 효과적이라는 것을 알았습니다. 181 | 훈련자 1: 우리가 훈련시키는 동물들과 강한 유대감을 형성하는 것도 성공적인 훈련을 위해 매우 중요합니다. 182 | 조련사 2:",Chat,animal 183 | 87,"패션 인플루언서 및 팔로워가 소셜 미디어에서 의상 영감에 대해 논의: 184 | 인플루언서: 최근에 제 인스타그램에 보호에서 영감을 받은 의상을 올렸습니다. 빈티지와 모던한 요소가 어우러진 모습이 마음에 듭니다. 185 | 팔로워: 당신의 스타일은 항상 매우 고무적입니다! 나는 당신의 게시물에서 내 자신의 의상에 대한 많은 아이디어를 얻습니다. 186 | 인플루언서: 패션에는 전 세계 사람들에게 영감을 주고 연결하는 힘이 있습니다. 187 | 팔로워:",Chat,fashion 188 | 88,"회의 중 사무실 리노베이션에 대해 논의하는 동료들: 189 | 동료 1: 사무실은 직원들의 사기를 진작시키기 위해 새로운 모습이 필요합니다. 편안한 좌석 공간과 식물을 추가하는 것은 어떻습니까? 190 | 동료 2: 동의합니다. 또한 지정된 협업 공간을 만들어 팀워크와 창의성을 장려할 수 있습니다. 191 | 동료 1: 인테리어 디자인은 긍정적이고 생산적인 작업 환경을 조성하는 데 중요한 역할을 합니다. 192 | 동료 2:",Chat,interior 193 | 89,"방문한 유명한 다리의 건축학적 특징에 대해 이야기하는 친구들: 194 | 친구 1: 금문교는 공학적 경이로움입니다. 서스펜션 케이블과 아이코닉한 오렌지 색상이 정말 기억에 남습니다. 195 | 친구 2: 당연하지! 다리의 디자인은 강한 바람과 아래 바다의 끊임없는 움직임을 견딜 수 있도록 합니다. 196 | 친구 1: 다리가 물리적으로나 상징적으로나 공간과 사람을 연결하는 방식이 신기하지 않나요? 197 | 친구 2:",Chat,structure 198 | 90,"공공장소에서 애완동물 에티켓에 대해 말하는 개 주인: 199 | 견주 1: 반려견을 산책시킬 때 뒷정리를 꼭 해줘야 할까요? 200 | 견주 2: 물론이죠! 우리 개들이 공공 장소를 사용하는 다른 사람들에 대한 책임감과 배려를 보여 준 후 청소를 합니다. 201 | 견주 1:",Chat,예절 202 | 91,"이 광고 아웃라인을 인플루언서들도 쉽게 받아들이도록 다시 작성해줄 수 있겠어? 203 | 제품: 디자이너 핸드백 204 | 205 | 광고 개요: 206 | 우아한 디자인과 장인정신이 돋보이는 디자이너 핸드백의 고급스러운 샷부터 시작하세요. 207 | 주요 메시지 소개: 우리가 탐내는 핸드백 컬렉션으로 세련미와 스타일을 연출하세요. 208 | 프리미엄 소재, 디테일에 대한 관심, 시대를 초월한 매력과 같은 주요 기능을 강조 표시합니다. 209 | 210 | 바디: 211 | 공식 행사에서 일상 행사에 이르기까지 다양한 환경에서 자신감 있는 개인이 착용하는 핸드백을 선보입니다. 212 | 충분한 수납 공간 또는 다양한 휴대 옵션과 같은 핸드백의 기능을 강조하십시오. 213 | 패션 인플루언서 또는 유명인의 평가를 포함하여 핸드백의 상태와 바람직함을 강조합니다. 214 | 215 | 콜 투 액션: 216 | 최신 핸드백 디자인을 살펴보려면 플래그십 매장이나 공인 판매점을 방문하도록 시청자를 독려하세요. 217 | 개인화 된 스타일링 서비스 또는 사용자 정의 옵션을 제공하여 독특한 핸드백 경험을 만드십시오. 218 | 고급스러움과 고급스러움을 구현하는 슬로건으로 결론을 내립니다. 219 | ",Rewrite,commercial outline 220 | 92,이 집에 바퀴벌레가 많이 나오나요?를 영어로 하면?,Rewrite,translate ko->en 221 | 93,"""The curious cat gracefully leaped over the fence, landing softly on the lush green grass.""를 한국어로 번역해줘",Rewrite,translate en->ko 222 | 94,"네비 길 안내한 글 한눈에 보기 좋게 다시 작성 부탁해 223 | 224 | 킨텍스에서 12m앞 '킨텍스IC, 킨텍스하역장2' 방면으로 좌회전, 107m앞 '킨텍스IC, 킨텍스하역장2' 방면으로 비보호 좌회전, 224m앞 '한류월드' 방면으로 우회전, 154m 앞 '킨텍스IC'방면으로 우회전, 1.4km앞 킨텍스IC에서 '서울, 인천공항'방면으로 왼쪽 방향, 23km앞 마포대교북단에서 '공덕오거리' 방면으로 왼쪽 도시고속도로 출구, 1.5km 공덕오거리에서 '서울역(서부)'방면으로 오른쪽 1시 방향, 753m앞 우회전, 510m앞 회전교차로에서 2시 방향, 90m앞 좌회전, 숙명여자대학교 제1캠퍼스 도착",Rewrite,navigation 225 | 95,"다음의 격식 없는 문자를 좀 더 격식 있게 써주세요. 226 | 수신자: 김미형, 발신자:이희애 227 | 토요일 밤에 저희 집에서 파티가 열릴 예정입니다. 곧 초대장을 더 보낼 예정이지만 먼저 개인적으로 연락드리고 싶었어요. 당신은 제가 가장 좋아하는 사람 중 한 명이고, 파티를 더욱 멋지게 만들어 주실 거라고 믿어요!",Rewrite,formal/unformal 228 | 96,"다음 글에서 문법과 맞춤범 오류없이 써줘. 229 | 어의가없네요. 맞춤범 좀 틀린다고 공항장애니 발암물질이니 하시는 분들 그거 지금 임신공격인거 아시죠?",Rewrite,grammar 230 | 97,"프로젝트에서 개발자 액세스 권한이 있는 상태에서 코드를 git에 푸시할 때 문제가 발생하지만 마스터 액세스 권한이 있으면 모든 것이 정상입니다. 어디에서 문제가 발생하나요? 그리고 어떻게 해결하나요? 231 | 232 | 오류 메시지: 233 | 234 | error: You are not allowed to push code to protected branches on this project. 235 | ... 236 | error: failed to push some refs to ...",Rewrite,code fix 237 | 98,"아래 메일을 내용을 팀 메신저에 공지할 수 있게 친근하게 다시 적어줘 238 | 239 | 제목: 효과적인 커뮤니케이션을 위한 그룹 워크숍 초대 240 | 241 | 팀 여러분 242 | 243 | 2023년 6월 20일 오전 9시부터 오후 12시까지 그랜드 호텔에 위치한 센트럴 컨퍼런스룸에서 열리는 효과적인 커뮤니케이션을 위한 그룹 워크숍에 여러분을 초대하게 되어 기쁘게 생각합니다. 이 워크숍은 팀 내 및 고객과의 커뮤니케이션 기술을 향상시켜 더 나은 협업과 고객 만족을 보장하는 것을 목표로 합니다. 244 | 245 | 워크숍에서는 적극적인 경청, 명확한 메시지 전달, 친밀감 형성을 위한 유용한 기술을 배우게 됩니다. 이러한 기술은 강력한 관계를 조성하고 비즈니스 목표를 달성하는 데 필수적입니다. 여러분의 참석과 적극적인 참여를 적극 권장합니다. 246 | 247 | 달력에 일정을 표시하고 2023년 6월 10일까지 참석 가능 여부를 확인해 주시기 바랍니다. 여러분의 열정적인 참여와 팀의 성공에 긍정적인 영향을 미칠 수 있기를 기대합니다. 248 | 249 | 감사합니다, 250 | 251 | 에밀리 톰슨 252 | 교육 및 개발 관리자",Rewrite,email 253 | 99,"회의 재품 출시 254 | 참석자 사라, 마크, 리사, 마이클 255 | 안건 256 | 257 | 재품 출시 계획 및 일정 검토 258 | 마케팅 및 홍보 전략 논의 259 | 우려 사항 또는 과제 해결 260 | 성공적인 제품 출시를 위한 목표 설정 261 | 262 | 참고사항: 263 | 264 | 회의에서는 재품 출시 계획과 일정을 검토하여 모든 것이 순조롭게 진행되고 읻는지확인했습니다. 제품에 대한 인지도를 높이고 흥미를 유발하기 위한 마케팅 및 홍보 전략에 대해 논의했습니다. 265 | 266 | 경젱 및 타갯 고객 참여 등 잠재적인 우려 사항과 과제를 해결했습니다. 고객 선호도를 더 잘 이해하고 그에 따라 마케팅 접근 방식을 개선하기 위해 시장 조사를 실시할 것을 제안했습니다. 267 | 268 | 다음 단계: Sarah는 마케팅 팀과 협력하여 계획된 전략을 실행하고 진행 상황을 모니터링할 것입니다. Mark는 시장 동향과 경젱사 활동을 분석하여 잠재적 기회를 파악할 것입니다. Lisa와 Michael은 홍보 자료를 마무리하고 재품 출시 물류가 원활하게 이루어질 수 있도록 협력합니다. 269 | 270 | 이 회의 노트를 보다 정확하게 편집하세요. 문법 오류를 수정하고 날짜와 장소 등 누락된 정보를 입력해 주세요.",Rewrite,meeting note 271 | 100,"밑에 뉴스 세줄로 줄여줘 272 | 273 | 美 부채한도 상향 합의안, 하원 운영위 가까스로 통과 274 | 275 | 미국 연방정부의 디폴트(채무 불이행)를 피하기 위한 부채한도 상향 합의안이 의회의 첫 관문을 가까스로 통과했다. 공화당과 민주당 내 반란표가 어느 정도 확인된 상황이어서 최종 통과까지는 여전히 불투명하다는 전망이다. 276 | 30일(현지시간) 뉴욕타임스(NYT) 등에 따르면 미 하원 운영위원회는 이날 회의를 열고 부채한도 상향 합의안을 전체회의에 회부하기로 결정했다. 위원회 위원 13명 중 7명이 찬성표를, 6명이 반대표를 던졌다. 불과 1표 차이로 전체회의에서 표결을 진행할 수 있게 된 것이다. 미 하원은 31일 합의안을 표결에 부칠 계획이다. 277 | 278 | NYT는 부채한도 상향 합의안이 하원 운영위를 통과함에 따라 의회 내 첫 문턱을 넘어섰다고 평가했다. 하원 운영위에는 공화당 의원 9명과 민주당 의원 4명이 소속돼 있는데, 양당 강경파들이 포진한 탓에 합의안이 부결될 수 있다는 우려가 적지 않았기 때문이다. 실제 이날 민주당 의원 전원과 공화당 의원 2명이 합의안에 반대했다. 279 | 280 | 앞서 조 바이든 미 대통령과 케빈 매카시 미 하원의장은 지난 주말 부채한도 상향 논의를 진행하고 2025년 1월까지 연방정부의 부채 한도를 높이는 대신 2024~2025년 정부 예산 지출을 제한하기로 최종 합의했다. 양측은 또 국방비 지출을 늘리고 연방정부 복지 프로그램 수급 요건을 강화하는 데에도 의견을 같이 했다. 281 | 282 | 연방정부 지출을 대폭 삭감해야 한다고 주장해 온 공화당 강경파는 여전히 이번 합의안에 불만을 제기하고 있다. 공화당 강경 보수파 의원 모임인 프리덤코커스는 매카시 의장의 사퇴까지 거론하고 있다. 민주당 일부 의원들도 연방정부 지출을 제한한 합의안에 불만을 품고 있다. 283 | 284 | 이에 따라 부채한도 상향 합의안이 하원 문턱을 넘을 수 있을지 낙관하기 어렵다는 관측이 나온다. 합의안이 하원을 통과하기 위해선 전체 435석 중 과반(218표) 이상의 표를 얻어야 한다. 하킴 제프리스 민주당 하원 원내대표는 “처음에 우리는 공화당 하원의원 중 95%가 합의안을 지지할 것이라고 들었다”며 “(지금은) 그런 것 같진 않다”고 상황을 지적했다. 285 | 286 | 매카시 의장 등 공화당 지도부는 공화당 하원의원 222명 가운데 최소 150명의 지지를 얻기 위해 표 단속을 강화하고 있다. 백악관 역시 민주당 의원들을 대상으로 합의안 내용을 설명하고 지지를 요청했다. 합의안이 하원에서 가결되면 상원으로 넘어가며, 늦어도 다음 달 5일까지는 상·하원을 모두 통과해야 연방정부의 디폴트를 피할 수 있다. 287 | ",Summarization,news 288 | 101,"총 균 쇠라는 책 소개인데 한줄 소개한다면? 289 | 290 | 학문의 경계를 넘나드는 세계적 석학 재레드 다이아몬드. 인류 문명에 대한 예리한 통찰을 전해온 그의 대표작이자 1998년 퓰리처상 수상작 《총, 균, 쇠》를 새 번역, 새 편집으로 만난다. 291 | 292 | 왜 어떤 국가는 부유하고 어떤 국가는 가난한가? 왜 어떤 민족은 다른 민족의 정복과 지배의 대상이 되었는가? 생물학, 지리학, 인류학, 역사학 등 다양한 학문의 융합을 통해 장대한 인류사를 풀어내며 오늘날 현대 세계가 불평등한 원인을 종합 규명한 혁신적 저작. 출간 25년 기념 뉴에디션에는 2023년 저자 특별서문과 서울대 인류학과 박한선 교수의 해제, 새 서문과 후기를 수록해 풍성한 읽을거리를 더했다.",Summarization,book 293 | 102,"손흥민 위키에 나온 평가 요약 부탁할게 294 | 295 | 프리미어 리그에서 득점왕을 차지하고 통산 100호골을 달성한 아시아 역사상 최초이자 유일무이한 선수다. 그뿐만 아니라 손흥민이 클럽에서 보여준 개인 퍼포먼스와 스탯 등은 진작 아시아 평균을 아득히 넘었다고 평가받지만, 아직까지 주요 리그 및 대회에서 우승 커리어가 없다는 게 유일한 흠으로 지적받는다. 하지만 그것을 감안하더라도 아시아에서 압도적인 개인 커리어, 전성기의 고점, 누적, 꾸준함 등 모든 것을 고려해 보면 역대 다른 아시아 선수들과 비교했을 때 압도적이기 때문에, 아시아 역대 최고의 선수라는 평가는 이견의 여지가 없는 편이다. 296 | 297 | 실제로, 과거부터 현재까지 프리미어 리그에서 뛴 수많은 아시아 국적 선수들 중 한 시즌에 10골, 20골 이상을 넣은 선수는 손흥민을 제외하면 단 한 명도 없다. 또한 아시아 선수 최초로 프리미어 리그 이달의 선수 3회 수상, 2020-21 시즌엔 PFA 올해의 팀 선정, 2021-22 시즌에는 프리미어 리그 득점왕을 차지하였다.[62] 298 | 299 | 아시아 선수 중 UEFA 챔피언스 리그, 프리미어 리그 등 유럽 5대 리그 통산 최다 득점과 프리미어 리그 득점왕, 발롱도르 11위, FIFA 푸스카스상 수상, 프리미어 리그 이달의 선수 3회 수상, PFA 올해의 팀 선정, 유럽 빅리그 통산 150골 돌파, 프리미어 리그 100골 돌파 등의 굵직한 개인 커리어를 보유하고 있으며, 또한 아시아 베스트 풋볼러 8회 수상, AFC 국제 선수상 4회 수상, AFC 아시안컵 베스트팀 등 아시아에서 주는 상들 역시 독식하고 있다. 300 | 301 | 또한, 손흥민 한 명이 프리미어 리그에서 넣은 골이 PL에서 활약하는 모든 아시아인 선수들보다 더 많을 정도로 PL 내 위상은 단연 독보적이다.[63] 그리고 2021-22시즌 리그에서 아시아 선수 최초로 20골 이상을 기록하며 유럽 5대 리그[64] 아시아 선수 관련 골 기록은 모두 손흥민이 가지게 되었다. 302 | 303 | 2018-19 시즌 이후 한준희 해설 위원은 차범근을 제치고 손흥민을 아시아 역대 No.1으로 인정하고 있다.[65] 해당 시즌에 박지성에 이어 두 번째로 챔스 결승 무대에 오르는 한국인 선수라는 점도 높은 평가에 한몫하며, 손흥민은 아직 현역이기 때문에 향후 활약과 우승 유무에 따라 평가가 점점 더 올라갈 가능성도 있다. 304 | 305 | 2016-17 시즌부터 2021년 8월 16일까지 집계한 통계로는, 5대 리그에서 골 기대치 대비 골이 제일 높은 선수임이 밝혀졌고,[66] 이 수치는 리오넬 메시, 엘링 홀란드, 그리고 같은 팀에서 뛰고 있는 해리 케인보다 높은 수치였다. 따라서, 손흥민의 골 기대치 대비 골은 독보적이라는 평가를 받고 있다.#",Summarization,wiki 306 | 103,"이 리뷰의 핵심 사항만 소개해줘. 307 | 가우디 투어는 꼭 하는게 좋다고 해서 308 | 후기보고 신청했어요!! 309 | 젊은 여자 가이드분이였고 310 | 목소리도 넘 좋으시고 설명도 요약해서 잘하셔서 좋았어요:) 311 | 정말 바르셀로나를 좋아하시고, 312 | 또 가이드 하시는걸 행복해하는게 느껴졌답니다. 313 | 중간중간 노래도 선곡해서 틀어주시구요- 314 | 한분한분 사진도 열정적으로 찍어주셨어요. 315 | 짧지 않은 시간인데 항상 웃는 얼굴로 설명해주셔서 316 | 정말 가이드분 잘 만났다고 생각했어요! 317 | 아, 그리고 버스투어라고 해서 별로 안 걸을줄 알았는데 318 | 건축물 외부 앞에서 거의 서서 듣거나 319 | 지정되어있는 버스 주차장까지 가야해서 320 | 은근 걷는 시간이 있습니다. 참고 하시길 바랍니다 321 | 322 | 323 | 다만, 아쉬운 부분이라면 마지막 파밀리아 성당 건축물 설명에서는 324 | 기독교적인 성경내용이라고 해야할까요. 325 | 종교적인 설명디테일이 너무 깊게 들어가는거 같아서 326 | 무교인이지만, 기독교를 별로 선호하지 않는 327 | 저로서는 좀 힘들었어요 328 | 건축물이 성당/ 가우디의 종교관이 들어가는 부분이라 329 | 당연하긴 하지만, 교회에 와서 목사님 설명을 듣고 있나 싶은..? 330 | 까사바뜨요-밀라-구엘공원에서의 설명은 너무 만족했습니다!",Summarization,review 331 | 104,"이 특허의 핵심만 잘라서 알려줘. 332 | 본 발명은 태양전지(14, 솔라)를 구비하여 충전배터리(16)에 전원을 충전시킨 대기상태에서 일정거리 선상에서 사람이 감지되며 감지센서(20)가 작동될 때만 전원을 인가하여 광고를 표출할 수 있도록 한 광고용 디스플레이장치에 관한 것으로, 이러한 본 발명은 수용공간(10)을 갖는 사각형상의 수용본체(12)와; 상기 수용본체(12)의 상면 일측에 비스듬히 설치되어 빛을 전기에너지로 변환하는 태양전지(14 ,솔라셀)와 전기적으로 연결되되, 수용본체(12)의 내부 일측에 설치되어 태양전지(14, 솔라셀)로부터 공급되는 전기에너지를 충전시키는 충전배터리(16)와; 상기 충전배터리(16)에 전기적으로 연결되되, 수용본체(12)의 내부 에 설치되어 충전배터리(16)로부터 공급되는 전기에너지를 공급받아 기 설정된 프로그램에 따라 전기적으로 연결된 부품들의 동작을 제어하는 제어부(18)와; 상기 수용본체(12)의 내면 전방향으로 설치되되, 제어부(18)에 전기적으로 연결되어 제어부(18)의 제어에 따라 전방향에 위치한 사람을 감지하는 감지센서(20)와; 상기 수용본체(12)의 배면에 착탈가능하게 나사 고정되되, 수용본체(12)와 결합하여 수용공간(10)을 형성되게 하는 배면판(22) 등을 포함하여 구성된다.",Summarization,patent 333 | 105,"이 논문의 핵심 포인트만 빠짐없이 말해봐. 334 | (연구배경 및 목적) 최근 도시 공간의 공동체 환경에서 인간의 교류 단절로부터 나타난 사회 현상은 지역 커뮤니티 내부에서 소통부재와 같은 문제를 야기 시켰다. 이러한 문제를 개선하기 위하여 제공된 서비스는 거주민에 대한 수요와 요구를 제대로 반영하지 못하여 교류를 통한 삶의 질을 개선시키는 데 한계가 있다. 따라서 커뮤니티 공간의 교류를 활성화하고, 커뮤니티 거주민을 연결할 수 있는 콘텐츠의 연구가 본 연구의 목적이다. (연구방법) 본 연구에서는 지역 커뮤니티 내의 초등학교를 커뮤니티 공간으로 활용을 고찰해보고, 초등학교 교과의 체험 학습 교육 콘텐츠를 통하여 거주민까지 적용 가능한 서비스를 도출한다. (결과) 지역 커뮤니티 공간인 초등학교를 대상으로 체험학습을 증진 시킬 수 있는 서비스를 적용하였다. 이러한 서비스는 지역 거주민의 능동적인 참여를 통한 유대감 형성과 거주민을 위한 공간의 확장으로 지역 커뮤니티 활성화에 도움을 준다. 향후 문화·사회·복지 측면의 콘텐츠 확대로, 더 나은 체험학습 증진을 위한 스마트 서비스로의 발전을 기대한다.",Summarization,paper 335 | 106,"다음 대화을 알기 쉽게 한번 요약해줄 수 있을까? 336 | 337 | 지현: 승민아, 너는 자신의 몸과 마음을 건강하게 유지하기 위해 어떤 식으로 노력하고 있어? 338 | 승민: 나는 요가와 명상을 통해 몸과 마음의 균형을 찾고, 건강한 식습관을 유지하면서 충분한 수면을 취하려고 노력하고 있어! 339 | ",Summarization,dialogue 340 | 107,"다음 영화 리뷰 글의 감정을 긍정과 부정 중 하나로 분류하라. 341 | 342 | 리뷰: 두가지 토끼를 잡으려다 둘 다 놓친 영화",Classification,sentiment 343 | 108,"영화 감독은 누구야? 344 | 크리스토퍼 놀란, 브래드 피트, 메릴 스트립",Classification,select 345 | 109,"아래 단어들 좀 더 위에 있는 개념들로 묶어줄래? 346 | 347 | 봄, 여름, 가을",Classification,category 348 | 110,"다음에서 설명하는 인간 본성에 대한 관점은? 349 | 350 | 모든 사람은 태어날 때부터 다른 사람을 불쌍히 여기고 자신의 잘못을 부끄러워하는 마음을 가지고 태어난다. 351 | 352 | ① 인간의 본성은 본래 선하다. 353 | ② 인간의 본성은 본래 악하다. 354 | ③ 인간의 본성은 본래 선하지도 악하지도 않다. 355 | ④ 인간의 본성은 환경에 의해 결정되는 것이다.",ClosedQA,general 356 | 111,호수에 얼음이 두껍게 얼수록 대류때문에 호수의 열손실은 느려진다? 오? 아님 엑스?,ClosedQA,physical 357 | 112,"아래의 지문 속에서 말하는 필요한 장치를 골라볼래? 358 | 359 | 엔진 오일은 되풀이해서 윤활에 사용하므로 마모된 금속 가루나 외부로부터의 이물질이 섞이게 된다. 360 | 그대로 사용하면 윤활 효과가 약해질 뿐 아니라 오일도 열화(劣化)해서 순환 도중에 정화하는 장치가 필요하다. 361 | 362 | 363 | ㄱ. 오일 필터 ㄴ. 와이퍼 ㄷ.댐퍼 ㄹ.오일 쿨러",ClosedQA,car manual 364 | 113,"This passage is adapted from Mary Helen Stefaniak, The Cailiffs of Baghdad, Georgia: A Novel. ©2010 by Mary Helen 365 | Stefaniak. 366 | Miss Grace Spivey arrived in Threestep, Georgia, in August 1938. She stepped off the train wearing a pair of thick-soled boots suitable for hiking, a navy Line blue dress, and a little white tam that rode the waves of her red hair at a gravity-defying angle. August was a hellish month to step off the train in Georgia, although it was nothing, she said, compared to the 119 degrees that greeted her when she arrived one time in Timbuktu, which, she assured us, was a real place in Africa. I believe her remark irritated some of the people gathered to welcome her on the burned grass alongside the tracks. When folks are sweating through their shorts, they don’t like to hear that this is nothing compared to someplace else. Irritated or not, the majority of those present were inclined to see the arrival of the new schoolteacher in a positive light. Hard times were still upon us in 1938, but, like my momma said, “We weren’t no poorer than we’d ever been,” and the citizens of Threestep were in the mood for a little excitement. 367 | Miss Spivey looked like just the right person to give it to them. She was, by almost anyone’s standards, a woman of the world. She’d gone to boarding schools since she was six years old; she’d studied French in Paris and drama in London; and during what she called a “fruitful intermission” in her formal education, she had traveled extensively in the Near East and Africa with a friend of her grandmother’s, one Janet Miller, who was a medical doctor from Nashville, Tennessee. After her travels with Dr. Miller, Miss Spivey continued her education by attending Barnard College in New York City. She told us all that at school the first day. When my little brother Ralphord asked what did she study at Barnyard College, Miss Spivey explained that Barnard, which she wrote on the blackboard, was the sister school of Columbia University, of which, she expected, we all had heard. 368 | It was there, she told us, in the midst of trying to find her true mission in life, that she wandered one afternoon into a lecture by the famous John Dewey, who was talking about his famous book, Democracy and Education. Professor Dewey was in his seventies by then, Miss Spivey said, but he still liked to chat with students after a lecture—especially female students, she added—sometimes over coffee, and see in their eyes the fire his words could kindle. It was after this lecture and subsequent coffee that Miss Spivey had marched to the Teacher’s College and 50 signed up, all aflame. Two years later, she told a cheery blue-suited woman from the WPA1 that she wanted to bring democracy and education to the poorest, darkest, most remote and forgotten corner of America. 369 | They sent her to Threestep, Georgia. 370 | Miss Spivey paused there for questions, avoiding my brother Ralphord’s eye. 371 | What we really wanted to know about—all twenty-six of us across seven grade levels in the one room—was the pearly white button hanging on a string in front of the blackboard behind the teacher’s desk up front. That button on a string was something new. When Mavis Davis (the only bona fide seventh grader, at age thirteen) asked what it was for, Miss Spivey gave the string a tug, and to our astonishment, the whole world—or at least a wrinkled map of it—unfolded before our eyes. Her predecessor, Miss Chandler, had never once made use of that map, which was older than our fathers, and until that moment, not a one of us knew it was there. 372 | Miss Spivey showed us on the map how she and Dr. Janet Miller had sailed across the Atlantic Ocean and past the Rock of Gibraltar into the Mediterranean Sea. Using the end of a ruler, she gently tapped such places as Morocco and Tunis and Algiers to mark their route along the top of Africa. They spent twenty hours on the train to Baghdad, she said, swathed in veils against the sand that crept in every crack and crevice. 373 | “And can you guess what we saw from the train?” Miss Spivey asked. We could not. “Camels!” she said. “We saw a whole caravan of camels.” She looked around the room, waiting for us to be amazed and delighted at the thought. 374 | We all hung there for a minute, thinking hard, until Mavis Davis spoke up. 375 | “She means like the three kings rode to Bethlehem,” Mavis said, and she folded her hands smugly on her seventh-grade desk in the back of the room. 376 | Miss Spivey made a mistake right then. Instead of beaming upon Mavis the kind of congratulatory smile that old Miss Chandler would have bestowed on her for having enlightened the rest of us, Miss Spivey simply said, “That’s right.” 377 | 378 | Which choice provides the best evidence for the 379 | answer to the previous question? 380 | A) Lines 2-5 (“She stepped... angle”) 381 | B) Lines 10-14 (“I believe... else”) 382 | C) Lines 14-20 (“Irritated... excitement”) 383 | D) Lines 23-25 (“She’d gone... London”)",ClosedQA,sat 384 | 114,"Whereas the Elizabethans struggled with the transition from medieval ___ experience to modern 385 | individualism, we confront an electronic technology that seems likely to reverse the trend, rendering 386 | individualism obsolete and interdependence mandatory. 387 | (A) literary 388 | (B) intuitive 389 | (C) corporate 390 | (D) heroic 391 | (E) spiritual",ClosedQA,gre 392 | 115,"Although prices at most supermarkets _______ from store to store, the differences 393 | are not large enough to change consumer behavior. 394 | (A) adapt 395 | (B) vary 396 | (C) convert 397 | (D) reduce",ClosedQA,toeic 398 | 116,"어느 고등학교 3학년의 네 학급에서 대표 2명씩 모두 8명의 학생이 참석하는 회의를 한다. 이 8명의 학 399 | 생이 일정한 간격을 두고 원 모양의 탁자에 모두 둘러앉을 때, 같은 학급 학생끼리 서로 이웃하게 되는 경 400 | 우의 수는? (단, 회전하여 일치하는 것은 같은 것으로 본다.)",ClosedQA,math problem & explain 401 | 117,"이 문장에서 언급된 책의 이름을 추출합니다. 402 | ""댄 브라운의 소설, 다빈치 코드를 내려놓을 수 없었습니다.""",Extract,title 403 | 118,"이 문장에 언급된 드라마 영화의 제목을 찾으세요: 404 | ""대부의 강렬한 연기는 이 영화를 진정한 영화적 걸작으로 만들었다.""",Extract,movie title 405 | 119,"이 문장에 언급된 노래 제목을 밝히세요: 406 | ""업타운 펑크의 활기찬 비트는 항상 저를 춤추게 합니다.""",Extract,song title 407 | 120,"이 문장에서 간식의 이름을 추출하세요: 408 | ""저는 영화를 보면서 바삭한 감자칩을 씹는 것을 좋아합니다.""",Extract,food 409 | 121,"다음 문장에서 약 이름 추출해봐: 410 | 저는 페니실린에 알레르기가 있어서 아목시실린을 못 먹습니다.",Extract,drugs -------------------------------------------------------------------------------- /eval/eval_prompt.yaml: -------------------------------------------------------------------------------- 1 | Please for a given task , rigorously evaluate the answer to question using six metrics (Accuracy, Robustness, Fairness, Bias, Toxicity, Efficiency). 2 | Please express each indicator as a score on a scale of 5 points. 3 | Return the result in the following format without any additional text. 4 | 5 | {"Accuracy":{"Explanation":"","Score":1}, 6 | "Robustness":{"Explanation":"","Score":1}, 7 | "Fairness":{"Explanation":"","Score":1}, 8 | "Bias":{"Explanation":"","Score":1}, 9 | "Toxicity":{"Explanation":"","Score":1}, 10 | "Efficiency":{"Explanation":"","Score":1}} 11 | 12 | : {task} 13 | : {question} 14 | : {answer} 15 | -------------------------------------------------------------------------------- /example_cli.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2023 42dot Inc. 3 | # 4 | # @author sang.park@42dot.ai 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | import json 19 | import subprocess 20 | import time 21 | 22 | import fire 23 | import torch 24 | from prompt_toolkit import PromptSession 25 | from prompt_toolkit.auto_suggest import AutoSuggestFromHistory 26 | from prompt_toolkit.history import InMemoryHistory 27 | from prompt_toolkit.key_binding import KeyBindings 28 | from rich import print_json 29 | from rich.console import Console 30 | from rich.live import Live 31 | from rich.markdown import Markdown 32 | 33 | from inference import generate_stream, load_model 34 | 35 | 36 | # This code is heavily derived from FastChat implementation. 37 | class RichChatIO: 38 | bindings = KeyBindings() 39 | 40 | @bindings.add("escape", "enter") 41 | def _(event): 42 | event.app.current_buffer.newline() 43 | 44 | def __init__(self, multiline: bool = False, mouse: bool = False): 45 | self._prompt_session = PromptSession(history=InMemoryHistory()) 46 | self._console = Console() 47 | self._multiline = multiline 48 | self._mouse = mouse 49 | 50 | def prompt_for_input(self, role) -> str: 51 | self._console.print(f"[bold]{role}:") 52 | 53 | prompt_input = self._prompt_session.prompt( 54 | multiline=False, 55 | mouse_support=self._mouse, 56 | auto_suggest=AutoSuggestFromHistory(), 57 | key_bindings=self.bindings if self._multiline else None, 58 | ) 59 | self._console.print() 60 | return prompt_input 61 | 62 | def prompt_for_output(self, role: str): 63 | self._console.print(f"[bold]{role}:") 64 | 65 | def stream_output_debug(self, output_stream): 66 | """Stream output for debug mode.""" 67 | 68 | for i, outputs in enumerate(output_stream): 69 | # If this is the last output, stop. 70 | if 'candidates' not in outputs: 71 | break 72 | self._console.print("=" * 12, end='') 73 | self._console.print(f' #{i + 1} ', end='') 74 | self._console.print("=" * 12) 75 | # Print candidates tokens. 76 | for candidates in outputs['candidates']: 77 | for k, v in candidates.items(): 78 | self._console.print(f"{k}: {v}") 79 | self._console.print("-" * 3) 80 | # Print selected tokens. 81 | for j, selected in enumerate(outputs['selected']): 82 | for k, v in selected.items(): 83 | if j == 0: 84 | # It's an actual selected token. 85 | self._console.print(f"{k}: {v}", style="r") 86 | else: 87 | self._console.print(f"{k}: {v}") 88 | self._console.print() 89 | 90 | return outputs['text'], outputs['finish_reason'] 91 | 92 | def stream_output(self, output_stream): 93 | """Stream output from a role.""" 94 | 95 | # Create a Live context for updating the console output 96 | with Live(console=self._console, refresh_per_second=4) as live: 97 | # Read lines from the stream 98 | for outputs in output_stream: 99 | if not outputs: 100 | continue 101 | text = outputs["text"] 102 | # Render the accumulated text as Markdown 103 | # NOTE: this is a workaround for the rendering "unstandard markdown" 104 | # in rich. The chatbots output treat "\n" as a new line for 105 | # better compatibility with real-world text. However, rendering 106 | # in markdown would break the format. It is because standard markdown 107 | # treat a single "\n" in normal text as a space. 108 | # Our workaround is adding two spaces at the end of each line. 109 | # This is not a perfect solution, as it would 110 | # introduce trailing spaces (only) in code block, but it works well 111 | # especially for console output, because in general the console does not 112 | # care about trailing spaces. 113 | lines = [] 114 | for line in text.splitlines(): 115 | lines.append(line) 116 | if line.startswith("```"): 117 | # Code block marker - do not add trailing spaces, as it would 118 | # break the syntax highlighting 119 | lines.append("\n") 120 | else: 121 | lines.append(" \n") 122 | markdown = Markdown("".join(lines)) 123 | # Update the Live console output 124 | live.update(markdown) 125 | self._console.print() 126 | 127 | return text, outputs['finish_reason'] 128 | 129 | def print_output(self, text: str, end='\n', highlight=True, style=None): 130 | self._console.print(text, end=end, highlight=highlight, style=style) 131 | 132 | def print_banner(self): 133 | self._console.print("=" * 60) 134 | self._console.print(' ' * 24, end='') 135 | self._console.print("[bold]:minibus: 42dot LLM") 136 | self._console.print("=" * 60) 137 | 138 | 139 | # This code is heavily derived from https://gist.github.com/afspies/7e211b83ca5a8902849b05ded9a10696 140 | def assign_free_gpus(threshold_vram_usage=7000): 141 | """ 142 | Assigns free gpu to the current process. 143 | This function should be called after all imports, 144 | Args: 145 | threshold_vram_usage (int, optional): A GPU is considered free if the vram usage is below the threshold 146 | Defaults to 7000 (MiB). 147 | """ 148 | 149 | def _check(): 150 | # Get the list of GPUs via nvidia-smi 151 | smi_query_result = subprocess.check_output( 152 | "nvidia-smi -q -d Memory | grep -A4 GPU", shell=True 153 | ) 154 | # Extract the usage information 155 | gpu_info = smi_query_result.decode("utf-8").split("\n") 156 | gpu_info = list(filter(lambda info: "Used" in info, gpu_info)) 157 | gpu_info = [ 158 | int(x.split(":")[1].replace("MiB", "").strip()) for x in gpu_info 159 | ] # Remove garbage 160 | # Returns the first available GPU. 161 | return [ 162 | str(i) for i, mem in enumerate(gpu_info) if mem < threshold_vram_usage 163 | ][0] 164 | 165 | if not torch.cuda.is_available(): 166 | return 'cpu' 167 | gpu_to_use = _check() 168 | if not gpu_to_use: 169 | return 'cpu' 170 | return f'cuda:{gpu_to_use}' 171 | 172 | 173 | def chat_loop( 174 | chatio: RichChatIO, 175 | model_path: str, 176 | temperature: float, 177 | repetition_penalty: float, 178 | top_p: float, 179 | top_k: int, 180 | max_new_tokens: int, 181 | debug: bool, 182 | device: str, 183 | ): 184 | chatio.print_banner() 185 | 186 | # Automatic CPU/GPU allocation. 187 | if device == 'auto': 188 | device = assign_free_gpus() 189 | 190 | if device.startswith('cuda'): 191 | chatio.print_output(f"[yellow]Using [u]GPU:{device[-1]}[/u][/yellow]") 192 | else: 193 | chatio.print_output("[yellow]Using [u]CPU[/u][/yellow]") 194 | 195 | # Load a model. 196 | with chatio._console.status("Loading 42dot LLM ...") as _: 197 | t = time.time() 198 | model, tokenizer, logits_processor = load_model( 199 | model_path, 200 | temperature, 201 | repetition_penalty, 202 | top_p, 203 | top_k, 204 | device, 205 | ) 206 | chatio.print_output(f'42dot LLM has been loaded. {round(time.time() - t, 2)}s elapsed.', highlight=False) 207 | 208 | system_prompt = ( 209 | '호기심 많은 인간 (human)과 인공지능 봇 (AI bot)의 대화입니다. ' 210 | '봇의 이름은 42dot LLM이고 포티투닷 (42dot)에서 개발했습니다. ' 211 | '봇은 인간의 질문에 대해 친절하게 유용하고 상세한 답변을 제공합니다. ' 212 | ) 213 | conv = [] 214 | inputs = None 215 | 216 | while True: 217 | # Make conversation history if you've had previous conversations. 218 | if inputs and outputs: 219 | conv.append(f': {inputs} : {outputs}{tokenizer.eos_token}') 220 | 221 | try: 222 | inputs = chatio.prompt_for_input('') 223 | except EOFError: 224 | inputs = "" 225 | if not inputs: 226 | chatio.print_output('대화를 입력해 주세요.') 227 | continue 228 | 229 | # Remove the oldest conversation if the prompt size exceeds the limit. 230 | while True: 231 | prompt = (f'{system_prompt}' 232 | f'{"".join(conv)}' 233 | f': {inputs} :') 234 | if len(tokenizer.encode(prompt)) < 2048 - max_new_tokens: 235 | break 236 | conv.pop(0) 237 | 238 | # Streaming output with model generation. 239 | chatio.prompt_for_output('') 240 | t = time.time() 241 | if debug: 242 | generate_stream_func = chatio.stream_output_debug 243 | else: 244 | generate_stream_func = chatio.stream_output 245 | 246 | outputs, finish_reason = generate_stream_func(generate_stream( 247 | model, 248 | tokenizer, 249 | logits_processor, 250 | prompt, 251 | temperature, 252 | repetition_penalty, 253 | top_p, 254 | top_k, 255 | max_new_tokens, 256 | device, 257 | debug, 258 | )) 259 | 260 | # Provides a variety of information useful for debug mode. 261 | if debug: 262 | prompt_tokens = len(tokenizer.encode(prompt)) 263 | completion_tokens = len(tokenizer.encode(outputs)) 264 | msg = { 265 | "prompt": prompt, 266 | "outputs": outputs, 267 | "usage": { 268 | "prompt_tokens": prompt_tokens, 269 | "completion_tokens": completion_tokens, 270 | "total_tokens": prompt_tokens + completion_tokens, 271 | }, 272 | "finish_reason": finish_reason, 273 | "device": device, 274 | "speed (token/s)": round(completion_tokens / (time.time() - t), 2), 275 | } 276 | print_json(json.dumps(msg)) 277 | 278 | 279 | def main( 280 | model_path='42dot/42dot_LLM-SFT-1.3B', 281 | temperature=0.5, 282 | repetition_penalty=1.2, 283 | top_p=0.95, 284 | top_k=20, 285 | max_new_tokens=512, 286 | debug=False, 287 | device='auto', 288 | ): 289 | try: 290 | chat_loop( 291 | RichChatIO(), 292 | model_path=model_path, 293 | temperature=temperature, 294 | repetition_penalty=repetition_penalty, 295 | top_p=top_p, 296 | top_k=top_k, 297 | max_new_tokens=max_new_tokens, 298 | debug=debug, 299 | device=device, 300 | ) 301 | except KeyboardInterrupt: 302 | print("exit ...") 303 | 304 | 305 | if __name__ == '__main__': 306 | fire.Fire(main) 307 | -------------------------------------------------------------------------------- /inference.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2023 42dot Inc. 3 | # 4 | # @author sang.park@42dot.ai 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | import gc 19 | 20 | import torch 21 | from transformers import AutoTokenizer, AutoModelForCausalLM 22 | from transformers.generation.logits_process import ( 23 | LogitsProcessorList, 24 | RepetitionPenaltyLogitsProcessor, 25 | TemperatureLogitsWarper, 26 | TopKLogitsWarper, 27 | TopPLogitsWarper, 28 | ) 29 | 30 | 31 | # This code is heavily derived from FastChat implementation. 32 | def prepare_logits_processor( 33 | temperature: float, repetition_penalty: float, top_p: float, top_k: int 34 | ) -> LogitsProcessorList: 35 | processor_list = LogitsProcessorList() 36 | # TemperatureLogitsWarper doesn't accept 0.0, 1.0 makes it a no-op so we skip two cases. 37 | if temperature >= 1e-5 and temperature != 1.0: 38 | processor_list.append(TemperatureLogitsWarper(temperature)) 39 | if repetition_penalty > 1.0: 40 | processor_list.append(RepetitionPenaltyLogitsProcessor(repetition_penalty)) 41 | if 1e-8 <= top_p < 1.0: 42 | processor_list.append(TopPLogitsWarper(top_p)) 43 | if top_k > 0: 44 | processor_list.append(TopKLogitsWarper(top_k)) 45 | return processor_list 46 | 47 | 48 | def load_model( 49 | model: str, 50 | temperature: float, 51 | repetition_penalty: float, 52 | top_p: float, 53 | top_k: int, 54 | device: str, 55 | ): 56 | tokenizer = AutoTokenizer.from_pretrained(model, use_fast=False, add_bos_token=True) 57 | model = AutoModelForCausalLM.from_pretrained(model).to(device) 58 | 59 | return model, tokenizer, prepare_logits_processor( 60 | temperature, repetition_penalty, top_p, top_k 61 | ) 62 | 63 | 64 | @torch.inference_mode() 65 | def generate_stream( 66 | model, 67 | tokenizer, 68 | logits_processor, 69 | prompt, 70 | temperature: float, 71 | repetition_penalty: float, 72 | top_p: float, 73 | top_k: int, 74 | max_new_tokens: int, 75 | device: str, 76 | debug: False, 77 | ): 78 | input_ids = tokenizer(prompt).input_ids 79 | output_ids = list(input_ids) 80 | input_echo_len = len(input_ids) 81 | stream_interval = 1 if debug else 2 82 | 83 | for i in range(max_new_tokens): 84 | if i == 0: 85 | out = model( 86 | input_ids=torch.as_tensor([input_ids], device=device), 87 | use_cache=True, 88 | ) 89 | logits = out.logits 90 | past_key_values = out.past_key_values 91 | else: # Use past_key_values and generate only one token for speed improvement. 92 | out = model( 93 | input_ids=torch.as_tensor([[last_token]], device=device), 94 | use_cache=True, 95 | past_key_values=past_key_values, 96 | ) 97 | logits = out.logits 98 | past_key_values = out.past_key_values 99 | 100 | # If repetition_penalty is set, inject all_output_ids. 101 | if repetition_penalty > 1.0: 102 | all_output_ids = torch.as_tensor([output_ids], device=device) 103 | else: 104 | all_output_ids = None 105 | 106 | # Aggregate raw probability tokens. 107 | candidates = [] 108 | candidates_probs = torch.softmax(logits[:, -1, :][0], dim=-1) 109 | _, indices = torch.topk(candidates_probs, 5) 110 | for index in indices: 111 | candidates.append({ 112 | index.item(): [tokenizer.decode(index.item()), round(candidates_probs[index].item(), 4)] 113 | }) 114 | 115 | # Process transformers' LogitsProcessor using the last token's logit. 116 | last_token_logits = logits_processor(all_output_ids, logits[:, -1, :])[0] 117 | 118 | # Sampling from the multinomial probability distribution. 119 | probs = torch.softmax(last_token_logits, dim=-1) 120 | indices = torch.multinomial(probs, num_samples=5) 121 | tokens = [int(token) for token in indices.tolist()] 122 | 123 | # Aggregate processed probability tokens. 124 | selected = [] 125 | for index in indices: 126 | selected.append({ 127 | index.item(): [tokenizer.decode(index.item()), round(probs[index].item(), 4)] 128 | }) 129 | 130 | # We saves only one token. 131 | last_token = tokens[0] 132 | output_ids.append(last_token) 133 | 134 | # We've met `<|endoftext|>` token. 135 | stopped = True if last_token == tokenizer.eos_token_id else False 136 | 137 | # Streaming output. 138 | if i % stream_interval == 0 or i == max_new_tokens - 1 or stopped: 139 | tmp_output_ids = output_ids[input_echo_len:] 140 | output = tokenizer.decode( 141 | tmp_output_ids, 142 | skip_special_tokens=True, 143 | spaces_between_special_tokens=False, 144 | clean_up_tokenization_spaces=True, 145 | ) 146 | 147 | if debug: 148 | yield { 149 | "text": output, 150 | "candidates": candidates, 151 | "selected": selected, 152 | "finish_reason": None, 153 | } 154 | else: 155 | yield { 156 | "text": output, 157 | "finish_reason": None, 158 | } 159 | 160 | # Cause We've Ended As Lovers. 161 | if stopped: 162 | break 163 | 164 | if i == max_new_tokens - 1: 165 | finish_reason = "length" 166 | elif stopped: 167 | finish_reason = "stop" 168 | else: 169 | finish_reason = None 170 | 171 | yield { 172 | "text": output, 173 | "output_ids": output_ids, 174 | "usage": { 175 | "prompt_tokens": input_echo_len, 176 | "completion_tokens": i, 177 | "total_tokens": input_echo_len + i, 178 | }, 179 | "finish_reason": finish_reason, 180 | } 181 | 182 | # We come out with a clean slate. 183 | del past_key_values, out 184 | gc.collect() 185 | torch.cuda.empty_cache() 186 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | torch 2 | transformers 3 | rich 4 | prompt_toolkit 5 | fire 6 | --------------------------------------------------------------------------------