Skip to content

231370/cv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

学习笔记:Hugging Face → 量化 → LangChain Agent

本仓库按个人学习顺序组织示例代码,便于复习与复现。

目录结构

顺序 目录 内容
1 01-huggingface/ Transformers / Hub 入门(Jupyter Notebook)
2 02-quantization/ 普通模型与 4bit 量化显存对比脚本
3 03-langchain/ 最小 ReAct Agent(计算器 + 当前时间,默认 Ollama)

环境

  • Python 3.10+ 推荐
  • 02 量化脚本:需要 NVIDIA GPU + CUDA(无 GPU 时脚本会提示并退出)
  • 03 Agent:需本机安装并启动 Ollama,并拉取 qwen2.5:1.5b(或修改脚本内 OLLAMA_MODEL
cd /path/to/repo  # 本仓库根目录
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

运行示例

# 1) Hugging Face 入门(在 notebook 中逐格运行)
jupyter notebook 01-huggingface/huggingFace.ipynb

# 2) 量化显存对比(需在仓库根目录存在已下载的 gpt2/,或能联网拉取模型)
python 02-quantization/quantization_demo.py

# 3) LangChain Agent(先 ollama serve,再执行)
python 03-langchain/task1_minimal_agent.py

模型文件说明(不随仓库上传)

  • 仓库根目录下的 gpt2/ 为本地下载的模型权重,体积大,已列入 .gitignore
  • 01-huggingface/huggingFace.ipynb:首格只从本地加载(local_files_only=True),会在当前目录、上一级、上上一级中查找含 config.jsongpt2/;若模型在其他路径,可设置环境变量 HF_MODEL_PATHGPT2_LOCAL_PATH
  • 02 量化脚本:未放置模型时,可设置 HF_ENDPOINT(如镜像)或 QUANT_DEMO_MODEL 指向本地模型目录,详见 02-quantization/quantization_demo.py 内注释。

上传到 GitHub

在仓库根目录执行:

git init
git add .
git status   # 确认未包含 gpt2/ 等大文件
git commit -m "chore: organize learning notes by topic"
git branch -M main
git remote add origin https://github.com/<你的用户名>/<仓库名>.git
git push -u origin main

若 GitHub 要求登录,请使用 Personal Access Token 或配置 SSH

许可

个人学习用途;第三方库与模型版权归各自所有者。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors