Text Generation
Safetensors
GGUF
Chinese
diet-nutrition
patient-education
qa
rag
qwen3
lora
retrieval-augmented-generation
health-routing
conversational
Instructions to use chenhaodev/diet-nutrition-qa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use chenhaodev/diet-nutrition-qa with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0 # Run inference directly in the terminal: llama cli -hf chenhaodev/diet-nutrition-qa:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0 # Run inference directly in the terminal: llama cli -hf chenhaodev/diet-nutrition-qa:Q8_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf chenhaodev/diet-nutrition-qa:Q8_0
Use Docker
docker model run hf.co/chenhaodev/diet-nutrition-qa:Q8_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use chenhaodev/diet-nutrition-qa with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chenhaodev/diet-nutrition-qa" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chenhaodev/diet-nutrition-qa", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chenhaodev/diet-nutrition-qa:Q8_0
- Ollama
How to use chenhaodev/diet-nutrition-qa with Ollama:
ollama run hf.co/chenhaodev/diet-nutrition-qa:Q8_0
- Unsloth Desktop
- Pi
How to use chenhaodev/diet-nutrition-qa with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "chenhaodev/diet-nutrition-qa:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use chenhaodev/diet-nutrition-qa with Docker Model Runner:
docker model run hf.co/chenhaodev/diet-nutrition-qa:Q8_0
- Lemonade
How to use chenhaodev/diet-nutrition-qa with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull chenhaodev/diet-nutrition-qa:Q8_0
Run and chat with the model
lemonade run user.diet-nutrition-qa-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use chenhaodev/diet-nutrition-qa with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default chenhaodev/diet-nutrition-qa:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use chenhaodev/diet-nutrition-qa with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf chenhaodev/diet-nutrition-qa:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "chenhaodev/diet-nutrition-qa:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download scripts/parse_pdfs.py from chenhaodev/diet-nutrition-qa: direct link, hf CLI and curl.
- Browser
- Download file 6.27 kB
-
https://huggingface.co/chenhaodev/diet-nutrition-qa/resolve/main/scripts/parse_pdfs.py
- Command line
-
hf download hf://chenhaodev/diet-nutrition-qa/scripts/parse_pdfs.py
-
curl -L -o parse_pdfs.py https://huggingface.co/chenhaodev/diet-nutrition-qa/resolve/main/scripts/parse_pdfs.py
6.27 kB
| #!/usr/bin/env python3 | |
| """Parse the three diet/nutrition PDFs into structured Q/A records. | |
| Format of all three books (prose Q&A, not multi-column tables): | |
| 第N章 | |
| <chapter title> | |
| 1.<question title> | |
| <prose answer...> | |
| Uses a streaming line-by-line state machine: | |
| - a "第N章" line -> finalize current Q, set chapter/category | |
| - a numbered-title line -> finalize current Q, start a new (question, answer) | |
| - any other line -> append to the open question's answer | |
| This is robust to question titles that appear mid-block (no blank-line delimiters). | |
| Output: data/qa_<book>.jsonl records: | |
| {category, book, chapter, question, answer, page, slug} | |
| category == the RAG index dir name (router must emit exactly this). | |
| """ | |
| import glob | |
| import hashlib | |
| import json | |
| import os | |
| import re | |
| from collections import Counter | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| BOOKS = [ | |
| ("胃肠疾病营养与膳食指导", "gastro"), | |
| ("糖尿病营养与膳食指导", "diabetes"), | |
| ("骨质疏松症营养与膳食指导", "osteoporosis"), | |
| ] | |
| GASTRO_CAT = { | |
| "食管癌": "esophagus-cancer", | |
| "胃炎": "gastritis", | |
| "消化性溃疡": "peptic-ulcer", | |
| "胃癌": "stomach-cancer", | |
| "腹泻": "diarrhea", | |
| "消化道出血": "gi-bleeding", | |
| "大肠癌": "colorectal-cancer", | |
| "便秘": "constipation", | |
| "肠易激综合征": "ibs", | |
| "炎性肠病": "ibd", | |
| } | |
| _CHAPTER_RE = re.compile(r"^\s*第\s*[一二三四五六七八九十百\d]+\s*章\s*(.*)$") | |
| _QUESTION_RE = re.compile( | |
| r"^\s*(?P<num>\d{1,2}|[一二三四五六七八九十百]+)\s*[.、.]\s*" | |
| r"(?P<title>.{2,120}?)\s*[??]?\s*$") | |
| def strip_footer(t): | |
| t = re.sub(r"\n?下载.*?permission\.\n?", "\n", t, flags=re.DOTALL) | |
| t = re.sub(r"\n?Downloaded by \[.*?permission\.\n?", "\n", t, flags=re.DOTALL) | |
| return t | |
| def slug(q, page): | |
| return hashlib.md5((q + str(page)).encode("utf-8")).hexdigest()[:12] | |
| def is_question_line(line, book): | |
| """Heuristic: a numbered title that opens a new Q/A unit.""" | |
| if not re.match(r"^\s*\d|[一二三四五六七八九十百]", line): | |
| return False | |
| m = _QUESTION_RE.match(line) | |
| if not m: | |
| return False | |
| title = m.group("title").strip() | |
| # reject obvious page/header noise | |
| if title.isdigit() or len(title) < 4: | |
| return False | |
| # In gastro book questions are prose titles; require the line to look like a | |
| # heading (not a sentence running into body text). We accept short titles. | |
| return True | |
| def parse_one(pdf_path, book): | |
| import pymupdf | |
| doc = pymupdf.open(pdf_path) | |
| toc_cat = {} | |
| current_cat = None | |
| for lvl, title, page in doc.get_toc(): | |
| chm = re.match(r"^\s*第\s*[一二三四五六七八九十百\d]+\s*章\s*(.*)$", title) | |
| if lvl == 1 and chm: | |
| raw = chm.group(1).strip() | |
| if book == "gastro": | |
| current_cat = GASTRO_CAT.get(raw, current_cat) | |
| elif book == "diabetes": | |
| current_cat = "diabetes" | |
| elif book == "osteoporosis": | |
| current_cat = "osteoporosis" | |
| toc_cat[page] = current_cat | |
| def cat_at(page1): | |
| c = None | |
| for p in range(page1, 0, -1): | |
| if p in toc_cat and toc_cat[p]: | |
| c = toc_cat[p] | |
| break | |
| return c | |
| records = [] | |
| cur_question = None | |
| cur_answer = [] | |
| cur_page = None | |
| def flush(): | |
| nonlocal cur_question, cur_answer | |
| if cur_question and cur_answer: | |
| ans = "".join(cur_answer).strip() | |
| if len(ans) >= 10: | |
| records.append({ | |
| "category": cur_question[1], | |
| "book": book, | |
| "chapter": cur_question[2], | |
| "question": cur_question[0], | |
| "answer": ans, | |
| "page": cur_question[3], | |
| "slug": slug(cur_question[0], cur_question[3]), | |
| }) | |
| cur_question, cur_answer = None, [] | |
| for pno in range(doc.page_count): | |
| page1 = pno + 1 | |
| cat = cat_at(page1) | |
| text = strip_footer(doc.load_page(pno).get_text("text")) | |
| # chapter lines: set category from TOC line directly | |
| for line in text.splitlines(): | |
| line = line.strip() | |
| if not line: | |
| continue | |
| chm = _CHAPTER_RE.match(line) | |
| if chm: | |
| flush() | |
| raw = chm.group(1).strip() | |
| if book == "gastro": | |
| cat = GASTRO_CAT.get(raw, cat) | |
| elif book in ("diabetes", "osteoporosis"): | |
| cat = book | |
| continue | |
| if is_question_line(line, book): | |
| flush() | |
| m = _QUESTION_RE.match(line) | |
| title = m.group("title").strip() | |
| if not title.endswith(("?", "?", "。")): | |
| title += "。" | |
| cur_question = (title, cat, line, page1) | |
| cur_answer = [] | |
| else: | |
| if cur_question is None: | |
| # prelude text before first question (chapter intro) - skip | |
| continue | |
| cur_answer.append(line) | |
| flush() | |
| return records | |
| def main(): | |
| out_all = os.path.join(ROOT, "data") | |
| os.makedirs(out_all, exist_ok=True) | |
| for base, key in BOOKS: | |
| pdfs = glob.glob("/workspace/Med-Books-20260914/" + base + "*.pdf") | |
| if not pdfs: | |
| print("MISSING", base) | |
| continue | |
| recs = parse_one(pdfs[0], key) | |
| # drop preface-outline rows whose "answer" is just a following section heading | |
| recs = [r for r in recs if len(r["answer"]) >= 30] | |
| for r in recs: | |
| if not r["category"]: | |
| r["category"] = "diabetes" if key == "diabetes" else "osteoporosis" | |
| with open(os.path.join(out_all, f"qa_{key}.jsonl"), "w", encoding="utf-8") as f: | |
| for r in recs: | |
| f.write(json.dumps(r, ensure_ascii=False) + "\n") | |
| print(f"[{key}] records={len(recs)}") | |
| for c, n in Counter(r["category"] for r in recs).most_common(): | |
| print(f" {c}: {n}") | |
| if __name__ == "__main__": | |
| main() | |