Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dancing-with-coffee
Copy link
Contributor

지금 LlamaCppEmbeddings 코드를 실행하면 2가지 이슈가 있습니다.

하나는 코드 자체가 실행이 안되는 이슈가 있고, 해당 이슈는 아래 이슈를 체크해서 해결하였습니다.
가까운 미래에 해당 issue가 공식적으로 resolve되고 나면 tutorial update가 필요할 수 있습니다.

두번째는 현재 llamacpp에서 호환이 되는 여러 모델들을 가져와서 테스트를 해봤을 떄, 모든 임베딩 벡터가 같은 값이 나옵니다. 이게 Apple Silcon(테스트한 환경은 M2 Ultra) 문제인지 확인이 필요합니다.
테스트해봤던 모델은 다음 3가지 입니다.

  1. https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/blob/main/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf
  2. https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/blob/main/Meta-Llama-3.1-8B-Instruct-Q6_K.gguf
  3. https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/blob/main/Meta-Llama-3.1-8B-Instruct-f32.gguf

사실상 fp32 full weight까지 테스트를 해봤기 때문에, 모델 자체는 문제가 아니고 hardware dependency이거나, Llama-cpp-python 라이브러리 문제일 수 있습니다.

EmphiServer added 3 commits January 1, 2025 23:46
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
… inference하는데 에러는 없지만 성능이 너무 낮아서, Apple Silcon 문제인지 확인 필요.
@dancing-with-coffee dancing-with-coffee added docs tutorial proofreading 번역/검수팀 제안사항 반영 labels Jan 1, 2025
@dancing-with-coffee dancing-with-coffee self-assigned this Jan 1, 2025
하단의 Reference 목차를 상단의 Overview 에 병합
Embedding model 를 https://huggingface.co/CompendiumLabs/bge-large-en-v1.5-gguf/tree/main

로 변경

예제 수정
Q: What is LangChain?
A: LangChain 관련된 답변 추가

Embedding 사용시 List[] 로 오류 수정
teddylee777
teddylee777 previously approved these changes Jan 1, 2025
Copy link
Contributor

@teddylee777 teddylee777 left a 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 에서도 언급된 바가 있어 같이 공유 드립니다.

https://www.reddit.com/r/LocalLLaMA/comments/1goyyij/how_good_is_llama_or_qwen_as_an_embedding_model/


따라서, embedding 모델 변경에 따른 text 수정, reference 수정 등등을 반영해 두었습니다.

검토해 보시고, 수정사항 있으시면 재 commit 해주시면 되겠습니다^^

Copy link
Contributor

@pupba pupba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Review]

  1. Review OS(Windows/Mac/Linux): Windows
  2. Template Rule 가이드를 준수 하였는가(YES/NO): YES
  3. Table of Contents 의 링크가 원활하게 동작하는지 확인하였는가?(YES/NO): YES
  4. 이미지가 포함되어 있다면, 이미지의 파일명이 가이드를 준수하였는가?(YES/NO): YES
  5. import 구문이 예전 legacy 방식이 아닌 최신 버전을 따르는가?(YES/NO): YES
  6. 모든 코드가 동작에 오류 없이 동작하는가? (만약, warning 발생시 코멘트에 적어주세요): No
  7. 기타 의견:

기존 코드를 보면 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 부분 수정해주세요!

@dancing-with-coffee
Copy link
Contributor Author

@teddylee777 @pupba 두 분이 제안주신 내용 모두 확인했습니다!
teddy님이 제안주신 모델에다가 광원님이 제안주신 코드로 돌리니 정상적으로 동작합니다. 근데 llama-3.1 계열 모델들로 진행을 하니 모두 이전과 같은 에러로 실행이 되지 않네요.. 원래대로 돌리면 모두 같은 벡터가 나오는 방식이 도돌이표됩니다.

그래서 우선 bge-large-en 모델을 사용하는 정상 작동하는 코드로 최종 commit하고 추후에 해당 이슈가 어떤 문제가 있는지 체크해서 업데이트해두겠습니다. 아마 tutorial을 보는 유저들이 llama-3.1을 사용하려고 할 것 같아서요!

Copy link
Contributor

@pupba pupba left a 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 하셔서 다시 요청드려야 할 것 같아요!

Copy link
Contributor

@teddylee777 teddylee777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니다!

@teddylee777 teddylee777 merged commit a1bd019 into LangChain-OpenTutorial:main Jan 2, 2025
1 check failed
@chaeyoonyunakim chaeyoonyunakim removed the proofreading 번역/검수팀 제안사항 반영 label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs tutorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants