Train and fine-tune AI on a set of pre-read Tử Vi charts

Nhat Nguyet's chart readings set is ready-made data for fine-tuning a language model: one chart per JSON line, each section with readings in three languages, classical passages with book and chapter, under CC BY 4.0. This guide shows how to read a row and turn it into question and answer pairs for fine-tuning.
The datasets are on Hugging Face: nhatnguyet/ziwei-readings (Tử Vi), nhatnguyet/bazi-readings (Bát Tự) and nhatnguyet/numerology-readings. Folder and field names are English; Vietnamese text sits in the vi fields.
Which files make up the set?
Chart files come one per birth year, zstd compressed (extension .jsonl.zst), one JSON object per line. To read them in Python, run pip install zstandard.
charts/ziwei/<year>.jsonl.zst: one chart per line, with the text replaced by ids.store/readings/ziwei.jsonl.zst,store/passages/ziwei.jsonl.zst,store/further-reading/ziwei.jsonl.zst: what the ids point to (reading text, classical passages, articles), one file each.assembled/ziwei/<vi|en|zh>/<year>.jsonl.zst: the text already assembled in one language, as markdown.meta.json: the layout of each folder, the id scheme, the licence, and the credit line in three languages.
If you only need the text, read assembled directly: each line is {key, system, lang, input, text}, where text is the full reading of one chart. If you need each section and each book passage, read charts together with store as below.
What is in one chart row?
A Tử Vi chart has 13 sections: an overview and the 12 palaces.

