Skip to content

Yunle-Lee/Leema.cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Leema.cpp

基于 llama.cpp 的终端本地大模型并排对比框架。

在终端中实时对比两个本地 GGUF 模型的输出质量、生成速度与首 token 延迟。

pic1

功能特性

  • 两个模型同时流式输出,左右并排显示
  • 每次回复显示指标:TTFT(首 token 延迟)、token 数生成速度(t/s)
  • 对每次回复投票:A 胜 / B 胜 / 平局
  • 结果自动追加到 leema_log.jsonl,方便离线分析
  • 两个模型并行加载,节省启动时间
  • 纯终端 UI,基于 Textual

环境要求

  • Python 3.8+
  • 足够的内存/显存同时运行两个 GGUF 模型
  • llama-cpp-python(推荐开启 GPU 支持)

pic2

安装依赖

git clone https://github.com/your-username/leema.git
cd leema
pip install -r requirements.txt

如需 CUDA GPU 加速:

CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python --force-reinstall --no-cache-dir

使用方法

  1. 修改 leema.py 中的模型路径:
MODEL_A = "/path/to/your/model-a.gguf"
MODEL_B = "/path/to/your/model-b.gguf"
  1. 运行:
python3 leema.py
  1. 在底部输入框输入 prompt,回车发送,两个模型将同时开始生成。

  2. 生成结束后按键记录结果:

    • A — A 的回答更好
    • B — B 的回答更好
    • = — 平局
  3. Ctrl+C 退出。


日志格式

结果追加写入当前目录的 leema_log.jsonl,每行一条 JSON 记录:

{
  "timestamp": "2026-04-05T09:00:00",
  "prompt": "法国的首都是哪里?",
  "a": { "output": "巴黎。", "tokens": 4, "ttft": 0.31, "tps": 18.5 },
  "b": { "output": "法国的首都是巴黎。", "tokens": 9, "ttft": 0.28, "tps": 12.1 },
  "winner": "b"
}

复刻指南

用自己的模型复现此项目:

  1. Hugging Face 下载任意两个 GGUF 格式模型
  2. 修改 leema.py 中的 MODEL_AMODEL_B 路径
  3. 根据硬件调整参数:
    • n_gpu_layers=-1:全部层卸载到 GPU
    • n_gpu_layers=0:纯 CPU 运行
    • n_ctx=2048:上下文窗口大小
  4. 安装依赖后直接运行

自定义调整TUI构图

pic3
pic4

About

Based on the llama.cpp-python i run two or more models so u can compare their output speed and quality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages