Embedding document fails if tokens length > n_ctx
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- ai, backend-api-design, machine-learning
Hướng nghiên cứu
Lỗi xảy ra trong llama_cpp/llama.py, cụ thể là trong phương thức eval ở dòng 549. Hãy bắt đầu bằng cách kiểm tra phương thức create_embedding (dòng 869) và phương thức embed (dòng 905) để hiểu cách xử lý token. Bản sửa lỗi có thể sẽ bao gồm việc thêm một bước kiểm tra độ dài token so với n_ctx trước khi gọi eval, đồng thời phát sinh một lỗi hoặc cảnh báo rõ ràng. Hãy tìm các mẫu xác thực hiện có trong codebase và kiểm thử với một tài liệu dài để tái hiện sự cố.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [X ] I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- [ X] I carefully followed the README.md.
- [ X] I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- [ X] I reviewed the Discussions, and have a new bug or useful enhancement to share.
Expected Behavior
Embedding a document, if embedding document tokens are > to n_ctx , it should warn or exit()
Current Behavior
it fails with error
File "/home/mac/chatest/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 113, in embed_documents
embeddings = [self.client.embed(text) for text in texts]
File "/home/mac/chatest/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 113, in
embeddings = [self.client.embed(text) for text in texts]
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 905, in embed
return list(map(float, self.create_embedding(input)["data"][0]["embedding"]))
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 869, in create_embedding
self.eval(tokens)
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 549, in eval
self.input_ids[self.n_tokens : self.n_tokens + n_tokens] = batch
ValueError: could not broadcast input array from shape (8,) into shape (0,)
Environment and Context
Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
document = open("DOC/mybigdocument.txt,"r")
text = document.read()
embeddings = LlamaCppEmbeddings(model_path=model_path,verbose=False)
embeddings.embed_documents([text])
Failure Logs
Pl File "/home/mac/chatest/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 113, in embed_documents
embeddings = [self.client.embed(text) for text in texts]
File "/home/mac/chatest/lib/python3.10/site-packages/langchain/embeddings/llamacpp.py", line 113, in
embeddings = [self.client.embed(text) for text in texts]
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 905, in embed
return list(map(float, self.create_embedding(input)["data"][0]["embedding"]))
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 869, in create_embedding
self.eval(tokens)
File "/home/mac/chatest/lib/python3.10/site-packages/llama_cpp/llama.py", line 549, in eval
self.input_ids[self.n_tokens : self.n_tokens + n_tokens] = batch
ValueError: could not broadcast input array from shape (8,) into shape (0,)
- Ngôn ngữ chính
- Python
- Star
- 10.6k
- Fork
- 1.5k
- Merge trung bình
- 6 giờ 43 phút
- Pull request đã merge (30 ngày)
- 2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của abetlen/llama-cpp-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
abetlen/llama-cpp-python#2371 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
abetlen/llama-cpp-python#2352 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
abetlen/llama-cpp-python#2211 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
abetlen/llama-cpp-python#2210 ·
-
Improve error messages Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
abetlen/llama-cpp-python#2145 ·
Tất cả issue của abetlen/llama-cpp-python
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·