Skip to main content

Posts

Showing posts from June, 2023

CentOS 安装 nginx

 sudo yum install epel-release sudo yum install nginx sudo systemctl start nginx sudo systemctl status nginx Output ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2022-01-24 20:14:24 UTC; 5s ago Process: 1898 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 1896 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 1895 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 1900 (nginx) CGroup: /system.slice/nginx.service ├─1900 nginx: master process /usr/sbin/nginx └─1901 nginx: worker process Jan 24 20:14:24 centos-updates systemd[1]: Starting The nginx HTTP and reverse proxy server... Jan 24 20:14:24 centos-updates nginx[1896]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Jan 24 20:14:24 centos-updates nginx[1896]: nginx...

FAISS Vector DB 学习笔记(一)

 1. 安装Faiss: 按照Faiss官方资源库提供的安装说明,确保你有必要的依赖和兼容的硬件(如果使用GPU加速)。 2. 2.准备好你的数据: Faiss使用密集向量工作,所以确保你的数据以浮点数组或矩阵的形式表示,其中每一行对应一个向量。确保你的向量的尺寸是一致的。 3. 导入必要的模块: 在你的Python脚本中,导入所需的Faiss模块: ``python import faiss import numpy as np ``` 4. 创建一个索引: 根据你的需要,选择适当的索引类型。下面是一个创建IndexFlatL2索引的例子: ```python d = 128  # Dimension of your vectors index = faiss.IndexFlatL2(d)  # Initialize the index ``` 你可以探索其他的索引类型,比如IndexIVFFlat或IndexHNSW,这取决于你愿意做出的折衷。 5. 为索引添加向量: 一旦你初始化了你的索引,使用`add'方法将你的向量添加到它里面。传入一个NumPy数组或一个兼容的数据结构: ``python vectors = np.random.random((1000, d)).astype('float32')  # Example vectors index.add(vectors)  # Add the vectors to the index ``` 6. 进行相似性搜索: 要为一个查询向量找到最近的邻居,可以使用`search`方法。传入查询向量和需要检索的近邻数量: ``python k = 5  # Number of nearest neighbors to retrieve query_vector = np.random.random((1, d)).astype('float32')  # Example query vector D, I = index.search(query_vector, k)  # Perform the search ``` 返回的`D`数组包含与最近的邻居的距离,`I`数组包含它们在原始数据集中的相应索引。 7. 自定义和优化: Faiss...

CentOS Nginx Proxy for OpenAI Error host not found in upstream "api.openai.com"

centos上用nginx搭建openai的反向代理服务器,始终报如下错误,但是我另外一台服务器上同样的nginx配置就是没问题的,真的恼人,2个小时的研究,终于找到了问题所在。 果然操作系统层面的问题,centos,竟然 SELinux settings 导致的问题,修改相关参数。再重启就没有问题了。 错误信息如下: nginx: [emerg] host not found in upstream "api.openai.com" in /etc/nginx/nginx.conf:57   解决办法 检查SElinux的参数配置 It will display the current SELinux mode, such as "Enforcing," "Permissive," or "Disabled." [root@ servername  nginx]# sestatus SELinux status:                 enabled SELinuxfs mount:                /sys/fs/selinux SELinux root directory:         /etc/selinux Loaded policy name:             targeted Current mode:                   enforcing Mode from config file:          enforcing Policy MLS status:              enabled Policy deny_unknown status:     allowed M...