Views
No views yet
| 문제 유형 | 설명 |
|---|---|
| 제목 추론 | 지문의 가장 적절한 제목을 찾는 문제 |
| 주제 추론 | 지문의 핵심 주제를 파악하는 문제 |
| 내용 불일치 | 지문 내용과 일치하지 않는 선택지를 찾는 문제 |
| 빈칸 추론 | 문맥상 빈칸에 들어갈 적절한 표현을 찾는 문제 |
| 어법 오류 | 문법적으로 잘못된 부분을 찾는 문제 |
pip install transformers peft torch1from peft import AutoPeftModelForCausalLM
2from transformers import AutoTokenizer
3import torch
4
5# 모델 로드
6model = AutoPeftModelForCausalLM.from_pretrained(
7 "huggingface-KREW/Qwen3-8B-Korean-Highschool-English-Exam",
8 device_map="auto",
9 torch_dtype=torch.bfloat16
10)
11tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B")
12
13# 영어 지문 예시
14passage = """
15If the brain has already stored someone's face and name, why do we still end up
16remembering one and not the other? This is because the brain has a two-tier memory
17system at work when it comes to retrieving memories, giving rise to a common yet
18infuriating sensation: recognising someone but not being able to remember how or why,
19or what their name is.
20"""
21
22# 문제 생성 함수
23def generate_question(passage, question_type):
24 messages = [
25 {
26 "role": "user",
27 "content": f"다음 영어 지문을 {question_type} 문제로 만들어주세요.\n\n지문:\n{passage}\n\n"
28 }
29 ]
30
31 prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
32 inputs = tokenizer(prompt, return_tensors="pt")
33 outputs = model.generate(
34 inputs["input_ids"].to("cuda"),
35 max_new_tokens=1024,
36 temperature=0.7,
37 do_sample=True
38 )
39
40 return tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
41
42# 제목 추론 문제 생성
43result = generate_question(passage, "제목 추론")
44print(result)1# 모든 문제 유형에 대해 문제 생성
2question_types = ["제목 추론", "주제 추론", "내용 불일치", "빈칸 추론", "어법 오류", "요지 추론"]
3
4for q_type in question_types:
5 print(f"\n{'='*50}")
6 print(f"{q_type} 문제")
7 print('='*50)
8 result = generate_question(passage, q_type)
9 print(result)1{
2 "passage": "The Great Fire of London occurred in September 1666...",
3 "passage_length": 320,
4 "questions": [
5 {
6 "year": 2024,
7 "type": "main_idea",
8 "grade_level": "HighSchool 2nd Grade",
9 "difficulty": "easy",
10 "question": "What is the main idea of the passage?",
11 "options": [
12 "London has always been...",
13 "The Great Fire caused...",
14 "St. Paul's Cathedral was...",
15 "Wooden buildings were..."
16 ],
17 "answer": "The Great Fire caused....",
18 "cognitive_skill": "comprehension"
19 }
20 ]
21}1{
2 "instruction": "Generate a multiple-choice question for grade: HighSchool 2nd Grade, level: Medium, question type: Main Idea.",
3 "input": "Passage: 'The Great Fire of London occurred in September 1666...",
4 "output": "Question: 'What is the main idea of the passage?'\nA) The Great Fire ...\nB) The fire started ...\nC) The fire spread ...\nD) The Great Fire of London had ...\nAnswer: C"
5}📊 성능 지표는 현재 평가 진행 중입니다
1passage = "Climate change is one of the most pressing issues..."
2question = generate_question(passage, "제목 추론")다음 글의 제목으로 가장 적절한 것은?
① The History of Climate Research
② Climate Change: An Urgent Global Challenge
③ Weather Patterns Around the World
④ Scientific Methods in Environmental Studies
⑤ The Future of Renewable Energy
정답: ②question = generate_question(passage, "빈칸 추론")다음 글의 빈 칸에 들어갈 말로 가장 적절한 것은?
Climate change is _________________ that requires immediate action.
① a minor environmental concern
② an inevitable natural process
③ one of humanity's greatest challenges
④ primarily an economic issue
⑤ a problem for future generations
정답: ③1@misc{qwen3-korean-english-exam,
2 title={Qwen3-8B-Korean-Highschool-English-Exam},
3 author={Hugging Face KREW},
4 year={2024},
5 publisher={suil0109},
6 url={https://huggingface.co/huggingface-KREW/Qwen3-8B-Korean-Highschool-English-Exam}
7}