| key | content |
|---|---|
key | chart id: birth date, hour index, sex (1990-01-01-0-male) |
input | input: day, month, year, double hour, sex, year viewed 2026 |
summary | the structured chart: element bureau, nạp âm element, branch of the Life palace, patterns, ten-year and yearly periods, in three languages |
sections[].code | section code: overview, palace-life... |
sections[].chart | the palace cell of that section: branch, stem and branch, stars with their brightness |
sections[].title, sections[].readings | ids of the section title and of each piece of reading, looked up in store/readings to get vi, en, zh; the text is built by the calculation engine, not written by a model |
sections[].steps | calculation steps (placing the Life palace, the element bureau...), each with name, input, formula, intermediate, result as ids in store/readings |
sections[].passages | ids of public-domain classical passages, looked up in store/passages to get book, author, chapter, lookup key and original text |
sections[].further_reading | article slugs, looked up in store/further-reading |
source | name, address, licence and credit line |
Steps to build a fine-tuning set
- Download
meta.json, the year file you need,charts/ziwei/1990.jsonl.zst, and the text storestore/readings/ziwei.jsonl.zst, for example withhf download nhatnguyet/ziwei-readings meta.json charts/ziwei/1990.jsonl.zst store/readings/ziwei.jsonl.zst --repo-type dataset --local-dir .(thehfcommand comes withhuggingface_hub). - Load the text store into a lookup table from id to text in three languages.
- Read each chart line; every section with a reading becomes one sample per language.
- Build the question from the chart's own
inputandsummary; the answer is the ids inreadingslooked up and joined. - Attach to each sample the credit line in that sample's language:
attributioninmeta.jsonhasvi,enandzh. - Write JSONL in the
messagesformat most fine-tuning tools read.
import io, json
import zstandard # pip install zstandard
def read(path):
"""Read a .jsonl.zst file, one JSON object per line."""
with open(path, "rb") as f:
for line in io.TextIOWrapper(zstandard.ZstdDecompressor().stream_reader(f), encoding="utf-8"):
yield json.loads(line)
# Text store: id -> {vi, en, zh}, one file for the whole set.
TEXT = {x["id"]: x for x in read("store/readings/ziwei.jsonl.zst")}
CREDIT = json.load(open("meta.json", encoding="utf-8"))["attribution"] # {"vi": ..., "en": ..., "zh": ...}
TEMPLATE = { # question template per language
"vi": ("Sinh {date}, giờ {hour}, {sex}. Lá {year}, {bureau}, Mệnh tại {life}. Luận {section}.", {"male": "nam", "female": "nữ"}),
"en": ("Born {date}, {hour} hour, {sex}. Chart: {year}, {bureau}, Mệnh at {life}. Read the {section}.", {"male": "male", "female": "female"}),
"zh": ("{date}生,{hour}时,{sex}。命盘:{year},{bureau},命宫在{life}。论{section}。", {"male": "男", "female": "女"}),
}
count, first = 0, []
with open("fine-tune.jsonl", "w", encoding="utf-8") as out:
for chart in read("charts/ziwei/1990.jsonl.zst"):
i, s = chart["input"], chart["summary"]
for section in chart["sections"]:
if not section["readings"]:
continue
for lang, (template, sex) in TEMPLATE.items():
question = template.format(date=f"{i['day']}/{i['month']}/{i['year']}", hour=i["hour_name"][lang],
sex=sex[i["sex"]], year=s["year_stem_branch"][lang], bureau=s["element_bureau"][lang],
life=s["life_palace_branch"][lang], section=TEXT[section["title"]][lang])
answer = "\n".join(TEXT[x][lang] for x in section["readings"])
sample = {"messages": [{"role": "user", "content": question},
{"role": "assistant", "content": answer}],
"source": CREDIT[lang]}
out.write(json.dumps(sample, ensure_ascii=False) + "\n")
count += 1
if len(first) < 6:
first.append(sample)
print("Samples:", count)
for m in first[3:6]:
print(m["messages"][0]["content"])
print(" ->", m["messages"][1]["content"][:150], "...")
print(" ", m["source"])Samples: 323106
Sinh 1/1/1990, giờ Tý, nam. Lá Kỷ Tỵ, Thủy Nhị Cục, Mệnh tại Sửu. Luận Cung Mệnh.
-> Cung Mệnh của anh chị có Thiên Phủ. Sách Tử Vi tả Thiên Phủ là sao điềm đạm, chắc chắn, giỏi giữ của và quản lý.
Sách Tử Vi tả Thiên Phủ là sao kho: đ ...
Dữ liệu: Nhật Nguyệt (nhatnguyet.org)
Born 1/1/1990, Tý hour, male. Chart: Kỷ Tỵ, Water Two, Mệnh at Sửu. Read the Life Palace.
-> Your Mệnh palace holds Thiên Phủ. In Tử Vi books, Thiên Phủ is described as: steady and reliable, good at keeping and managing resources.
Tử Vi books ...
Data: Nhat Nguyet (nhatnguyet.org)
1/1/1990生,子时,男。命盘:己巳,水二局,命宫在丑。论命宫。
-> 你的命宫有天府。紫微斗数的书说天府:稳重踏实、善于守财和管理。
紫微书中称天府为库星:稳重谨慎,善于积累和管理,可靠;另一面是保守、怕冒险。在命宫(自身),天府处平之位:上述特点表现一般。
以文昌所在宫为初一,顺数至生日,再退一宫。
以文曲所在宫为初一,逆数至生日,再退一宫(越南书的排法;中国书顺数 ...
数据:Nhat Nguyet (nhatnguyet.org)8,760 charts from 1990 (365 days, 12 double hours, two sexes) give 323,106 samples in three languages; the output file is about 276 MB. The 1990 charts file is only 6.7 MB because each sentence sits once in the store. The assembled files for the same year are 18.4 MB in Vietnamese, 14.8 MB in English and 12.2 MB in Chinese.
What to watch for when training
- The Vietnamese readings address the reader as "anh chị"; a model trained on them will speak that way.
- Classical passages are original Chinese text, not translated. If you want the model to quote books, look up the
passagesids instore/passagesand keepbook_titleandchapternext toclassical_text, not the text alone. - Split your evaluation set by chart, not by sample: if the three language versions of one section land on both sides, the scores look better than they are.
- The readings follow the rules of one Tử Vi school, which have not been tested. A model learns how that school reads a chart, not anything true about a life; say so when you ship it.
Licence and credit
The data is CC BY 4.0: you may train on it, including for commercial products, provided you credit "Data: Nhat Nguyet (nhatnguyet.org)". The classical texts are in the public domain; the segmentation, chart links and checking against printed editions are Nhat Nguyet's work under the same licence.



