作者归档:admin

生成任意字符的单页PDF

中心思想,生成txt文件,再用liberoffice转为PDF

import os

com1="echo "+info_text+":信息 >swap.txt"
com2="libreoffice --convert-to pdf:writer_pdf_Export swap.txt --outdir "+self.download
os.system(com1)
os.system(com2)
  • HTML貌似不可用,目前无法修改字体大小

MAC 似乎游戏 Intel 大模型微调来自AI KIMI TAG

在Intel Mac上进行大模型微调,您可以遵循以下步骤:

  1. 安装Homebrew
  • Homebrew是macOS上的包管理器,用于简化软件包的安装和管理。在终端中输入以下命令安装Homebrew:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • 参考链接:Homebrew安装指南
  1. 安装Miniforge
  • Miniforge是为ARM架构设计的Conda发行版,适合在Intel Mac上使用。下载并运行Miniforge安装脚本:
    curl -LO https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh bash Miniforge3-MacOSX-x86_64.sh
  • 按照提示完成安装。
  1. 创建并激活Conda环境
  • 创建一个新的Conda环境,例如名为tensorflow_2
    conda create --name tensorflow_2 python=3.9
  • 激活环境:
    conda activate tensorflow_2
  1. 安装TensorFlow
  • 在Conda环境中,使用pip安装TensorFlow:
    pip install tensorflow-macos
  • 这将安装适用于Intel Mac的TensorFlow版本。
  1. 验证TensorFlow安装
  • 打开Python解释器并运行以下代码以验证TensorFlow是否正确安装:
    import tensorflow as tf print("TensorFlow version:", tf.__version__) print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
  • 如果能够看到输出TensorFlow版本和GPU信息,说明TensorFlow已成功安装。
  1. 准备数据集
  • 准备您的数据集,例如JSON格式的数据集,其中包含问题和答案:
    json [ { "instruction": "你好", "input": "", "output": "皇上好,我是甄嬛,家父是大理寺少卿甄远道。" }, { "instruction": "你不愿意见我?", "input": "", "output": "不该相见自然不愿见,还望王爷尊重我的意愿。" } ]
  1. 选择模型并开始微调
  • 选择一个适合您任务的预训练模型,例如LLM-Research/Meta-Llama-3-8B-Instruct,并开始微调。您可以修改train.py文件中的model_id变量来选择不同的模型。
  • 开始微调,执行以下命令:
    python train.py
  1. 测试微调后的模型
  • 微调完成后,您可以使用ChatBot进行对话测试,执行以下命令:
    streamlit run chat.py
  • 这将启动一个Web界面,您可以在其中与微调后的模型进行交互。

以上步骤提供了在Intel Mac上进行大模型微调的详细指南,帮助您充分利用现有的硬件资源和软件工具。

TAG

来自KIMI

MAC下的大模型微调 数据格式 三种 chat completion text(CoT)

要义 MLX 针对mac的ARM处理器优化的大模型训练架构

看了那么多资料主要还是PIP安装 huggingface_hub mlx-lm transformers torch numpy

然后对应大模型文件微调

针对数据 Completion(问答类型,一问一答) chat(角色问答) text(单文本类型,训练特定文本) 三种类型 都是JSON格式

chat解析:

{
  "messages": [
    {
      "role": "user",
      "content": "How do I use this product?"
    },
    {
      "role": "assistantA",
      "content": "To use this product, first insert the batteries and then press the power button."
    },
    {
      "role": "assistantB",
      "content": "To operate this product, make sure it's charged, and then follow the instructions in the manual."
    }
  ]
}

message包裹下为信息,role为user的content为询问,assistantB和assistantA给出不同的content

completion解析

[{
  "prompt": "What is the capital of France?",
  "completion": "Paris."
},
{
  "prompt": "A?",
  "completion": "BBBB"
}]

TEXT格式

{"text": "table: 1-1000181-1\ncolumns: State/territory, Text/background colour, Format, Current slogan, Current series, Notes\nQ: Tell me what the notes are for South Australia \nA: SELECT Notes FROM 1-1000181-1 WHERE Current slogan = 'SOUTH AUSTRALIA'"}