Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,116 @@
|
|
| 1 |
---
|
| 2 |
base_model: MLP-KTLim/llama-3-Korean-Bllossom-8B
|
| 3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
##
|
| 13 |
|
| 14 |
-
###
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
|
|
|
|
|
|
| 18 |
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
### Model Sources [optional]
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 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 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
|
| 171 |
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
**BibTeX:**
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
| 192 |
|
| 193 |
## Model Card Authors [optional]
|
|
|
|
| 194 |
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
| 200 |
### Framework versions
|
| 201 |
-
|
| 202 |
- PEFT 0.11.0
|
|
|
|
| 1 |
---
|
| 2 |
base_model: MLP-KTLim/llama-3-Korean-Bllossom-8B
|
| 3 |
library_name: peft
|
| 4 |
+
license: llama3
|
| 5 |
+
datasets:
|
| 6 |
+
- iknow-lab/ko-genstruct-v1
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# Ko-genstruct v0.1
|
| 10 |
|
| 11 |
+
Ko-genstruct는 주어진 문서로부터 instruction tuning에 필요한 instruction을 생성해내는 모델입니다. 시험문제와 글쓰기 문제 두가지 유형의 지시문을 생성해낼 수 있습니다.
|
| 12 |
+
이 모델은 [Ada-instruct](https://arxiv.org/abs/2310.04484)와 [Genstruct](https://huggingface.co/NousResearch/Genstruct-7B)로부터 영감을 받았습니다.
|
| 13 |
|
| 14 |
+
다음과 같은 용도로 활용할 수 있습니다.
|
| 15 |
+
- 검색 모델을 학습하기 위해 주어진 텍스트로부터 질문을 생성하기
|
| 16 |
+
- Instruction Tuning 학습 데이터를 생성하기 위해 Ko-genstruct로 instruction을 생성 후, 다른 LLM을 이용하여 답변 생성
|
| 17 |
|
| 18 |
+
## Details
|
| 19 |
+
- **Developed by:** [iKnow-Lab](https://github.com/iKnowLab-Projects/ko-genstruct)
|
| 20 |
+
- **License:** [llama3]
|
| 21 |
+
- **Lora-tuned from model:** [MLP-KTLim/llama-3-Korean-Bllossom-8B](https://huggingface.co/MLP-KTLim/llama-3-Korean-Bllossom-8B)
|
| 22 |
|
| 23 |
+
## 사용방법
|
| 24 |
|
| 25 |
+
### 질문 생성
|
| 26 |
+
아래 예제를 활용하여, 주어진 문서로부터 지시문을 생성할 수 있습니다. 시험문제와 글쓰기 문제 두가지 프롬프트 유형이 존재합니다.
|
| 27 |
|
| 28 |
+
```python
|
| 29 |
+
import transformers
|
| 30 |
+
import peft
|
| 31 |
|
| 32 |
+
model_id = "MLP-KTLim/llama-3-Korean-Bllossom-8B"
|
| 33 |
+
peft_model_id = "iknow-lab/ko-genstruct-v0.1"
|
| 34 |
|
| 35 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
|
| 36 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype="auto").eval()
|
| 37 |
|
| 38 |
+
model.load_adapter(peft_model_id, revision="epoch-1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
|
|
|
| 40 |
|
| 41 |
+
title = ""
|
| 42 |
+
text = ""
|
| 43 |
|
| 44 |
+
PROMPT_QA = """당신은 시험문제 출제위원입니다. 다음 자료에 기반하여 전문가 수준의 시험문제를 출제할 것입니다. 자료를 바탕으로 지시사항에 맞는 결과물을 json 형식으로 반환해주세요.
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
1. 생성한 문제는 실생활에서 사용하는 질문의 말투를 사용해야 합니다(~무엇인가요? ~작성해주세요. ~ 어떻게 해야하죠?)
|
| 47 |
+
2. 먼저 고등학교 수준의 문제를 생성하고, 이를 전문가 수준으로 고난이도 문제로 향상해주세요. 각 문제는 반드시 제시된 자료를 바탕으로 만들어져야 합니다. 연관성이 적더라도, 창의적인 아이디어로 해당 자료를 활용하세요.
|
| 48 |
+
3. 문제에는 답안 작성에 필요한 내용을 주어진 자료에서 추출해서 함께 제공해야합니다.
|
| 49 |
+
4. 출제할 문제의 과목 후보는 다음과 같습니다: 글쓰기, 한국어, 영어, 수학, 사회과학, 과학, 역사 문화예술, 법, 도덕, 정치, 종교, 외국어, 경제, 경영, 의료, 공학, 인문학 등 - 후보에 없어도, 적절한 과목을 자유롭게 말할 수 있다.
|
| 50 |
|
| 51 |
+
# 제목: {title}
|
| 52 |
+
# 자료:
|
| 53 |
+
{text}"""
|
| 54 |
|
| 55 |
+
PROMPT_WRITING = """당신은 글쓰기 시험문제 출제위원입니다. 다음 자료에 기반하여 전문가 수준의 시험문제를 출제할 것입니다. 자료를 바탕으로 지시사항에 맞는 결과물을 json 형식으로 반환해주세요.
|
| 56 |
|
| 57 |
+
1. 생성한 문제는 실생활에서 사용하는 질문의 말투를 사용해야 합니다(~무엇인가요? ~작성해주세요. ~ 어떻게 해야하죠?)
|
| 58 |
+
2. 먼저 고등학교 수준의 문제를 생성하고, 이를 전문가 수준으로 고난이도 문제로 향상해주세요. 각 문제는 반드시 제시된 자료를 바탕으로 만들어져야 합니다. 연관성이 적더라도, 창의적인 아이디어로 해당 자료를 활용하세요.
|
| 59 |
+
3. 문제에는 글쓰기 작성에 필요한 내용을 주어진 자료에서 추출해서 함께 제공해야합니다.
|
| 60 |
+
4. 출제할 문제의 주제 후보는 다음과 같습니다. 이 중에서 적절한 주제를 3가지 선택하세요: 이력서, 노래가사, 시 혹은 소설, 에세이, 극본, 시나리오, 여행일기, 여행계획서, 요리레시피, 해설, 자기���개서, 편지, 이메일, 리뷰 및 평가, 소셜 미디어 포스트, 일기, 청원서, 항의서, 쇼핑 리스트, 메모, 연구 논문 및 계획서, 비즈니스 보고서 및 게획서, 기술 문서, 발표자료, 계약서 혹은 법률 문서, 편집 및 출판 문서, 광고 카피라이트, 웹 콘텐츠, 뉴스레터, 연설문, 자기계발서, 분석보고서, 기획안, 제안서
|
| 61 |
|
| 62 |
+
# 제목: {title}
|
| 63 |
+
# 자료:
|
| 64 |
+
{text}"""
|
| 65 |
|
| 66 |
+
def generate_question(title, text, is_writing: bool = False):
|
| 67 |
+
prompt=PROMPT_WRITING if is_writing else PROMPT_QA
|
| 68 |
+
prompt = prompt.format(title=title, text=text)
|
| 69 |
+
|
| 70 |
+
prompt = [{"content": prompt, "role": "user"}]
|
| 71 |
+
inputs = tokenizer.apply_chat_template(prompt, return_tensors="pt", add_generation_prompt=True, tokenize=False)
|
| 72 |
+
inputs = inputs.strip() + "\n\n```json\n{\n \"topic\":"
|
| 73 |
+
inputs = tokenizer.encode(inputs, add_special_tokens=False, return_tensors="pt").to(model.device)
|
| 74 |
+
outputs = model.generate(input_ids=inputs, max_new_tokens=256, do_sample=True, early_stopping=True, eos_token_id=128009, temperature=1.0)
|
| 75 |
|
| 76 |
+
question = tokenizer.decode(outputs[0, inputs.shape[1]:], skip_special_tokens=False)
|
| 77 |
|
| 78 |
+
return question
|
| 79 |
|
| 80 |
+
print("Question generation test")
|
| 81 |
+
for _ in range(5):
|
| 82 |
+
question = generate_question(title, text)
|
| 83 |
+
print(question)
|
| 84 |
|
| 85 |
+
print("Writing generation test")
|
| 86 |
+
for _ in range(5):
|
| 87 |
+
question = generate_question(title, text, True)
|
| 88 |
+
print(question)
|
| 89 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
## Citation [optional]
|
|
|
|
|
|
|
|
|
|
| 92 |
**BibTeX:**
|
| 93 |
|
| 94 |
+
```
|
| 95 |
+
@misc{cui2023adainstructadaptinginstructiongenerators,
|
| 96 |
+
title={Ada-Instruct: Adapting Instruction Generators for Complex Reasoning},
|
| 97 |
+
author={Wanyun Cui and Qianle Wang},
|
| 98 |
+
year={2023},
|
| 99 |
+
eprint={2310.04484},
|
| 100 |
+
archivePrefix={arXiv},
|
| 101 |
+
primaryClass={cs.CL},
|
| 102 |
+
url={https://arxiv.org/abs/2310.04484},
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
@misc{Genstruct,
|
| 106 |
+
url={[https://https://huggingface.co/NousResearch/Genstruct-7B](https://huggingface.co/NousResearch/https://huggingface.co/NousResearch/Genstruct-7B)},
|
| 107 |
+
title={Genstruct},
|
| 108 |
+
author={"euclaise"}
|
| 109 |
+
}
|
| 110 |
+
```
|
| 111 |
|
| 112 |
## Model Card Authors [optional]
|
| 113 |
+
- 김희규 ([email protected])
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
### Framework versions
|
|
|
|
| 116 |
- PEFT 0.11.0
|