Coder Social home page Coder Social logo

ko_alpaca_data 관련 문의 about koalpaca HOT 6 CLOSED

beomi avatar beomi commented on July 16, 2024
ko_alpaca_data 관련 문의

from koalpaca.

Comments (6)

Beomi avatar Beomi commented on July 16, 2024

아주 간단한 이유입니다 :)
질문의 종류가 다르기 때문인데요.

예를들어 "한국의 국가 전화번호가 어떻게 돼?"라는 질문은 추가적인 맥락 전달 없이도 "+82"라는 답변을 뱉을 수 있어서,
Instruct와 Output만 있으면 됩니다.

하지만 기사요약과 같은 종류라면, "아래 기사를 요약해줘."라는 Instruct와, 해당 기사 내용인 Input을 넣어주어야 제대로 된 Output을 생성하는 것이 가능하기 때문에, 데이터셋에서 input이 있는 것과 없는 종류의 Task가 나뉘고, 이에 따라 Prompt 종류 역시 달라지게 됩니다.

from koalpaca.

daje0601 avatar daje0601 commented on July 16, 2024

먼저, 친절한 답변 너무 감사드립니다.

제가 이러한 질문을 드리게 된 계기는 alpaca를 reproduction하는 중에 regen.jsonl 까지는 따라왔는데 이를 활용하여 어떻게 alpaca_data.json이 되었는지 이유를 찾지 못하였습니다.

[
    {
        "instruction": "Retrieve the biggest peak in the world.",
        "input": "",
        "output": "The highest peak in the world is Mount Everest, which has a summit elevation of 8,848 meters (29,032 feet).",
        "most_similar_instructions": {
            "find the toxic word or phrase in the sentence.": 0.375,
            "Identify the bias or stereotype in the given prompt.": 0.375,
            "Replace all the human names in the paragraph with <anonymized>.": 0.3529411764705882,
            "Replace the placeholders in the given text with appropriate named entities.": 0.33333333333333326,
            "Identify the pos tag of the word in the given sentence.": 0.33333333333333326,
            "Find the misspelling in the sentence, and give me the correct spelling.": 0.3157894736842105,
            "Return the SSN number for the person.": 0.2857142857142857,
            "Select the oldest person from the list.": 0.2857142857142857,
            "Give me the definition of the word.": 0.2857142857142857,
            "Extract all the country names in the paragraph, and list them separated by commas.": 0.2857142857142857
        },
        "avg_similarity_score": 0.12068036281982937
    },

번외의 질문인줄 알지만, 혹시 alpaca의 regen.jsonl이 어떻게 alpaca_data.json으로 만드는지 원리를 아신다면 간략하게만 설명 가능하실까요?ㅠ 아니면 제가 참고해볼만한 링크 알려주시면 읽고 공부해보겠습니다.

from koalpaca.

Beomi avatar Beomi commented on July 16, 2024

regen.json 파일은 generate_instruction_following_data 하는 부분에서 생성되는 부분이죠 :)

사람이 직접 만든 SEED Instruct 데이터셋에서 해당 과정을 거치면 GPT가 새로운 instruct들을 생성합니다. (이때 Input도 같이 생성하죠! 만약 input이 없다면 <noinput>을 생성하도록 하고, 프로그래밍적 방식으로 제거해줍니다.)

위 결과물에서 similarity score가 0.7 이상인 instruct를 생성했다면 해당 Instruct는 제거합니다.

이후에 instruct, input을 갖고 다시 GPT3에 넣어 alpaca_data.json파일로 만든 것으로 보면 될 것 같습니다! :D

from koalpaca.

daje0601 avatar daje0601 commented on July 16, 2024

regen.json 파일은 generate_instruction_following_data 하는 부분에서 생성되는 부분이죠 :)

사람이 직접 만든 SEED Instruct 데이터셋에서 해당 과정을 거치면 GPT가 새로운 instruct들을 생성합니다. (이때 Input도 같이 생성하죠! 만약 input이 없다면 <noinput>을 생성하도록 하고, 프로그래밍적 방식으로 제거해줍니다.)

