gpt4all

3.1k 词

gpt4all

pip install gpt4all

Embeddings

翻译成中文为“嵌入”,是指将一个数据集或模型的特征值映射到一个更小的向量空间内的过程。在计算机自然语言处理领域中,Embeddings 通常被用来表示文本、图像或其他数据类型的特征,并使得模型能够更好地理解这些特征。️Embeddings翻译成中文,翻译成计算机自言语言处理的专业词汇️

from gpt4all import GPT4All, Embed4All
text = 'The quick brown fox jumps over the lazy dog'
embedder = Embed4All()
output = embedder.embed(text)
print(output)

https://docs.gpt4all.io/gpt4all_python_embedding.html#gpt4all.gpt4all.Embed4All.__init__

~/.username/.cache/gpt4all/ggml-all-MiniLM-L6-v2-f16.bin

git clone https://github.com/nomic-ai/gpt4all

https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf

pip install -U langchain

pip install gpt4all
from langchain.embeddings import GPT4AllEmbeddings

 gpt4all_embd = GPT4AllEmbeddings()
 query_result = gpt4all_embd.embed_query("This is test doc")
 print(query_result)
pip install langchain sentence_transformers
from langchain.embeddings import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings()
text = "This is a test document."
query_result = embeddings.embed_query(text)
print(query_result [:3])
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")

sentence-transformers/all-MiniLM-L6-v2

sentence_bert_config.json

modules.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 349/349 [00:00<00:00, 836kB/s]
config_sentence_transformers.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 116/116 [00:00<00:00, 254kB/s]
README.md: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10.6k/10.6k [00:00<00:00, 12.6MB/s]
sentence_bert_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████| 53.0/53.0 [00:00<00:00, 130kB/s]
config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 571/571 [00:00<00:00, 703kB/s]
pytorch_model.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 438M/438M [06:21<00:00, 1.15MB/s]
/home/parallels/miniconda3/envs/rag/lib/python3.11/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()

#https://abetlen.github.io/llama-cpp-python/

#%pip uninstall -y llama-cpp-python
#%pip install --upgrade llama-cpp-python


from langchain.embeddings import LlamaCppEmbeddings
llama = LlamaCppEmbeddings(model_path=GPT4ALL_MODEL_PATH)

%%time
text = "This is a test document."​
query_result = llama.embed_query(text)
CPU times: user 12.9 s, sys: 1.57 s, total: 14.5 s
Wall time: 2.13 s
%%time
doc_result = llama.embed_documents([text])
CPU times: user 10.4 s, sys: 59.7 ms, total: 10.4 s
Wall time: 1.47 s

nc监听端口,如何可以指定IP

要指定IP地址来监听端口,可以使用以下命令:

nc -l <IP地址> <端口号>

例如,要在IP地址为192.168.1.100上监听端口8888,可以运行以下命令:

nc -l 192.168.1.100 8888

这将使nc程序在指定的IP地址和端口上启动监听。