Код: Выделить всё
python --version
Python 3.12.4
Код: Выделить всё
python -m pip install langchain langchain-huggingface langchain-community faiss-gpu-cu12[fix_cuda]
Код: Выделить всё
from langchain_community.vectorstores import FAISS
from langchain_huggingface import HuggingFaceEmbeddings
from sentence_transformers import SentenceTransformer
docs = [ 'sefsl;fk lskdf;lk s', 'ewrl kwelklekfl ls ;' ]
embedder = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
f = FAISS.from_texts(docs, embedding=embedder)
embeddings = embedder.encode(docs)
Код: Выделить всё
Traceback (most recent call last):
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/langchain_community/vectorstores/faiss.py", line 55, in dependable_faiss_import
import faiss
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/faiss/__init__.py", line 16, in
from .loader import *
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/faiss/loader.py", line 111, in
from .swigfaiss import *
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/faiss/swigfaiss.py", line 10, in
from . import _swigfaiss
ImportError: /home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/faiss/_swigfaiss.cpython-312-x86_64-linux-gnu.so: ELF load command address/offset not properly aligned
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jupyterlab_user/erwan/RAG/minimal-faiss-expl2.py", line 9, in
f = FAISS.from_texts(docs, embedding=embedder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/langchain_community/vectorstores/faiss.py", line 1042, in from_texts
return cls.__from(
^^^^^^^^^^^
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/langchain_community/vectorstores/faiss.py", line 994, in __from
faiss = dependable_faiss_import()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jupyterlab_user/erwan/RAG/.venv/lib/python3.12/site-packages/langchain_community/vectorstores/faiss.py", line 57, in dependable_faiss_import
raise ImportError(
ImportError: Could not import faiss python package. Please install it with `pip install faiss-gpu` (for CUDA supported GPU) or `pip install faiss-cpu` (depending on Python version).
На данный момент я ограничен использованием faiss-cpu, поэтому любые предложения приветствуются!
Подробнее здесь: https://stackoverflow.com/questions/790 ... stallation