위 결과물에서 similarity score가 0.7 이상인 instruct를 생성했다면 해당 Instruct는 제거합니다.

이후에 instruct, input을 갖고 다시 GPT3에 넣어 alpaca_data.json파일로 만든 것으로 보면 될 것 같습니다! :D

막! 깨달아서 글을 쓰고 있었는데 답을 주셨네요! 제가 이해한 게 맞다는걸 확인해주셔서 너무 감사드립니다.
이 원리를 이용하여 한국어 데이터셋을 만들어 보았는데.. 생각보다 품질이 좋지 않네요..

{
    'instruction': '0에서 10 사이의 숫자를 오름차순으로 정렬하세요.', 
    'input': '3, 5, 7, 8, 2, 1, 0, 10',
    'output': '0, 1, 2, 3, 5, 7, 8, 10', 
    'most_similar_instructions': {
        '다음 인스턴스가 속삭이는 공격인지 아닌지 확인하세요. 속삭이는 공격에 대해 1을 출력하고, 그렇지 않으면 0을 출력하세요.': 0.5, 
        '능추론이 논리적으로 타당한지 판단하세요.': 0, 
        '문장의 감정을 긍정적, 부정적 또는 중간으로 분류하세요.': 0, 
        '목록에서 가장 나이가 많은 사람을 선택하세요.': 0, 
        '다음 객관식 질문에 답하세요. 최종 답변으로 A, B, C 또는 D를 선택하세요.': 0.0}, 
    'avg_similarity_score': 0.1
},
{
'instruction': '4인스턴스를 나열하여 다음 목록을 작성하세요.', 
'input': '치킨, 피자, 샌드위치, 닭갈비',
'output': '치킨, 피자, 샌드위치, 닭갈비', 
'most_similar_instructions': {
    '능추론이 논리적으로 타당한지 판단하세요.': 0, 
    '다음 인스턴스가 속삭이는 공격인지 아닌지 확인하세요. 속삭이는 공격에 대해 1을 출력하고, 그렇지 않으면 0을 출력하세요.': 0.0, 
    '문장의 감정을 긍정적, 부정적 또는 중간으로 분류하세요.': 0, 
    '목록에서 가장 나이가 많은 사람을 선택하세요.': 0, 
    '다음 객관식 질문에 답하세요. 최종 답변으로 A, B, C 또는 D를 선택하세요.': 0.0
    },
'avg_similarity_score': 0.0
}

다시 한번 감사드립니다. :D

from koalpaca.

Beomi avatar Beomi commented on July 16, 2024

위 같은 케이스에서는... 지금 보시면 similarity 계산이 되지 않고 있어요.

현재 코드에서는 영문으로 지어진 inst를 비교하기 위해서 ROUGE Score(

from rouge_score import rouge_scorer
)를 사용하고 있어요.

그런데 한국어의 경우 ROUGE score를 곧바로 사용하시면 유사도 비교가 제대로 측정되지 않아요.

해당 스코어는 한글한글은 이란 두 단어를 다른 단어로 봐서 유사도를 0으로 보기 때문에, 뭔가 Semantic한 부분을 가져가고 싶으시다면 KR-SBERT등을 사용해 유사도 비교를 해서 Score를 뽑는 것이 좋을 것 같습니다.

+그리고 데이터셋 생성시에는 GPT Turbo(ChatGPT)를 쓰시는게 API 가성비가 월등히 좋습니다.

from koalpaca.

daje0601 avatar daje0601 commented on July 16, 2024

제가 잘못 이해한 부분이 없는지 다시 한번 디버깅 하느라 답글이 늦었습니다.
말씀해주신 유사도 검사는 sentenceBERT 등을 활용하여 score를 구해보겠습니다.

꿀팁까지 너무 감사드립니다!!

from koalpaca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.