1. 镜像构建
git clone https://github.com/hiyouga/LLaMA-Factory.git -b v0.7.0
cd LLaMA-Factory
docker build -f ./Dockerfile -t llama-factory:v0.7.0 .
2.数据准备
-
模型
为了节省时间,提前下载模型
root@ndoe:/data/models# tree -L 2 . ├── BAAI │ └── bge-reranker-large ├── databricks │ ├── dbrx-instruct ├── hpcai-tech │ └── Open-Sora ├── meta-llama │ ├── Meta-Llama-3-70B-Instruct │ └── Meta-Llama-3-8B ├── mistralai │ └── Mixtral-8x7B-Instruct-v0.1 ├── moka-ai │ └── m3e-large └── xai-org └── grok-1
-
数据集
使用官方提供的测试用数据集
https://github.com/hiyouga/LLaMA-Factory/blob/main/data/alpaca_data_zh_51k.jsonroot@node:/data/llama-factory# tree -L 2 . ├── data │ ├── alpaca_data_zh_51k.json │ └── dataset_info.json └── output
-
数据集配置
{ "alpaca_data_zh_51k.json": { "file_name":"alpaca_data_zh_51k.json", "file_sha1":"2ba9827122c158dc256668d42bd1bcb8bc6b786e" } }
3.部署
-
使用k8s
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: llamaf namespace: llm spec: ingressClassName: nginx rules: - host: llamaf.xxx.cn http: paths: - backend: serviceName: llamaf servicePort: 7860 path: / pathType: Prefix --- apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/name: llamaf name: llamaf namespace: llm spec: ports: - name: llamaf port: 7860 protocol: TCP targetPort: 7860 selector: app.kubernetes.io/name: llamaf sessionAffinity: None type: ClusterIP --- apiVersion: apps/v1 kind: Deployment metadata: name: llamaf namespace: llm spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: llamaf template: metadata: labels: app.kubernetes.io/name: llamaf spec: containers: - name: llamaf image: llama-factory:v0.7.0 imagePullPolicy: IfNotPresent env: - name: TZ value: Asia/Shanghai resources: limits: cpu: "8" memory: 32Gi tencent.com/vcuda-core: "100" tencent.com/vcuda-memory: "320" requests: cpu: "8" memory: 16Gi tencent.com/vcuda-core: "100" tencent.com/vcuda-memory: "320" volumeMounts: - name: localtime mountPath: /etc/localtime - name: shm mountPath: /dev/shm - name: model mountPath: /root/.cache/huggingface - name: data mountPath: /app/data - name: output mountPath: /app/output volumes: - name: shm emptyDir: medium: Memory sizeLimit: 16G - name: localtime hostPath: path: /etc/localtime - name: model hostPath: path: /data/models type: DirectoryOrCreate - name: data hostPath: path: /data/llama-factory/data type: DirectoryOrCreate - name: output hostPath: path: /data/llama-factory/output type: DirectoryOrCreate
4.微调
5.详解
TODO: