LLM-大语言模型相关

LLM:大语言模型相关

准备

1
2
## 安装anaconda
$  winget install Anaconda.Anaconda3

hf-mirror: hugging-faces镜像网站

hfd: 大模型数据下载工具

1
2
3
4
5
## 安装
$ wget 

## 用法
$ hfd.sh jartine/llava-v1.5-7B-GGUF  --include "llava-v1.5-7b-q4.llamafile"

概念

GGUF:

  • gguf:

ONNX: 开发神经网络交换格式

  • onnx: Open Neural Network Exchange,是一种模型IR,用于在各种深度学习训练和推理框架转换的一个中间表示格式。

  • 用protobuf定义;

  • ONNX 模型结构:

    • ModelProto

      • GraphProto
        • NodeProto
        • ValueInfoProto

框架

RAG:

工具

llama-cli

ollama: 命令行运行llama工具

  • 支持平台: mac, linux, windows
1
2
3
4
5
6
7
8
## 创建模型配置文件
$ cat "FROM d:\code\llm\<LLM_MODEL_GGUF>" > modelfile.txt
## ollama导入模型
$ ollama create <MODLE_NAME> -f modelfile.txt
## 查看ollama导入的模型
$ ollama list
## 运行模型
$ ollama run <MODLE_IMPORT_NAME>

llamafile: 单文件大模型运行工具

  • 支持平台: mac, linux, win
1
2
3
4
5
6
7
## 安装llamafile命令行命令
$ wget -O /c/app/llamafile.exe https://github.com/Mozilla-Ocho/llamafile/releases/download/0.7/llamafile-0.7

## 启动 llama服务
$ llamafile -m qwen1_5-14b-chat-q4_0.gguf

## 启动浏览器: http://127.0.0.1:8080

gpt4all

lm-studio

AnythingLLM

应用

Chat: 文本对话

语音识别

whisper.cpp

  • 基于whispe.cpp语音对话模型;
  • windows下wsl编译
1
2
3
4
5
6
7
8
$ git clone  git@github.com:ggerganov/whisper.cpp.git
$ cd whisper.cpp
## 编译talk-llama
$ make talk-llama
## 下载ggml语音模型
$ models/download-ggml-model.sh small
## 运行
$ ./talk-llama -mw /mnt/c/code/llm/whisper-models/ggml-whisper-small.bin -ml /mnt/c/code/llm/lmstudio/Qwen/Qwen1.5-0.5B-Chat-GGUF/qwen1_5-7b-chat-q4_0.gguf -p "Jack" -t 8 -l zh

TTS: 文本转语音

图片生成

2d转3d

知识系统

平台

Nvidia

CUDA

AMD

ZLUDA

  • zluda: 是无修改直接在amd gpu上运行cuda程序的cuda兼容库;
1
2
3
4
5
## download and install
$ wget https://github.com/vosen/ZLUDA/releases/download/v3/zluda-3-windows.zip
## run with zlud
$ <ZLUDA_DIRECTORY>\zluda.exe -- <APPLICATION> <APPLICATION_ARGUMENTS>

  • olive
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 1. 创建虚拟环境
$ conda create --name=llama2_opt python=3.11.5
## 2. 激活虚拟环境
$ conda active llama2_opt
## 下载olive源码
$ git clone https://github.com/microsoft/Olive.git
## 安装依赖包
$ pip install -r ./requirements.txt
## 
$ pip install -e .


参考

  1. https://www.deepin.org/zh/llamafile-a-must-have-tool/
  2. https://www.cvmart.net/community/detail/6550
  3. https://zhuanlan.zhihu.com/p/686886176
updatedupdated2024-05-102024-05-10