Veblen34's picture
Upload folder using huggingface_hub
cd6775d verified
Raw
History Blame Contribute Delete
1.49 kB
"""查询分割统一入口(进程内函数版,无需启动任何本地服务)。
from decompose import icl_decompose, unsupervised_decompose, supervised_decompose
subs = icl_decompose("your question here") # -> ['sub q1', 'sub q2', ...]
命令行:
python decompose.py icl "Who directed the highest-grossing film of 1997?"
python decompose.py supervised "..."
python decompose.py unsupervised "..."
这是对 `qd_baselines` 包的薄封装:①监督式(本地 Llama+LoRA)、②无监督(本地 XLM)、
③ICL(gpt-4o-mini,可插拔)。所需环境变量见 .env.example。
④ SearChain 是检索反馈闭环,仍为服务版,见 使用说明.md 第 4 节。
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from qd_baselines import ( # noqa: E402
supervised_decompose,
unsupervised_decompose,
icl_decompose,
METHODS,
)
__all__ = ["supervised_decompose", "unsupervised_decompose", "icl_decompose", "METHODS"]
if __name__ == "__main__":
import json
method = sys.argv[1] if len(sys.argv) > 1 else "icl"
query = sys.argv[2] if len(sys.argv) > 2 else \
"Who directed the highest-grossing film of 1997?"
if method not in METHODS:
sys.exit(f"未知方法 '{method}',可选:{list(METHODS)}")
subs = METHODS[method](query)
print(json.dumps({"method": method, "query": query, "sub_queries": subs},
ensure_ascii=False, indent=2))