Dataset Viewer
Auto-converted to Parquet Duplicate
num_paragraphs
int64
dim
int64
model
string
precision
string
encode_seconds
float64
sentences_per_sec
int64
gpu
string
batch_size
int64
built_at
timestamp[s]
50,000
1,024
BAAI/bge-m3
fp16 encode, fp32 index
52.2
958
NVIDIA GeForce RTX 4090
128
2026-07-11T23:20:55

繁體中文維基百科語意搜尋索引(bge-m3 + FAISS)

這個 repo 存放 zhtw-wiki-semantic-search 專案預先建好的索引,供 Gradio demo Space 啟動時下載使用。

檔案

檔案 內容
index.faiss FAISS IndexFlatIP,50,000 × 1024 維、L2-normalized 的 BAAI/bge-m3 dense embedding(內積 = cosine 相似度)
metadata.parquet 每列對應一個 FAISS vector id:id(= 向量位置)、pageidtitletext(段落全文)、url(維基原文連結)

建置方式

  • 來源:zetavg/zh-tw-wikipedia (中文維基百科的 zh-tw 變體快照)
  • 清理:去除 markdown 標記/表格/列表/註腳/尾部參考章節後,切成 100–500 字的段落
  • 抽樣:page 層級 deterministic 抽樣(seed=42)→ 每頁最多 4 段 → 隨機取 50,000 段
  • Embedding:NVIDIA GeForce RTX 4090 上以 fp16 批次編碼, 52.2 秒完成(約 958 段/秒)

使用範例

import faiss, numpy as np, pandas as pd
from huggingface_hub import hf_hub_download
from sentence_transformers import SentenceTransformer

repo = "steven0226/zhtw-wiki-semsearch-index"
index = faiss.deserialize_index(np.frombuffer(bytearray(open(
    hf_hub_download(repo, "index.faiss", repo_type="dataset"), "rb").read()), dtype=np.uint8))
df = pd.read_parquet(hf_hub_download(repo, "metadata.parquet", repo_type="dataset"))

model = SentenceTransformer("BAAI/bge-m3")  # 查詢不需要任何 instruction prefix
q = model.encode(["天空為什麼藍藍的"], normalize_embeddings=True)
scores, ids = index.search(q.astype("float32"), 5)
print(df.iloc[ids[0]][["title", "url"]])

授權與署名

  • metadata.parquet 中的段落文字取自中文維基百科, © Wikipedia 貢獻者,依 CC BY-SA 4.0 授權(維基媒體自 2023 年 6 月起採 4.0 版)。每列的 url 欄位即該段落的來源條目,供逐條署名。
  • 由文字衍生的 embedding 與索引同樣依 CC BY-SA 4.0 之相同方式分享條款發布。
  • 上游整理版本:zetavg/zh-tw-wikipedia

Source repository

程式碼、訓練與評估流程、測試與完整證據都在 GitHub:https://github.com/kuotunyu/zhtw-wiki-semantic-search。GitHub kuotunyu 與 Hugging Face steven0226 為同一人。

Source code, the training/evaluation pipeline, tests and the full evidence trail live at https://github.com/kuotunyu/zhtw-wiki-semantic-search. GitHub kuotunyu and Hugging Face steven0226 are the same author.

Downloads last month
95

Space using steven0226/zhtw-wiki-semsearch-index 1

Collection including steven0226/zhtw-wiki-semsearch-index