-
Notifications
You must be signed in to change notification settings - Fork 282
[N-3] 08-EMBEDDING / 06-LlamaCppEmbeddings #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[N-3] 08-EMBEDDING / 06-LlamaCppEmbeddings #65
Conversation
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
하단의 Reference 목차를 상단의 Overview 에 병합 Embedding model 를 https://huggingface.co/CompendiumLabs/bge-large-en-v1.5-gguf/tree/main 로 변경 예제 수정 Q: What is LangChain? A: LangChain 관련된 답변 추가 Embedding 사용시 List[] 로 오류 수정
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최근 commit 에 수정사항 안내 드렸습니다.
<@785393896073986059> 님 안녕하세요!
Peer Review 완료하여
ac8f6d6
commit 에 반영해 두었습니다.
우선, 제가 임의 수정하여 반영했기 때문에 용담님께서 한 번 검토해 주시면 좋을 것 같아요.
참고로, embedding 모델에 llama 3.1 사용하는 예제가 들어가 있는 것을 embedding 전용 모델인
https://huggingface.co/CompendiumLabs/bge-large-en-v1.5-gguf/tree/main
로 변경해 두었습니다.
llama3.1 모델과 같이 llm 기반 모델이 embedding 모델로 활용 가능하나, 일반적으로 성능이 엄청 별로라고 하더라고요. 실제 embedding model bge-large 모델은 300 mb 의 소형 모델이지만 퍼포먼스를 훨씬 더 좋은 것 같습니다.
이와 관련된 글은 reddit 에서도 언급된 바가 있어 같이 공유 드립니다.
따라서, embedding 모델 변경에 따른 text 수정, reference 수정 등등을 반영해 두었습니다.
검토해 보시고, 수정사항 있으시면 재 commit 해주시면 되겠습니다^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Review]
- Review OS(Windows/Mac/Linux): Windows
- Template Rule 가이드를 준수 하였는가(YES/NO): YES
- Table of Contents 의 링크가 원활하게 동작하는지 확인하였는가?(YES/NO): YES
- 이미지가 포함되어 있다면, 이미지의 파일명이 가이드를 준수하였는가?(YES/NO): YES
- import 구문이 예전 legacy 방식이 아닌 최신 버전을 따르는가?(YES/NO): YES
- 모든 코드가 동작에 오류 없이 동작하는가? (만약, warning 발생시 코멘트에 적어주세요): No
- 기타 의견:
기존 코드를 보면 docs
임베딩 시 docs가 리스트로 묶여서 들어가서 유사도 기반 검색 시 기존 Docs의 내용 중 0
index의 text에 대한 결과 하나만 나오게 됩니다. docs
의 전체가 embedding 되어서 index로 선택할 수 있어야 합니다.
기존 코드의 embed_documents
메서드는 embed_query
메서드를 리스트 안에 있는 text의 개수 만큼 동작하여 리스트로 만들어야 합니다.
그러기 위해서는 embed_documents
내부에 텍스트 별로 embedding 할 때 text
가 들어가는게 아닌 List[str]
형태인 [text]
가 들어가야 합니다.
이부분 제외하고는 @teddylee777 님이 추가해주신 내용 포함 Window 및 코랩에서 이상 없습니다!
Suggested change
부분 수정해주세요!
@teddylee777 @pupba 두 분이 제안주신 내용 모두 확인했습니다! 그래서 우선 bge-large-en 모델을 사용하는 정상 작동하는 코드로 최종 commit하고 추후에 해당 이슈가 어떤 문제가 있는지 체크해서 업데이트해두겠습니다. 아마 tutorial을 보는 유저들이 llama-3.1을 사용하려고 할 것 같아서요! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! @dancing-with-coffee 님! 그런데 @teddylee777 님 review dismissed 하셔서 다시 요청드려야 할 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생 많으셨습니다!
지금 LlamaCppEmbeddings 코드를 실행하면 2가지 이슈가 있습니다.
하나는 코드 자체가 실행이 안되는 이슈가 있고, 해당 이슈는 아래 이슈를 체크해서 해결하였습니다.
가까운 미래에 해당 issue가 공식적으로 resolve되고 나면 tutorial update가 필요할 수 있습니다.
두번째는 현재 llamacpp에서 호환이 되는 여러 모델들을 가져와서 테스트를 해봤을 떄, 모든 임베딩 벡터가 같은 값이 나옵니다. 이게 Apple Silcon(테스트한 환경은 M2 Ultra) 문제인지 확인이 필요합니다.
테스트해봤던 모델은 다음 3가지 입니다.
사실상 fp32 full weight까지 테스트를 해봤기 때문에, 모델 자체는 문제가 아니고 hardware dependency이거나, Llama-cpp-python 라이브러리 문제일 수 있습니다.